kbl_rt5663_rt5514_max98927.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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_component *component = rtd->codec_dai->component;
  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. snd_soc_component_set_jack(component, &ctx->kabylake_headset, NULL);
  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_format(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_format(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->component,
  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. 2,
  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. runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
  356. snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
  357. return snd_pcm_hw_constraint_list(substream->runtime, 0,
  358. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  359. }
  360. static struct snd_soc_ops kabylake_dmic_ops = {
  361. .startup = kabylake_dmic_startup,
  362. };
  363. /* kabylake digital audio interface glue - connects codec <--> CPU */
  364. static struct snd_soc_dai_link kabylake_dais[] = {
  365. /* Front End DAI links */
  366. [KBL_DPCM_AUDIO_PB] = {
  367. .name = "Kbl Audio Port",
  368. .stream_name = "Audio",
  369. .cpu_dai_name = "System Pin",
  370. .platform_name = "0000:00:1f.3",
  371. .dynamic = 1,
  372. .codec_name = "snd-soc-dummy",
  373. .codec_dai_name = "snd-soc-dummy-dai",
  374. .nonatomic = 1,
  375. .init = kabylake_rt5663_fe_init,
  376. .trigger = {
  377. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  378. .dpcm_playback = 1,
  379. .ops = &kabylake_rt5663_fe_ops,
  380. },
  381. [KBL_DPCM_AUDIO_CP] = {
  382. .name = "Kbl Audio Capture Port",
  383. .stream_name = "Audio Record",
  384. .cpu_dai_name = "System Pin",
  385. .platform_name = "0000:00:1f.3",
  386. .dynamic = 1,
  387. .codec_name = "snd-soc-dummy",
  388. .codec_dai_name = "snd-soc-dummy-dai",
  389. .nonatomic = 1,
  390. .trigger = {
  391. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  392. .dpcm_capture = 1,
  393. .ops = &kabylake_rt5663_fe_ops,
  394. },
  395. [KBL_DPCM_AUDIO_HS_PB] = {
  396. .name = "Kbl Audio Headset Playback",
  397. .stream_name = "Headset Audio",
  398. .cpu_dai_name = "System Pin2",
  399. .codec_name = "snd-soc-dummy",
  400. .codec_dai_name = "snd-soc-dummy-dai",
  401. .platform_name = "0000:00:1f.3",
  402. .dpcm_playback = 1,
  403. .nonatomic = 1,
  404. .dynamic = 1,
  405. },
  406. [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
  407. .name = "Kbl Audio Echo Reference cap",
  408. .stream_name = "Echoreference Capture",
  409. .cpu_dai_name = "Echoref Pin",
  410. .codec_name = "snd-soc-dummy",
  411. .codec_dai_name = "snd-soc-dummy-dai",
  412. .platform_name = "0000:00:1f.3",
  413. .init = NULL,
  414. .capture_only = 1,
  415. .nonatomic = 1,
  416. },
  417. [KBL_DPCM_AUDIO_RT5514_DSP] = {
  418. .name = "rt5514 dsp",
  419. .stream_name = "Wake on Voice",
  420. .cpu_dai_name = "spi-PRP0001:00",
  421. .platform_name = "spi-PRP0001:00",
  422. .codec_name = "snd-soc-dummy",
  423. .codec_dai_name = "snd-soc-dummy-dai",
  424. },
  425. [KBL_DPCM_AUDIO_DMIC_CP] = {
  426. .name = "Kbl Audio DMIC cap",
  427. .stream_name = "dmiccap",
  428. .cpu_dai_name = "DMIC Pin",
  429. .codec_name = "snd-soc-dummy",
  430. .codec_dai_name = "snd-soc-dummy-dai",
  431. .platform_name = "0000:00:1f.3",
  432. .init = NULL,
  433. .dpcm_capture = 1,
  434. .nonatomic = 1,
  435. .dynamic = 1,
  436. .ops = &kabylake_dmic_ops,
  437. },
  438. [KBL_DPCM_AUDIO_HDMI1_PB] = {
  439. .name = "Kbl HDMI Port1",
  440. .stream_name = "Hdmi1",
  441. .cpu_dai_name = "HDMI1 Pin",
  442. .codec_name = "snd-soc-dummy",
  443. .codec_dai_name = "snd-soc-dummy-dai",
  444. .platform_name = "0000:00:1f.3",
  445. .dpcm_playback = 1,
  446. .init = NULL,
  447. .trigger = {
  448. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  449. .nonatomic = 1,
  450. .dynamic = 1,
  451. },
  452. [KBL_DPCM_AUDIO_HDMI2_PB] = {
  453. .name = "Kbl HDMI Port2",
  454. .stream_name = "Hdmi2",
  455. .cpu_dai_name = "HDMI2 Pin",
  456. .codec_name = "snd-soc-dummy",
  457. .codec_dai_name = "snd-soc-dummy-dai",
  458. .platform_name = "0000:00:1f.3",
  459. .dpcm_playback = 1,
  460. .init = NULL,
  461. .trigger = {
  462. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  463. .nonatomic = 1,
  464. .dynamic = 1,
  465. },
  466. /* Back End DAI links */
  467. /* single Back end dai for both max speakers and dmic */
  468. {
  469. /* SSP0 - Codec */
  470. .name = "SSP0-Codec",
  471. .id = 0,
  472. .cpu_dai_name = "SSP0 Pin",
  473. .platform_name = "0000:00:1f.3",
  474. .no_pcm = 1,
  475. .codecs = ssp0_codec_components,
  476. .num_codecs = ARRAY_SIZE(ssp0_codec_components),
  477. .dai_fmt = SND_SOC_DAIFMT_DSP_B |
  478. SND_SOC_DAIFMT_NB_NF |
  479. SND_SOC_DAIFMT_CBS_CFS,
  480. .ignore_pmdown_time = 1,
  481. .be_hw_params_fixup = kabylake_ssp_fixup,
  482. .dpcm_playback = 1,
  483. .dpcm_capture = 1,
  484. .ops = &kabylake_ssp0_ops,
  485. },
  486. {
  487. .name = "SSP1-Codec",
  488. .id = 1,
  489. .cpu_dai_name = "SSP1 Pin",
  490. .platform_name = "0000:00:1f.3",
  491. .no_pcm = 1,
  492. .codec_name = RT5663_DEV_NAME,
  493. .codec_dai_name = KBL_REALTEK_CODEC_DAI,
  494. .init = kabylake_rt5663_codec_init,
  495. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  496. SND_SOC_DAIFMT_CBS_CFS,
  497. .ignore_pmdown_time = 1,
  498. .be_hw_params_fixup = kabylake_ssp_fixup,
  499. .ops = &kabylake_rt5663_ops,
  500. .dpcm_playback = 1,
  501. .dpcm_capture = 1,
  502. },
  503. {
  504. .name = "iDisp1",
  505. .id = 3,
  506. .cpu_dai_name = "iDisp1 Pin",
  507. .codec_name = "ehdaudio0D2",
  508. .codec_dai_name = "intel-hdmi-hifi1",
  509. .platform_name = "0000:00:1f.3",
  510. .dpcm_playback = 1,
  511. .init = kabylake_hdmi1_init,
  512. .no_pcm = 1,
  513. },
  514. {
  515. .name = "iDisp2",
  516. .id = 4,
  517. .cpu_dai_name = "iDisp2 Pin",
  518. .codec_name = "ehdaudio0D2",
  519. .codec_dai_name = "intel-hdmi-hifi2",
  520. .platform_name = "0000:00:1f.3",
  521. .init = kabylake_hdmi2_init,
  522. .dpcm_playback = 1,
  523. .no_pcm = 1,
  524. },
  525. };
  526. static int kabylake_card_late_probe(struct snd_soc_card *card)
  527. {
  528. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
  529. struct kbl_hdmi_pcm *pcm;
  530. struct snd_soc_component *component = NULL;
  531. int err, i = 0;
  532. char jack_name[NAME_SIZE];
  533. list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
  534. component = pcm->codec_dai->component;
  535. snprintf(jack_name, sizeof(jack_name),
  536. "HDMI/DP,pcm=%d Jack", pcm->device);
  537. err = snd_soc_card_jack_new(card, jack_name,
  538. SND_JACK_AVOUT, &ctx->kabylake_hdmi[i],
  539. NULL, 0);
  540. if (err)
  541. return err;
  542. err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
  543. &ctx->kabylake_hdmi[i]);
  544. if (err < 0)
  545. return err;
  546. i++;
  547. }
  548. if (!component)
  549. return -EINVAL;
  550. return hdac_hdmi_jack_port_init(component, &card->dapm);
  551. }
  552. /*
  553. * kabylake audio machine driver for MAX98927 + RT5514 + RT5663
  554. */
  555. static struct snd_soc_card kabylake_audio_card = {
  556. .name = "kbl_r5514_5663_max",
  557. .owner = THIS_MODULE,
  558. .dai_link = kabylake_dais,
  559. .num_links = ARRAY_SIZE(kabylake_dais),
  560. .controls = kabylake_controls,
  561. .num_controls = ARRAY_SIZE(kabylake_controls),
  562. .dapm_widgets = kabylake_widgets,
  563. .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
  564. .dapm_routes = kabylake_map,
  565. .num_dapm_routes = ARRAY_SIZE(kabylake_map),
  566. .codec_conf = max98927_codec_conf,
  567. .num_configs = ARRAY_SIZE(max98927_codec_conf),
  568. .fully_routed = true,
  569. .late_probe = kabylake_card_late_probe,
  570. };
  571. static int kabylake_audio_probe(struct platform_device *pdev)
  572. {
  573. struct kbl_codec_private *ctx;
  574. struct skl_machine_pdata *pdata;
  575. ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
  576. if (!ctx)
  577. return -ENOMEM;
  578. INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
  579. kabylake_audio_card.dev = &pdev->dev;
  580. snd_soc_card_set_drvdata(&kabylake_audio_card, ctx);
  581. pdata = dev_get_drvdata(&pdev->dev);
  582. if (pdata)
  583. dmic_constraints = pdata->dmic_num == 2 ?
  584. &constraints_dmic_2ch : &constraints_dmic_channels;
  585. return devm_snd_soc_register_card(&pdev->dev, &kabylake_audio_card);
  586. }
  587. static const struct platform_device_id kbl_board_ids[] = {
  588. { .name = "kbl_r5514_5663_max" },
  589. { }
  590. };
  591. static struct platform_driver kabylake_audio = {
  592. .probe = kabylake_audio_probe,
  593. .driver = {
  594. .name = "kbl_r5514_5663_max",
  595. .pm = &snd_soc_pm_ops,
  596. },
  597. .id_table = kbl_board_ids,
  598. };
  599. module_platform_driver(kabylake_audio)
  600. /* Module information */
  601. MODULE_DESCRIPTION("Audio Machine driver-RT5663 RT5514 & MAX98927");
  602. MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
  603. MODULE_LICENSE("GPL v2");
  604. MODULE_ALIAS("platform:kbl_r5514_5663_max");