skl-topology.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  1. /*
  2. * skl-topology.c - Implements Platform component ALSA controls/widget
  3. * handlers.
  4. *
  5. * Copyright (C) 2014-2015 Intel Corp
  6. * Author: Jeeja KP <jeeja.kp@intel.com>
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. #include <linux/slab.h>
  19. #include <linux/types.h>
  20. #include <linux/firmware.h>
  21. #include <sound/soc.h>
  22. #include <sound/soc-topology.h>
  23. #include "skl-sst-dsp.h"
  24. #include "skl-sst-ipc.h"
  25. #include "skl-topology.h"
  26. #include "skl.h"
  27. #include "skl-tplg-interface.h"
  28. #define SKL_CH_FIXUP_MASK (1 << 0)
  29. #define SKL_RATE_FIXUP_MASK (1 << 1)
  30. #define SKL_FMT_FIXUP_MASK (1 << 2)
  31. /*
  32. * SKL DSP driver modelling uses only few DAPM widgets so for rest we will
  33. * ignore. This helpers checks if the SKL driver handles this widget type
  34. */
  35. static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w)
  36. {
  37. switch (w->id) {
  38. case snd_soc_dapm_dai_link:
  39. case snd_soc_dapm_dai_in:
  40. case snd_soc_dapm_aif_in:
  41. case snd_soc_dapm_aif_out:
  42. case snd_soc_dapm_dai_out:
  43. case snd_soc_dapm_switch:
  44. return false;
  45. default:
  46. return true;
  47. }
  48. }
  49. /*
  50. * Each pipelines needs memory to be allocated. Check if we have free memory
  51. * from available pool. Then only add this to pool
  52. * This is freed when pipe is deleted
  53. * Note: DSP does actual memory management we only keep track for complete
  54. * pool
  55. */
  56. static bool skl_tplg_alloc_pipe_mem(struct skl *skl,
  57. struct skl_module_cfg *mconfig)
  58. {
  59. struct skl_sst *ctx = skl->skl_sst;
  60. if (skl->resource.mem + mconfig->pipe->memory_pages >
  61. skl->resource.max_mem) {
  62. dev_err(ctx->dev,
  63. "%s: module_id %d instance %d\n", __func__,
  64. mconfig->id.module_id,
  65. mconfig->id.instance_id);
  66. dev_err(ctx->dev,
  67. "exceeds ppl memory available %d mem %d\n",
  68. skl->resource.max_mem, skl->resource.mem);
  69. return false;
  70. }
  71. skl->resource.mem += mconfig->pipe->memory_pages;
  72. return true;
  73. }
  74. /*
  75. * Pipeline needs needs DSP CPU resources for computation, this is
  76. * quantified in MCPS (Million Clocks Per Second) required for module/pipe
  77. *
  78. * Each pipelines needs mcps to be allocated. Check if we have mcps for this
  79. * pipe. This adds the mcps to driver counter
  80. * This is removed on pipeline delete
  81. */
  82. static bool skl_tplg_alloc_pipe_mcps(struct skl *skl,
  83. struct skl_module_cfg *mconfig)
  84. {
  85. struct skl_sst *ctx = skl->skl_sst;
  86. if (skl->resource.mcps + mconfig->mcps > skl->resource.max_mcps) {
  87. dev_err(ctx->dev,
  88. "%s: module_id %d instance %d\n", __func__,
  89. mconfig->id.module_id, mconfig->id.instance_id);
  90. dev_err(ctx->dev,
  91. "exceeds ppl memory available %d > mem %d\n",
  92. skl->resource.max_mcps, skl->resource.mcps);
  93. return false;
  94. }
  95. skl->resource.mcps += mconfig->mcps;
  96. return true;
  97. }
  98. /*
  99. * Free the mcps when tearing down
  100. */
  101. static void
  102. skl_tplg_free_pipe_mcps(struct skl *skl, struct skl_module_cfg *mconfig)
  103. {
  104. skl->resource.mcps -= mconfig->mcps;
  105. }
  106. /*
  107. * Free the memory when tearing down
  108. */
  109. static void
  110. skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig)
  111. {
  112. skl->resource.mem -= mconfig->pipe->memory_pages;
  113. }
  114. static void skl_dump_mconfig(struct skl_sst *ctx,
  115. struct skl_module_cfg *mcfg)
  116. {
  117. dev_dbg(ctx->dev, "Dumping config\n");
  118. dev_dbg(ctx->dev, "Input Format:\n");
  119. dev_dbg(ctx->dev, "channels = %d\n", mcfg->in_fmt.channels);
  120. dev_dbg(ctx->dev, "s_freq = %d\n", mcfg->in_fmt.s_freq);
  121. dev_dbg(ctx->dev, "ch_cfg = %d\n", mcfg->in_fmt.ch_cfg);
  122. dev_dbg(ctx->dev, "valid bit depth = %d\n",
  123. mcfg->in_fmt.valid_bit_depth);
  124. dev_dbg(ctx->dev, "Output Format:\n");
  125. dev_dbg(ctx->dev, "channels = %d\n", mcfg->out_fmt.channels);
  126. dev_dbg(ctx->dev, "s_freq = %d\n", mcfg->out_fmt.s_freq);
  127. dev_dbg(ctx->dev, "valid bit depth = %d\n",
  128. mcfg->out_fmt.valid_bit_depth);
  129. dev_dbg(ctx->dev, "ch_cfg = %d\n", mcfg->out_fmt.ch_cfg);
  130. }
  131. static void skl_tplg_update_params(struct skl_module_fmt *fmt,
  132. struct skl_pipe_params *params, int fixup)
  133. {
  134. if (fixup & SKL_RATE_FIXUP_MASK)
  135. fmt->s_freq = params->s_freq;
  136. if (fixup & SKL_CH_FIXUP_MASK)
  137. fmt->channels = params->ch;
  138. if (fixup & SKL_FMT_FIXUP_MASK)
  139. fmt->valid_bit_depth = params->s_fmt;
  140. }
  141. /*
  142. * A pipeline may have modules which impact the pcm parameters, like SRC,
  143. * channel converter, format converter.
  144. * We need to calculate the output params by applying the 'fixup'
  145. * Topology will tell driver which type of fixup is to be applied by
  146. * supplying the fixup mask, so based on that we calculate the output
  147. *
  148. * Now In FE the pcm hw_params is source/target format. Same is applicable
  149. * for BE with its hw_params invoked.
  150. * here based on FE, BE pipeline and direction we calculate the input and
  151. * outfix and then apply that for a module
  152. */
  153. static void skl_tplg_update_params_fixup(struct skl_module_cfg *m_cfg,
  154. struct skl_pipe_params *params, bool is_fe)
  155. {
  156. int in_fixup, out_fixup;
  157. struct skl_module_fmt *in_fmt, *out_fmt;
  158. in_fmt = &m_cfg->in_fmt;
  159. out_fmt = &m_cfg->out_fmt;
  160. if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  161. if (is_fe) {
  162. in_fixup = m_cfg->params_fixup;
  163. out_fixup = (~m_cfg->converter) &
  164. m_cfg->params_fixup;
  165. } else {
  166. out_fixup = m_cfg->params_fixup;
  167. in_fixup = (~m_cfg->converter) &
  168. m_cfg->params_fixup;
  169. }
  170. } else {
  171. if (is_fe) {
  172. out_fixup = m_cfg->params_fixup;
  173. in_fixup = (~m_cfg->converter) &
  174. m_cfg->params_fixup;
  175. } else {
  176. in_fixup = m_cfg->params_fixup;
  177. out_fixup = (~m_cfg->converter) &
  178. m_cfg->params_fixup;
  179. }
  180. }
  181. skl_tplg_update_params(in_fmt, params, in_fixup);
  182. skl_tplg_update_params(out_fmt, params, out_fixup);
  183. }
  184. /*
  185. * A module needs input and output buffers, which are dependent upon pcm
  186. * params, so once we have calculate params, we need buffer calculation as
  187. * well.
  188. */
  189. static void skl_tplg_update_buffer_size(struct skl_sst *ctx,
  190. struct skl_module_cfg *mcfg)
  191. {
  192. int multiplier = 1;
  193. if (mcfg->m_type == SKL_MODULE_TYPE_SRCINT)
  194. multiplier = 5;
  195. mcfg->ibs = (mcfg->in_fmt.s_freq / 1000) *
  196. (mcfg->in_fmt.channels) *
  197. (mcfg->in_fmt.bit_depth >> 3) *
  198. multiplier;
  199. mcfg->obs = (mcfg->out_fmt.s_freq / 1000) *
  200. (mcfg->out_fmt.channels) *
  201. (mcfg->out_fmt.bit_depth >> 3) *
  202. multiplier;
  203. }
  204. static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w,
  205. struct skl_sst *ctx)
  206. {
  207. struct skl_module_cfg *m_cfg = w->priv;
  208. struct skl_pipe_params *params = m_cfg->pipe->p_params;
  209. int p_conn_type = m_cfg->pipe->conn_type;
  210. bool is_fe;
  211. if (!m_cfg->params_fixup)
  212. return;
  213. dev_dbg(ctx->dev, "Mconfig for widget=%s BEFORE updation\n",
  214. w->name);
  215. skl_dump_mconfig(ctx, m_cfg);
  216. if (p_conn_type == SKL_PIPE_CONN_TYPE_FE)
  217. is_fe = true;
  218. else
  219. is_fe = false;
  220. skl_tplg_update_params_fixup(m_cfg, params, is_fe);
  221. skl_tplg_update_buffer_size(ctx, m_cfg);
  222. dev_dbg(ctx->dev, "Mconfig for widget=%s AFTER updation\n",
  223. w->name);
  224. skl_dump_mconfig(ctx, m_cfg);
  225. }
  226. /*
  227. * A pipe can have multiple modules, each of them will be a DAPM widget as
  228. * well. While managing a pipeline we need to get the list of all the
  229. * widgets in a pipelines, so this helper - skl_tplg_get_pipe_widget() helps
  230. * to get the SKL type widgets in that pipeline
  231. */
  232. static int skl_tplg_alloc_pipe_widget(struct device *dev,
  233. struct snd_soc_dapm_widget *w, struct skl_pipe *pipe)
  234. {
  235. struct skl_module_cfg *src_module = NULL;
  236. struct snd_soc_dapm_path *p = NULL;
  237. struct skl_pipe_module *p_module = NULL;
  238. p_module = devm_kzalloc(dev, sizeof(*p_module), GFP_KERNEL);
  239. if (!p_module)
  240. return -ENOMEM;
  241. p_module->w = w;
  242. list_add_tail(&p_module->node, &pipe->w_list);
  243. snd_soc_dapm_widget_for_each_sink_path(w, p) {
  244. if ((p->sink->priv == NULL)
  245. && (!is_skl_dsp_widget_type(w)))
  246. continue;
  247. if ((p->sink->priv != NULL) && p->connect
  248. && is_skl_dsp_widget_type(p->sink)) {
  249. src_module = p->sink->priv;
  250. if (pipe->ppl_id == src_module->pipe->ppl_id)
  251. skl_tplg_alloc_pipe_widget(dev,
  252. p->sink, pipe);
  253. }
  254. }
  255. return 0;
  256. }
  257. /*
  258. * Inside a pipe instance, we can have various modules. These modules need
  259. * to instantiated in DSP by invoking INIT_MODULE IPC, which is achieved by
  260. * skl_init_module() routine, so invoke that for all modules in a pipeline
  261. */
  262. static int
  263. skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
  264. {
  265. struct skl_pipe_module *w_module;
  266. struct snd_soc_dapm_widget *w;
  267. struct skl_module_cfg *mconfig;
  268. struct skl_sst *ctx = skl->skl_sst;
  269. int ret = 0;
  270. list_for_each_entry(w_module, &pipe->w_list, node) {
  271. w = w_module->w;
  272. mconfig = w->priv;
  273. /* check resource available */
  274. if (!skl_tplg_alloc_pipe_mcps(skl, mconfig))
  275. return -ENOMEM;
  276. /*
  277. * apply fix/conversion to module params based on
  278. * FE/BE params
  279. */
  280. skl_tplg_update_module_params(w, ctx);
  281. ret = skl_init_module(ctx, mconfig, NULL);
  282. if (ret < 0)
  283. return ret;
  284. }
  285. return 0;
  286. }
  287. /*
  288. * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we
  289. * need create the pipeline. So we do following:
  290. * - check the resources
  291. * - Create the pipeline
  292. * - Initialize the modules in pipeline
  293. * - finally bind all modules together
  294. */
  295. static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
  296. struct skl *skl)
  297. {
  298. int ret;
  299. struct skl_module_cfg *mconfig = w->priv;
  300. struct skl_pipe_module *w_module;
  301. struct skl_pipe *s_pipe = mconfig->pipe;
  302. struct skl_module_cfg *src_module = NULL, *dst_module;
  303. struct skl_sst *ctx = skl->skl_sst;
  304. /* check resource available */
  305. if (!skl_tplg_alloc_pipe_mcps(skl, mconfig))
  306. return -EBUSY;
  307. if (!skl_tplg_alloc_pipe_mem(skl, mconfig))
  308. return -ENOMEM;
  309. /*
  310. * Create a list of modules for pipe.
  311. * This list contains modules from source to sink
  312. */
  313. ret = skl_create_pipeline(ctx, mconfig->pipe);
  314. if (ret < 0)
  315. return ret;
  316. /*
  317. * we create a w_list of all widgets in that pipe. This list is not
  318. * freed on PMD event as widgets within a pipe are static. This
  319. * saves us cycles to get widgets in pipe every time.
  320. *
  321. * So if we have already initialized all the widgets of a pipeline
  322. * we skip, so check for list_empty and create the list if empty
  323. */
  324. if (list_empty(&s_pipe->w_list)) {
  325. ret = skl_tplg_alloc_pipe_widget(ctx->dev, w, s_pipe);
  326. if (ret < 0)
  327. return ret;
  328. }
  329. /* Init all pipe modules from source to sink */
  330. ret = skl_tplg_init_pipe_modules(skl, s_pipe);
  331. if (ret < 0)
  332. return ret;
  333. /* Bind modules from source to sink */
  334. list_for_each_entry(w_module, &s_pipe->w_list, node) {
  335. dst_module = w_module->w->priv;
  336. if (src_module == NULL) {
  337. src_module = dst_module;
  338. continue;
  339. }
  340. ret = skl_bind_modules(ctx, src_module, dst_module);
  341. if (ret < 0)
  342. return ret;
  343. src_module = dst_module;
  344. }
  345. return 0;
  346. }
  347. /*
  348. * A PGA represents a module in a pipeline. So in the Pre-PMU event of PGA
  349. * we need to do following:
  350. * - Bind to sink pipeline
  351. * Since the sink pipes can be running and we don't get mixer event on
  352. * connect for already running mixer, we need to find the sink pipes
  353. * here and bind to them. This way dynamic connect works.
  354. * - Start sink pipeline, if not running
  355. * - Then run current pipe
  356. */
  357. static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
  358. struct skl *skl)
  359. {
  360. struct snd_soc_dapm_path *p;
  361. struct skl_dapm_path_list *path_list;
  362. struct snd_soc_dapm_widget *source, *sink;
  363. struct skl_module_cfg *src_mconfig, *sink_mconfig;
  364. struct skl_sst *ctx = skl->skl_sst;
  365. int ret = 0;
  366. source = w;
  367. src_mconfig = source->priv;
  368. /*
  369. * find which sink it is connected to, bind with the sink,
  370. * if sink is not started, start sink pipe first, then start
  371. * this pipe
  372. */
  373. snd_soc_dapm_widget_for_each_source_path(w, p) {
  374. if (!p->connect)
  375. continue;
  376. dev_dbg(ctx->dev, "%s: src widget=%s\n", __func__, w->name);
  377. dev_dbg(ctx->dev, "%s: sink widget=%s\n", __func__, p->sink->name);
  378. /*
  379. * here we will check widgets in sink pipelines, so that
  380. * can be any widgets type and we are only interested if
  381. * they are ones used for SKL so check that first
  382. */
  383. if ((p->sink->priv != NULL) &&
  384. is_skl_dsp_widget_type(p->sink)) {
  385. sink = p->sink;
  386. src_mconfig = source->priv;
  387. sink_mconfig = sink->priv;
  388. /* Bind source to sink, mixin is always source */
  389. ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig);
  390. if (ret)
  391. return ret;
  392. /* Start sinks pipe first */
  393. if (sink_mconfig->pipe->state != SKL_PIPE_STARTED) {
  394. ret = skl_run_pipe(ctx, sink_mconfig->pipe);
  395. if (ret)
  396. return ret;
  397. }
  398. path_list = kzalloc(
  399. sizeof(struct skl_dapm_path_list),
  400. GFP_KERNEL);
  401. if (path_list == NULL)
  402. return -ENOMEM;
  403. /* Add connected path to one global list */
  404. path_list->dapm_path = p;
  405. list_add_tail(&path_list->node, &skl->dapm_path_list);
  406. break;
  407. }
  408. }
  409. /* Start source pipe last after starting all sinks */
  410. ret = skl_run_pipe(ctx, src_mconfig->pipe);
  411. if (ret)
  412. return ret;
  413. return 0;
  414. }
  415. /*
  416. * in the Post-PMU event of mixer we need to do following:
  417. * - Check if this pipe is running
  418. * - if not, then
  419. * - bind this pipeline to its source pipeline
  420. * if source pipe is already running, this means it is a dynamic
  421. * connection and we need to bind only to that pipe
  422. * - start this pipeline
  423. */
  424. static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w,
  425. struct skl *skl)
  426. {
  427. int ret = 0;
  428. struct snd_soc_dapm_path *p;
  429. struct snd_soc_dapm_widget *source, *sink;
  430. struct skl_module_cfg *src_mconfig, *sink_mconfig;
  431. struct skl_sst *ctx = skl->skl_sst;
  432. int src_pipe_started = 0;
  433. sink = w;
  434. sink_mconfig = sink->priv;
  435. /*
  436. * If source pipe is already started, that means source is driving
  437. * one more sink before this sink got connected, Since source is
  438. * started, bind this sink to source and start this pipe.
  439. */
  440. snd_soc_dapm_widget_for_each_sink_path(w, p) {
  441. if (!p->connect)
  442. continue;
  443. dev_dbg(ctx->dev, "sink widget=%s\n", w->name);
  444. dev_dbg(ctx->dev, "src widget=%s\n", p->source->name);
  445. /*
  446. * here we will check widgets in sink pipelines, so that
  447. * can be any widgets type and we are only interested if
  448. * they are ones used for SKL so check that first
  449. */
  450. if ((p->source->priv != NULL) &&
  451. is_skl_dsp_widget_type(p->source)) {
  452. source = p->source;
  453. src_mconfig = source->priv;
  454. sink_mconfig = sink->priv;
  455. src_pipe_started = 1;
  456. /*
  457. * check pipe state, then no need to bind or start
  458. * the pipe
  459. */
  460. if (src_mconfig->pipe->state != SKL_PIPE_STARTED)
  461. src_pipe_started = 0;
  462. }
  463. }
  464. if (src_pipe_started) {
  465. ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig);
  466. if (ret)
  467. return ret;
  468. ret = skl_run_pipe(ctx, sink_mconfig->pipe);
  469. }
  470. return ret;
  471. }
  472. /*
  473. * in the Pre-PMD event of mixer we need to do following:
  474. * - Stop the pipe
  475. * - find the source connections and remove that from dapm_path_list
  476. * - unbind with source pipelines if still connected
  477. */
  478. static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w,
  479. struct skl *skl)
  480. {
  481. struct snd_soc_dapm_widget *source, *sink;
  482. struct skl_module_cfg *src_mconfig, *sink_mconfig;
  483. int ret = 0, path_found = 0;
  484. struct skl_dapm_path_list *path_list, *tmp_list;
  485. struct skl_sst *ctx = skl->skl_sst;
  486. sink = w;
  487. sink_mconfig = sink->priv;
  488. /* Stop the pipe */
  489. ret = skl_stop_pipe(ctx, sink_mconfig->pipe);
  490. if (ret)
  491. return ret;
  492. /*
  493. * This list, dapm_path_list handling here does not need any locks
  494. * as we are under dapm lock while handling widget events.
  495. * List can be manipulated safely only under dapm widgets handler
  496. * routines
  497. */
  498. list_for_each_entry_safe(path_list, tmp_list,
  499. &skl->dapm_path_list, node) {
  500. if (path_list->dapm_path->sink == sink) {
  501. dev_dbg(ctx->dev, "Path found = %s\n",
  502. path_list->dapm_path->name);
  503. source = path_list->dapm_path->source;
  504. src_mconfig = source->priv;
  505. path_found = 1;
  506. list_del(&path_list->node);
  507. kfree(path_list);
  508. break;
  509. }
  510. }
  511. /*
  512. * If path_found == 1, that means pmd for source pipe has
  513. * not occurred, source is connected to some other sink.
  514. * so its responsibility of sink to unbind itself from source.
  515. */
  516. if (path_found) {
  517. ret = skl_stop_pipe(ctx, src_mconfig->pipe);
  518. if (ret < 0)
  519. return ret;
  520. ret = skl_unbind_modules(ctx, src_mconfig, sink_mconfig);
  521. }
  522. return ret;
  523. }
  524. /*
  525. * in the Post-PMD event of mixer we need to do following:
  526. * - Free the mcps used
  527. * - Free the mem used
  528. * - Unbind the modules within the pipeline
  529. * - Delete the pipeline (modules are not required to be explicitly
  530. * deleted, pipeline delete is enough here
  531. */
  532. static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
  533. struct skl *skl)
  534. {
  535. struct skl_module_cfg *mconfig = w->priv;
  536. struct skl_pipe_module *w_module;
  537. struct skl_module_cfg *src_module = NULL, *dst_module;
  538. struct skl_sst *ctx = skl->skl_sst;
  539. struct skl_pipe *s_pipe = mconfig->pipe;
  540. int ret = 0;
  541. skl_tplg_free_pipe_mcps(skl, mconfig);
  542. list_for_each_entry(w_module, &s_pipe->w_list, node) {
  543. dst_module = w_module->w->priv;
  544. if (src_module == NULL) {
  545. src_module = dst_module;
  546. continue;
  547. }
  548. ret = skl_unbind_modules(ctx, src_module, dst_module);
  549. if (ret < 0)
  550. return ret;
  551. src_module = dst_module;
  552. }
  553. ret = skl_delete_pipe(ctx, mconfig->pipe);
  554. skl_tplg_free_pipe_mem(skl, mconfig);
  555. return ret;
  556. }
  557. /*
  558. * in the Post-PMD event of PGA we need to do following:
  559. * - Free the mcps used
  560. * - Stop the pipeline
  561. * - In source pipe is connected, unbind with source pipelines
  562. */
  563. static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
  564. struct skl *skl)
  565. {
  566. struct snd_soc_dapm_widget *source, *sink;
  567. struct skl_module_cfg *src_mconfig, *sink_mconfig;
  568. int ret = 0, path_found = 0;
  569. struct skl_dapm_path_list *path_list, *tmp_path_list;
  570. struct skl_sst *ctx = skl->skl_sst;
  571. source = w;
  572. src_mconfig = source->priv;
  573. skl_tplg_free_pipe_mcps(skl, src_mconfig);
  574. /* Stop the pipe since this is a mixin module */
  575. ret = skl_stop_pipe(ctx, src_mconfig->pipe);
  576. if (ret)
  577. return ret;
  578. list_for_each_entry_safe(path_list, tmp_path_list, &skl->dapm_path_list, node) {
  579. if (path_list->dapm_path->source == source) {
  580. dev_dbg(ctx->dev, "Path found = %s\n",
  581. path_list->dapm_path->name);
  582. sink = path_list->dapm_path->sink;
  583. sink_mconfig = sink->priv;
  584. path_found = 1;
  585. list_del(&path_list->node);
  586. kfree(path_list);
  587. break;
  588. }
  589. }
  590. /*
  591. * This is a connector and if path is found that means
  592. * unbind between source and sink has not happened yet
  593. */
  594. if (path_found) {
  595. ret = skl_stop_pipe(ctx, src_mconfig->pipe);
  596. if (ret < 0)
  597. return ret;
  598. ret = skl_unbind_modules(ctx, src_mconfig, sink_mconfig);
  599. }
  600. return ret;
  601. }
  602. /*
  603. * In modelling, we assume there will be ONLY one mixer in a pipeline. If
  604. * mixer is not required then it is treated as static mixer aka vmixer with
  605. * a hard path to source module
  606. * So we don't need to check if source is started or not as hard path puts
  607. * dependency on each other
  608. */
  609. static int skl_tplg_vmixer_event(struct snd_soc_dapm_widget *w,
  610. struct snd_kcontrol *k, int event)
  611. {
  612. struct snd_soc_dapm_context *dapm = w->dapm;
  613. struct skl *skl = get_skl_ctx(dapm->dev);
  614. switch (event) {
  615. case SND_SOC_DAPM_PRE_PMU:
  616. return skl_tplg_mixer_dapm_pre_pmu_event(w, skl);
  617. case SND_SOC_DAPM_POST_PMD:
  618. return skl_tplg_mixer_dapm_post_pmd_event(w, skl);
  619. }
  620. return 0;
  621. }
  622. /*
  623. * In modelling, we assume there will be ONLY one mixer in a pipeline. If a
  624. * second one is required that is created as another pipe entity.
  625. * The mixer is responsible for pipe management and represent a pipeline
  626. * instance
  627. */
  628. static int skl_tplg_mixer_event(struct snd_soc_dapm_widget *w,
  629. struct snd_kcontrol *k, int event)
  630. {
  631. struct snd_soc_dapm_context *dapm = w->dapm;
  632. struct skl *skl = get_skl_ctx(dapm->dev);
  633. switch (event) {
  634. case SND_SOC_DAPM_PRE_PMU:
  635. return skl_tplg_mixer_dapm_pre_pmu_event(w, skl);
  636. case SND_SOC_DAPM_POST_PMU:
  637. return skl_tplg_mixer_dapm_post_pmu_event(w, skl);
  638. case SND_SOC_DAPM_PRE_PMD:
  639. return skl_tplg_mixer_dapm_pre_pmd_event(w, skl);
  640. case SND_SOC_DAPM_POST_PMD:
  641. return skl_tplg_mixer_dapm_post_pmd_event(w, skl);
  642. }
  643. return 0;
  644. }
  645. /*
  646. * In modelling, we assumed rest of the modules in pipeline are PGA. But we
  647. * are interested in last PGA (leaf PGA) in a pipeline to disconnect with
  648. * the sink when it is running (two FE to one BE or one FE to two BE)
  649. * scenarios
  650. */
  651. static int skl_tplg_pga_event(struct snd_soc_dapm_widget *w,
  652. struct snd_kcontrol *k, int event)
  653. {
  654. struct snd_soc_dapm_context *dapm = w->dapm;
  655. struct skl *skl = get_skl_ctx(dapm->dev);
  656. switch (event) {
  657. case SND_SOC_DAPM_PRE_PMU:
  658. return skl_tplg_pga_dapm_pre_pmu_event(w, skl);
  659. case SND_SOC_DAPM_POST_PMD:
  660. return skl_tplg_pga_dapm_post_pmd_event(w, skl);
  661. }
  662. return 0;
  663. }
  664. /*
  665. * The FE params are passed by hw_params of the DAI.
  666. * On hw_params, the params are stored in Gateway module of the FE and we
  667. * need to calculate the format in DSP module configuration, that
  668. * conversion is done here
  669. */
  670. int skl_tplg_update_pipe_params(struct device *dev,
  671. struct skl_module_cfg *mconfig,
  672. struct skl_pipe_params *params)
  673. {
  674. struct skl_pipe *pipe = mconfig->pipe;
  675. struct skl_module_fmt *format = NULL;
  676. memcpy(pipe->p_params, params, sizeof(*params));
  677. if (params->stream == SNDRV_PCM_STREAM_PLAYBACK)
  678. format = &mconfig->in_fmt;
  679. else
  680. format = &mconfig->out_fmt;
  681. /* set the hw_params */
  682. format->s_freq = params->s_freq;
  683. format->channels = params->ch;
  684. format->valid_bit_depth = skl_get_bit_depth(params->s_fmt);
  685. /*
  686. * 16 bit is 16 bit container whereas 24 bit is in 32 bit
  687. * container so update bit depth accordingly
  688. */
  689. switch (format->valid_bit_depth) {
  690. case SKL_DEPTH_16BIT:
  691. format->bit_depth = format->valid_bit_depth;
  692. break;
  693. case SKL_DEPTH_24BIT:
  694. format->bit_depth = SKL_DEPTH_32BIT;
  695. break;
  696. default:
  697. dev_err(dev, "Invalid bit depth %x for pipe\n",
  698. format->valid_bit_depth);
  699. return -EINVAL;
  700. }
  701. if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  702. mconfig->ibs = (format->s_freq / 1000) *
  703. (format->channels) *
  704. (format->bit_depth >> 3);
  705. } else {
  706. mconfig->obs = (format->s_freq / 1000) *
  707. (format->channels) *
  708. (format->bit_depth >> 3);
  709. }
  710. return 0;
  711. }
  712. /*
  713. * Query the module config for the FE DAI
  714. * This is used to find the hw_params set for that DAI and apply to FE
  715. * pipeline
  716. */
  717. struct skl_module_cfg *
  718. skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream)
  719. {
  720. struct snd_soc_dapm_widget *w;
  721. struct snd_soc_dapm_path *p = NULL;
  722. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  723. w = dai->playback_widget;
  724. snd_soc_dapm_widget_for_each_sink_path(w, p) {
  725. if (p->connect && p->sink->power &&
  726. is_skl_dsp_widget_type(p->sink))
  727. continue;
  728. if (p->sink->priv) {
  729. dev_dbg(dai->dev, "set params for %s\n",
  730. p->sink->name);
  731. return p->sink->priv;
  732. }
  733. }
  734. } else {
  735. w = dai->capture_widget;
  736. snd_soc_dapm_widget_for_each_source_path(w, p) {
  737. if (p->connect && p->source->power &&
  738. is_skl_dsp_widget_type(p->source))
  739. continue;
  740. if (p->source->priv) {
  741. dev_dbg(dai->dev, "set params for %s\n",
  742. p->source->name);
  743. return p->source->priv;
  744. }
  745. }
  746. }
  747. return NULL;
  748. }
  749. static u8 skl_tplg_be_link_type(int dev_type)
  750. {
  751. int ret;
  752. switch (dev_type) {
  753. case SKL_DEVICE_BT:
  754. ret = NHLT_LINK_SSP;
  755. break;
  756. case SKL_DEVICE_DMIC:
  757. ret = NHLT_LINK_DMIC;
  758. break;
  759. case SKL_DEVICE_I2S:
  760. ret = NHLT_LINK_SSP;
  761. break;
  762. case SKL_DEVICE_HDALINK:
  763. ret = NHLT_LINK_HDA;
  764. break;
  765. default:
  766. ret = NHLT_LINK_INVALID;
  767. break;
  768. }
  769. return ret;
  770. }
  771. /*
  772. * Fill the BE gateway parameters
  773. * The BE gateway expects a blob of parameters which are kept in the ACPI
  774. * NHLT blob, so query the blob for interface type (i2s/pdm) and instance.
  775. * The port can have multiple settings so pick based on the PCM
  776. * parameters
  777. */
  778. static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai,
  779. struct skl_module_cfg *mconfig,
  780. struct skl_pipe_params *params)
  781. {
  782. struct skl_pipe *pipe = mconfig->pipe;
  783. struct nhlt_specific_cfg *cfg;
  784. struct skl *skl = get_skl_ctx(dai->dev);
  785. int link_type = skl_tplg_be_link_type(mconfig->dev_type);
  786. memcpy(pipe->p_params, params, sizeof(*params));
  787. /* update the blob based on virtual bus_id*/
  788. cfg = skl_get_ep_blob(skl, mconfig->vbus_id, link_type,
  789. params->s_fmt, params->ch,
  790. params->s_freq, params->stream);
  791. if (cfg) {
  792. mconfig->formats_config.caps_size = cfg->size;
  793. mconfig->formats_config.caps = (u32 *) &cfg->caps;
  794. } else {
  795. dev_err(dai->dev, "Blob NULL for id %x type %d dirn %d\n",
  796. mconfig->vbus_id, link_type,
  797. params->stream);
  798. dev_err(dai->dev, "PCM: ch %d, freq %d, fmt %d\n",
  799. params->ch, params->s_freq, params->s_fmt);
  800. return -EINVAL;
  801. }
  802. return 0;
  803. }
  804. static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai *dai,
  805. struct snd_soc_dapm_widget *w,
  806. struct skl_pipe_params *params)
  807. {
  808. struct snd_soc_dapm_path *p;
  809. int ret = -EIO;
  810. snd_soc_dapm_widget_for_each_source_path(w, p) {
  811. if (p->connect && is_skl_dsp_widget_type(p->source) &&
  812. p->source->priv) {
  813. if (!p->source->power) {
  814. ret = skl_tplg_be_fill_pipe_params(
  815. dai, p->source->priv,
  816. params);
  817. if (ret < 0)
  818. return ret;
  819. } else {
  820. return -EBUSY;
  821. }
  822. } else {
  823. ret = skl_tplg_be_set_src_pipe_params(
  824. dai, p->source, params);
  825. if (ret < 0)
  826. return ret;
  827. }
  828. }
  829. return ret;
  830. }
  831. static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai,
  832. struct snd_soc_dapm_widget *w, struct skl_pipe_params *params)
  833. {
  834. struct snd_soc_dapm_path *p = NULL;
  835. int ret = -EIO;
  836. snd_soc_dapm_widget_for_each_sink_path(w, p) {
  837. if (p->connect && is_skl_dsp_widget_type(p->sink) &&
  838. p->sink->priv) {
  839. if (!p->sink->power) {
  840. ret = skl_tplg_be_fill_pipe_params(
  841. dai, p->sink->priv, params);
  842. if (ret < 0)
  843. return ret;
  844. } else {
  845. return -EBUSY;
  846. }
  847. } else {
  848. ret = skl_tplg_be_set_sink_pipe_params(
  849. dai, p->sink, params);
  850. if (ret < 0)
  851. return ret;
  852. }
  853. }
  854. return ret;
  855. }
  856. /*
  857. * BE hw_params can be a source parameters (capture) or sink parameters
  858. * (playback). Based on sink and source we need to either find the source
  859. * list or the sink list and set the pipeline parameters
  860. */
  861. int skl_tplg_be_update_params(struct snd_soc_dai *dai,
  862. struct skl_pipe_params *params)
  863. {
  864. struct snd_soc_dapm_widget *w;
  865. if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  866. w = dai->playback_widget;
  867. return skl_tplg_be_set_src_pipe_params(dai, w, params);
  868. } else {
  869. w = dai->capture_widget;
  870. return skl_tplg_be_set_sink_pipe_params(dai, w, params);
  871. }
  872. return 0;
  873. }
  874. static const struct snd_soc_tplg_widget_events skl_tplg_widget_ops[] = {
  875. {SKL_MIXER_EVENT, skl_tplg_mixer_event},
  876. {SKL_VMIXER_EVENT, skl_tplg_vmixer_event},
  877. {SKL_PGA_EVENT, skl_tplg_pga_event},
  878. };
  879. /*
  880. * The topology binary passes the pin info for a module so initialize the pin
  881. * info passed into module instance
  882. */
  883. static void skl_fill_module_pin_info(struct skl_dfw_module_pin *dfw_pin,
  884. struct skl_module_pin *m_pin,
  885. bool is_dynamic, int max_pin)
  886. {
  887. int i;
  888. for (i = 0; i < max_pin; i++) {
  889. m_pin[i].id.module_id = dfw_pin[i].module_id;
  890. m_pin[i].id.instance_id = dfw_pin[i].instance_id;
  891. m_pin[i].in_use = false;
  892. m_pin[i].is_dynamic = is_dynamic;
  893. }
  894. }
  895. /*
  896. * Add pipeline from topology binary into driver pipeline list
  897. *
  898. * If already added we return that instance
  899. * Otherwise we create a new instance and add into driver list
  900. */
  901. static struct skl_pipe *skl_tplg_add_pipe(struct device *dev,
  902. struct skl *skl, struct skl_dfw_pipe *dfw_pipe)
  903. {
  904. struct skl_pipeline *ppl;
  905. struct skl_pipe *pipe;
  906. struct skl_pipe_params *params;
  907. list_for_each_entry(ppl, &skl->ppl_list, node) {
  908. if (ppl->pipe->ppl_id == dfw_pipe->pipe_id)
  909. return ppl->pipe;
  910. }
  911. ppl = devm_kzalloc(dev, sizeof(*ppl), GFP_KERNEL);
  912. if (!ppl)
  913. return NULL;
  914. pipe = devm_kzalloc(dev, sizeof(*pipe), GFP_KERNEL);
  915. if (!pipe)
  916. return NULL;
  917. params = devm_kzalloc(dev, sizeof(*params), GFP_KERNEL);
  918. if (!params)
  919. return NULL;
  920. pipe->ppl_id = dfw_pipe->pipe_id;
  921. pipe->memory_pages = dfw_pipe->memory_pages;
  922. pipe->pipe_priority = dfw_pipe->pipe_priority;
  923. pipe->conn_type = dfw_pipe->conn_type;
  924. pipe->state = SKL_PIPE_INVALID;
  925. pipe->p_params = params;
  926. INIT_LIST_HEAD(&pipe->w_list);
  927. ppl->pipe = pipe;
  928. list_add(&ppl->node, &skl->ppl_list);
  929. return ppl->pipe;
  930. }
  931. /*
  932. * Topology core widget load callback
  933. *
  934. * This is used to save the private data for each widget which gives
  935. * information to the driver about module and pipeline parameters which DSP
  936. * FW expects like ids, resource values, formats etc
  937. */
  938. static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,
  939. struct snd_soc_dapm_widget *w,
  940. struct snd_soc_tplg_dapm_widget *tplg_w)
  941. {
  942. int ret;
  943. struct hdac_ext_bus *ebus = snd_soc_component_get_drvdata(cmpnt);
  944. struct skl *skl = ebus_to_skl(ebus);
  945. struct hdac_bus *bus = ebus_to_hbus(ebus);
  946. struct skl_module_cfg *mconfig;
  947. struct skl_pipe *pipe;
  948. struct skl_dfw_module *dfw_config =
  949. (struct skl_dfw_module *)tplg_w->priv.data;
  950. if (!tplg_w->priv.size)
  951. goto bind_event;
  952. mconfig = devm_kzalloc(bus->dev, sizeof(*mconfig), GFP_KERNEL);
  953. if (!mconfig)
  954. return -ENOMEM;
  955. w->priv = mconfig;
  956. mconfig->id.module_id = dfw_config->module_id;
  957. mconfig->id.instance_id = dfw_config->instance_id;
  958. mconfig->mcps = dfw_config->max_mcps;
  959. mconfig->ibs = dfw_config->ibs;
  960. mconfig->obs = dfw_config->obs;
  961. mconfig->core_id = dfw_config->core_id;
  962. mconfig->max_in_queue = dfw_config->max_in_queue;
  963. mconfig->max_out_queue = dfw_config->max_out_queue;
  964. mconfig->is_loadable = dfw_config->is_loadable;
  965. mconfig->in_fmt.channels = dfw_config->in_fmt.channels;
  966. mconfig->in_fmt.s_freq = dfw_config->in_fmt.freq;
  967. mconfig->in_fmt.bit_depth = dfw_config->in_fmt.bit_depth;
  968. mconfig->in_fmt.valid_bit_depth =
  969. dfw_config->in_fmt.valid_bit_depth;
  970. mconfig->in_fmt.ch_cfg = dfw_config->in_fmt.ch_cfg;
  971. mconfig->out_fmt.channels = dfw_config->out_fmt.channels;
  972. mconfig->out_fmt.s_freq = dfw_config->out_fmt.freq;
  973. mconfig->out_fmt.bit_depth = dfw_config->out_fmt.bit_depth;
  974. mconfig->out_fmt.valid_bit_depth =
  975. dfw_config->out_fmt.valid_bit_depth;
  976. mconfig->out_fmt.ch_cfg = dfw_config->out_fmt.ch_cfg;
  977. mconfig->params_fixup = dfw_config->params_fixup;
  978. mconfig->converter = dfw_config->converter;
  979. mconfig->m_type = dfw_config->module_type;
  980. mconfig->vbus_id = dfw_config->vbus_id;
  981. pipe = skl_tplg_add_pipe(bus->dev, skl, &dfw_config->pipe);
  982. if (pipe)
  983. mconfig->pipe = pipe;
  984. mconfig->dev_type = dfw_config->dev_type;
  985. mconfig->hw_conn_type = dfw_config->hw_conn_type;
  986. mconfig->time_slot = dfw_config->time_slot;
  987. mconfig->formats_config.caps_size = dfw_config->caps.caps_size;
  988. mconfig->m_in_pin = devm_kzalloc(bus->dev,
  989. (mconfig->max_in_queue) *
  990. sizeof(*mconfig->m_in_pin),
  991. GFP_KERNEL);
  992. if (!mconfig->m_in_pin)
  993. return -ENOMEM;
  994. mconfig->m_out_pin = devm_kzalloc(bus->dev, (mconfig->max_out_queue) *
  995. sizeof(*mconfig->m_out_pin),
  996. GFP_KERNEL);
  997. if (!mconfig->m_out_pin)
  998. return -ENOMEM;
  999. skl_fill_module_pin_info(dfw_config->in_pin, mconfig->m_in_pin,
  1000. dfw_config->is_dynamic_in_pin,
  1001. mconfig->max_in_queue);
  1002. skl_fill_module_pin_info(dfw_config->out_pin, mconfig->m_out_pin,
  1003. dfw_config->is_dynamic_out_pin,
  1004. mconfig->max_out_queue);
  1005. if (mconfig->formats_config.caps_size == 0)
  1006. goto bind_event;
  1007. mconfig->formats_config.caps = (u32 *)devm_kzalloc(bus->dev,
  1008. mconfig->formats_config.caps_size, GFP_KERNEL);
  1009. if (mconfig->formats_config.caps == NULL)
  1010. return -ENOMEM;
  1011. memcpy(mconfig->formats_config.caps, dfw_config->caps.caps,
  1012. dfw_config->caps.caps_size);
  1013. bind_event:
  1014. if (tplg_w->event_type == 0) {
  1015. dev_dbg(bus->dev, "ASoC: No event handler required\n");
  1016. return 0;
  1017. }
  1018. ret = snd_soc_tplg_widget_bind_event(w, skl_tplg_widget_ops,
  1019. ARRAY_SIZE(skl_tplg_widget_ops),
  1020. tplg_w->event_type);
  1021. if (ret) {
  1022. dev_err(bus->dev, "%s: No matching event handlers found for %d\n",
  1023. __func__, tplg_w->event_type);
  1024. return -EINVAL;
  1025. }
  1026. return 0;
  1027. }
  1028. static struct snd_soc_tplg_ops skl_tplg_ops = {
  1029. .widget_load = skl_tplg_widget_load,
  1030. };
  1031. /* This will be read from topology manifest, currently defined here */
  1032. #define SKL_MAX_MCPS 30000000
  1033. #define SKL_FW_MAX_MEM 1000000
  1034. /*
  1035. * SKL topology init routine
  1036. */
  1037. int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus)
  1038. {
  1039. int ret;
  1040. const struct firmware *fw;
  1041. struct hdac_bus *bus = ebus_to_hbus(ebus);
  1042. struct skl *skl = ebus_to_skl(ebus);
  1043. ret = request_firmware(&fw, "dfw_sst.bin", bus->dev);
  1044. if (ret < 0) {
  1045. dev_err(bus->dev, "tplg fw %s load failed with %d\n",
  1046. "dfw_sst.bin", ret);
  1047. return ret;
  1048. }
  1049. /*
  1050. * The complete tplg for SKL is loaded as index 0, we don't use
  1051. * any other index
  1052. */
  1053. ret = snd_soc_tplg_component_load(&platform->component,
  1054. &skl_tplg_ops, fw, 0);
  1055. if (ret < 0) {
  1056. dev_err(bus->dev, "tplg component load failed%d\n", ret);
  1057. return -EINVAL;
  1058. }
  1059. skl->resource.max_mcps = SKL_MAX_MCPS;
  1060. skl->resource.max_mem = SKL_FW_MAX_MEM;
  1061. skl->tplg = fw;
  1062. return 0;
  1063. }