kbl_da7219_max98357a.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright(c) 2017-18 Intel Corporation.
  3. /*
  4. * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs
  5. *
  6. * Modified from:
  7. * Intel Kabylake I2S Machine driver supporting MAXIM98927 and
  8. * RT5663 codecs
  9. */
  10. #include <linux/input.h>
  11. #include <linux/module.h>
  12. #include <linux/platform_device.h>
  13. #include <sound/core.h>
  14. #include <sound/jack.h>
  15. #include <sound/pcm.h>
  16. #include <sound/pcm_params.h>
  17. #include <sound/soc.h>
  18. #include "../../codecs/da7219.h"
  19. #include "../../codecs/hdac_hdmi.h"
  20. #include "../skylake/skl.h"
  21. #include "../../codecs/da7219-aad.h"
  22. #define KBL_DIALOG_CODEC_DAI "da7219-hifi"
  23. #define KBL_MAXIM_CODEC_DAI "HiFi"
  24. #define MAXIM_DEV0_NAME "MX98357A:00"
  25. #define DUAL_CHANNEL 2
  26. #define QUAD_CHANNEL 4
  27. static struct snd_soc_card *kabylake_audio_card;
  28. static struct snd_soc_jack skylake_hdmi[3];
  29. struct kbl_hdmi_pcm {
  30. struct list_head head;
  31. struct snd_soc_dai *codec_dai;
  32. int device;
  33. };
  34. struct kbl_codec_private {
  35. struct snd_soc_jack kabylake_headset;
  36. struct list_head hdmi_pcm_list;
  37. };
  38. enum {
  39. KBL_DPCM_AUDIO_PB = 0,
  40. KBL_DPCM_AUDIO_CP,
  41. KBL_DPCM_AUDIO_DMIC_CP,
  42. KBL_DPCM_AUDIO_HDMI1_PB,
  43. KBL_DPCM_AUDIO_HDMI2_PB,
  44. KBL_DPCM_AUDIO_HDMI3_PB,
  45. };
  46. static int platform_clock_control(struct snd_soc_dapm_widget *w,
  47. struct snd_kcontrol *k, int event)
  48. {
  49. struct snd_soc_dapm_context *dapm = w->dapm;
  50. struct snd_soc_card *card = dapm->card;
  51. struct snd_soc_dai *codec_dai;
  52. int ret = 0;
  53. codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI);
  54. if (!codec_dai) {
  55. dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
  56. return -EIO;
  57. }
  58. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  59. ret = snd_soc_dai_set_pll(codec_dai, 0,
  60. DA7219_SYSCLK_MCLK, 0, 0);
  61. if (ret)
  62. dev_err(card->dev, "failed to stop PLL: %d\n", ret);
  63. } else if (SND_SOC_DAPM_EVENT_ON(event)) {
  64. ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM,
  65. 0, DA7219_PLL_FREQ_OUT_98304);
  66. if (ret)
  67. dev_err(card->dev, "failed to start PLL: %d\n", ret);
  68. }
  69. return ret;
  70. }
  71. static const struct snd_kcontrol_new kabylake_controls[] = {
  72. SOC_DAPM_PIN_SWITCH("Headphone Jack"),
  73. SOC_DAPM_PIN_SWITCH("Headset Mic"),
  74. SOC_DAPM_PIN_SWITCH("Spk"),
  75. };
  76. static const struct snd_soc_dapm_widget kabylake_widgets[] = {
  77. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  78. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  79. SND_SOC_DAPM_SPK("Spk", NULL),
  80. SND_SOC_DAPM_MIC("SoC DMIC", NULL),
  81. SND_SOC_DAPM_SPK("DP", NULL),
  82. SND_SOC_DAPM_SPK("HDMI", NULL),
  83. SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
  84. platform_clock_control, SND_SOC_DAPM_PRE_PMU |
  85. SND_SOC_DAPM_POST_PMD),
  86. };
  87. static const struct snd_soc_dapm_route kabylake_map[] = {
  88. { "Headphone Jack", NULL, "HPL" },
  89. { "Headphone Jack", NULL, "HPR" },
  90. /* speaker */
  91. { "Spk", NULL, "Speaker" },
  92. /* other jacks */
  93. { "MIC", NULL, "Headset Mic" },
  94. { "DMic", NULL, "SoC DMIC" },
  95. { "HDMI", NULL, "hif5 Output" },
  96. { "DP", NULL, "hif6 Output" },
  97. /* CODEC BE connections */
  98. { "HiFi Playback", NULL, "ssp0 Tx" },
  99. { "ssp0 Tx", NULL, "codec0_out" },
  100. { "Playback", NULL, "ssp1 Tx" },
  101. { "ssp1 Tx", NULL, "codec1_out" },
  102. { "codec0_in", NULL, "ssp1 Rx" },
  103. { "ssp1 Rx", NULL, "Capture" },
  104. /* DMIC */
  105. { "dmic01_hifi", NULL, "DMIC01 Rx" },
  106. { "DMIC01 Rx", NULL, "DMIC AIF" },
  107. { "hifi1", NULL, "iDisp1 Tx" },
  108. { "iDisp1 Tx", NULL, "iDisp1_out" },
  109. { "hifi2", NULL, "iDisp2 Tx" },
  110. { "iDisp2 Tx", NULL, "iDisp2_out" },
  111. { "hifi3", NULL, "iDisp3 Tx"},
  112. { "iDisp3 Tx", NULL, "iDisp3_out"},
  113. { "Headphone Jack", NULL, "Platform Clock" },
  114. { "Headset Mic", NULL, "Platform Clock" },
  115. };
  116. static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
  117. struct snd_pcm_hw_params *params)
  118. {
  119. struct snd_interval *rate = hw_param_interval(params,
  120. SNDRV_PCM_HW_PARAM_RATE);
  121. struct snd_interval *channels = hw_param_interval(params,
  122. SNDRV_PCM_HW_PARAM_CHANNELS);
  123. struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
  124. /* The ADSP will convert the FE rate to 48k, stereo */
  125. rate->min = rate->max = 48000;
  126. channels->min = channels->max = DUAL_CHANNEL;
  127. /* set SSP to 24 bit */
  128. snd_mask_none(fmt);
  129. snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
  130. return 0;
  131. }
  132. static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
  133. {
  134. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  135. struct snd_soc_component *component = rtd->codec_dai->component;
  136. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  137. struct snd_soc_jack *jack;
  138. int ret;
  139. /* Configure sysclk for codec */
  140. ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000,
  141. SND_SOC_CLOCK_IN);
  142. if (ret) {
  143. dev_err(rtd->dev, "can't set codec sysclk configuration\n");
  144. return ret;
  145. }
  146. /*
  147. * Headset buttons map to the google Reference headset.
  148. * These can be configured by userspace.
  149. */
  150. ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack",
  151. SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
  152. SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
  153. &ctx->kabylake_headset, NULL, 0);
  154. if (ret) {
  155. dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
  156. return ret;
  157. }
  158. jack = &ctx->kabylake_headset;
  159. snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
  160. snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
  161. snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
  162. snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
  163. da7219_aad_jack_det(component, &ctx->kabylake_headset);
  164. ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
  165. if (ret)
  166. dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret);
  167. return ret;
  168. }
  169. static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
  170. {
  171. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  172. struct snd_soc_dai *dai = rtd->codec_dai;
  173. struct kbl_hdmi_pcm *pcm;
  174. pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
  175. if (!pcm)
  176. return -ENOMEM;
  177. pcm->device = device;
  178. pcm->codec_dai = dai;
  179. list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
  180. return 0;
  181. }
  182. static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
  183. {
  184. return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB);
  185. }
  186. static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
  187. {
  188. return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB);
  189. }
  190. static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
  191. {
  192. return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB);
  193. }
  194. static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd)
  195. {
  196. struct snd_soc_dapm_context *dapm;
  197. struct snd_soc_component *component = rtd->cpu_dai->component;
  198. dapm = snd_soc_component_get_dapm(component);
  199. snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
  200. return 0;
  201. }
  202. static const unsigned int rates[] = {
  203. 48000,
  204. };
  205. static const struct snd_pcm_hw_constraint_list constraints_rates = {
  206. .count = ARRAY_SIZE(rates),
  207. .list = rates,
  208. .mask = 0,
  209. };
  210. static const unsigned int channels[] = {
  211. DUAL_CHANNEL,
  212. };
  213. static const struct snd_pcm_hw_constraint_list constraints_channels = {
  214. .count = ARRAY_SIZE(channels),
  215. .list = channels,
  216. .mask = 0,
  217. };
  218. static unsigned int channels_quad[] = {
  219. QUAD_CHANNEL,
  220. };
  221. static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
  222. .count = ARRAY_SIZE(channels_quad),
  223. .list = channels_quad,
  224. .mask = 0,
  225. };
  226. static int kbl_fe_startup(struct snd_pcm_substream *substream)
  227. {
  228. struct snd_pcm_runtime *runtime = substream->runtime;
  229. /*
  230. * On this platform for PCM device we support,
  231. * 48Khz
  232. * stereo
  233. * 16 bit audio
  234. */
  235. runtime->hw.channels_max = DUAL_CHANNEL;
  236. snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
  237. &constraints_channels);
  238. runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
  239. snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
  240. snd_pcm_hw_constraint_list(runtime, 0,
  241. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  242. return 0;
  243. }
  244. static const struct snd_soc_ops kabylake_da7219_fe_ops = {
  245. .startup = kbl_fe_startup,
  246. };
  247. static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
  248. struct snd_pcm_hw_params *params)
  249. {
  250. struct snd_interval *channels = hw_param_interval(params,
  251. SNDRV_PCM_HW_PARAM_CHANNELS);
  252. /*
  253. * set BE channel constraint as user FE channels
  254. */
  255. if (params_channels(params) == 2)
  256. channels->min = channels->max = 2;
  257. else
  258. channels->min = channels->max = 4;
  259. return 0;
  260. }
  261. static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
  262. {
  263. struct snd_pcm_runtime *runtime = substream->runtime;
  264. runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
  265. snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
  266. &constraints_channels_quad);
  267. return snd_pcm_hw_constraint_list(substream->runtime, 0,
  268. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  269. }
  270. static struct snd_soc_ops kabylake_dmic_ops = {
  271. .startup = kabylake_dmic_startup,
  272. };
  273. static const unsigned int rates_16000[] = {
  274. 16000,
  275. };
  276. static const struct snd_pcm_hw_constraint_list constraints_16000 = {
  277. .count = ARRAY_SIZE(rates_16000),
  278. .list = rates_16000,
  279. };
  280. static const unsigned int ch_mono[] = {
  281. 1,
  282. };
  283. /* kabylake digital audio interface glue - connects codec <--> CPU */
  284. static struct snd_soc_dai_link kabylake_dais[] = {
  285. /* Front End DAI links */
  286. [KBL_DPCM_AUDIO_PB] = {
  287. .name = "Kbl Audio Port",
  288. .stream_name = "Audio",
  289. .cpu_dai_name = "System Pin",
  290. .platform_name = "0000:00:1f.3",
  291. .dynamic = 1,
  292. .codec_name = "snd-soc-dummy",
  293. .codec_dai_name = "snd-soc-dummy-dai",
  294. .nonatomic = 1,
  295. .init = kabylake_da7219_fe_init,
  296. .trigger = {
  297. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  298. .dpcm_playback = 1,
  299. .ops = &kabylake_da7219_fe_ops,
  300. },
  301. [KBL_DPCM_AUDIO_CP] = {
  302. .name = "Kbl Audio Capture Port",
  303. .stream_name = "Audio Record",
  304. .cpu_dai_name = "System Pin",
  305. .platform_name = "0000:00:1f.3",
  306. .dynamic = 1,
  307. .codec_name = "snd-soc-dummy",
  308. .codec_dai_name = "snd-soc-dummy-dai",
  309. .nonatomic = 1,
  310. .trigger = {
  311. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  312. .dpcm_capture = 1,
  313. .ops = &kabylake_da7219_fe_ops,
  314. },
  315. [KBL_DPCM_AUDIO_DMIC_CP] = {
  316. .name = "Kbl Audio DMIC cap",
  317. .stream_name = "dmiccap",
  318. .cpu_dai_name = "DMIC Pin",
  319. .codec_name = "snd-soc-dummy",
  320. .codec_dai_name = "snd-soc-dummy-dai",
  321. .platform_name = "0000:00:1f.3",
  322. .init = NULL,
  323. .dpcm_capture = 1,
  324. .nonatomic = 1,
  325. .dynamic = 1,
  326. .ops = &kabylake_dmic_ops,
  327. },
  328. [KBL_DPCM_AUDIO_HDMI1_PB] = {
  329. .name = "Kbl HDMI Port1",
  330. .stream_name = "Hdmi1",
  331. .cpu_dai_name = "HDMI1 Pin",
  332. .codec_name = "snd-soc-dummy",
  333. .codec_dai_name = "snd-soc-dummy-dai",
  334. .platform_name = "0000:00:1f.3",
  335. .dpcm_playback = 1,
  336. .init = NULL,
  337. .trigger = {
  338. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  339. .nonatomic = 1,
  340. .dynamic = 1,
  341. },
  342. [KBL_DPCM_AUDIO_HDMI2_PB] = {
  343. .name = "Kbl HDMI Port2",
  344. .stream_name = "Hdmi2",
  345. .cpu_dai_name = "HDMI2 Pin",
  346. .codec_name = "snd-soc-dummy",
  347. .codec_dai_name = "snd-soc-dummy-dai",
  348. .platform_name = "0000:00:1f.3",
  349. .dpcm_playback = 1,
  350. .init = NULL,
  351. .trigger = {
  352. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  353. .nonatomic = 1,
  354. .dynamic = 1,
  355. },
  356. [KBL_DPCM_AUDIO_HDMI3_PB] = {
  357. .name = "Kbl HDMI Port3",
  358. .stream_name = "Hdmi3",
  359. .cpu_dai_name = "HDMI3 Pin",
  360. .codec_name = "snd-soc-dummy",
  361. .codec_dai_name = "snd-soc-dummy-dai",
  362. .platform_name = "0000:00:1f.3",
  363. .trigger = {
  364. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  365. .dpcm_playback = 1,
  366. .init = NULL,
  367. .nonatomic = 1,
  368. .dynamic = 1,
  369. },
  370. /* Back End DAI links */
  371. {
  372. /* SSP0 - Codec */
  373. .name = "SSP0-Codec",
  374. .id = 0,
  375. .cpu_dai_name = "SSP0 Pin",
  376. .platform_name = "0000:00:1f.3",
  377. .no_pcm = 1,
  378. .codec_name = MAXIM_DEV0_NAME,
  379. .codec_dai_name = KBL_MAXIM_CODEC_DAI,
  380. .dai_fmt = SND_SOC_DAIFMT_I2S |
  381. SND_SOC_DAIFMT_NB_NF |
  382. SND_SOC_DAIFMT_CBS_CFS,
  383. .ignore_pmdown_time = 1,
  384. .be_hw_params_fixup = kabylake_ssp_fixup,
  385. .dpcm_playback = 1,
  386. },
  387. {
  388. /* SSP1 - Codec */
  389. .name = "SSP1-Codec",
  390. .id = 1,
  391. .cpu_dai_name = "SSP1 Pin",
  392. .platform_name = "0000:00:1f.3",
  393. .no_pcm = 1,
  394. .codec_name = "i2c-DLGS7219:00",
  395. .codec_dai_name = KBL_DIALOG_CODEC_DAI,
  396. .init = kabylake_da7219_codec_init,
  397. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  398. SND_SOC_DAIFMT_CBS_CFS,
  399. .ignore_pmdown_time = 1,
  400. .be_hw_params_fixup = kabylake_ssp_fixup,
  401. .dpcm_playback = 1,
  402. .dpcm_capture = 1,
  403. },
  404. {
  405. .name = "dmic01",
  406. .id = 2,
  407. .cpu_dai_name = "DMIC01 Pin",
  408. .codec_name = "dmic-codec",
  409. .codec_dai_name = "dmic-hifi",
  410. .platform_name = "0000:00:1f.3",
  411. .be_hw_params_fixup = kabylake_dmic_fixup,
  412. .ignore_suspend = 1,
  413. .dpcm_capture = 1,
  414. .no_pcm = 1,
  415. },
  416. {
  417. .name = "iDisp1",
  418. .id = 3,
  419. .cpu_dai_name = "iDisp1 Pin",
  420. .codec_name = "ehdaudio0D2",
  421. .codec_dai_name = "intel-hdmi-hifi1",
  422. .platform_name = "0000:00:1f.3",
  423. .dpcm_playback = 1,
  424. .init = kabylake_hdmi1_init,
  425. .no_pcm = 1,
  426. },
  427. {
  428. .name = "iDisp2",
  429. .id = 4,
  430. .cpu_dai_name = "iDisp2 Pin",
  431. .codec_name = "ehdaudio0D2",
  432. .codec_dai_name = "intel-hdmi-hifi2",
  433. .platform_name = "0000:00:1f.3",
  434. .init = kabylake_hdmi2_init,
  435. .dpcm_playback = 1,
  436. .no_pcm = 1,
  437. },
  438. {
  439. .name = "iDisp3",
  440. .id = 5,
  441. .cpu_dai_name = "iDisp3 Pin",
  442. .codec_name = "ehdaudio0D2",
  443. .codec_dai_name = "intel-hdmi-hifi3",
  444. .platform_name = "0000:00:1f.3",
  445. .init = kabylake_hdmi3_init,
  446. .dpcm_playback = 1,
  447. .no_pcm = 1,
  448. },
  449. };
  450. #define NAME_SIZE 32
  451. static int kabylake_card_late_probe(struct snd_soc_card *card)
  452. {
  453. struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
  454. struct kbl_hdmi_pcm *pcm;
  455. struct snd_soc_component *component = NULL;
  456. int err, i = 0;
  457. char jack_name[NAME_SIZE];
  458. list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
  459. component = pcm->codec_dai->component;
  460. snprintf(jack_name, sizeof(jack_name),
  461. "HDMI/DP, pcm=%d Jack", pcm->device);
  462. err = snd_soc_card_jack_new(card, jack_name,
  463. SND_JACK_AVOUT, &skylake_hdmi[i],
  464. NULL, 0);
  465. if (err)
  466. return err;
  467. err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
  468. &skylake_hdmi[i]);
  469. if (err < 0)
  470. return err;
  471. i++;
  472. }
  473. if (!component)
  474. return -EINVAL;
  475. return hdac_hdmi_jack_port_init(component, &card->dapm);
  476. }
  477. /* kabylake audio machine driver for SPT + DA7219 */
  478. static struct snd_soc_card kabylake_audio_card_da7219_m98357a = {
  479. .name = "kblda7219max",
  480. .owner = THIS_MODULE,
  481. .dai_link = kabylake_dais,
  482. .num_links = ARRAY_SIZE(kabylake_dais),
  483. .controls = kabylake_controls,
  484. .num_controls = ARRAY_SIZE(kabylake_controls),
  485. .dapm_widgets = kabylake_widgets,
  486. .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets),
  487. .dapm_routes = kabylake_map,
  488. .num_dapm_routes = ARRAY_SIZE(kabylake_map),
  489. .fully_routed = true,
  490. .late_probe = kabylake_card_late_probe,
  491. };
  492. static int kabylake_audio_probe(struct platform_device *pdev)
  493. {
  494. struct kbl_codec_private *ctx;
  495. ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
  496. if (!ctx)
  497. return -ENOMEM;
  498. INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
  499. kabylake_audio_card =
  500. (struct snd_soc_card *)pdev->id_entry->driver_data;
  501. kabylake_audio_card->dev = &pdev->dev;
  502. snd_soc_card_set_drvdata(kabylake_audio_card, ctx);
  503. return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card);
  504. }
  505. static const struct platform_device_id kbl_board_ids[] = {
  506. {
  507. .name = "kbl_da7219_max98357a",
  508. .driver_data =
  509. (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a,
  510. },
  511. { }
  512. };
  513. static struct platform_driver kabylake_audio = {
  514. .probe = kabylake_audio_probe,
  515. .driver = {
  516. .name = "kbl_da7219_max98357a",
  517. .pm = &snd_soc_pm_ops,
  518. },
  519. .id_table = kbl_board_ids,
  520. };
  521. module_platform_driver(kabylake_audio)
  522. /* Module information */
  523. MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode");
  524. MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
  525. MODULE_LICENSE("GPL v2");
  526. MODULE_ALIAS("platform:kbl_da7219_max98357a");