2 * skl-topology.c - Implements Platform component ALSA controls/widget
5 * Copyright (C) 2014-2015 Intel Corp
6 * Author: Jeeja KP <jeeja.kp@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
19 #include <linux/slab.h>
20 #include <linux/types.h>
21 #include <linux/firmware.h>
22 #include <sound/soc.h>
23 #include <sound/soc-topology.h>
24 #include "skl-sst-dsp.h"
25 #include "skl-sst-ipc.h"
26 #include "skl-topology.h"
28 #include "skl-tplg-interface.h"
29 #include "../common/sst-dsp.h"
30 #include "../common/sst-dsp-priv.h"
32 #define SKL_CH_FIXUP_MASK (1 << 0)
33 #define SKL_RATE_FIXUP_MASK (1 << 1)
34 #define SKL_FMT_FIXUP_MASK (1 << 2)
37 * SKL DSP driver modelling uses only few DAPM widgets so for rest we will
38 * ignore. This helpers checks if the SKL driver handles this widget type
40 static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget
*w
)
43 case snd_soc_dapm_dai_link
:
44 case snd_soc_dapm_dai_in
:
45 case snd_soc_dapm_aif_in
:
46 case snd_soc_dapm_aif_out
:
47 case snd_soc_dapm_dai_out
:
48 case snd_soc_dapm_switch
:
56 * Each pipelines needs memory to be allocated. Check if we have free memory
57 * from available pool. Then only add this to pool
58 * This is freed when pipe is deleted
59 * Note: DSP does actual memory management we only keep track for complete
62 static bool skl_tplg_alloc_pipe_mem(struct skl
*skl
,
63 struct skl_module_cfg
*mconfig
)
65 struct skl_sst
*ctx
= skl
->skl_sst
;
67 if (skl
->resource
.mem
+ mconfig
->pipe
->memory_pages
>
68 skl
->resource
.max_mem
) {
70 "%s: module_id %d instance %d\n", __func__
,
71 mconfig
->id
.module_id
,
72 mconfig
->id
.instance_id
);
74 "exceeds ppl memory available %d mem %d\n",
75 skl
->resource
.max_mem
, skl
->resource
.mem
);
79 skl
->resource
.mem
+= mconfig
->pipe
->memory_pages
;
84 * Pipeline needs needs DSP CPU resources for computation, this is
85 * quantified in MCPS (Million Clocks Per Second) required for module/pipe
87 * Each pipelines needs mcps to be allocated. Check if we have mcps for this
88 * pipe. This adds the mcps to driver counter
89 * This is removed on pipeline delete
91 static bool skl_tplg_alloc_pipe_mcps(struct skl
*skl
,
92 struct skl_module_cfg
*mconfig
)
94 struct skl_sst
*ctx
= skl
->skl_sst
;
96 if (skl
->resource
.mcps
+ mconfig
->mcps
> skl
->resource
.max_mcps
) {
98 "%s: module_id %d instance %d\n", __func__
,
99 mconfig
->id
.module_id
, mconfig
->id
.instance_id
);
101 "exceeds ppl memory available %d > mem %d\n",
102 skl
->resource
.max_mcps
, skl
->resource
.mcps
);
106 skl
->resource
.mcps
+= mconfig
->mcps
;
111 * Free the mcps when tearing down
114 skl_tplg_free_pipe_mcps(struct skl
*skl
, struct skl_module_cfg
*mconfig
)
116 skl
->resource
.mcps
-= mconfig
->mcps
;
120 * Free the memory when tearing down
123 skl_tplg_free_pipe_mem(struct skl
*skl
, struct skl_module_cfg
*mconfig
)
125 skl
->resource
.mem
-= mconfig
->pipe
->memory_pages
;
129 static void skl_dump_mconfig(struct skl_sst
*ctx
,
130 struct skl_module_cfg
*mcfg
)
132 dev_dbg(ctx
->dev
, "Dumping config\n");
133 dev_dbg(ctx
->dev
, "Input Format:\n");
134 dev_dbg(ctx
->dev
, "channels = %d\n", mcfg
->in_fmt
[0].channels
);
135 dev_dbg(ctx
->dev
, "s_freq = %d\n", mcfg
->in_fmt
[0].s_freq
);
136 dev_dbg(ctx
->dev
, "ch_cfg = %d\n", mcfg
->in_fmt
[0].ch_cfg
);
137 dev_dbg(ctx
->dev
, "valid bit depth = %d\n", mcfg
->in_fmt
[0].valid_bit_depth
);
138 dev_dbg(ctx
->dev
, "Output Format:\n");
139 dev_dbg(ctx
->dev
, "channels = %d\n", mcfg
->out_fmt
[0].channels
);
140 dev_dbg(ctx
->dev
, "s_freq = %d\n", mcfg
->out_fmt
[0].s_freq
);
141 dev_dbg(ctx
->dev
, "valid bit depth = %d\n", mcfg
->out_fmt
[0].valid_bit_depth
);
142 dev_dbg(ctx
->dev
, "ch_cfg = %d\n", mcfg
->out_fmt
[0].ch_cfg
);
145 static void skl_tplg_update_params(struct skl_module_fmt
*fmt
,
146 struct skl_pipe_params
*params
, int fixup
)
148 if (fixup
& SKL_RATE_FIXUP_MASK
)
149 fmt
->s_freq
= params
->s_freq
;
150 if (fixup
& SKL_CH_FIXUP_MASK
)
151 fmt
->channels
= params
->ch
;
152 if (fixup
& SKL_FMT_FIXUP_MASK
) {
153 fmt
->valid_bit_depth
= skl_get_bit_depth(params
->s_fmt
);
156 * 16 bit is 16 bit container whereas 24 bit is in 32 bit
157 * container so update bit depth accordingly
159 switch (fmt
->valid_bit_depth
) {
160 case SKL_DEPTH_16BIT
:
161 fmt
->bit_depth
= fmt
->valid_bit_depth
;
165 fmt
->bit_depth
= SKL_DEPTH_32BIT
;
173 * A pipeline may have modules which impact the pcm parameters, like SRC,
174 * channel converter, format converter.
175 * We need to calculate the output params by applying the 'fixup'
176 * Topology will tell driver which type of fixup is to be applied by
177 * supplying the fixup mask, so based on that we calculate the output
179 * Now In FE the pcm hw_params is source/target format. Same is applicable
180 * for BE with its hw_params invoked.
181 * here based on FE, BE pipeline and direction we calculate the input and
182 * outfix and then apply that for a module
184 static void skl_tplg_update_params_fixup(struct skl_module_cfg
*m_cfg
,
185 struct skl_pipe_params
*params
, bool is_fe
)
187 int in_fixup
, out_fixup
;
188 struct skl_module_fmt
*in_fmt
, *out_fmt
;
190 /* Fixups will be applied to pin 0 only */
191 in_fmt
= &m_cfg
->in_fmt
[0];
192 out_fmt
= &m_cfg
->out_fmt
[0];
194 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
196 in_fixup
= m_cfg
->params_fixup
;
197 out_fixup
= (~m_cfg
->converter
) &
200 out_fixup
= m_cfg
->params_fixup
;
201 in_fixup
= (~m_cfg
->converter
) &
206 out_fixup
= m_cfg
->params_fixup
;
207 in_fixup
= (~m_cfg
->converter
) &
210 in_fixup
= m_cfg
->params_fixup
;
211 out_fixup
= (~m_cfg
->converter
) &
216 skl_tplg_update_params(in_fmt
, params
, in_fixup
);
217 skl_tplg_update_params(out_fmt
, params
, out_fixup
);
221 * A module needs input and output buffers, which are dependent upon pcm
222 * params, so once we have calculate params, we need buffer calculation as
225 static void skl_tplg_update_buffer_size(struct skl_sst
*ctx
,
226 struct skl_module_cfg
*mcfg
)
229 struct skl_module_fmt
*in_fmt
, *out_fmt
;
232 /* Since fixups is applied to pin 0 only, ibs, obs needs
233 * change for pin 0 only
235 in_fmt
= &mcfg
->in_fmt
[0];
236 out_fmt
= &mcfg
->out_fmt
[0];
238 if (mcfg
->m_type
== SKL_MODULE_TYPE_SRCINT
)
240 mcfg
->ibs
= (in_fmt
->s_freq
/ 1000) *
241 (mcfg
->in_fmt
->channels
) *
242 (mcfg
->in_fmt
->bit_depth
>> 3) *
245 mcfg
->obs
= (mcfg
->out_fmt
->s_freq
/ 1000) *
246 (mcfg
->out_fmt
->channels
) *
247 (mcfg
->out_fmt
->bit_depth
>> 3) *
251 static void skl_tplg_update_module_params(struct snd_soc_dapm_widget
*w
,
254 struct skl_module_cfg
*m_cfg
= w
->priv
;
255 struct skl_pipe_params
*params
= m_cfg
->pipe
->p_params
;
256 int p_conn_type
= m_cfg
->pipe
->conn_type
;
259 if (!m_cfg
->params_fixup
)
262 dev_dbg(ctx
->dev
, "Mconfig for widget=%s BEFORE updation\n",
265 skl_dump_mconfig(ctx
, m_cfg
);
267 if (p_conn_type
== SKL_PIPE_CONN_TYPE_FE
)
272 skl_tplg_update_params_fixup(m_cfg
, params
, is_fe
);
273 skl_tplg_update_buffer_size(ctx
, m_cfg
);
275 dev_dbg(ctx
->dev
, "Mconfig for widget=%s AFTER updation\n",
278 skl_dump_mconfig(ctx
, m_cfg
);
282 * A pipe can have multiple modules, each of them will be a DAPM widget as
283 * well. While managing a pipeline we need to get the list of all the
284 * widgets in a pipelines, so this helper - skl_tplg_get_pipe_widget() helps
285 * to get the SKL type widgets in that pipeline
287 static int skl_tplg_alloc_pipe_widget(struct device
*dev
,
288 struct snd_soc_dapm_widget
*w
, struct skl_pipe
*pipe
)
290 struct skl_module_cfg
*src_module
= NULL
;
291 struct snd_soc_dapm_path
*p
= NULL
;
292 struct skl_pipe_module
*p_module
= NULL
;
294 p_module
= devm_kzalloc(dev
, sizeof(*p_module
), GFP_KERNEL
);
299 list_add_tail(&p_module
->node
, &pipe
->w_list
);
301 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
302 if ((p
->sink
->priv
== NULL
)
303 && (!is_skl_dsp_widget_type(w
)))
306 if ((p
->sink
->priv
!= NULL
) && p
->connect
307 && is_skl_dsp_widget_type(p
->sink
)) {
309 src_module
= p
->sink
->priv
;
310 if (pipe
->ppl_id
== src_module
->pipe
->ppl_id
)
311 skl_tplg_alloc_pipe_widget(dev
,
319 * some modules can have multiple params set from user control and
320 * need to be set after module is initialized. If set_param flag is
321 * set module params will be done after module is initialised.
323 static int skl_tplg_set_module_params(struct snd_soc_dapm_widget
*w
,
327 struct skl_module_cfg
*mconfig
= w
->priv
;
328 const struct snd_kcontrol_new
*k
;
329 struct soc_bytes_ext
*sb
;
330 struct skl_algo_data
*bc
;
331 struct skl_specific_cfg
*sp_cfg
;
333 if (mconfig
->formats_config
.caps_size
> 0 &&
334 mconfig
->formats_config
.set_params
== SKL_PARAM_SET
) {
335 sp_cfg
= &mconfig
->formats_config
;
336 ret
= skl_set_module_params(ctx
, sp_cfg
->caps
,
338 sp_cfg
->param_id
, mconfig
);
343 for (i
= 0; i
< w
->num_kcontrols
; i
++) {
344 k
= &w
->kcontrol_news
[i
];
345 if (k
->access
& SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
) {
346 sb
= (void *) k
->private_value
;
347 bc
= (struct skl_algo_data
*)sb
->dobj
.private;
349 if (bc
->set_params
== SKL_PARAM_SET
) {
350 ret
= skl_set_module_params(ctx
,
351 (u32
*)bc
->params
, bc
->max
,
352 bc
->param_id
, mconfig
);
363 * some module param can set from user control and this is required as
364 * when module is initailzed. if module param is required in init it is
365 * identifed by set_param flag. if set_param flag is not set, then this
366 * parameter needs to set as part of module init.
368 static int skl_tplg_set_module_init_data(struct snd_soc_dapm_widget
*w
)
370 const struct snd_kcontrol_new
*k
;
371 struct soc_bytes_ext
*sb
;
372 struct skl_algo_data
*bc
;
373 struct skl_module_cfg
*mconfig
= w
->priv
;
376 for (i
= 0; i
< w
->num_kcontrols
; i
++) {
377 k
= &w
->kcontrol_news
[i
];
378 if (k
->access
& SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
) {
379 sb
= (struct soc_bytes_ext
*)k
->private_value
;
380 bc
= (struct skl_algo_data
*)sb
->dobj
.private;
382 if (bc
->set_params
!= SKL_PARAM_INIT
)
385 mconfig
->formats_config
.caps
= (u32
*)&bc
->params
;
386 mconfig
->formats_config
.caps_size
= bc
->max
;
396 * Inside a pipe instance, we can have various modules. These modules need
397 * to instantiated in DSP by invoking INIT_MODULE IPC, which is achieved by
398 * skl_init_module() routine, so invoke that for all modules in a pipeline
401 skl_tplg_init_pipe_modules(struct skl
*skl
, struct skl_pipe
*pipe
)
403 struct skl_pipe_module
*w_module
;
404 struct snd_soc_dapm_widget
*w
;
405 struct skl_module_cfg
*mconfig
;
406 struct skl_sst
*ctx
= skl
->skl_sst
;
409 list_for_each_entry(w_module
, &pipe
->w_list
, node
) {
413 /* check resource available */
414 if (!skl_tplg_alloc_pipe_mcps(skl
, mconfig
))
417 if (mconfig
->is_loadable
&& ctx
->dsp
->fw_ops
.load_mod
) {
418 ret
= ctx
->dsp
->fw_ops
.load_mod(ctx
->dsp
,
419 mconfig
->id
.module_id
, mconfig
->guid
);
425 * apply fix/conversion to module params based on
428 skl_tplg_update_module_params(w
, ctx
);
430 skl_tplg_set_module_init_data(w
);
431 ret
= skl_init_module(ctx
, mconfig
);
435 ret
= skl_tplg_set_module_params(w
, ctx
);
443 static int skl_tplg_unload_pipe_modules(struct skl_sst
*ctx
,
444 struct skl_pipe
*pipe
)
446 struct skl_pipe_module
*w_module
= NULL
;
447 struct skl_module_cfg
*mconfig
= NULL
;
449 list_for_each_entry(w_module
, &pipe
->w_list
, node
) {
450 mconfig
= w_module
->w
->priv
;
452 if (mconfig
->is_loadable
&& ctx
->dsp
->fw_ops
.unload_mod
)
453 return ctx
->dsp
->fw_ops
.unload_mod(ctx
->dsp
,
454 mconfig
->id
.module_id
);
457 /* no modules to unload in this path, so return */
462 * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we
463 * need create the pipeline. So we do following:
464 * - check the resources
465 * - Create the pipeline
466 * - Initialize the modules in pipeline
467 * - finally bind all modules together
469 static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget
*w
,
473 struct skl_module_cfg
*mconfig
= w
->priv
;
474 struct skl_pipe_module
*w_module
;
475 struct skl_pipe
*s_pipe
= mconfig
->pipe
;
476 struct skl_module_cfg
*src_module
= NULL
, *dst_module
;
477 struct skl_sst
*ctx
= skl
->skl_sst
;
479 /* check resource available */
480 if (!skl_tplg_alloc_pipe_mcps(skl
, mconfig
))
483 if (!skl_tplg_alloc_pipe_mem(skl
, mconfig
))
487 * Create a list of modules for pipe.
488 * This list contains modules from source to sink
490 ret
= skl_create_pipeline(ctx
, mconfig
->pipe
);
495 * we create a w_list of all widgets in that pipe. This list is not
496 * freed on PMD event as widgets within a pipe are static. This
497 * saves us cycles to get widgets in pipe every time.
499 * So if we have already initialized all the widgets of a pipeline
500 * we skip, so check for list_empty and create the list if empty
502 if (list_empty(&s_pipe
->w_list
)) {
503 ret
= skl_tplg_alloc_pipe_widget(ctx
->dev
, w
, s_pipe
);
508 /* Init all pipe modules from source to sink */
509 ret
= skl_tplg_init_pipe_modules(skl
, s_pipe
);
513 /* Bind modules from source to sink */
514 list_for_each_entry(w_module
, &s_pipe
->w_list
, node
) {
515 dst_module
= w_module
->w
->priv
;
517 if (src_module
== NULL
) {
518 src_module
= dst_module
;
522 ret
= skl_bind_modules(ctx
, src_module
, dst_module
);
526 src_module
= dst_module
;
532 static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget
*w
,
534 struct skl_module_cfg
*src_mconfig
)
536 struct snd_soc_dapm_path
*p
;
537 struct snd_soc_dapm_widget
*sink
= NULL
, *next_sink
= NULL
;
538 struct skl_module_cfg
*sink_mconfig
;
539 struct skl_sst
*ctx
= skl
->skl_sst
;
542 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
546 dev_dbg(ctx
->dev
, "%s: src widget=%s\n", __func__
, w
->name
);
547 dev_dbg(ctx
->dev
, "%s: sink widget=%s\n", __func__
, p
->sink
->name
);
551 * here we will check widgets in sink pipelines, so that
552 * can be any widgets type and we are only interested if
553 * they are ones used for SKL so check that first
555 if ((p
->sink
->priv
!= NULL
) &&
556 is_skl_dsp_widget_type(p
->sink
)) {
559 sink_mconfig
= sink
->priv
;
561 /* Bind source to sink, mixin is always source */
562 ret
= skl_bind_modules(ctx
, src_mconfig
, sink_mconfig
);
566 /* Start sinks pipe first */
567 if (sink_mconfig
->pipe
->state
!= SKL_PIPE_STARTED
) {
568 if (sink_mconfig
->pipe
->conn_type
!=
569 SKL_PIPE_CONN_TYPE_FE
)
570 ret
= skl_run_pipe(ctx
,
579 return skl_tplg_bind_sinks(next_sink
, skl
, src_mconfig
);
585 * A PGA represents a module in a pipeline. So in the Pre-PMU event of PGA
586 * we need to do following:
587 * - Bind to sink pipeline
588 * Since the sink pipes can be running and we don't get mixer event on
589 * connect for already running mixer, we need to find the sink pipes
590 * here and bind to them. This way dynamic connect works.
591 * - Start sink pipeline, if not running
592 * - Then run current pipe
594 static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget
*w
,
597 struct skl_module_cfg
*src_mconfig
;
598 struct skl_sst
*ctx
= skl
->skl_sst
;
601 src_mconfig
= w
->priv
;
604 * find which sink it is connected to, bind with the sink,
605 * if sink is not started, start sink pipe first, then start
608 ret
= skl_tplg_bind_sinks(w
, skl
, src_mconfig
);
612 /* Start source pipe last after starting all sinks */
613 if (src_mconfig
->pipe
->conn_type
!= SKL_PIPE_CONN_TYPE_FE
)
614 return skl_run_pipe(ctx
, src_mconfig
->pipe
);
619 static struct snd_soc_dapm_widget
*skl_get_src_dsp_widget(
620 struct snd_soc_dapm_widget
*w
, struct skl
*skl
)
622 struct snd_soc_dapm_path
*p
;
623 struct snd_soc_dapm_widget
*src_w
= NULL
;
624 struct skl_sst
*ctx
= skl
->skl_sst
;
626 snd_soc_dapm_widget_for_each_source_path(w
, p
) {
631 dev_dbg(ctx
->dev
, "sink widget=%s\n", w
->name
);
632 dev_dbg(ctx
->dev
, "src widget=%s\n", p
->source
->name
);
635 * here we will check widgets in sink pipelines, so that can
636 * be any widgets type and we are only interested if they are
637 * ones used for SKL so check that first
639 if ((p
->source
->priv
!= NULL
) &&
640 is_skl_dsp_widget_type(p
->source
)) {
646 return skl_get_src_dsp_widget(src_w
, skl
);
652 * in the Post-PMU event of mixer we need to do following:
653 * - Check if this pipe is running
655 * - bind this pipeline to its source pipeline
656 * if source pipe is already running, this means it is a dynamic
657 * connection and we need to bind only to that pipe
658 * - start this pipeline
660 static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget
*w
,
664 struct snd_soc_dapm_widget
*source
, *sink
;
665 struct skl_module_cfg
*src_mconfig
, *sink_mconfig
;
666 struct skl_sst
*ctx
= skl
->skl_sst
;
667 int src_pipe_started
= 0;
670 sink_mconfig
= sink
->priv
;
673 * If source pipe is already started, that means source is driving
674 * one more sink before this sink got connected, Since source is
675 * started, bind this sink to source and start this pipe.
677 source
= skl_get_src_dsp_widget(w
, skl
);
678 if (source
!= NULL
) {
679 src_mconfig
= source
->priv
;
680 sink_mconfig
= sink
->priv
;
681 src_pipe_started
= 1;
684 * check pipe state, then no need to bind or start the
687 if (src_mconfig
->pipe
->state
!= SKL_PIPE_STARTED
)
688 src_pipe_started
= 0;
691 if (src_pipe_started
) {
692 ret
= skl_bind_modules(ctx
, src_mconfig
, sink_mconfig
);
696 if (sink_mconfig
->pipe
->conn_type
!= SKL_PIPE_CONN_TYPE_FE
)
697 ret
= skl_run_pipe(ctx
, sink_mconfig
->pipe
);
704 * in the Pre-PMD event of mixer we need to do following:
706 * - find the source connections and remove that from dapm_path_list
707 * - unbind with source pipelines if still connected
709 static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget
*w
,
712 struct skl_module_cfg
*src_mconfig
, *sink_mconfig
;
714 struct skl_sst
*ctx
= skl
->skl_sst
;
716 sink_mconfig
= w
->priv
;
719 ret
= skl_stop_pipe(ctx
, sink_mconfig
->pipe
);
723 for (i
= 0; i
< sink_mconfig
->max_in_queue
; i
++) {
724 if (sink_mconfig
->m_in_pin
[i
].pin_state
== SKL_PIN_BIND_DONE
) {
725 src_mconfig
= sink_mconfig
->m_in_pin
[i
].tgt_mcfg
;
729 * If path_found == 1, that means pmd for source
730 * pipe has not occurred, source is connected to
731 * some other sink. so its responsibility of sink
732 * to unbind itself from source.
734 ret
= skl_stop_pipe(ctx
, src_mconfig
->pipe
);
738 ret
= skl_unbind_modules(ctx
,
739 src_mconfig
, sink_mconfig
);
747 * in the Post-PMD event of mixer we need to do following:
748 * - Free the mcps used
749 * - Free the mem used
750 * - Unbind the modules within the pipeline
751 * - Delete the pipeline (modules are not required to be explicitly
752 * deleted, pipeline delete is enough here
754 static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget
*w
,
757 struct skl_module_cfg
*mconfig
= w
->priv
;
758 struct skl_pipe_module
*w_module
;
759 struct skl_module_cfg
*src_module
= NULL
, *dst_module
;
760 struct skl_sst
*ctx
= skl
->skl_sst
;
761 struct skl_pipe
*s_pipe
= mconfig
->pipe
;
764 skl_tplg_free_pipe_mcps(skl
, mconfig
);
765 skl_tplg_free_pipe_mem(skl
, mconfig
);
767 list_for_each_entry(w_module
, &s_pipe
->w_list
, node
) {
768 dst_module
= w_module
->w
->priv
;
770 skl_tplg_free_pipe_mcps(skl
, dst_module
);
771 if (src_module
== NULL
) {
772 src_module
= dst_module
;
776 ret
= skl_unbind_modules(ctx
, src_module
, dst_module
);
780 src_module
= dst_module
;
783 ret
= skl_delete_pipe(ctx
, mconfig
->pipe
);
785 return skl_tplg_unload_pipe_modules(ctx
, s_pipe
);
789 * in the Post-PMD event of PGA we need to do following:
790 * - Free the mcps used
791 * - Stop the pipeline
792 * - In source pipe is connected, unbind with source pipelines
794 static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget
*w
,
797 struct skl_module_cfg
*src_mconfig
, *sink_mconfig
;
799 struct skl_sst
*ctx
= skl
->skl_sst
;
801 src_mconfig
= w
->priv
;
803 /* Stop the pipe since this is a mixin module */
804 ret
= skl_stop_pipe(ctx
, src_mconfig
->pipe
);
808 for (i
= 0; i
< src_mconfig
->max_out_queue
; i
++) {
809 if (src_mconfig
->m_out_pin
[i
].pin_state
== SKL_PIN_BIND_DONE
) {
810 sink_mconfig
= src_mconfig
->m_out_pin
[i
].tgt_mcfg
;
814 * This is a connecter and if path is found that means
815 * unbind between source and sink has not happened yet
817 ret
= skl_stop_pipe(ctx
, sink_mconfig
->pipe
);
820 ret
= skl_unbind_modules(ctx
, src_mconfig
,
829 * In modelling, we assume there will be ONLY one mixer in a pipeline. If
830 * mixer is not required then it is treated as static mixer aka vmixer with
831 * a hard path to source module
832 * So we don't need to check if source is started or not as hard path puts
833 * dependency on each other
835 static int skl_tplg_vmixer_event(struct snd_soc_dapm_widget
*w
,
836 struct snd_kcontrol
*k
, int event
)
838 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
839 struct skl
*skl
= get_skl_ctx(dapm
->dev
);
842 case SND_SOC_DAPM_PRE_PMU
:
843 return skl_tplg_mixer_dapm_pre_pmu_event(w
, skl
);
845 case SND_SOC_DAPM_POST_PMD
:
846 return skl_tplg_mixer_dapm_post_pmd_event(w
, skl
);
853 * In modelling, we assume there will be ONLY one mixer in a pipeline. If a
854 * second one is required that is created as another pipe entity.
855 * The mixer is responsible for pipe management and represent a pipeline
858 static int skl_tplg_mixer_event(struct snd_soc_dapm_widget
*w
,
859 struct snd_kcontrol
*k
, int event
)
861 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
862 struct skl
*skl
= get_skl_ctx(dapm
->dev
);
865 case SND_SOC_DAPM_PRE_PMU
:
866 return skl_tplg_mixer_dapm_pre_pmu_event(w
, skl
);
868 case SND_SOC_DAPM_POST_PMU
:
869 return skl_tplg_mixer_dapm_post_pmu_event(w
, skl
);
871 case SND_SOC_DAPM_PRE_PMD
:
872 return skl_tplg_mixer_dapm_pre_pmd_event(w
, skl
);
874 case SND_SOC_DAPM_POST_PMD
:
875 return skl_tplg_mixer_dapm_post_pmd_event(w
, skl
);
882 * In modelling, we assumed rest of the modules in pipeline are PGA. But we
883 * are interested in last PGA (leaf PGA) in a pipeline to disconnect with
884 * the sink when it is running (two FE to one BE or one FE to two BE)
887 static int skl_tplg_pga_event(struct snd_soc_dapm_widget
*w
,
888 struct snd_kcontrol
*k
, int event
)
891 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
892 struct skl
*skl
= get_skl_ctx(dapm
->dev
);
895 case SND_SOC_DAPM_PRE_PMU
:
896 return skl_tplg_pga_dapm_pre_pmu_event(w
, skl
);
898 case SND_SOC_DAPM_POST_PMD
:
899 return skl_tplg_pga_dapm_post_pmd_event(w
, skl
);
905 static int skl_tplg_tlv_control_get(struct snd_kcontrol
*kcontrol
,
906 unsigned int __user
*data
, unsigned int size
)
908 struct soc_bytes_ext
*sb
=
909 (struct soc_bytes_ext
*)kcontrol
->private_value
;
910 struct skl_algo_data
*bc
= (struct skl_algo_data
*)sb
->dobj
.private;
911 struct snd_soc_dapm_widget
*w
= snd_soc_dapm_kcontrol_widget(kcontrol
);
912 struct skl_module_cfg
*mconfig
= w
->priv
;
913 struct skl
*skl
= get_skl_ctx(w
->dapm
->dev
);
916 skl_get_module_params(skl
->skl_sst
, (u32
*)bc
->params
,
917 bc
->max
, bc
->param_id
, mconfig
);
920 if (copy_to_user(data
, &bc
->param_id
, sizeof(u32
)))
922 if (copy_to_user(data
+ 1, &size
, sizeof(u32
)))
924 if (copy_to_user(data
+ 2, bc
->params
, size
))
931 #define SKL_PARAM_VENDOR_ID 0xff
933 static int skl_tplg_tlv_control_set(struct snd_kcontrol
*kcontrol
,
934 const unsigned int __user
*data
, unsigned int size
)
936 struct snd_soc_dapm_widget
*w
= snd_soc_dapm_kcontrol_widget(kcontrol
);
937 struct skl_module_cfg
*mconfig
= w
->priv
;
938 struct soc_bytes_ext
*sb
=
939 (struct soc_bytes_ext
*)kcontrol
->private_value
;
940 struct skl_algo_data
*ac
= (struct skl_algo_data
*)sb
->dobj
.private;
941 struct skl
*skl
= get_skl_ctx(w
->dapm
->dev
);
945 * if the param_is is of type Vendor, firmware expects actual
946 * parameter id and size from the control.
948 if (ac
->param_id
== SKL_PARAM_VENDOR_ID
) {
949 if (copy_from_user(ac
->params
, data
, size
))
952 if (copy_from_user(ac
->params
,
953 data
+ 2 * sizeof(u32
), size
))
958 return skl_set_module_params(skl
->skl_sst
,
959 (u32
*)ac
->params
, ac
->max
,
960 ac
->param_id
, mconfig
);
967 * The FE params are passed by hw_params of the DAI.
968 * On hw_params, the params are stored in Gateway module of the FE and we
969 * need to calculate the format in DSP module configuration, that
970 * conversion is done here
972 int skl_tplg_update_pipe_params(struct device
*dev
,
973 struct skl_module_cfg
*mconfig
,
974 struct skl_pipe_params
*params
)
976 struct skl_pipe
*pipe
= mconfig
->pipe
;
977 struct skl_module_fmt
*format
= NULL
;
979 memcpy(pipe
->p_params
, params
, sizeof(*params
));
981 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
982 format
= &mconfig
->in_fmt
[0];
984 format
= &mconfig
->out_fmt
[0];
986 /* set the hw_params */
987 format
->s_freq
= params
->s_freq
;
988 format
->channels
= params
->ch
;
989 format
->valid_bit_depth
= skl_get_bit_depth(params
->s_fmt
);
992 * 16 bit is 16 bit container whereas 24 bit is in 32 bit
993 * container so update bit depth accordingly
995 switch (format
->valid_bit_depth
) {
996 case SKL_DEPTH_16BIT
:
997 format
->bit_depth
= format
->valid_bit_depth
;
1000 case SKL_DEPTH_24BIT
:
1001 case SKL_DEPTH_32BIT
:
1002 format
->bit_depth
= SKL_DEPTH_32BIT
;
1006 dev_err(dev
, "Invalid bit depth %x for pipe\n",
1007 format
->valid_bit_depth
);
1011 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1012 mconfig
->ibs
= (format
->s_freq
/ 1000) *
1013 (format
->channels
) *
1014 (format
->bit_depth
>> 3);
1016 mconfig
->obs
= (format
->s_freq
/ 1000) *
1017 (format
->channels
) *
1018 (format
->bit_depth
>> 3);
1025 * Query the module config for the FE DAI
1026 * This is used to find the hw_params set for that DAI and apply to FE
1029 struct skl_module_cfg
*
1030 skl_tplg_fe_get_cpr_module(struct snd_soc_dai
*dai
, int stream
)
1032 struct snd_soc_dapm_widget
*w
;
1033 struct snd_soc_dapm_path
*p
= NULL
;
1035 if (stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1036 w
= dai
->playback_widget
;
1037 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
1038 if (p
->connect
&& p
->sink
->power
&&
1039 !is_skl_dsp_widget_type(p
->sink
))
1042 if (p
->sink
->priv
) {
1043 dev_dbg(dai
->dev
, "set params for %s\n",
1045 return p
->sink
->priv
;
1049 w
= dai
->capture_widget
;
1050 snd_soc_dapm_widget_for_each_source_path(w
, p
) {
1051 if (p
->connect
&& p
->source
->power
&&
1052 !is_skl_dsp_widget_type(p
->source
))
1055 if (p
->source
->priv
) {
1056 dev_dbg(dai
->dev
, "set params for %s\n",
1058 return p
->source
->priv
;
1066 static u8
skl_tplg_be_link_type(int dev_type
)
1072 ret
= NHLT_LINK_SSP
;
1075 case SKL_DEVICE_DMIC
:
1076 ret
= NHLT_LINK_DMIC
;
1079 case SKL_DEVICE_I2S
:
1080 ret
= NHLT_LINK_SSP
;
1083 case SKL_DEVICE_HDALINK
:
1084 ret
= NHLT_LINK_HDA
;
1088 ret
= NHLT_LINK_INVALID
;
1096 * Fill the BE gateway parameters
1097 * The BE gateway expects a blob of parameters which are kept in the ACPI
1098 * NHLT blob, so query the blob for interface type (i2s/pdm) and instance.
1099 * The port can have multiple settings so pick based on the PCM
1102 static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai
*dai
,
1103 struct skl_module_cfg
*mconfig
,
1104 struct skl_pipe_params
*params
)
1106 struct skl_pipe
*pipe
= mconfig
->pipe
;
1107 struct nhlt_specific_cfg
*cfg
;
1108 struct skl
*skl
= get_skl_ctx(dai
->dev
);
1109 int link_type
= skl_tplg_be_link_type(mconfig
->dev_type
);
1111 memcpy(pipe
->p_params
, params
, sizeof(*params
));
1113 if (link_type
== NHLT_LINK_HDA
)
1116 /* update the blob based on virtual bus_id*/
1117 cfg
= skl_get_ep_blob(skl
, mconfig
->vbus_id
, link_type
,
1118 params
->s_fmt
, params
->ch
,
1119 params
->s_freq
, params
->stream
);
1121 mconfig
->formats_config
.caps_size
= cfg
->size
;
1122 mconfig
->formats_config
.caps
= (u32
*) &cfg
->caps
;
1124 dev_err(dai
->dev
, "Blob NULL for id %x type %d dirn %d\n",
1125 mconfig
->vbus_id
, link_type
,
1127 dev_err(dai
->dev
, "PCM: ch %d, freq %d, fmt %d\n",
1128 params
->ch
, params
->s_freq
, params
->s_fmt
);
1135 static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai
*dai
,
1136 struct snd_soc_dapm_widget
*w
,
1137 struct skl_pipe_params
*params
)
1139 struct snd_soc_dapm_path
*p
;
1142 snd_soc_dapm_widget_for_each_source_path(w
, p
) {
1143 if (p
->connect
&& is_skl_dsp_widget_type(p
->source
) &&
1146 ret
= skl_tplg_be_fill_pipe_params(dai
,
1147 p
->source
->priv
, params
);
1151 ret
= skl_tplg_be_set_src_pipe_params(dai
,
1161 static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai
*dai
,
1162 struct snd_soc_dapm_widget
*w
, struct skl_pipe_params
*params
)
1164 struct snd_soc_dapm_path
*p
= NULL
;
1167 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
1168 if (p
->connect
&& is_skl_dsp_widget_type(p
->sink
) &&
1171 ret
= skl_tplg_be_fill_pipe_params(dai
,
1172 p
->sink
->priv
, params
);
1176 ret
= skl_tplg_be_set_sink_pipe_params(
1177 dai
, p
->sink
, params
);
1187 * BE hw_params can be a source parameters (capture) or sink parameters
1188 * (playback). Based on sink and source we need to either find the source
1189 * list or the sink list and set the pipeline parameters
1191 int skl_tplg_be_update_params(struct snd_soc_dai
*dai
,
1192 struct skl_pipe_params
*params
)
1194 struct snd_soc_dapm_widget
*w
;
1196 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1197 w
= dai
->playback_widget
;
1199 return skl_tplg_be_set_src_pipe_params(dai
, w
, params
);
1202 w
= dai
->capture_widget
;
1204 return skl_tplg_be_set_sink_pipe_params(dai
, w
, params
);
1210 static const struct snd_soc_tplg_widget_events skl_tplg_widget_ops
[] = {
1211 {SKL_MIXER_EVENT
, skl_tplg_mixer_event
},
1212 {SKL_VMIXER_EVENT
, skl_tplg_vmixer_event
},
1213 {SKL_PGA_EVENT
, skl_tplg_pga_event
},
1216 static const struct snd_soc_tplg_bytes_ext_ops skl_tlv_ops
[] = {
1217 {SKL_CONTROL_TYPE_BYTE_TLV
, skl_tplg_tlv_control_get
,
1218 skl_tplg_tlv_control_set
},
1222 * The topology binary passes the pin info for a module so initialize the pin
1223 * info passed into module instance
1225 static void skl_fill_module_pin_info(struct skl_dfw_module_pin
*dfw_pin
,
1226 struct skl_module_pin
*m_pin
,
1227 bool is_dynamic
, int max_pin
)
1231 for (i
= 0; i
< max_pin
; i
++) {
1232 m_pin
[i
].id
.module_id
= dfw_pin
[i
].module_id
;
1233 m_pin
[i
].id
.instance_id
= dfw_pin
[i
].instance_id
;
1234 m_pin
[i
].in_use
= false;
1235 m_pin
[i
].is_dynamic
= is_dynamic
;
1236 m_pin
[i
].pin_state
= SKL_PIN_UNBIND
;
1241 * Add pipeline from topology binary into driver pipeline list
1243 * If already added we return that instance
1244 * Otherwise we create a new instance and add into driver list
1246 static struct skl_pipe
*skl_tplg_add_pipe(struct device
*dev
,
1247 struct skl
*skl
, struct skl_dfw_pipe
*dfw_pipe
)
1249 struct skl_pipeline
*ppl
;
1250 struct skl_pipe
*pipe
;
1251 struct skl_pipe_params
*params
;
1253 list_for_each_entry(ppl
, &skl
->ppl_list
, node
) {
1254 if (ppl
->pipe
->ppl_id
== dfw_pipe
->pipe_id
)
1258 ppl
= devm_kzalloc(dev
, sizeof(*ppl
), GFP_KERNEL
);
1262 pipe
= devm_kzalloc(dev
, sizeof(*pipe
), GFP_KERNEL
);
1266 params
= devm_kzalloc(dev
, sizeof(*params
), GFP_KERNEL
);
1270 pipe
->ppl_id
= dfw_pipe
->pipe_id
;
1271 pipe
->memory_pages
= dfw_pipe
->memory_pages
;
1272 pipe
->pipe_priority
= dfw_pipe
->pipe_priority
;
1273 pipe
->conn_type
= dfw_pipe
->conn_type
;
1274 pipe
->state
= SKL_PIPE_INVALID
;
1275 pipe
->p_params
= params
;
1276 INIT_LIST_HEAD(&pipe
->w_list
);
1279 list_add(&ppl
->node
, &skl
->ppl_list
);
1284 static void skl_tplg_fill_fmt(struct skl_module_fmt
*dst_fmt
,
1285 struct skl_dfw_module_fmt
*src_fmt
,
1290 for (i
= 0; i
< pins
; i
++) {
1291 dst_fmt
[i
].channels
= src_fmt
[i
].channels
;
1292 dst_fmt
[i
].s_freq
= src_fmt
[i
].freq
;
1293 dst_fmt
[i
].bit_depth
= src_fmt
[i
].bit_depth
;
1294 dst_fmt
[i
].valid_bit_depth
= src_fmt
[i
].valid_bit_depth
;
1295 dst_fmt
[i
].ch_cfg
= src_fmt
[i
].ch_cfg
;
1296 dst_fmt
[i
].ch_map
= src_fmt
[i
].ch_map
;
1297 dst_fmt
[i
].interleaving_style
= src_fmt
[i
].interleaving_style
;
1298 dst_fmt
[i
].sample_type
= src_fmt
[i
].sample_type
;
1303 * Topology core widget load callback
1305 * This is used to save the private data for each widget which gives
1306 * information to the driver about module and pipeline parameters which DSP
1307 * FW expects like ids, resource values, formats etc
1309 static int skl_tplg_widget_load(struct snd_soc_component
*cmpnt
,
1310 struct snd_soc_dapm_widget
*w
,
1311 struct snd_soc_tplg_dapm_widget
*tplg_w
)
1314 struct hdac_ext_bus
*ebus
= snd_soc_component_get_drvdata(cmpnt
);
1315 struct skl
*skl
= ebus_to_skl(ebus
);
1316 struct hdac_bus
*bus
= ebus_to_hbus(ebus
);
1317 struct skl_module_cfg
*mconfig
;
1318 struct skl_pipe
*pipe
;
1319 struct skl_dfw_module
*dfw_config
=
1320 (struct skl_dfw_module
*)tplg_w
->priv
.data
;
1322 if (!tplg_w
->priv
.size
)
1325 mconfig
= devm_kzalloc(bus
->dev
, sizeof(*mconfig
), GFP_KERNEL
);
1331 mconfig
->id
.module_id
= dfw_config
->module_id
;
1332 mconfig
->id
.instance_id
= dfw_config
->instance_id
;
1333 mconfig
->mcps
= dfw_config
->max_mcps
;
1334 mconfig
->ibs
= dfw_config
->ibs
;
1335 mconfig
->obs
= dfw_config
->obs
;
1336 mconfig
->core_id
= dfw_config
->core_id
;
1337 mconfig
->max_in_queue
= dfw_config
->max_in_queue
;
1338 mconfig
->max_out_queue
= dfw_config
->max_out_queue
;
1339 mconfig
->is_loadable
= dfw_config
->is_loadable
;
1340 skl_tplg_fill_fmt(mconfig
->in_fmt
, dfw_config
->in_fmt
,
1341 MODULE_MAX_IN_PINS
);
1342 skl_tplg_fill_fmt(mconfig
->out_fmt
, dfw_config
->out_fmt
,
1343 MODULE_MAX_OUT_PINS
);
1345 mconfig
->params_fixup
= dfw_config
->params_fixup
;
1346 mconfig
->converter
= dfw_config
->converter
;
1347 mconfig
->m_type
= dfw_config
->module_type
;
1348 mconfig
->vbus_id
= dfw_config
->vbus_id
;
1349 mconfig
->mem_pages
= dfw_config
->mem_pages
;
1351 pipe
= skl_tplg_add_pipe(bus
->dev
, skl
, &dfw_config
->pipe
);
1353 mconfig
->pipe
= pipe
;
1355 mconfig
->dev_type
= dfw_config
->dev_type
;
1356 mconfig
->hw_conn_type
= dfw_config
->hw_conn_type
;
1357 mconfig
->time_slot
= dfw_config
->time_slot
;
1358 mconfig
->formats_config
.caps_size
= dfw_config
->caps
.caps_size
;
1360 if (dfw_config
->is_loadable
)
1361 memcpy(mconfig
->guid
, dfw_config
->uuid
,
1362 ARRAY_SIZE(dfw_config
->uuid
));
1364 mconfig
->m_in_pin
= devm_kzalloc(bus
->dev
, (mconfig
->max_in_queue
) *
1365 sizeof(*mconfig
->m_in_pin
),
1367 if (!mconfig
->m_in_pin
)
1370 mconfig
->m_out_pin
= devm_kzalloc(bus
->dev
, (mconfig
->max_out_queue
) *
1371 sizeof(*mconfig
->m_out_pin
),
1373 if (!mconfig
->m_out_pin
)
1376 skl_fill_module_pin_info(dfw_config
->in_pin
, mconfig
->m_in_pin
,
1377 dfw_config
->is_dynamic_in_pin
,
1378 mconfig
->max_in_queue
);
1380 skl_fill_module_pin_info(dfw_config
->out_pin
, mconfig
->m_out_pin
,
1381 dfw_config
->is_dynamic_out_pin
,
1382 mconfig
->max_out_queue
);
1385 if (mconfig
->formats_config
.caps_size
== 0)
1388 mconfig
->formats_config
.caps
= (u32
*)devm_kzalloc(bus
->dev
,
1389 mconfig
->formats_config
.caps_size
, GFP_KERNEL
);
1391 if (mconfig
->formats_config
.caps
== NULL
)
1394 memcpy(mconfig
->formats_config
.caps
, dfw_config
->caps
.caps
,
1395 dfw_config
->caps
.caps_size
);
1396 mconfig
->formats_config
.param_id
= dfw_config
->caps
.param_id
;
1397 mconfig
->formats_config
.set_params
= dfw_config
->caps
.set_params
;
1400 if (tplg_w
->event_type
== 0) {
1401 dev_dbg(bus
->dev
, "ASoC: No event handler required\n");
1405 ret
= snd_soc_tplg_widget_bind_event(w
, skl_tplg_widget_ops
,
1406 ARRAY_SIZE(skl_tplg_widget_ops
),
1407 tplg_w
->event_type
);
1410 dev_err(bus
->dev
, "%s: No matching event handlers found for %d\n",
1411 __func__
, tplg_w
->event_type
);
1418 static int skl_init_algo_data(struct device
*dev
, struct soc_bytes_ext
*be
,
1419 struct snd_soc_tplg_bytes_control
*bc
)
1421 struct skl_algo_data
*ac
;
1422 struct skl_dfw_algo_data
*dfw_ac
=
1423 (struct skl_dfw_algo_data
*)bc
->priv
.data
;
1425 ac
= devm_kzalloc(dev
, sizeof(*ac
), GFP_KERNEL
);
1429 /* Fill private data */
1430 ac
->max
= dfw_ac
->max
;
1431 ac
->param_id
= dfw_ac
->param_id
;
1432 ac
->set_params
= dfw_ac
->set_params
;
1435 ac
->params
= (char *) devm_kzalloc(dev
, ac
->max
, GFP_KERNEL
);
1440 memcpy(ac
->params
, dfw_ac
->params
, ac
->max
);
1443 be
->dobj
.private = ac
;
1447 static int skl_tplg_control_load(struct snd_soc_component
*cmpnt
,
1448 struct snd_kcontrol_new
*kctl
,
1449 struct snd_soc_tplg_ctl_hdr
*hdr
)
1451 struct soc_bytes_ext
*sb
;
1452 struct snd_soc_tplg_bytes_control
*tplg_bc
;
1453 struct hdac_ext_bus
*ebus
= snd_soc_component_get_drvdata(cmpnt
);
1454 struct hdac_bus
*bus
= ebus_to_hbus(ebus
);
1456 switch (hdr
->ops
.info
) {
1457 case SND_SOC_TPLG_CTL_BYTES
:
1458 tplg_bc
= container_of(hdr
,
1459 struct snd_soc_tplg_bytes_control
, hdr
);
1460 if (kctl
->access
& SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
) {
1461 sb
= (struct soc_bytes_ext
*)kctl
->private_value
;
1462 if (tplg_bc
->priv
.size
)
1463 return skl_init_algo_data(
1464 bus
->dev
, sb
, tplg_bc
);
1469 dev_warn(bus
->dev
, "Control load not supported %d:%d:%d\n",
1470 hdr
->ops
.get
, hdr
->ops
.put
, hdr
->ops
.info
);
1477 static struct snd_soc_tplg_ops skl_tplg_ops
= {
1478 .widget_load
= skl_tplg_widget_load
,
1479 .control_load
= skl_tplg_control_load
,
1480 .bytes_ext_ops
= skl_tlv_ops
,
1481 .bytes_ext_ops_count
= ARRAY_SIZE(skl_tlv_ops
),
1484 /* This will be read from topology manifest, currently defined here */
1485 #define SKL_MAX_MCPS 30000000
1486 #define SKL_FW_MAX_MEM 1000000
1489 * SKL topology init routine
1491 int skl_tplg_init(struct snd_soc_platform
*platform
, struct hdac_ext_bus
*ebus
)
1494 const struct firmware
*fw
;
1495 struct hdac_bus
*bus
= ebus_to_hbus(ebus
);
1496 struct skl
*skl
= ebus_to_skl(ebus
);
1498 ret
= request_firmware(&fw
, "dfw_sst.bin", bus
->dev
);
1500 dev_err(bus
->dev
, "tplg fw %s load failed with %d\n",
1501 "dfw_sst.bin", ret
);
1506 * The complete tplg for SKL is loaded as index 0, we don't use
1509 ret
= snd_soc_tplg_component_load(&platform
->component
,
1510 &skl_tplg_ops
, fw
, 0);
1512 dev_err(bus
->dev
, "tplg component load failed%d\n", ret
);
1516 skl
->resource
.max_mcps
= SKL_MAX_MCPS
;
1517 skl
->resource
.max_mem
= SKL_FW_MAX_MEM
;