kbl_rt5663_rt5514_max98927.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * Intel Kabylake I2S Machine Driver with MAXIM98927
  3. * RT5514 and RT5663 Codecs
  4. *
  5. * Copyright (C) 2017, Intel Corporation. All rights reserved.
  6. *
  7. * Modified from:
  8. * Intel Kabylake I2S Machine driver supporting MAXIM98927 and
  9. * RT5663 codecs
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License version
  13. * 2 as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. */
  20. #include <linux/input.h>
  21. #include <linux/module.h>
  22. #include <linux/platform_device.h>
  23. #include <sound/core.h>
  24. #include <sound/jack.h>
  25. #include <sound/pcm.h>
  26. #include <sound/pcm_params.h>
  27. #include <sound/soc.h>
  28. #include "../../codecs/rt5514.h"
  29. #include "../../codecs/rt5663.h"
  30. #include "../../codecs/hdac_hdmi.h"
  31. #include "../skylake/skl.h"
  32. #define KBL_REALTEK_CODEC_DAI "rt5663-aif"
  33. #define KBL_REALTEK_DMIC_CODEC_DAI "rt5514-aif1"
  34. #define KBL_MAXIM_CODEC_DAI "max98927-aif1"
  35. #define MAXIM_DEV0_NAME "i2c-MX98927:00"
  36. #define MAXIM_DEV1_NAME "i2c-MX98927:01"
  37. #define RT5514_DEV_NAME "i2c-10EC5514:00"
  38. #define RT5663_DEV_NAME "i2c-10EC5663:00"
  39. #define RT5514_AIF1_BCLK_FREQ (48000 * 8 * 16)
  40. #define RT5514_AIF1_SYSCLK_FREQ 12288000
  41. #define NAME_SIZE 32
  42. #define DMIC_CH(p) p->list[p->count-1]
  43. static struct snd_soc_card kabylake_audio_card;
  44. static const struct snd_pcm_hw_constraint_list *dmic_constraints;
  45. struct kbl_hdmi_pcm {
  46. struct list_head head;
  47. struct snd_soc_dai *codec_dai;
  48. int device;
  49. };
  50. struct kbl_codec_private {
  51. struct snd_soc_jack kabylake_headset;
  52. struct list_head hdmi_pcm_list;
  53. struct snd_soc_jack kabylake_hdmi[2];
  54. };
  55. enum {
  56. KBL_DPCM_AUDIO_PB = 0,
  57. KBL_DPCM_AUDIO_CP,
  58. KBL_DPCM_AUDIO_HS_PB,
  59. KBL_DPCM_AUDIO_ECHO_REF_CP,
  60. KBL_DPCM_AUDIO_DMIC_CP,
  61. KBL_DPCM_AUDIO_RT5514_DSP,
  62. KBL_DPCM_AUDIO_HDMI1_PB,
  63. KBL_DPCM_AUDIO_HDMI2_PB,
  64. };
  65. static const struct snd_kcontrol_new kabylake_controls[] = {
  66. SOC_DAPM_PIN_SWITCH("Headphone Jack"),
  67. SOC_DAPM_PIN_SWITCH("Headset Mic"),
  68. SOC_DAPM_PIN_SWITCH("Left Spk"),
  69. SOC_DAPM_PIN_SWITCH("Right Spk"),
  70. SOC_DAPM_PIN_SWITCH("DMIC"),
  71. };
  72. static const struct snd_soc_dapm_widget kabylake_widgets[] = {
  73. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  74. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  75. SND_SOC_DAPM_SPK("Left Spk", NULL),
  76. SND_SOC_DAPM_SPK("Right Spk", NULL),
  77. SND_SOC_DAPM_MIC("DMIC", NULL),
  78. SND_SOC_DAPM_SPK("HDMI1", NULL),
  79. SND_SOC_DAPM_SPK("HDMI2", NULL),
  80. };
  81. static const struct snd_soc_dapm_route kabylake_map[] = {
  82. /* Headphones */
  83. { "Headphone Jack", NULL, "HPOL" },
  84. { "Headphone Jack", NULL, "HPOR" },
  85. /* speaker */
  86. { "Left Spk", NULL, "Left BE_OUT" },
  87. { "Right Spk", NULL, "Right BE_OUT" },
  88. /* other jacks */
  89. { "IN1P", NULL, "Headset Mic" },
  90. { "IN1N", NULL, "Headset Mic" },
  91. /* CODEC BE connections */
  92. { "Left HiFi Playback", NULL, "ssp0 Tx" },
  93. { "Right HiFi Playback", NULL, "ssp0 Tx" },
  94. { "ssp0 Tx", NULL, "spk_out" },
  95. { "AIF Playback", NULL, "ssp1 Tx" },
  96. { "ssp1 Tx", NULL, "codec1_out" },
  97. { "hs_in", NULL, "ssp1 Rx" },
  98. { "ssp1 Rx", NULL, "AIF Capture" },
  99. { "codec1_in", NULL, "ssp0 Rx" },
  100. { "ssp0 Rx", NULL, "AIF1 Capture" },
  101. /* IV feedback path */
  102. { "codec0_fb_in", NULL, "ssp0 Rx"},
  103. { "ssp0 Rx", NULL, "Left HiFi Capture" },
  104. { "ssp0 Rx", NULL, "Right HiFi Capture" },
  105. /* DMIC */
  106. { "DMIC1L", NULL, "DMIC" },
  107. { "DMIC1R", NULL, "DMIC" },
  108. { "DMIC2L", NULL, "DMIC" },
  109. { "DMIC2R", NULL, "DMIC" },
  110. { "hifi2", NULL, "iDisp2 Tx" },
  111. { "iDisp2 Tx", NULL, "iDisp2_out" },
  112. { "hifi1", NULL, "iDisp1 Tx" },
  113. { "iDisp1 Tx", NULL, "iDisp1_out" },
  114. };
  115. static struct snd_soc_codec_conf max98927_codec_conf[] = {
  116. {
  117. .dev_name = MAXIM_DEV0_NAME,
  118. .name_prefix = "Right",
  119. },
  120. {
  121. .dev_name = MAXIM_DEV1_NAME,
  122. .name_prefix = "Left",
  123. },
  124. };
  125. static struct snd_soc_dai_link_component ssp0_codec_components[] = {
  126. { /* Left */
  127. .name = MAXIM_DEV0_NAME,
  128. .dai_name = KBL_MAXIM_CODEC_DAI,
  129. },
  130. { /* Right */
  131. .name = MAXIM_DEV1_NAME,
  132. .dai_name = KBL_MAXIM_CODEC_DAI,
  133. },
  134. { /*dmic */
  135. .name = RT5514_DEV_NAME,
  136. .dai_name = KBL_REALTEK_DMIC_CODEC_DAI,
  137. },
  138. };
  139. static int kabylake_rt5663_fe_init(struct snd_soc_pcm_runtime *rtd)
  140. {
  141. struct snd_soc_dapm_context *dapm;
  142. struct snd_soc_component *component = rtd->cpu_dai->component;
  143. int ret;
  144. dapm = snd_soc_component_get_dapm(component);
  145. ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
  146. if (ret)
  147. dev_err(rtd->dev, "Ref Cap -Ignore suspend failed = %d\n", ret);
  148. return ret;
  149. }
  150. static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
  151. {
  152. int ret;
  153. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  154. struct snd_soc_codec *codec = rtd->codec;
  155. struct snd_soc_jack *jack;
  156. /*
  157. * Headset buttons map to the google Reference headset.
  158. * These can be configured by userspace.
  159. */
  160. ret = snd_soc_card_jack_new(&kabylake_audio_card, "Headset Jack",
  161. SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
  162. SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->kabylake_headset,
  163. NULL, 0);
  164. if (ret) {
  165. dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
  166. return ret;
  167. }
  168. jack = &ctx->kabylake_headset;
  169. snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
  170. snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
  171. snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
  172. snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
  173. rt5663_set_jack_detect(codec, &ctx->kabylake_headset);
  174. ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC");
  175. if (ret)
  176. dev_err(rtd->dev, "DMIC - Ignore suspend failed = %d\n", ret);
  177. return ret;
  178. }
  179. static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
  180. {
  181. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  182. struct snd_soc_dai *dai = rtd->codec_dai;
  183. struct kbl_hdmi_pcm *pcm;
  184. pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
  185. if (!pcm)
  186. return -ENOMEM;
  187. pcm->device = device;
  188. pcm->codec_dai = dai;
  189. list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
  190. return 0;
  191. }
  192. static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
  193. {
  194. return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
  195. }
  196. static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
  197. {
  198. return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
  199. }
  200. static const unsigned int rates[] = {
  201. 48000,
  202. };
  203. static const struct snd_pcm_hw_constraint_list constraints_rates = {
  204. .count = ARRAY_SIZE(rates),
  205. .list = rates,
  206. .mask = 0,
  207. };
  208. static const unsigned int channels[] = {
  209. 2,
  210. };
  211. static const struct snd_pcm_hw_constraint_list constraints_channels = {
  212. .count = ARRAY_SIZE(channels),
  213. .list = channels,
  214. .mask = 0,
  215. };
  216. static int kbl_fe_startup(struct snd_pcm_substream *substream)
  217. {
  218. struct snd_pcm_runtime *runtime = substream->runtime;
  219. /*
  220. * On this platform for PCM device we support,
  221. * 48Khz
  222. * stereo
  223. * 16 bit audio
  224. */
  225. runtime->hw.channels_max = 2;
  226. snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
  227. &constraints_channels);
  228. runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
  229. snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
  230. snd_pcm_hw_constraint_list(runtime, 0,
  231. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  232. return 0;
  233. }
  234. static const struct snd_soc_ops kabylake_rt5663_fe_ops = {
  235. .startup = kbl_fe_startup,
  236. };
  237. static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
  238. struct snd_pcm_hw_params *params)
  239. {
  240. struct snd_interval *rate = hw_param_interval(params,
  241. SNDRV_PCM_HW_PARAM_RATE);
  242. struct snd_interval *channels = hw_param_interval(params,
  243. SNDRV_PCM_HW_PARAM_CHANNELS);
  244. struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
  245. struct snd_soc_dpcm *dpcm = container_of(
  246. params, struct snd_soc_dpcm, hw_params);
  247. struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
  248. struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
  249. /*
  250. * The ADSP will convert the FE rate to 48k, stereo, 24 bit
  251. */
  252. if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
  253. !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
  254. !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
  255. rate->min = rate->max = 48000;
  256. channels->min = channels->max = 2;
  257. snd_mask_none(fmt);
  258. snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
  259. } else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
  260. if (params_channels(params) == 2 ||
  261. DMIC_CH(dmic_constraints) == 2)
  262. channels->min = channels->max = 2;
  263. else
  264. channels->min = channels->max = 4;
  265. }
  266. /*
  267. * The speaker on the SSP0 supports S16_LE and not S24_LE.
  268. * thus changing the mask here
  269. */
  270. if (!strcmp(be_dai_link->name, "SSP0-Codec"))
  271. snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
  272. return 0;
  273. }
  274. static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
  275. struct snd_pcm_hw_params *params)
  276. {
  277. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  278. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  279. int ret;
  280. /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
  281. rt5663_sel_asrc_clk_src(codec_dai->codec,
  282. RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
  283. RT5663_CLK_SEL_I2S1_ASRC);
  284. ret = snd_soc_dai_set_sysclk(codec_dai,
  285. RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
  286. if (ret < 0)
  287. dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
  288. return ret;
  289. }
  290. static struct snd_soc_ops kabylake_rt5663_ops = {
  291. .hw_params = kabylake_rt5663_hw_params,
  292. };
  293. static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
  294. struct snd_pcm_hw_params *params)
  295. {
  296. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  297. int ret = 0, j;
  298. for (j = 0; j < rtd->num_codecs; j++) {
  299. struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
  300. if (!strcmp(codec_dai->component->name, RT5514_DEV_NAME)) {
  301. ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0, 8, 16);
  302. if (ret < 0) {
  303. dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
  304. return ret;
  305. }
  306. ret = snd_soc_dai_set_sysclk(codec_dai,
  307. RT5514_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
  308. if (ret < 0) {
  309. dev_err(rtd->dev, "set sysclk err: %d\n", ret);
  310. return ret;
  311. }
  312. }
  313. if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
  314. ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
  315. if (ret < 0) {
  316. dev_err(rtd->dev, "DEV0 TDM slot err:%d\n", ret);
  317. return ret;
  318. }
  319. }
  320. if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) {
  321. ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
  322. if (ret < 0) {
  323. dev_err(rtd->dev, "DEV1 TDM slot err:%d\n", ret);
  324. return ret;
  325. }
  326. }
  327. }
  328. return ret;
  329. }
  330. static struct snd_soc_ops kabylake_ssp0_ops = {
  331. .hw_params = kabylake_ssp0_hw_params,
  332. };
  333. static const unsigned int channels_dmic[] = {
  334. 4,
  335. };
  336. static const struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
  337. .count = ARRAY_SIZE(channels_dmic),
  338. .list = channels_dmic,
  339. .mask = 0,
  340. };
  341. static const unsigned int dmic_2ch[] = {
  342. 4,
  343. };
  344. static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
  345. .count = ARRAY_SIZE(dmic_2ch),
  346. .list = dmic_2ch,
  347. .mask = 0,
  348. };
  349. static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
  350. {
  351. struct snd_pcm_runtime *runtime = substream->runtime;
  352. runtime->hw.channels_max = DMIC_CH(dmic_constraints);
  353. snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
  354. dmic_constraints);
  355. return snd_pcm_hw_constraint_list(substream->runtime, 0,
  356. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  357. }
  358. static struct snd_soc_ops kabylake_dmic_ops = {
  359. .startup = kabylake_dmic_startup,
  360. };
  361. /* kabylake digital audio interface glue - connects codec <--> CPU */
  362. static struct snd_soc_dai_link kabylake_dais[] = {
  363. /* Front End DAI links */
  364. [KBL_DPCM_AUDIO_PB] = {
  365. .name = "Kbl Audio Port",
  366. .stream_name = "Audio",
  367. .cpu_dai_name = "System Pin",
  368. .platform_name = "0000:00:1f.3",
  369. .dynamic = 1,
  370. .codec_name = "snd-soc-dummy",
  371. .codec_dai_name = "snd-soc-dummy-dai",
  372. .nonatomic = 1,
  373. .init = kabylake_rt5663_fe_init,
  374. .trigger = {
  375. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  376. .dpcm_playback = 1,
  377. .ops = &kabylake_rt5663_fe_ops,
  378. },
  379. [KBL_DPCM_AUDIO_CP] = {
  380. .name = "Kbl Audio Capture Port",
  381. .stream_name = "Audio Record",
  382. .cpu_dai_name = "System Pin",
  383. .platform_name = "0000:00:1f.3",
  384. .dynamic = 1,
  385. .codec_name = "snd-soc-dummy",
  386. .codec_dai_name = "snd-soc-dummy-dai",
  387. .nonatomic = 1,
  388. .trigger = {
  389. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  390. .dpcm_capture = 1,
  391. .ops = &kabylake_rt5663_fe_ops,
  392. },
  393. [KBL_DPCM_AUDIO_HS_PB] = {
  394. .name = "Kbl Audio Headset Playback",
  395. .stream_name = "Headset Audio",
  396. .cpu_dai_name = "System Pin2",
  397. .codec_name = "snd-soc-dummy",
  398. .codec_dai_name = "snd-soc-dummy-dai",
  399. .platform_name = "0000:00:1f.3",
  400. .dpcm_playback = 1,
  401. .nonatomic = 1,
  402. .dynamic = 1,
  403. },
  404. [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
  405. .name = "Kbl Audio Echo Reference cap",
  406. .stream_name = "Echoreference Capture",
  407. .cpu_dai_name = "Echoref Pin",
  408. .codec_name = "snd-soc-dummy",
  409. .codec_dai_name = "snd-soc-dummy-dai",
  410. .platform_name = "0000:00:1f.3",
  411. .init = NULL,
  412. .capture_only = 1,
  413. .nonatomic = 1,
  414. },
  415. [KBL_DPCM_AUDIO_RT5514_DSP] = {
  416. .name = "rt5514 dsp",
  417. .stream_name = "Wake on Voice",
  418. .cpu_dai_name = "spi-PRP0001:00",
  419. .platform_name = "spi-PRP0001:00",
  420. .codec_name = "snd-soc-dummy",
  421. .codec_dai_name = "snd-soc-dummy-dai",
  422. },
  423. [KBL_DPCM_AUDIO_DMIC_CP] = {
  424. .name = "Kbl Audio DMIC cap",
  425. .stream_name = "dmiccap",
  426. .cpu_dai_name = "DMIC Pin",
  427. .codec_name = "snd-soc-dummy",
  428. .codec_dai_name = "snd-soc-dummy-dai",
  429. .platform_name = "0000:00:1f.3",
  430. .init = NULL,
  431. .dpcm_capture = 1,
  432. .nonatomic = 1,
  433. .dynamic = 1,
  434. .ops = &kabylake_dmic_ops,
  435. },
  436. [KBL_DPCM_AUDIO_HDMI1_PB] = {
  437. .name = "Kbl HDMI Port1",
  438. .stream_name = "Hdmi1",
  439. .cpu_dai_name = "HDMI1 Pin",
  440. .codec_name = "snd-soc-dummy",
  441. .codec_dai_name = "snd-soc-dummy-dai",
  442. .platform_name = "0000:00:1f.3",
  443. .dpcm_playback = 1,
  444. .init = NULL,
  445. .trigger = {
  446. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  447. .nonatomic = 1,
  448. .dynamic = 1,
  449. },
  450. [KBL_DPCM_AUDIO_HDMI2_PB] = {
  451. .name = "Kbl HDMI Port2",
  452. .stream_name = "Hdmi2",
  453. .cpu_dai_name = "HDMI2 Pin",
  454. .codec_name = "snd-soc-dummy",
  455. .codec_dai_name = "snd-soc-dummy-dai",
  456. .platform_name = "0000:00:1f.3",
  457. .dpcm_playback = 1,
  458. .init = NULL,
  459. .trigger = {
  460. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  461. .nonatomic = 1,
  462. .dynamic = 1,
  463. },
  464. /* Back End DAI links */
  465. /* single Back end dai for both max speakers and dmic */
  466. {
  467. /* SSP0 - Codec */
  468. .name = "SSP0-Codec",
  469. .id = 0,
  470. .cpu_dai_name = "SSP0 Pin",
  471. .platform_name = "0000:00:1f.3",
  472. .no_pcm = 1,
  473. .codecs = ssp0_codec_components,
  474. .num_codecs = ARRAY_SIZE(ssp0_codec_components),
  475. .dai_fmt = SND_SOC_DAIFMT_DSP_B |
  476. SND_SOC_DAIFMT_NB_NF |
  477. SND_SOC_DAIFMT_CBS_CFS,
  478. .ignore_pmdown_time = 1,
  479. .be_hw_params_fixup = kabylake_ssp_fixup,
  480. .dpcm_playback = 1,
  481. .dpcm_capture = 1,
  482. .ops = &kabylake_ssp0_ops,
  483. },
  484. {
  485. .name = "SSP1-Codec",
  486. .id = 1,
  487. .cpu_dai_name = "SSP1 Pin",
  488. .platform_name = "0000:00:1f.3",
  489. .no_pcm = 1,
  490. .codec_name = RT5663_DEV_NAME,
  491. .codec_dai_name = KBL_REALTEK_CODEC_DAI,
  492. .init = kabylake_rt5663_codec_init,
  493. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  494. SND_SOC_DAIFMT_CBS_CFS,
  495. .ignore_pmdown_time = 1,
  496. .be_hw_params_fixup = kabylake_ssp_fixup,
  497. .ops = &kabylake_rt5663_ops,
  498. .dpcm_playback = 1,
  499. .dpcm_capture = 1,
  500. },
  501. {
  502. .name = "iDisp1",
  503. .id = 3,
  504. .cpu_dai_name = "iDisp1 Pin",
  505. .codec_name = "ehdaudio0D2",
  506. .codec_dai_name = "intel-hdmi-hifi1",
  507. .platform_name = "0000:00:1f.3",
  508. .dpcm_playback = 1,
  509. .init = kabylake_hdmi1_init,
  510. .no_pcm = 1,
  511. },
  512. {
  513. .name = "iDisp2",
  514. .id = 4,
  515. .cpu_dai_name = "iDisp2 Pin",
  516. .codec_name = "ehdaudio0D2",
  517. .codec_dai_name = "intel-hdmi-hifi2",
  518. .platform_name = "0000:00:1f.3",
  519. .init = kabylake_hdmi2_init,
  520. .dpcm_playback = 1,
  521. .no_pcm = 1,
  522. },
  523. };
  524. static int kabylake_card_late_probe(struct snd_soc_card *card)
  525. {
  526. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
  527. struct kbl_hdmi_pcm *pcm;
  528. struct snd_soc_codec *codec = NULL;
  529. int err, i = 0;
  530. char jack_name[NAME_SIZE];
  531. list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
  532. codec = pcm->codec_dai->codec;
  533. snprintf(jack_name, sizeof(jack_name),
  534. "HDMI/DP,pcm=%d Jack", pcm->device);
  535. err = snd_soc_card_jack_new(card, jack_name,
  536. SND_JACK_AVOUT, &ctx->kabylake_hdmi[i],
  537. NULL, 0);
  538. if (err)
  539. return err;
  540. err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
  541. &ctx->kabylake_hdmi[i]);
  542. if (err < 0)
  543. return err;
  544. i++;
  545. }
  546. if (!codec)
  547. return -EINVAL;
  548. return hdac_hdmi_jack_port_init(codec, &card->dapm);
  549. }
  550. /*
  551. * kabylake audio machine driver for MAX98927 + RT5514 + RT5663
  552. */
  553. static struct snd_soc_card kabylake_audio_card = {
  554. .name = "kbl_r5514_5663_max",
  555. .owner = THIS_MODULE,
  556. .dai_link = kabylake_dais,
  557. .num_links = ARRAY_SIZE(kabylake_dais),
  558. .controls = kabylake_controls,
  559. .num_controls = ARRAY_SIZE(kabylake_controls),
  560. .dapm_widgets = kabylake_widgets,
  561. .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
  562. .dapm_routes = kabylake_map,
  563. .num_dapm_routes = ARRAY_SIZE(kabylake_map),
  564. .codec_conf = max98927_codec_conf,
  565. .num_configs = ARRAY_SIZE(max98927_codec_conf),
  566. .fully_routed = true,
  567. .late_probe = kabylake_card_late_probe,
  568. };
  569. static int kabylake_audio_probe(struct platform_device *pdev)
  570. {
  571. struct kbl_codec_private *ctx;
  572. struct skl_machine_pdata *pdata;
  573. ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
  574. if (!ctx)
  575. return -ENOMEM;
  576. INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
  577. kabylake_audio_card.dev = &pdev->dev;
  578. snd_soc_card_set_drvdata(&kabylake_audio_card, ctx);
  579. pdata = dev_get_drvdata(&pdev->dev);
  580. if (pdata)
  581. dmic_constraints = pdata->dmic_num == 2 ?
  582. &constraints_dmic_2ch : &constraints_dmic_channels;
  583. return devm_snd_soc_register_card(&pdev->dev, &kabylake_audio_card);
  584. }
  585. static const struct platform_device_id kbl_board_ids[] = {
  586. { .name = "kbl_r5514_5663_max" },
  587. { }
  588. };
  589. static struct platform_driver kabylake_audio = {
  590. .probe = kabylake_audio_probe,
  591. .driver = {
  592. .name = "kbl_r5514_5663_max",
  593. .pm = &snd_soc_pm_ops,
  594. },
  595. .id_table = kbl_board_ids,
  596. };
  597. module_platform_driver(kabylake_audio)
  598. /* Module information */
  599. MODULE_DESCRIPTION("Audio Machine driver-RT5663 RT5514 & MAX98927");
  600. MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
  601. MODULE_LICENSE("GPL v2");
  602. MODULE_ALIAS("platform:kbl_r5514_5663_max");