Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ed2d3ce authored by flar2's avatar flar2 Committed by Razziell
Browse files

ASoC: msm8x16-wcd: Sound control: add mic gain

parent 3629a313
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -5852,8 +5852,36 @@ static struct kobj_attribute headphone_gain_attribute =
		headphone_gain_show,
		headphone_gain_store);

static ssize_t mic_gain_show(struct kobject *kobj,
		struct kobj_attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n",
		snd_soc_read(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_TX1_VOL_CTL_GAIN));
}

static ssize_t mic_gain_store(struct kobject *kobj,
		struct kobj_attribute *attr, const char *buf, size_t count)
{
	int input;

	sscanf(buf, "%d", &input);

	if (input < -10 || input > 20)
		input = 0;

	snd_soc_write(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_TX1_VOL_CTL_GAIN, input);

	return count;
}

static struct kobj_attribute mic_gain_attribute =
	__ATTR(mic_gain, 0664,
		mic_gain_show,
		mic_gain_store);

static struct attribute *sound_control_attrs[] = {
		&headphone_gain_attribute.attr,
		&mic_gain_attribute.attr,
		NULL,
};