Skip to content

Commit 8619fd0

Browse files
jwrdegoedebroonie
authored andcommitted
ASoC: Intel: bytcr_wm5102: Add BYT_WM5102_IN_MAP quirk
Unlike all designs supported sofar the Lenovo Yoga Tab 3 YT3-X90 does not have its internal microphone (intmic) on IN3L with the headset microphone on IN1L. Instead this tablet has the intmic on IN1L and the hsmic on IN2L. Add a BYT_WM5102_IN_MAP quirk mechanism to allow selecting between different input maps and add support for both setups with the current settings being the default map. The new INTMIC_IN1L_HSMIC_IN2L map is enabled by default on CHT because the Lenovo Yoga Tab 3 YT3-X90 model is the only Cherry Trail design currently supported. If different CHT designs turn up which need different input maps we can add DMI quirks to select a different map later. The userspace UCM profile also needs to know about this so extend the components string with this info too. Acked-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c556d20 commit 8619fd0

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

sound/soc/intel/boards/bytcr_wm5102.c

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@ struct byt_wm5102_private {
3838
int mclk_freq;
3939
};
4040

41-
/* Bits 0-3 are reserved for the input-map */
41+
#define BYT_WM5102_IN_MAP GENMASK(3, 0)
4242
#define BYT_WM5102_OUT_MAP GENMASK(7, 4)
4343
#define BYT_WM5102_SSP2 BIT(16)
4444
#define BYT_WM5102_MCLK_19_2MHZ BIT(17)
4545

46+
enum {
47+
BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L,
48+
BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L,
49+
};
50+
4651
/* Note these values are pre-shifted for easy use of setting quirks */
4752
enum {
4853
BYT_WM5102_SPK_SPK_MAP = FIELD_PREP_CONST(BYT_WM5102_OUT_MAP, 0),
@@ -57,6 +62,20 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");
5762

5863
static void log_quirks(struct device *dev)
5964
{
65+
switch (quirk & BYT_WM5102_IN_MAP) {
66+
case BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L:
67+
dev_info_once(dev, "quirk INTMIC_IN3L_HSMIC_IN1L enabled\n");
68+
break;
69+
case BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L:
70+
dev_info_once(dev, "quirk INTMIC_IN1L_HSMIC_IN2L enabled\n");
71+
break;
72+
default:
73+
dev_warn_once(dev, "quirk sets invalid input map: 0x%lx, defaulting to INTMIC_IN3L_HSMIC_IN1L\n",
74+
quirk & BYT_WM5102_IN_MAP);
75+
quirk &= ~BYT_WM5102_IN_MAP;
76+
quirk |= BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L;
77+
break;
78+
}
6079
switch (quirk & BYT_WM5102_OUT_MAP) {
6180
case BYT_WM5102_SPK_SPK_MAP:
6281
dev_info_once(dev, "quirk SPK_SPK_MAP enabled\n");
@@ -191,16 +210,13 @@ static const struct snd_soc_dapm_route byt_wm5102_audio_map[] = {
191210
{"Headphone", NULL, "HPOUT1L"},
192211
{"Headphone", NULL, "HPOUT1R"},
193212

194-
{"Internal Mic", NULL, "MICBIAS3"},
195-
{"IN3L", NULL, "Internal Mic"},
196-
197213
/*
198214
* The Headset Mix uses MICBIAS1 or 2 depending on if a CTIA/OMTP Headset
199215
* is connected, as the MICBIAS is applied after the CTIA/OMTP cross-switch.
200216
*/
201217
{"Headset Mic", NULL, "MICBIAS1"},
202218
{"Headset Mic", NULL, "MICBIAS2"},
203-
{"IN1L", NULL, "Headset Mic"},
219+
{"Internal Mic", NULL, "MICBIAS3"},
204220
};
205221

206222
static const struct snd_soc_dapm_route bytcr_wm5102_ssp0_map[] = {
@@ -231,6 +247,16 @@ static const struct snd_soc_dapm_route byt_wm5102_spk_hpout2_map[] = {
231247
{"Speaker", NULL, "HPOUT2R"},
232248
};
233249

250+
static const struct snd_soc_dapm_route byt_wm5102_intmic_in3l_hsmic_in1l_map[] = {
251+
{"IN3L", NULL, "Internal Mic"},
252+
{"IN1L", NULL, "Headset Mic"},
253+
};
254+
255+
static const struct snd_soc_dapm_route byt_wm5102_intmic_in1l_hsmic_in2l_map[] = {
256+
{"IN1L", NULL, "Internal Mic"},
257+
{"IN2L", NULL, "Headset Mic"},
258+
};
259+
234260
static const struct snd_kcontrol_new byt_wm5102_controls[] = {
235261
SOC_DAPM_PIN_SWITCH("Headphone"),
236262
SOC_DAPM_PIN_SWITCH("Headset Mic"),
@@ -271,6 +297,20 @@ static int byt_wm5102_init(struct snd_soc_pcm_runtime *runtime)
271297
return ret;
272298
}
273299

300+
switch (quirk & BYT_WM5102_IN_MAP) {
301+
case BYT_WM5102_INTMIC_IN3L_HSMIC_IN1L:
302+
custom_map = byt_wm5102_intmic_in3l_hsmic_in1l_map;
303+
num_routes = ARRAY_SIZE(byt_wm5102_intmic_in3l_hsmic_in1l_map);
304+
break;
305+
case BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L:
306+
custom_map = byt_wm5102_intmic_in1l_hsmic_in2l_map;
307+
num_routes = ARRAY_SIZE(byt_wm5102_intmic_in1l_hsmic_in2l_map);
308+
break;
309+
}
310+
ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
311+
if (ret)
312+
return ret;
313+
274314
switch (quirk & BYT_WM5102_OUT_MAP) {
275315
case BYT_WM5102_SPK_SPK_MAP:
276316
custom_map = byt_wm5102_spk_spk_map;
@@ -481,6 +521,8 @@ static char byt_wm5102_components[64]; /* = "cfg-spk:* cfg-int-mic:* cfg-hs-mic:
481521
static int snd_byt_wm5102_mc_probe(struct platform_device *pdev)
482522
{
483523
static const char * const out_map_name[] = { "spk", "hpout2" };
524+
static const char * const intmic_map_name[] = { "in3l", "in1l" };
525+
static const char * const hsmic_map_name[] = { "in1l", "in2l" };
484526
char codec_name[SND_ACPI_I2C_ID_LEN];
485527
struct device *dev = &pdev->dev;
486528
struct byt_wm5102_private *priv;
@@ -541,9 +583,10 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev)
541583
/*
542584
* CHT always uses SSP2 and 19.2 MHz; and
543585
* the one currently supported CHT design uses HPOUT2 as
544-
* speaker output.
586+
* speaker output and has the intmic on IN1L + hsmic on IN2L.
545587
*/
546588
quirk = BYT_WM5102_SSP2 | BYT_WM5102_MCLK_19_2MHZ |
589+
BYT_WM5102_INTMIC_IN1L_HSMIC_IN2L |
547590
BYT_WM5102_SPK_HPOUT2_MAP;
548591
}
549592
if (quirk_override != -1) {
@@ -554,7 +597,10 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev)
554597
log_quirks(dev);
555598

556599
snprintf(byt_wm5102_components, sizeof(byt_wm5102_components),
557-
"cfg-spk:%s", out_map_name[FIELD_GET(BYT_WM5102_OUT_MAP, quirk)]);
600+
"cfg-spk:%s cfg-intmic:%s cfg-hsmic:%s",
601+
out_map_name[FIELD_GET(BYT_WM5102_OUT_MAP, quirk)],
602+
intmic_map_name[FIELD_GET(BYT_WM5102_IN_MAP, quirk)],
603+
hsmic_map_name[FIELD_GET(BYT_WM5102_IN_MAP, quirk)]);
558604
byt_wm5102_card.components = byt_wm5102_components;
559605

560606
/* find index of codec dai */

0 commit comments

Comments
 (0)