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

Commit d9a4d05c authored by flar2's avatar flar2 Committed by Razziell
Browse files

ASoC: msm8x16-wcd: add speaker gain and prevent reset

parent 8ed2d3ce
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -2641,7 +2641,7 @@ static const struct snd_kcontrol_new msm8x16_wcd_snd_controls[] = {
					8, 0, analog_gain),
	SOC_SINGLE_TLV("ADC3 Volume", MSM8X16_WCD_A_ANALOG_TX_3_EN, 3,
					8, 0, analog_gain),

#ifndef CONFIG_SOUND_CONTROL
	SOC_SINGLE_SX_TLV("RX1 Digital Volume",
			  MSM8X16_WCD_A_CDC_RX1_VOL_CTL_B2_CTL,
			0,  -84, 40, digital_gain),
@@ -2651,7 +2651,7 @@ static const struct snd_kcontrol_new msm8x16_wcd_snd_controls[] = {
	SOC_SINGLE_SX_TLV("RX3 Digital Volume",
			  MSM8X16_WCD_A_CDC_RX3_VOL_CTL_B2_CTL,
			0,  -84, 40, digital_gain),

#endif
	SOC_SINGLE_SX_TLV("DEC1 Volume",
			  MSM8X16_WCD_A_CDC_TX1_VOL_CTL_GAIN,
			0,  -84, 40, digital_gain),
@@ -5879,9 +5879,37 @@ static struct kobj_attribute mic_gain_attribute =
		mic_gain_show,
		mic_gain_store);

static ssize_t speaker_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_RX3_VOL_CTL_B2_CTL));
}

static ssize_t speaker_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_RX3_VOL_CTL_B2_CTL, input);

	return count;
}

static struct kobj_attribute speaker_gain_attribute =
	__ATTR(speaker_gain, 0664,
		speaker_gain_show,
		speaker_gain_store);

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