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

ASoC: Intel: byt-rt5640: Add quirk for Asus T100

Asus T100 internal microphone is not digital but analogue connected to IN1P
pin of the RT564x codec with shared bias between internal and headset
microphones. Because of this there is need to have machine specific DAPM
routes in byt-rt5640.

Add handling for them with the help of DMI quirk that is used to add custom
routes in addition to common. Because "Internal Mic" connected to DMIC1 is
not common to all move it as a default custom route when there is no match
in quirk table.

Custom "Internal Mic" -> "IN1P" with MICBIAS1 route is added for Asus T100.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jarkko Nikula and committed by
Mark Brown
f8a770c2 ac06dd8d

+52 -1
+52 -1
sound/soc/intel/byt-rt5640.c
··· 17 17 #include <linux/platform_device.h> 18 18 #include <linux/acpi.h> 19 19 #include <linux/device.h> 20 + #include <linux/dmi.h> 20 21 #include <linux/slab.h> 21 22 #include <sound/pcm.h> 22 23 #include <sound/pcm_params.h> ··· 37 36 static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = { 38 37 {"Headset Mic", NULL, "MICBIAS1"}, 39 38 {"IN2P", NULL, "Headset Mic"}, 40 - {"DMIC1", NULL, "Internal Mic"}, 41 39 {"Headphone", NULL, "HPOL"}, 42 40 {"Headphone", NULL, "HPOR"}, 43 41 {"Speaker", NULL, "SPOLP"}, ··· 44 44 {"Speaker", NULL, "SPORP"}, 45 45 {"Speaker", NULL, "SPORN"}, 46 46 }; 47 + 48 + static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = { 49 + {"DMIC1", NULL, "Internal Mic"}, 50 + }; 51 + 52 + static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = { 53 + {"Internal Mic", NULL, "MICBIAS1"}, 54 + {"IN1P", NULL, "Internal Mic"}, 55 + }; 56 + 57 + enum { 58 + BYT_RT5640_DMIC1_MAP, 59 + BYT_RT5640_IN1_MAP, 60 + }; 61 + 62 + static unsigned long byt_rt5640_custom_map = BYT_RT5640_DMIC1_MAP; 47 63 48 64 static const struct snd_kcontrol_new byt_rt5640_controls[] = { 49 65 SOC_DAPM_PIN_SWITCH("Headphone"), ··· 92 76 return 0; 93 77 } 94 78 79 + static int byt_rt5640_quirk_cb(const struct dmi_system_id *id) 80 + { 81 + byt_rt5640_custom_map = (unsigned long)id->driver_data; 82 + return 1; 83 + } 84 + 85 + static const struct dmi_system_id byt_rt5640_quirk_table[] = { 86 + { 87 + .callback = byt_rt5640_quirk_cb, 88 + .matches = { 89 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 90 + DMI_MATCH(DMI_PRODUCT_NAME, "T100TA"), 91 + }, 92 + .driver_data = (unsigned long *)BYT_RT5640_IN1_MAP, 93 + }, 94 + {} 95 + }; 96 + 95 97 static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) 96 98 { 97 99 int ret; 98 100 struct snd_soc_codec *codec = runtime->codec; 99 101 struct snd_soc_dapm_context *dapm = &codec->dapm; 100 102 struct snd_soc_card *card = runtime->card; 103 + const struct snd_soc_dapm_route *custom_map; 104 + int num_routes; 101 105 102 106 card->dapm.idle_bias_off = true; 103 107 ··· 127 91 dev_err(card->dev, "unable to add card controls\n"); 128 92 return ret; 129 93 } 94 + 95 + dmi_check_system(byt_rt5640_quirk_table); 96 + switch (byt_rt5640_custom_map) { 97 + case BYT_RT5640_IN1_MAP: 98 + custom_map = byt_rt5640_intmic_in1_map; 99 + num_routes = ARRAY_SIZE(byt_rt5640_intmic_in1_map); 100 + break; 101 + default: 102 + custom_map = byt_rt5640_intmic_dmic1_map; 103 + num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map); 104 + }; 105 + 106 + ret = snd_soc_dapm_add_routes(dapm, custom_map, num_routes); 107 + if (ret) 108 + return ret; 130 109 131 110 snd_soc_dapm_ignore_suspend(dapm, "HPOL"); 132 111 snd_soc_dapm_ignore_suspend(dapm, "HPOR");