History

ASoC: wcd9335: Use int array instead of bitmask for TX mixers

Currently slim_tx_mixer_get reports all TX mixers as enabled when at least one is, due to it reading the entire tx_port_value bitmask without testing the specific bit corresponding to a TX port. Furthermore, using the same bitmask for all capture DAIs makes setting one mixer affect them all. To prevent this, and since the SLIM TX muxes effectively only connect to one of the mixers at a time, turn tx_port_value into an int array storing the DAI index each of the ports is connected to.

Yassine Oudjana committed 4 years ago

Commit a5d6d281 parent 7d90c8e1 file · +11 −6Browse files

Unified · Split

sound/soc/codecs/wcd9335.c+11−6
@@ -342,7 +342,7 @@ struct wcd9335_codec { · 341 unmodified lines
342 struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY];342 struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY];
343 343
344 unsigned int rx_port_value[WCD9335_RX_MAX];344 unsigned int rx_port_value[WCD9335_RX_MAX];
345 unsigned int tx_port_value;345 unsigned int tx_port_value[WCD9335_TX_MAX];
346 int hph_l_gain;346 int hph_l_gain;
347 int hph_r_gain;347 int hph_r_gain;
348 u32 rx_bias_count;348 u32 rx_bias_count;
@@ -1334,8 +1334,13 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc, · 985 unmodified lines
1334 1334
1335 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc);1335 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc);
1336 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev);1336 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev);
1337 struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc);
1338 struct soc_mixer_control *mixer =
1339 (struct soc_mixer_control *)kc->private_value;
1340 int dai_id = widget->shift;
1341 int port_id = mixer->shift;
1337 1342
1338 ucontrol->value.integer.value[0] = wcd->tx_port_value;1343 ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id;
1339 1344
1340 return 0;1345 return 0;
1341}1346}
@@ -1358,12 +1363,12 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc, · 16 unmodified lines
1358 case AIF2_CAP:1363 case AIF2_CAP:
1359 case AIF3_CAP:1364 case AIF3_CAP:
1360 /* only add to the list if value not set */1365 /* only add to the list if value not set */
1361 if (enable && !(wcd->tx_port_value & BIT(port_id))) {1366 if (enable && wcd->tx_port_value[port_id] != dai_id) {
1362 wcd->tx_port_value |= BIT(port_id);1367 wcd->tx_port_value[port_id] = dai_id;
1363 list_add_tail(&wcd->tx_chs[port_id].list,1368 list_add_tail(&wcd->tx_chs[port_id].list,
1364 &wcd->dai[dai_id].slim_ch_list);1369 &wcd->dai[dai_id].slim_ch_list);
1365 } else if (!enable && (wcd->tx_port_value & BIT(port_id))) {1370 } else if (!enable && wcd->tx_port_value[port_id] == dai_id) {
1366 wcd->tx_port_value &= ~BIT(port_id);1371 wcd->tx_port_value[port_id] = -1;
1367 list_del_init(&wcd->tx_chs[port_id].list);1372 list_del_init(&wcd->tx_chs[port_id].list);
1368 }1373 }
1369 break;1374 break;