Skip to content

Commit 7c70825

Browse files
committed
ASoC: qcom: volume fixes and codec cleanups
Merge series from Johan Hovold <johan+linaro@kernel.org>: To reduce the risk of speaker damage the PA gain needs to be limited on machines like the Lenovo Thinkpad X13s until we have active speaker protection in place. Limit the gain to the current default setting provided by the UCM configuration which most user have so far been using (due to a bug in the configuration files which prevented hardware volume control [1]). The wsa883x PA volume control also turned out to be broken, which meant that the default setting used by UCM configuration is actually the lowest level (-3 dB). With the codec driver fixed, hardware volume control also works as expected. Note that the new wsa884x driver most likely suffers from a similar bug, I'll send a fix for that once I've got that confirmed. Included is also a related fix for the LPASS WSA macro driver, which was changing the digital gain setting behind the back of user space and which can result in excessive (or too low) digital gain. There are further Qualcomm codec drivers that similarly appear to manipulate various gain settings, but on closer inspection it turns out that they only write back the current settings. Tests reveal that these writes are indeed needed for any prior updates to take effect (at least for the WSA and RX macros). [1] alsa-project/alsa-ucm-conf#382
2 parents 7c834a7 + aafa3ac commit 7c70825

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

sound/soc/codecs/lpass-wsa-macro.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,6 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w,
15841584
u16 gain_reg;
15851585
u16 reg;
15861586
int val;
1587-
int offset_val = 0;
15881587
struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
15891588

15901589
if (w->shift == WSA_MACRO_COMP1) {
@@ -1623,10 +1622,8 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w,
16231622
CDC_WSA_RX1_RX_PATH_MIX_SEC0,
16241623
CDC_WSA_RX_PGA_HALF_DB_MASK,
16251624
CDC_WSA_RX_PGA_HALF_DB_ENABLE);
1626-
offset_val = -2;
16271625
}
16281626
val = snd_soc_component_read(component, gain_reg);
1629-
val += offset_val;
16301627
snd_soc_component_write(component, gain_reg, val);
16311628
wsa_macro_config_ear_spkr_gain(component, wsa,
16321629
event, gain_reg);
@@ -1654,10 +1651,6 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w,
16541651
CDC_WSA_RX1_RX_PATH_MIX_SEC0,
16551652
CDC_WSA_RX_PGA_HALF_DB_MASK,
16561653
CDC_WSA_RX_PGA_HALF_DB_DISABLE);
1657-
offset_val = 2;
1658-
val = snd_soc_component_read(component, gain_reg);
1659-
val += offset_val;
1660-
snd_soc_component_write(component, gain_reg, val);
16611654
}
16621655
wsa_macro_config_ear_spkr_gain(component, wsa,
16631656
event, gain_reg);

sound/soc/codecs/wcd9335.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,6 @@ static int wcd9335_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
30333033
{
30343034
struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
30353035
u16 gain_reg;
3036-
int offset_val = 0;
30373036
int val = 0;
30383037

30393038
switch (w->reg) {
@@ -3073,7 +3072,6 @@ static int wcd9335_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
30733072
switch (event) {
30743073
case SND_SOC_DAPM_POST_PMU:
30753074
val = snd_soc_component_read(comp, gain_reg);
3076-
val += offset_val;
30773075
snd_soc_component_write(comp, gain_reg, val);
30783076
break;
30793077
case SND_SOC_DAPM_POST_PMD:
@@ -3294,7 +3292,6 @@ static int wcd9335_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
32943292
u16 gain_reg;
32953293
u16 reg;
32963294
int val;
3297-
int offset_val = 0;
32983295

32993296
if (!(snd_soc_dapm_widget_name_cmp(w, "RX INT0 INTERP"))) {
33003297
reg = WCD9335_CDC_RX0_RX_PATH_CTL;
@@ -3337,7 +3334,6 @@ static int wcd9335_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
33373334
case SND_SOC_DAPM_POST_PMU:
33383335
wcd9335_config_compander(comp, w->shift, event);
33393336
val = snd_soc_component_read(comp, gain_reg);
3340-
val += offset_val;
33413337
snd_soc_component_write(comp, gain_reg, val);
33423338
break;
33433339
case SND_SOC_DAPM_POST_PMD:

sound/soc/codecs/wsa883x.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,11 @@ static int wsa_dev_mode_put(struct snd_kcontrol *kcontrol,
10981098
return 1;
10991099
}
11001100

1101-
static const DECLARE_TLV_DB_SCALE(pa_gain, -300, 150, -300);
1101+
static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(pa_gain,
1102+
0, 14, TLV_DB_SCALE_ITEM(-300, 0, 0),
1103+
15, 29, TLV_DB_SCALE_ITEM(-300, 150, 0),
1104+
30, 31, TLV_DB_SCALE_ITEM(1800, 0, 0),
1105+
);
11021106

11031107
static int wsa883x_get_swr_port(struct snd_kcontrol *kcontrol,
11041108
struct snd_ctl_elem_value *ucontrol)

0 commit comments

Comments
 (0)