Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: cs42l52: Make MICA/B mixer dependent on mic config

MICA/B Single-Ended input selection depends on mica/b config so lets
make the mixer controls for them only show for selected mic's

Signed-off-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Brian Austin and committed by
Mark Brown
44b2ed54 a3d36bc2

+34 -11
+4 -4
include/sound/cs42l52.h
··· 16 16 /* MICBIAS Level. Check datasheet Pg48 */ 17 17 unsigned int micbias_lvl; 18 18 19 - /* MICA mode selection 0=Single 1=Differential */ 20 - unsigned int mica_cfg; 19 + /* MICA mode selection Differential or Single-ended */ 20 + bool mica_diff_cfg; 21 21 22 - /* MICB mode selection 0=Single 1=Differential */ 23 - unsigned int micb_cfg; 22 + /* MICB mode selection Differential or Single-ended */ 23 + bool micb_diff_cfg; 24 24 25 25 /* Charge Pump Freq. Check datasheet Pg73 */ 26 26 unsigned int chgfreq;
+30 -7
sound/soc/codecs/cs42l52.c
··· 419 419 420 420 SOC_DOUBLE("Bypass Mute", CS42L52_MISC_CTL, 4, 5, 1, 0), 421 421 422 - SOC_ENUM("MICA Select", mica_enum), 423 - SOC_ENUM("MICB Select", micb_enum), 424 - 425 422 SOC_DOUBLE_R_TLV("MIC Gain Volume", CS42L52_MICA_CTL, 426 423 CS42L52_MICB_CTL, 0, 0x10, 0, mic_tlv), 427 424 ··· 524 527 SOC_SINGLE("PGA MICB Switch", CS42L52_ADC_PGA_B, 4, 1, 0), 525 528 526 529 }; 530 + 531 + static const struct snd_kcontrol_new cs42l52_mica_controls[] = { 532 + SOC_ENUM("MICA Select", mica_enum), 533 + }; 534 + 535 + static const struct snd_kcontrol_new cs42l52_micb_controls[] = { 536 + SOC_ENUM("MICB Select", micb_enum), 537 + }; 538 + 539 + static int cs42l52_add_mic_controls(struct snd_soc_codec *codec) 540 + { 541 + struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); 542 + struct cs42l52_platform_data *pdata = &cs42l52->pdata; 543 + 544 + if (!pdata->mica_diff_cfg) 545 + snd_soc_add_codec_controls(codec, cs42l52_mica_controls, 546 + ARRAY_SIZE(cs42l52_mica_controls)); 547 + 548 + if (!pdata->micb_diff_cfg) 549 + snd_soc_add_codec_controls(codec, cs42l52_micb_controls, 550 + ARRAY_SIZE(cs42l52_micb_controls)); 551 + 552 + return 0; 553 + } 527 554 528 555 static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { 529 556 ··· 1125 1104 } 1126 1105 regcache_cache_only(cs42l52->regmap, true); 1127 1106 1107 + cs42l52_add_mic_controls(codec); 1108 + 1128 1109 cs42l52_init_beep(codec); 1129 1110 1130 1111 cs42l52_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ··· 1244 1221 reg & 0xFF); 1245 1222 1246 1223 /* Set Platform Data */ 1247 - if (cs42l52->pdata.mica_cfg) 1224 + if (cs42l52->pdata.mica_diff_cfg) 1248 1225 regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, 1249 1226 CS42L52_MIC_CTL_TYPE_MASK, 1250 - cs42l52->pdata.mica_cfg << 1227 + cs42l52->pdata.mica_diff_cfg << 1251 1228 CS42L52_MIC_CTL_TYPE_SHIFT); 1252 1229 1253 - if (cs42l52->pdata.micb_cfg) 1230 + if (cs42l52->pdata.micb_diff_cfg) 1254 1231 regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, 1255 1232 CS42L52_MIC_CTL_TYPE_MASK, 1256 - cs42l52->pdata.micb_cfg << 1233 + cs42l52->pdata.micb_diff_cfg << 1257 1234 CS42L52_MIC_CTL_TYPE_SHIFT); 1258 1235 1259 1236 if (cs42l52->pdata.chgfreq)