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.
59 static bool skl_is_pipe_mem_avail(struct skl
*skl
,
60 struct skl_module_cfg
*mconfig
)
62 struct skl_sst
*ctx
= skl
->skl_sst
;
64 if (skl
->resource
.mem
+ mconfig
->pipe
->memory_pages
>
65 skl
->resource
.max_mem
) {
67 "%s: module_id %d instance %d\n", __func__
,
68 mconfig
->id
.module_id
,
69 mconfig
->id
.instance_id
);
71 "exceeds ppl memory available %d mem %d\n",
72 skl
->resource
.max_mem
, skl
->resource
.mem
);
80 * Add the mem to the mem pool. This is freed when pipe is deleted.
81 * Note: DSP does actual memory management we only keep track for complete
84 static void skl_tplg_alloc_pipe_mem(struct skl
*skl
,
85 struct skl_module_cfg
*mconfig
)
87 skl
->resource
.mem
+= mconfig
->pipe
->memory_pages
;
91 * Pipeline needs needs DSP CPU resources for computation, this is
92 * quantified in MCPS (Million Clocks Per Second) required for module/pipe
94 * Each pipelines needs mcps to be allocated. Check if we have mcps for this
98 static bool skl_is_pipe_mcps_avail(struct skl
*skl
,
99 struct skl_module_cfg
*mconfig
)
101 struct skl_sst
*ctx
= skl
->skl_sst
;
103 if (skl
->resource
.mcps
+ mconfig
->mcps
> skl
->resource
.max_mcps
) {
105 "%s: module_id %d instance %d\n", __func__
,
106 mconfig
->id
.module_id
, mconfig
->id
.instance_id
);
108 "exceeds ppl mcps available %d > mem %d\n",
109 skl
->resource
.max_mcps
, skl
->resource
.mcps
);
116 static void skl_tplg_alloc_pipe_mcps(struct skl
*skl
,
117 struct skl_module_cfg
*mconfig
)
119 skl
->resource
.mcps
+= mconfig
->mcps
;
123 * Free the mcps when tearing down
126 skl_tplg_free_pipe_mcps(struct skl
*skl
, struct skl_module_cfg
*mconfig
)
128 skl
->resource
.mcps
-= mconfig
->mcps
;
132 * Free the memory when tearing down
135 skl_tplg_free_pipe_mem(struct skl
*skl
, struct skl_module_cfg
*mconfig
)
137 skl
->resource
.mem
-= mconfig
->pipe
->memory_pages
;
141 static void skl_dump_mconfig(struct skl_sst
*ctx
,
142 struct skl_module_cfg
*mcfg
)
144 dev_dbg(ctx
->dev
, "Dumping config\n");
145 dev_dbg(ctx
->dev
, "Input Format:\n");
146 dev_dbg(ctx
->dev
, "channels = %d\n", mcfg
->in_fmt
[0].channels
);
147 dev_dbg(ctx
->dev
, "s_freq = %d\n", mcfg
->in_fmt
[0].s_freq
);
148 dev_dbg(ctx
->dev
, "ch_cfg = %d\n", mcfg
->in_fmt
[0].ch_cfg
);
149 dev_dbg(ctx
->dev
, "valid bit depth = %d\n", mcfg
->in_fmt
[0].valid_bit_depth
);
150 dev_dbg(ctx
->dev
, "Output Format:\n");
151 dev_dbg(ctx
->dev
, "channels = %d\n", mcfg
->out_fmt
[0].channels
);
152 dev_dbg(ctx
->dev
, "s_freq = %d\n", mcfg
->out_fmt
[0].s_freq
);
153 dev_dbg(ctx
->dev
, "valid bit depth = %d\n", mcfg
->out_fmt
[0].valid_bit_depth
);
154 dev_dbg(ctx
->dev
, "ch_cfg = %d\n", mcfg
->out_fmt
[0].ch_cfg
);
157 static void skl_tplg_update_params(struct skl_module_fmt
*fmt
,
158 struct skl_pipe_params
*params
, int fixup
)
160 if (fixup
& SKL_RATE_FIXUP_MASK
)
161 fmt
->s_freq
= params
->s_freq
;
162 if (fixup
& SKL_CH_FIXUP_MASK
)
163 fmt
->channels
= params
->ch
;
164 if (fixup
& SKL_FMT_FIXUP_MASK
) {
165 fmt
->valid_bit_depth
= skl_get_bit_depth(params
->s_fmt
);
168 * 16 bit is 16 bit container whereas 24 bit is in 32 bit
169 * container so update bit depth accordingly
171 switch (fmt
->valid_bit_depth
) {
172 case SKL_DEPTH_16BIT
:
173 fmt
->bit_depth
= fmt
->valid_bit_depth
;
177 fmt
->bit_depth
= SKL_DEPTH_32BIT
;
185 * A pipeline may have modules which impact the pcm parameters, like SRC,
186 * channel converter, format converter.
187 * We need to calculate the output params by applying the 'fixup'
188 * Topology will tell driver which type of fixup is to be applied by
189 * supplying the fixup mask, so based on that we calculate the output
191 * Now In FE the pcm hw_params is source/target format. Same is applicable
192 * for BE with its hw_params invoked.
193 * here based on FE, BE pipeline and direction we calculate the input and
194 * outfix and then apply that for a module
196 static void skl_tplg_update_params_fixup(struct skl_module_cfg
*m_cfg
,
197 struct skl_pipe_params
*params
, bool is_fe
)
199 int in_fixup
, out_fixup
;
200 struct skl_module_fmt
*in_fmt
, *out_fmt
;
202 /* Fixups will be applied to pin 0 only */
203 in_fmt
= &m_cfg
->in_fmt
[0];
204 out_fmt
= &m_cfg
->out_fmt
[0];
206 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
208 in_fixup
= m_cfg
->params_fixup
;
209 out_fixup
= (~m_cfg
->converter
) &
212 out_fixup
= m_cfg
->params_fixup
;
213 in_fixup
= (~m_cfg
->converter
) &
218 out_fixup
= m_cfg
->params_fixup
;
219 in_fixup
= (~m_cfg
->converter
) &
222 in_fixup
= m_cfg
->params_fixup
;
223 out_fixup
= (~m_cfg
->converter
) &
228 skl_tplg_update_params(in_fmt
, params
, in_fixup
);
229 skl_tplg_update_params(out_fmt
, params
, out_fixup
);
233 * A module needs input and output buffers, which are dependent upon pcm
234 * params, so once we have calculate params, we need buffer calculation as
237 static void skl_tplg_update_buffer_size(struct skl_sst
*ctx
,
238 struct skl_module_cfg
*mcfg
)
241 struct skl_module_fmt
*in_fmt
, *out_fmt
;
244 /* Since fixups is applied to pin 0 only, ibs, obs needs
245 * change for pin 0 only
247 in_fmt
= &mcfg
->in_fmt
[0];
248 out_fmt
= &mcfg
->out_fmt
[0];
250 if (mcfg
->m_type
== SKL_MODULE_TYPE_SRCINT
)
252 mcfg
->ibs
= (in_fmt
->s_freq
/ 1000) *
253 (mcfg
->in_fmt
->channels
) *
254 (mcfg
->in_fmt
->bit_depth
>> 3) *
257 mcfg
->obs
= (mcfg
->out_fmt
->s_freq
/ 1000) *
258 (mcfg
->out_fmt
->channels
) *
259 (mcfg
->out_fmt
->bit_depth
>> 3) *
263 static void skl_tplg_update_module_params(struct snd_soc_dapm_widget
*w
,
266 struct skl_module_cfg
*m_cfg
= w
->priv
;
267 struct skl_pipe_params
*params
= m_cfg
->pipe
->p_params
;
268 int p_conn_type
= m_cfg
->pipe
->conn_type
;
271 if (!m_cfg
->params_fixup
)
274 dev_dbg(ctx
->dev
, "Mconfig for widget=%s BEFORE updation\n",
277 skl_dump_mconfig(ctx
, m_cfg
);
279 if (p_conn_type
== SKL_PIPE_CONN_TYPE_FE
)
284 skl_tplg_update_params_fixup(m_cfg
, params
, is_fe
);
285 skl_tplg_update_buffer_size(ctx
, m_cfg
);
287 dev_dbg(ctx
->dev
, "Mconfig for widget=%s AFTER updation\n",
290 skl_dump_mconfig(ctx
, m_cfg
);
294 * A pipe can have multiple modules, each of them will be a DAPM widget as
295 * well. While managing a pipeline we need to get the list of all the
296 * widgets in a pipelines, so this helper - skl_tplg_get_pipe_widget() helps
297 * to get the SKL type widgets in that pipeline
299 static int skl_tplg_alloc_pipe_widget(struct device
*dev
,
300 struct snd_soc_dapm_widget
*w
, struct skl_pipe
*pipe
)
302 struct skl_module_cfg
*src_module
= NULL
;
303 struct snd_soc_dapm_path
*p
= NULL
;
304 struct skl_pipe_module
*p_module
= NULL
;
306 p_module
= devm_kzalloc(dev
, sizeof(*p_module
), GFP_KERNEL
);
311 list_add_tail(&p_module
->node
, &pipe
->w_list
);
313 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
314 if ((p
->sink
->priv
== NULL
)
315 && (!is_skl_dsp_widget_type(w
)))
318 if ((p
->sink
->priv
!= NULL
) && p
->connect
319 && is_skl_dsp_widget_type(p
->sink
)) {
321 src_module
= p
->sink
->priv
;
322 if (pipe
->ppl_id
== src_module
->pipe
->ppl_id
)
323 skl_tplg_alloc_pipe_widget(dev
,
331 * some modules can have multiple params set from user control and
332 * need to be set after module is initialized. If set_param flag is
333 * set module params will be done after module is initialised.
335 static int skl_tplg_set_module_params(struct snd_soc_dapm_widget
*w
,
339 struct skl_module_cfg
*mconfig
= w
->priv
;
340 const struct snd_kcontrol_new
*k
;
341 struct soc_bytes_ext
*sb
;
342 struct skl_algo_data
*bc
;
343 struct skl_specific_cfg
*sp_cfg
;
345 if (mconfig
->formats_config
.caps_size
> 0 &&
346 mconfig
->formats_config
.set_params
== SKL_PARAM_SET
) {
347 sp_cfg
= &mconfig
->formats_config
;
348 ret
= skl_set_module_params(ctx
, sp_cfg
->caps
,
350 sp_cfg
->param_id
, mconfig
);
355 for (i
= 0; i
< w
->num_kcontrols
; i
++) {
356 k
= &w
->kcontrol_news
[i
];
357 if (k
->access
& SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
) {
358 sb
= (void *) k
->private_value
;
359 bc
= (struct skl_algo_data
*)sb
->dobj
.private;
361 if (bc
->set_params
== SKL_PARAM_SET
) {
362 ret
= skl_set_module_params(ctx
,
363 (u32
*)bc
->params
, bc
->max
,
364 bc
->param_id
, mconfig
);
375 * some module param can set from user control and this is required as
376 * when module is initailzed. if module param is required in init it is
377 * identifed by set_param flag. if set_param flag is not set, then this
378 * parameter needs to set as part of module init.
380 static int skl_tplg_set_module_init_data(struct snd_soc_dapm_widget
*w
)
382 const struct snd_kcontrol_new
*k
;
383 struct soc_bytes_ext
*sb
;
384 struct skl_algo_data
*bc
;
385 struct skl_module_cfg
*mconfig
= w
->priv
;
388 for (i
= 0; i
< w
->num_kcontrols
; i
++) {
389 k
= &w
->kcontrol_news
[i
];
390 if (k
->access
& SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
) {
391 sb
= (struct soc_bytes_ext
*)k
->private_value
;
392 bc
= (struct skl_algo_data
*)sb
->dobj
.private;
394 if (bc
->set_params
!= SKL_PARAM_INIT
)
397 mconfig
->formats_config
.caps
= (u32
*)&bc
->params
;
398 mconfig
->formats_config
.caps_size
= bc
->max
;
408 * Inside a pipe instance, we can have various modules. These modules need
409 * to instantiated in DSP by invoking INIT_MODULE IPC, which is achieved by
410 * skl_init_module() routine, so invoke that for all modules in a pipeline
413 skl_tplg_init_pipe_modules(struct skl
*skl
, struct skl_pipe
*pipe
)
415 struct skl_pipe_module
*w_module
;
416 struct snd_soc_dapm_widget
*w
;
417 struct skl_module_cfg
*mconfig
;
418 struct skl_sst
*ctx
= skl
->skl_sst
;
421 list_for_each_entry(w_module
, &pipe
->w_list
, node
) {
425 /* check resource available */
426 if (!skl_is_pipe_mcps_avail(skl
, mconfig
))
429 if (mconfig
->is_loadable
&& ctx
->dsp
->fw_ops
.load_mod
) {
430 ret
= ctx
->dsp
->fw_ops
.load_mod(ctx
->dsp
,
431 mconfig
->id
.module_id
, mconfig
->guid
);
437 * apply fix/conversion to module params based on
440 skl_tplg_update_module_params(w
, ctx
);
442 skl_tplg_set_module_init_data(w
);
443 ret
= skl_init_module(ctx
, mconfig
);
447 ret
= skl_tplg_set_module_params(w
, ctx
);
450 skl_tplg_alloc_pipe_mcps(skl
, mconfig
);
456 static int skl_tplg_unload_pipe_modules(struct skl_sst
*ctx
,
457 struct skl_pipe
*pipe
)
459 struct skl_pipe_module
*w_module
= NULL
;
460 struct skl_module_cfg
*mconfig
= NULL
;
462 list_for_each_entry(w_module
, &pipe
->w_list
, node
) {
463 mconfig
= w_module
->w
->priv
;
465 if (mconfig
->is_loadable
&& ctx
->dsp
->fw_ops
.unload_mod
)
466 return ctx
->dsp
->fw_ops
.unload_mod(ctx
->dsp
,
467 mconfig
->id
.module_id
);
470 /* no modules to unload in this path, so return */
475 * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we
476 * need create the pipeline. So we do following:
477 * - check the resources
478 * - Create the pipeline
479 * - Initialize the modules in pipeline
480 * - finally bind all modules together
482 static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget
*w
,
486 struct skl_module_cfg
*mconfig
= w
->priv
;
487 struct skl_pipe_module
*w_module
;
488 struct skl_pipe
*s_pipe
= mconfig
->pipe
;
489 struct skl_module_cfg
*src_module
= NULL
, *dst_module
;
490 struct skl_sst
*ctx
= skl
->skl_sst
;
492 /* check resource available */
493 if (!skl_is_pipe_mcps_avail(skl
, mconfig
))
496 if (!skl_is_pipe_mem_avail(skl
, mconfig
))
500 * Create a list of modules for pipe.
501 * This list contains modules from source to sink
503 ret
= skl_create_pipeline(ctx
, mconfig
->pipe
);
508 * we create a w_list of all widgets in that pipe. This list is not
509 * freed on PMD event as widgets within a pipe are static. This
510 * saves us cycles to get widgets in pipe every time.
512 * So if we have already initialized all the widgets of a pipeline
513 * we skip, so check for list_empty and create the list if empty
515 if (list_empty(&s_pipe
->w_list
)) {
516 ret
= skl_tplg_alloc_pipe_widget(ctx
->dev
, w
, s_pipe
);
521 /* Init all pipe modules from source to sink */
522 ret
= skl_tplg_init_pipe_modules(skl
, s_pipe
);
526 /* Bind modules from source to sink */
527 list_for_each_entry(w_module
, &s_pipe
->w_list
, node
) {
528 dst_module
= w_module
->w
->priv
;
530 if (src_module
== NULL
) {
531 src_module
= dst_module
;
535 ret
= skl_bind_modules(ctx
, src_module
, dst_module
);
539 src_module
= dst_module
;
542 skl_tplg_alloc_pipe_mem(skl
, mconfig
);
543 skl_tplg_alloc_pipe_mcps(skl
, mconfig
);
548 static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget
*w
,
550 struct skl_module_cfg
*src_mconfig
)
552 struct snd_soc_dapm_path
*p
;
553 struct snd_soc_dapm_widget
*sink
= NULL
, *next_sink
= NULL
;
554 struct skl_module_cfg
*sink_mconfig
;
555 struct skl_sst
*ctx
= skl
->skl_sst
;
558 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
562 dev_dbg(ctx
->dev
, "%s: src widget=%s\n", __func__
, w
->name
);
563 dev_dbg(ctx
->dev
, "%s: sink widget=%s\n", __func__
, p
->sink
->name
);
567 * here we will check widgets in sink pipelines, so that
568 * can be any widgets type and we are only interested if
569 * they are ones used for SKL so check that first
571 if ((p
->sink
->priv
!= NULL
) &&
572 is_skl_dsp_widget_type(p
->sink
)) {
575 sink_mconfig
= sink
->priv
;
577 /* Bind source to sink, mixin is always source */
578 ret
= skl_bind_modules(ctx
, src_mconfig
, sink_mconfig
);
582 /* Start sinks pipe first */
583 if (sink_mconfig
->pipe
->state
!= SKL_PIPE_STARTED
) {
584 if (sink_mconfig
->pipe
->conn_type
!=
585 SKL_PIPE_CONN_TYPE_FE
)
586 ret
= skl_run_pipe(ctx
,
595 return skl_tplg_bind_sinks(next_sink
, skl
, src_mconfig
);
601 * A PGA represents a module in a pipeline. So in the Pre-PMU event of PGA
602 * we need to do following:
603 * - Bind to sink pipeline
604 * Since the sink pipes can be running and we don't get mixer event on
605 * connect for already running mixer, we need to find the sink pipes
606 * here and bind to them. This way dynamic connect works.
607 * - Start sink pipeline, if not running
608 * - Then run current pipe
610 static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget
*w
,
613 struct skl_module_cfg
*src_mconfig
;
614 struct skl_sst
*ctx
= skl
->skl_sst
;
617 src_mconfig
= w
->priv
;
620 * find which sink it is connected to, bind with the sink,
621 * if sink is not started, start sink pipe first, then start
624 ret
= skl_tplg_bind_sinks(w
, skl
, src_mconfig
);
628 /* Start source pipe last after starting all sinks */
629 if (src_mconfig
->pipe
->conn_type
!= SKL_PIPE_CONN_TYPE_FE
)
630 return skl_run_pipe(ctx
, src_mconfig
->pipe
);
635 static struct snd_soc_dapm_widget
*skl_get_src_dsp_widget(
636 struct snd_soc_dapm_widget
*w
, struct skl
*skl
)
638 struct snd_soc_dapm_path
*p
;
639 struct snd_soc_dapm_widget
*src_w
= NULL
;
640 struct skl_sst
*ctx
= skl
->skl_sst
;
642 snd_soc_dapm_widget_for_each_source_path(w
, p
) {
647 dev_dbg(ctx
->dev
, "sink widget=%s\n", w
->name
);
648 dev_dbg(ctx
->dev
, "src widget=%s\n", p
->source
->name
);
651 * here we will check widgets in sink pipelines, so that can
652 * be any widgets type and we are only interested if they are
653 * ones used for SKL so check that first
655 if ((p
->source
->priv
!= NULL
) &&
656 is_skl_dsp_widget_type(p
->source
)) {
662 return skl_get_src_dsp_widget(src_w
, skl
);
668 * in the Post-PMU event of mixer we need to do following:
669 * - Check if this pipe is running
671 * - bind this pipeline to its source pipeline
672 * if source pipe is already running, this means it is a dynamic
673 * connection and we need to bind only to that pipe
674 * - start this pipeline
676 static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget
*w
,
680 struct snd_soc_dapm_widget
*source
, *sink
;
681 struct skl_module_cfg
*src_mconfig
, *sink_mconfig
;
682 struct skl_sst
*ctx
= skl
->skl_sst
;
683 int src_pipe_started
= 0;
686 sink_mconfig
= sink
->priv
;
689 * If source pipe is already started, that means source is driving
690 * one more sink before this sink got connected, Since source is
691 * started, bind this sink to source and start this pipe.
693 source
= skl_get_src_dsp_widget(w
, skl
);
694 if (source
!= NULL
) {
695 src_mconfig
= source
->priv
;
696 sink_mconfig
= sink
->priv
;
697 src_pipe_started
= 1;
700 * check pipe state, then no need to bind or start the
703 if (src_mconfig
->pipe
->state
!= SKL_PIPE_STARTED
)
704 src_pipe_started
= 0;
707 if (src_pipe_started
) {
708 ret
= skl_bind_modules(ctx
, src_mconfig
, sink_mconfig
);
712 if (sink_mconfig
->pipe
->conn_type
!= SKL_PIPE_CONN_TYPE_FE
)
713 ret
= skl_run_pipe(ctx
, sink_mconfig
->pipe
);
720 * in the Pre-PMD event of mixer we need to do following:
722 * - find the source connections and remove that from dapm_path_list
723 * - unbind with source pipelines if still connected
725 static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget
*w
,
728 struct skl_module_cfg
*src_mconfig
, *sink_mconfig
;
730 struct skl_sst
*ctx
= skl
->skl_sst
;
732 sink_mconfig
= w
->priv
;
735 ret
= skl_stop_pipe(ctx
, sink_mconfig
->pipe
);
739 for (i
= 0; i
< sink_mconfig
->max_in_queue
; i
++) {
740 if (sink_mconfig
->m_in_pin
[i
].pin_state
== SKL_PIN_BIND_DONE
) {
741 src_mconfig
= sink_mconfig
->m_in_pin
[i
].tgt_mcfg
;
745 * If path_found == 1, that means pmd for source
746 * pipe has not occurred, source is connected to
747 * some other sink. so its responsibility of sink
748 * to unbind itself from source.
750 ret
= skl_stop_pipe(ctx
, src_mconfig
->pipe
);
754 ret
= skl_unbind_modules(ctx
,
755 src_mconfig
, sink_mconfig
);
763 * in the Post-PMD event of mixer we need to do following:
764 * - Free the mcps used
765 * - Free the mem used
766 * - Unbind the modules within the pipeline
767 * - Delete the pipeline (modules are not required to be explicitly
768 * deleted, pipeline delete is enough here
770 static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget
*w
,
773 struct skl_module_cfg
*mconfig
= w
->priv
;
774 struct skl_pipe_module
*w_module
;
775 struct skl_module_cfg
*src_module
= NULL
, *dst_module
;
776 struct skl_sst
*ctx
= skl
->skl_sst
;
777 struct skl_pipe
*s_pipe
= mconfig
->pipe
;
780 skl_tplg_free_pipe_mcps(skl
, mconfig
);
781 skl_tplg_free_pipe_mem(skl
, mconfig
);
783 list_for_each_entry(w_module
, &s_pipe
->w_list
, node
) {
784 dst_module
= w_module
->w
->priv
;
786 skl_tplg_free_pipe_mcps(skl
, dst_module
);
787 if (src_module
== NULL
) {
788 src_module
= dst_module
;
792 skl_unbind_modules(ctx
, src_module
, dst_module
);
793 src_module
= dst_module
;
796 ret
= skl_delete_pipe(ctx
, mconfig
->pipe
);
798 return skl_tplg_unload_pipe_modules(ctx
, s_pipe
);
802 * in the Post-PMD event of PGA we need to do following:
803 * - Free the mcps used
804 * - Stop the pipeline
805 * - In source pipe is connected, unbind with source pipelines
807 static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget
*w
,
810 struct skl_module_cfg
*src_mconfig
, *sink_mconfig
;
812 struct skl_sst
*ctx
= skl
->skl_sst
;
814 src_mconfig
= w
->priv
;
816 /* Stop the pipe since this is a mixin module */
817 ret
= skl_stop_pipe(ctx
, src_mconfig
->pipe
);
821 for (i
= 0; i
< src_mconfig
->max_out_queue
; i
++) {
822 if (src_mconfig
->m_out_pin
[i
].pin_state
== SKL_PIN_BIND_DONE
) {
823 sink_mconfig
= src_mconfig
->m_out_pin
[i
].tgt_mcfg
;
827 * This is a connecter and if path is found that means
828 * unbind between source and sink has not happened yet
830 ret
= skl_unbind_modules(ctx
, src_mconfig
,
839 * In modelling, we assume there will be ONLY one mixer in a pipeline. If
840 * mixer is not required then it is treated as static mixer aka vmixer with
841 * a hard path to source module
842 * So we don't need to check if source is started or not as hard path puts
843 * dependency on each other
845 static int skl_tplg_vmixer_event(struct snd_soc_dapm_widget
*w
,
846 struct snd_kcontrol
*k
, int event
)
848 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
849 struct skl
*skl
= get_skl_ctx(dapm
->dev
);
852 case SND_SOC_DAPM_PRE_PMU
:
853 return skl_tplg_mixer_dapm_pre_pmu_event(w
, skl
);
855 case SND_SOC_DAPM_POST_PMD
:
856 return skl_tplg_mixer_dapm_post_pmd_event(w
, skl
);
863 * In modelling, we assume there will be ONLY one mixer in a pipeline. If a
864 * second one is required that is created as another pipe entity.
865 * The mixer is responsible for pipe management and represent a pipeline
868 static int skl_tplg_mixer_event(struct snd_soc_dapm_widget
*w
,
869 struct snd_kcontrol
*k
, int event
)
871 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
872 struct skl
*skl
= get_skl_ctx(dapm
->dev
);
875 case SND_SOC_DAPM_PRE_PMU
:
876 return skl_tplg_mixer_dapm_pre_pmu_event(w
, skl
);
878 case SND_SOC_DAPM_POST_PMU
:
879 return skl_tplg_mixer_dapm_post_pmu_event(w
, skl
);
881 case SND_SOC_DAPM_PRE_PMD
:
882 return skl_tplg_mixer_dapm_pre_pmd_event(w
, skl
);
884 case SND_SOC_DAPM_POST_PMD
:
885 return skl_tplg_mixer_dapm_post_pmd_event(w
, skl
);
892 * In modelling, we assumed rest of the modules in pipeline are PGA. But we
893 * are interested in last PGA (leaf PGA) in a pipeline to disconnect with
894 * the sink when it is running (two FE to one BE or one FE to two BE)
897 static int skl_tplg_pga_event(struct snd_soc_dapm_widget
*w
,
898 struct snd_kcontrol
*k
, int event
)
901 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
902 struct skl
*skl
= get_skl_ctx(dapm
->dev
);
905 case SND_SOC_DAPM_PRE_PMU
:
906 return skl_tplg_pga_dapm_pre_pmu_event(w
, skl
);
908 case SND_SOC_DAPM_POST_PMD
:
909 return skl_tplg_pga_dapm_post_pmd_event(w
, skl
);
915 static int skl_tplg_tlv_control_get(struct snd_kcontrol
*kcontrol
,
916 unsigned int __user
*data
, unsigned int size
)
918 struct soc_bytes_ext
*sb
=
919 (struct soc_bytes_ext
*)kcontrol
->private_value
;
920 struct skl_algo_data
*bc
= (struct skl_algo_data
*)sb
->dobj
.private;
921 struct snd_soc_dapm_widget
*w
= snd_soc_dapm_kcontrol_widget(kcontrol
);
922 struct skl_module_cfg
*mconfig
= w
->priv
;
923 struct skl
*skl
= get_skl_ctx(w
->dapm
->dev
);
926 skl_get_module_params(skl
->skl_sst
, (u32
*)bc
->params
,
927 bc
->max
, bc
->param_id
, mconfig
);
929 /* decrement size for TLV header */
930 size
-= 2 * sizeof(u32
);
932 /* check size as we don't want to send kernel data */
937 if (copy_to_user(data
, &bc
->param_id
, sizeof(u32
)))
939 if (copy_to_user(data
+ 1, &size
, sizeof(u32
)))
941 if (copy_to_user(data
+ 2, bc
->params
, size
))
948 #define SKL_PARAM_VENDOR_ID 0xff
950 static int skl_tplg_tlv_control_set(struct snd_kcontrol
*kcontrol
,
951 const unsigned int __user
*data
, unsigned int size
)
953 struct snd_soc_dapm_widget
*w
= snd_soc_dapm_kcontrol_widget(kcontrol
);
954 struct skl_module_cfg
*mconfig
= w
->priv
;
955 struct soc_bytes_ext
*sb
=
956 (struct soc_bytes_ext
*)kcontrol
->private_value
;
957 struct skl_algo_data
*ac
= (struct skl_algo_data
*)sb
->dobj
.private;
958 struct skl
*skl
= get_skl_ctx(w
->dapm
->dev
);
962 * if the param_is is of type Vendor, firmware expects actual
963 * parameter id and size from the control.
965 if (ac
->param_id
== SKL_PARAM_VENDOR_ID
) {
966 if (copy_from_user(ac
->params
, data
, size
))
969 if (copy_from_user(ac
->params
,
970 data
+ 2 * sizeof(u32
), size
))
975 return skl_set_module_params(skl
->skl_sst
,
976 (u32
*)ac
->params
, ac
->max
,
977 ac
->param_id
, mconfig
);
984 * The FE params are passed by hw_params of the DAI.
985 * On hw_params, the params are stored in Gateway module of the FE and we
986 * need to calculate the format in DSP module configuration, that
987 * conversion is done here
989 int skl_tplg_update_pipe_params(struct device
*dev
,
990 struct skl_module_cfg
*mconfig
,
991 struct skl_pipe_params
*params
)
993 struct skl_pipe
*pipe
= mconfig
->pipe
;
994 struct skl_module_fmt
*format
= NULL
;
996 memcpy(pipe
->p_params
, params
, sizeof(*params
));
998 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
999 format
= &mconfig
->in_fmt
[0];
1001 format
= &mconfig
->out_fmt
[0];
1003 /* set the hw_params */
1004 format
->s_freq
= params
->s_freq
;
1005 format
->channels
= params
->ch
;
1006 format
->valid_bit_depth
= skl_get_bit_depth(params
->s_fmt
);
1009 * 16 bit is 16 bit container whereas 24 bit is in 32 bit
1010 * container so update bit depth accordingly
1012 switch (format
->valid_bit_depth
) {
1013 case SKL_DEPTH_16BIT
:
1014 format
->bit_depth
= format
->valid_bit_depth
;
1017 case SKL_DEPTH_24BIT
:
1018 case SKL_DEPTH_32BIT
:
1019 format
->bit_depth
= SKL_DEPTH_32BIT
;
1023 dev_err(dev
, "Invalid bit depth %x for pipe\n",
1024 format
->valid_bit_depth
);
1028 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1029 mconfig
->ibs
= (format
->s_freq
/ 1000) *
1030 (format
->channels
) *
1031 (format
->bit_depth
>> 3);
1033 mconfig
->obs
= (format
->s_freq
/ 1000) *
1034 (format
->channels
) *
1035 (format
->bit_depth
>> 3);
1042 * Query the module config for the FE DAI
1043 * This is used to find the hw_params set for that DAI and apply to FE
1046 struct skl_module_cfg
*
1047 skl_tplg_fe_get_cpr_module(struct snd_soc_dai
*dai
, int stream
)
1049 struct snd_soc_dapm_widget
*w
;
1050 struct snd_soc_dapm_path
*p
= NULL
;
1052 if (stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1053 w
= dai
->playback_widget
;
1054 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
1055 if (p
->connect
&& p
->sink
->power
&&
1056 !is_skl_dsp_widget_type(p
->sink
))
1059 if (p
->sink
->priv
) {
1060 dev_dbg(dai
->dev
, "set params for %s\n",
1062 return p
->sink
->priv
;
1066 w
= dai
->capture_widget
;
1067 snd_soc_dapm_widget_for_each_source_path(w
, p
) {
1068 if (p
->connect
&& p
->source
->power
&&
1069 !is_skl_dsp_widget_type(p
->source
))
1072 if (p
->source
->priv
) {
1073 dev_dbg(dai
->dev
, "set params for %s\n",
1075 return p
->source
->priv
;
1083 static u8
skl_tplg_be_link_type(int dev_type
)
1089 ret
= NHLT_LINK_SSP
;
1092 case SKL_DEVICE_DMIC
:
1093 ret
= NHLT_LINK_DMIC
;
1096 case SKL_DEVICE_I2S
:
1097 ret
= NHLT_LINK_SSP
;
1100 case SKL_DEVICE_HDALINK
:
1101 ret
= NHLT_LINK_HDA
;
1105 ret
= NHLT_LINK_INVALID
;
1113 * Fill the BE gateway parameters
1114 * The BE gateway expects a blob of parameters which are kept in the ACPI
1115 * NHLT blob, so query the blob for interface type (i2s/pdm) and instance.
1116 * The port can have multiple settings so pick based on the PCM
1119 static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai
*dai
,
1120 struct skl_module_cfg
*mconfig
,
1121 struct skl_pipe_params
*params
)
1123 struct skl_pipe
*pipe
= mconfig
->pipe
;
1124 struct nhlt_specific_cfg
*cfg
;
1125 struct skl
*skl
= get_skl_ctx(dai
->dev
);
1126 int link_type
= skl_tplg_be_link_type(mconfig
->dev_type
);
1128 memcpy(pipe
->p_params
, params
, sizeof(*params
));
1130 if (link_type
== NHLT_LINK_HDA
)
1133 /* update the blob based on virtual bus_id*/
1134 cfg
= skl_get_ep_blob(skl
, mconfig
->vbus_id
, link_type
,
1135 params
->s_fmt
, params
->ch
,
1136 params
->s_freq
, params
->stream
);
1138 mconfig
->formats_config
.caps_size
= cfg
->size
;
1139 mconfig
->formats_config
.caps
= (u32
*) &cfg
->caps
;
1141 dev_err(dai
->dev
, "Blob NULL for id %x type %d dirn %d\n",
1142 mconfig
->vbus_id
, link_type
,
1144 dev_err(dai
->dev
, "PCM: ch %d, freq %d, fmt %d\n",
1145 params
->ch
, params
->s_freq
, params
->s_fmt
);
1152 static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai
*dai
,
1153 struct snd_soc_dapm_widget
*w
,
1154 struct skl_pipe_params
*params
)
1156 struct snd_soc_dapm_path
*p
;
1159 snd_soc_dapm_widget_for_each_source_path(w
, p
) {
1160 if (p
->connect
&& is_skl_dsp_widget_type(p
->source
) &&
1163 ret
= skl_tplg_be_fill_pipe_params(dai
,
1164 p
->source
->priv
, params
);
1168 ret
= skl_tplg_be_set_src_pipe_params(dai
,
1178 static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai
*dai
,
1179 struct snd_soc_dapm_widget
*w
, struct skl_pipe_params
*params
)
1181 struct snd_soc_dapm_path
*p
= NULL
;
1184 snd_soc_dapm_widget_for_each_sink_path(w
, p
) {
1185 if (p
->connect
&& is_skl_dsp_widget_type(p
->sink
) &&
1188 ret
= skl_tplg_be_fill_pipe_params(dai
,
1189 p
->sink
->priv
, params
);
1193 ret
= skl_tplg_be_set_sink_pipe_params(
1194 dai
, p
->sink
, params
);
1204 * BE hw_params can be a source parameters (capture) or sink parameters
1205 * (playback). Based on sink and source we need to either find the source
1206 * list or the sink list and set the pipeline parameters
1208 int skl_tplg_be_update_params(struct snd_soc_dai
*dai
,
1209 struct skl_pipe_params
*params
)
1211 struct snd_soc_dapm_widget
*w
;
1213 if (params
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1214 w
= dai
->playback_widget
;
1216 return skl_tplg_be_set_src_pipe_params(dai
, w
, params
);
1219 w
= dai
->capture_widget
;
1221 return skl_tplg_be_set_sink_pipe_params(dai
, w
, params
);
1227 static const struct snd_soc_tplg_widget_events skl_tplg_widget_ops
[] = {
1228 {SKL_MIXER_EVENT
, skl_tplg_mixer_event
},
1229 {SKL_VMIXER_EVENT
, skl_tplg_vmixer_event
},
1230 {SKL_PGA_EVENT
, skl_tplg_pga_event
},
1233 static const struct snd_soc_tplg_bytes_ext_ops skl_tlv_ops
[] = {
1234 {SKL_CONTROL_TYPE_BYTE_TLV
, skl_tplg_tlv_control_get
,
1235 skl_tplg_tlv_control_set
},
1239 * The topology binary passes the pin info for a module so initialize the pin
1240 * info passed into module instance
1242 static void skl_fill_module_pin_info(struct skl_dfw_module_pin
*dfw_pin
,
1243 struct skl_module_pin
*m_pin
,
1244 bool is_dynamic
, int max_pin
)
1248 for (i
= 0; i
< max_pin
; i
++) {
1249 m_pin
[i
].id
.module_id
= dfw_pin
[i
].module_id
;
1250 m_pin
[i
].id
.instance_id
= dfw_pin
[i
].instance_id
;
1251 m_pin
[i
].in_use
= false;
1252 m_pin
[i
].is_dynamic
= is_dynamic
;
1253 m_pin
[i
].pin_state
= SKL_PIN_UNBIND
;
1258 * Add pipeline from topology binary into driver pipeline list
1260 * If already added we return that instance
1261 * Otherwise we create a new instance and add into driver list
1263 static struct skl_pipe
*skl_tplg_add_pipe(struct device
*dev
,
1264 struct skl
*skl
, struct skl_dfw_pipe
*dfw_pipe
)
1266 struct skl_pipeline
*ppl
;
1267 struct skl_pipe
*pipe
;
1268 struct skl_pipe_params
*params
;
1270 list_for_each_entry(ppl
, &skl
->ppl_list
, node
) {
1271 if (ppl
->pipe
->ppl_id
== dfw_pipe
->pipe_id
)
1275 ppl
= devm_kzalloc(dev
, sizeof(*ppl
), GFP_KERNEL
);
1279 pipe
= devm_kzalloc(dev
, sizeof(*pipe
), GFP_KERNEL
);
1283 params
= devm_kzalloc(dev
, sizeof(*params
), GFP_KERNEL
);
1287 pipe
->ppl_id
= dfw_pipe
->pipe_id
;
1288 pipe
->memory_pages
= dfw_pipe
->memory_pages
;
1289 pipe
->pipe_priority
= dfw_pipe
->pipe_priority
;
1290 pipe
->conn_type
= dfw_pipe
->conn_type
;
1291 pipe
->state
= SKL_PIPE_INVALID
;
1292 pipe
->p_params
= params
;
1293 INIT_LIST_HEAD(&pipe
->w_list
);
1296 list_add(&ppl
->node
, &skl
->ppl_list
);
1301 static void skl_tplg_fill_fmt(struct skl_module_fmt
*dst_fmt
,
1302 struct skl_dfw_module_fmt
*src_fmt
,
1307 for (i
= 0; i
< pins
; i
++) {
1308 dst_fmt
[i
].channels
= src_fmt
[i
].channels
;
1309 dst_fmt
[i
].s_freq
= src_fmt
[i
].freq
;
1310 dst_fmt
[i
].bit_depth
= src_fmt
[i
].bit_depth
;
1311 dst_fmt
[i
].valid_bit_depth
= src_fmt
[i
].valid_bit_depth
;
1312 dst_fmt
[i
].ch_cfg
= src_fmt
[i
].ch_cfg
;
1313 dst_fmt
[i
].ch_map
= src_fmt
[i
].ch_map
;
1314 dst_fmt
[i
].interleaving_style
= src_fmt
[i
].interleaving_style
;
1315 dst_fmt
[i
].sample_type
= src_fmt
[i
].sample_type
;
1320 * Topology core widget load callback
1322 * This is used to save the private data for each widget which gives
1323 * information to the driver about module and pipeline parameters which DSP
1324 * FW expects like ids, resource values, formats etc
1326 static int skl_tplg_widget_load(struct snd_soc_component
*cmpnt
,
1327 struct snd_soc_dapm_widget
*w
,
1328 struct snd_soc_tplg_dapm_widget
*tplg_w
)
1331 struct hdac_ext_bus
*ebus
= snd_soc_component_get_drvdata(cmpnt
);
1332 struct skl
*skl
= ebus_to_skl(ebus
);
1333 struct hdac_bus
*bus
= ebus_to_hbus(ebus
);
1334 struct skl_module_cfg
*mconfig
;
1335 struct skl_pipe
*pipe
;
1336 struct skl_dfw_module
*dfw_config
=
1337 (struct skl_dfw_module
*)tplg_w
->priv
.data
;
1339 if (!tplg_w
->priv
.size
)
1342 mconfig
= devm_kzalloc(bus
->dev
, sizeof(*mconfig
), GFP_KERNEL
);
1348 mconfig
->id
.module_id
= dfw_config
->module_id
;
1349 mconfig
->id
.instance_id
= dfw_config
->instance_id
;
1350 mconfig
->mcps
= dfw_config
->max_mcps
;
1351 mconfig
->ibs
= dfw_config
->ibs
;
1352 mconfig
->obs
= dfw_config
->obs
;
1353 mconfig
->core_id
= dfw_config
->core_id
;
1354 mconfig
->max_in_queue
= dfw_config
->max_in_queue
;
1355 mconfig
->max_out_queue
= dfw_config
->max_out_queue
;
1356 mconfig
->is_loadable
= dfw_config
->is_loadable
;
1357 skl_tplg_fill_fmt(mconfig
->in_fmt
, dfw_config
->in_fmt
,
1358 MODULE_MAX_IN_PINS
);
1359 skl_tplg_fill_fmt(mconfig
->out_fmt
, dfw_config
->out_fmt
,
1360 MODULE_MAX_OUT_PINS
);
1362 mconfig
->params_fixup
= dfw_config
->params_fixup
;
1363 mconfig
->converter
= dfw_config
->converter
;
1364 mconfig
->m_type
= dfw_config
->module_type
;
1365 mconfig
->vbus_id
= dfw_config
->vbus_id
;
1366 mconfig
->mem_pages
= dfw_config
->mem_pages
;
1368 pipe
= skl_tplg_add_pipe(bus
->dev
, skl
, &dfw_config
->pipe
);
1370 mconfig
->pipe
= pipe
;
1372 mconfig
->dev_type
= dfw_config
->dev_type
;
1373 mconfig
->hw_conn_type
= dfw_config
->hw_conn_type
;
1374 mconfig
->time_slot
= dfw_config
->time_slot
;
1375 mconfig
->formats_config
.caps_size
= dfw_config
->caps
.caps_size
;
1377 if (dfw_config
->is_loadable
)
1378 memcpy(mconfig
->guid
, dfw_config
->uuid
,
1379 ARRAY_SIZE(dfw_config
->uuid
));
1381 mconfig
->m_in_pin
= devm_kzalloc(bus
->dev
, (mconfig
->max_in_queue
) *
1382 sizeof(*mconfig
->m_in_pin
),
1384 if (!mconfig
->m_in_pin
)
1387 mconfig
->m_out_pin
= devm_kzalloc(bus
->dev
, (mconfig
->max_out_queue
) *
1388 sizeof(*mconfig
->m_out_pin
),
1390 if (!mconfig
->m_out_pin
)
1393 skl_fill_module_pin_info(dfw_config
->in_pin
, mconfig
->m_in_pin
,
1394 dfw_config
->is_dynamic_in_pin
,
1395 mconfig
->max_in_queue
);
1397 skl_fill_module_pin_info(dfw_config
->out_pin
, mconfig
->m_out_pin
,
1398 dfw_config
->is_dynamic_out_pin
,
1399 mconfig
->max_out_queue
);
1402 if (mconfig
->formats_config
.caps_size
== 0)
1405 mconfig
->formats_config
.caps
= (u32
*)devm_kzalloc(bus
->dev
,
1406 mconfig
->formats_config
.caps_size
, GFP_KERNEL
);
1408 if (mconfig
->formats_config
.caps
== NULL
)
1411 memcpy(mconfig
->formats_config
.caps
, dfw_config
->caps
.caps
,
1412 dfw_config
->caps
.caps_size
);
1413 mconfig
->formats_config
.param_id
= dfw_config
->caps
.param_id
;
1414 mconfig
->formats_config
.set_params
= dfw_config
->caps
.set_params
;
1417 if (tplg_w
->event_type
== 0) {
1418 dev_dbg(bus
->dev
, "ASoC: No event handler required\n");
1422 ret
= snd_soc_tplg_widget_bind_event(w
, skl_tplg_widget_ops
,
1423 ARRAY_SIZE(skl_tplg_widget_ops
),
1424 tplg_w
->event_type
);
1427 dev_err(bus
->dev
, "%s: No matching event handlers found for %d\n",
1428 __func__
, tplg_w
->event_type
);
1435 static int skl_init_algo_data(struct device
*dev
, struct soc_bytes_ext
*be
,
1436 struct snd_soc_tplg_bytes_control
*bc
)
1438 struct skl_algo_data
*ac
;
1439 struct skl_dfw_algo_data
*dfw_ac
=
1440 (struct skl_dfw_algo_data
*)bc
->priv
.data
;
1442 ac
= devm_kzalloc(dev
, sizeof(*ac
), GFP_KERNEL
);
1446 /* Fill private data */
1447 ac
->max
= dfw_ac
->max
;
1448 ac
->param_id
= dfw_ac
->param_id
;
1449 ac
->set_params
= dfw_ac
->set_params
;
1452 ac
->params
= (char *) devm_kzalloc(dev
, ac
->max
, GFP_KERNEL
);
1457 memcpy(ac
->params
, dfw_ac
->params
, ac
->max
);
1460 be
->dobj
.private = ac
;
1464 static int skl_tplg_control_load(struct snd_soc_component
*cmpnt
,
1465 struct snd_kcontrol_new
*kctl
,
1466 struct snd_soc_tplg_ctl_hdr
*hdr
)
1468 struct soc_bytes_ext
*sb
;
1469 struct snd_soc_tplg_bytes_control
*tplg_bc
;
1470 struct hdac_ext_bus
*ebus
= snd_soc_component_get_drvdata(cmpnt
);
1471 struct hdac_bus
*bus
= ebus_to_hbus(ebus
);
1473 switch (hdr
->ops
.info
) {
1474 case SND_SOC_TPLG_CTL_BYTES
:
1475 tplg_bc
= container_of(hdr
,
1476 struct snd_soc_tplg_bytes_control
, hdr
);
1477 if (kctl
->access
& SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
) {
1478 sb
= (struct soc_bytes_ext
*)kctl
->private_value
;
1479 if (tplg_bc
->priv
.size
)
1480 return skl_init_algo_data(
1481 bus
->dev
, sb
, tplg_bc
);
1486 dev_warn(bus
->dev
, "Control load not supported %d:%d:%d\n",
1487 hdr
->ops
.get
, hdr
->ops
.put
, hdr
->ops
.info
);
1494 static struct snd_soc_tplg_ops skl_tplg_ops
= {
1495 .widget_load
= skl_tplg_widget_load
,
1496 .control_load
= skl_tplg_control_load
,
1497 .bytes_ext_ops
= skl_tlv_ops
,
1498 .bytes_ext_ops_count
= ARRAY_SIZE(skl_tlv_ops
),
1501 /* This will be read from topology manifest, currently defined here */
1502 #define SKL_MAX_MCPS 30000000
1503 #define SKL_FW_MAX_MEM 1000000
1506 * SKL topology init routine
1508 int skl_tplg_init(struct snd_soc_platform
*platform
, struct hdac_ext_bus
*ebus
)
1511 const struct firmware
*fw
;
1512 struct hdac_bus
*bus
= ebus_to_hbus(ebus
);
1513 struct skl
*skl
= ebus_to_skl(ebus
);
1515 ret
= request_firmware(&fw
, "dfw_sst.bin", bus
->dev
);
1517 dev_err(bus
->dev
, "tplg fw %s load failed with %d\n",
1518 "dfw_sst.bin", ret
);
1523 * The complete tplg for SKL is loaded as index 0, we don't use
1526 ret
= snd_soc_tplg_component_load(&platform
->component
,
1527 &skl_tplg_ops
, fw
, 0);
1528 release_firmware(fw
);
1530 dev_err(bus
->dev
, "tplg component load failed%d\n", ret
);
1531 release_firmware(fw
);
1535 skl
->resource
.max_mcps
= SKL_MAX_MCPS
;
1536 skl
->resource
.max_mem
= SKL_FW_MAX_MEM
;