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

ASoC: Intel: boards: merge DMI-based quirks in bytcr-rt5640 driver

Merge DMI quirks for various machines such as Asus T100
and clean-up code

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Mark Brown
9fd57471 a2d5563b

+62 -16
+62 -16
sound/soc/intel/boards/bytcr_rt5640.c
··· 39 39 }; 40 40 41 41 static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = { 42 + {"AIF1 Playback", NULL, "ssp2 Tx"}, 43 + {"ssp2 Tx", NULL, "codec_out0"}, 44 + {"ssp2 Tx", NULL, "codec_out1"}, 45 + {"codec_in0", NULL, "ssp2 Rx"}, 46 + {"codec_in1", NULL, "ssp2 Rx"}, 47 + {"ssp2 Rx", NULL, "AIF1 Capture"}, 48 + 42 49 {"Headset Mic", NULL, "MICBIAS1"}, 43 50 {"IN2P", NULL, "Headset Mic"}, 44 51 {"Headphone", NULL, "HPOL"}, ··· 54 47 {"Speaker", NULL, "SPOLN"}, 55 48 {"Speaker", NULL, "SPORP"}, 56 49 {"Speaker", NULL, "SPORN"}, 57 - {"Internal Mic", NULL, "MICBIAS1"}, 58 - {"IN1P", NULL, "Internal Mic"}, 59 - 60 - {"AIF1 Playback", NULL, "ssp2 Tx"}, 61 - {"ssp2 Tx", NULL, "codec_out0"}, 62 - {"ssp2 Tx", NULL, "codec_out1"}, 63 - {"codec_in0", NULL, "ssp2 Rx"}, 64 - {"codec_in1", NULL, "ssp2 Rx"}, 65 - {"ssp2 Rx", NULL, "AIF1 Capture"}, 66 50 }; 67 51 68 52 static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = { ··· 142 144 }, 143 145 {} 144 146 }; 147 + 148 + static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) 149 + { 150 + int ret; 151 + struct snd_soc_codec *codec = runtime->codec; 152 + struct snd_soc_card *card = runtime->card; 153 + const struct snd_soc_dapm_route *custom_map; 154 + int num_routes; 155 + 156 + card->dapm.idle_bias_off = true; 157 + 158 + ret = snd_soc_add_card_controls(card, byt_rt5640_controls, 159 + ARRAY_SIZE(byt_rt5640_controls)); 160 + if (ret) { 161 + dev_err(card->dev, "unable to add card controls\n"); 162 + return ret; 163 + } 164 + 165 + dmi_check_system(byt_rt5640_quirk_table); 166 + switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { 167 + case BYT_RT5640_IN1_MAP: 168 + custom_map = byt_rt5640_intmic_in1_map; 169 + num_routes = ARRAY_SIZE(byt_rt5640_intmic_in1_map); 170 + break; 171 + case BYT_RT5640_DMIC2_MAP: 172 + custom_map = byt_rt5640_intmic_dmic2_map; 173 + num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map); 174 + break; 175 + default: 176 + custom_map = byt_rt5640_intmic_dmic1_map; 177 + num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map); 178 + } 179 + 180 + ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); 181 + if (ret) 182 + return ret; 183 + 184 + if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) { 185 + ret = rt5640_dmic_enable(codec, 0, 0); 186 + if (ret) 187 + return ret; 188 + } 189 + 190 + snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone"); 191 + snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); 192 + 193 + return ret; 194 + } 145 195 146 196 static const struct snd_soc_pcm_stream byt_rt5640_dai_params = { 147 197 .formats = SNDRV_PCM_FMTBIT_S24_LE, ··· 290 244 .ignore_suspend = 1, 291 245 .dpcm_playback = 1, 292 246 .dpcm_capture = 1, 247 + .init = byt_rt5640_init, 293 248 .ops = &byt_rt5640_be_ssp2_ops, 294 249 }, 295 250 }; 296 251 297 252 /* SoC card */ 298 - static struct snd_soc_card snd_soc_card_byt_rt5640 = { 253 + static struct snd_soc_card byt_rt5640_card = { 299 254 .name = "bytcr-rt5640", 300 255 .owner = THIS_MODULE, 301 256 .dai_link = byt_rt5640_dais, ··· 305 258 .num_dapm_widgets = ARRAY_SIZE(byt_rt5640_widgets), 306 259 .dapm_routes = byt_rt5640_audio_map, 307 260 .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map), 308 - .controls = byt_rt5640_controls, 309 - .num_controls = ARRAY_SIZE(byt_rt5640_controls), 261 + .fully_routed = true, 310 262 }; 311 263 312 264 static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ··· 313 267 int ret_val = 0; 314 268 315 269 /* register the soc card */ 316 - snd_soc_card_byt_rt5640.dev = &pdev->dev; 270 + byt_rt5640_card.dev = &pdev->dev; 317 271 318 - ret_val = devm_snd_soc_register_card(&pdev->dev, 319 - &snd_soc_card_byt_rt5640); 272 + ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card); 273 + 320 274 if (ret_val) { 321 275 dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", 322 276 ret_val); 323 277 return ret_val; 324 278 } 325 - platform_set_drvdata(pdev, &snd_soc_card_byt_rt5640); 279 + platform_set_drvdata(pdev, &byt_rt5640_card); 326 280 return ret_val; 327 281 } 328 282