aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeeja KP <jeeja.kp@intel.com>2015-11-28 04:31:49 -0500
committerMark Brown <broonie@kernel.org>2015-12-01 17:17:00 -0500
commitabb740033b56a2f57582e8e26bb9ea3650b6a3cc (patch)
tree7c16babc93c2a43f45f15d6c8e5f6bc65f4cda94
parent399b210bef097ce01d9e7b03ce5d4435f0624111 (diff)
ASoC: Intel: Skylake: Add support to configure module params
This adds support to configure module parameter during module initialization or after module init using set module param required by the DSP firmware sequence. Signed-off-by: Jeeja KP <jeeja.kp@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/intel/skylake/skl-topology.c87
-rw-r--r--sound/soc/intel/skylake/skl-topology.h9
2 files changed, 95 insertions, 1 deletions
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 7a03bea48a9a..bfc138df56bc 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -314,6 +314,83 @@ static int skl_tplg_alloc_pipe_widget(struct device *dev,
314} 314}
315 315
316/* 316/*
317 * some modules can have multiple params set from user control and
318 * need to be set after module is initialized. If set_param flag is
319 * set module params will be done after module is initialised.
320 */
321static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w,
322 struct skl_sst *ctx)
323{
324 int i, ret;
325 struct skl_module_cfg *mconfig = w->priv;
326 const struct snd_kcontrol_new *k;
327 struct soc_bytes_ext *sb;
328 struct skl_algo_data *bc;
329 struct skl_specific_cfg *sp_cfg;
330
331 if (mconfig->formats_config.caps_size > 0 &&
332 mconfig->formats_config.set_params) {
333 sp_cfg = &mconfig->formats_config;
334 ret = skl_set_module_params(ctx, sp_cfg->caps,
335 sp_cfg->caps_size,
336 sp_cfg->param_id, mconfig);
337 if (ret < 0)
338 return ret;
339 }
340
341 for (i = 0; i < w->num_kcontrols; i++) {
342 k = &w->kcontrol_news[i];
343 if (k->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
344 sb = (void *) k->private_value;
345 bc = (struct skl_algo_data *)sb->dobj.private;
346
347 if (bc->set_params) {
348 ret = skl_set_module_params(ctx,
349 (u32 *)bc->params, bc->max,
350 bc->param_id, mconfig);
351 if (ret < 0)
352 return ret;
353 }
354 }
355 }
356
357 return 0;
358}
359
360/*
361 * some module param can set from user control and this is required as
362 * when module is initailzed. if module param is required in init it is
363 * identifed by set_param flag. if set_param flag is not set, then this
364 * parameter needs to set as part of module init.
365 */
366static int skl_tplg_set_module_init_data(struct snd_soc_dapm_widget *w)
367{
368 const struct snd_kcontrol_new *k;
369 struct soc_bytes_ext *sb;
370 struct skl_algo_data *bc;
371 struct skl_module_cfg *mconfig = w->priv;
372 int i;
373
374 for (i = 0; i < w->num_kcontrols; i++) {
375 k = &w->kcontrol_news[i];
376 if (k->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
377 sb = (struct soc_bytes_ext *)k->private_value;
378 bc = (struct skl_algo_data *)sb->dobj.private;
379
380 if (bc->set_params)
381 continue;
382
383 mconfig->formats_config.caps = (u32 *)&bc->params;
384 mconfig->formats_config.caps_size = bc->max;
385
386 break;
387 }
388 }
389
390 return 0;
391}
392
393/*
317 * Inside a pipe instance, we can have various modules. These modules need 394 * Inside a pipe instance, we can have various modules. These modules need
318 * to instantiated in DSP by invoking INIT_MODULE IPC, which is achieved by 395 * to instantiated in DSP by invoking INIT_MODULE IPC, which is achieved by
319 * skl_init_module() routine, so invoke that for all modules in a pipeline 396 * skl_init_module() routine, so invoke that for all modules in a pipeline
@@ -340,9 +417,15 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
340 * FE/BE params 417 * FE/BE params
341 */ 418 */
342 skl_tplg_update_module_params(w, ctx); 419 skl_tplg_update_module_params(w, ctx);
420
421 skl_tplg_set_module_init_data(w);
343 ret = skl_init_module(ctx, mconfig); 422 ret = skl_init_module(ctx, mconfig);
344 if (ret < 0) 423 if (ret < 0)
345 return ret; 424 return ret;
425
426 ret = skl_tplg_set_module_params(w, ctx);
427 if (ret < 0)
428 return ret;
346 } 429 }
347 430
348 return 0; 431 return 0;
@@ -1215,7 +1298,9 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,
1215 return -ENOMEM; 1298 return -ENOMEM;
1216 1299
1217 memcpy(mconfig->formats_config.caps, dfw_config->caps.caps, 1300 memcpy(mconfig->formats_config.caps, dfw_config->caps.caps,
1218 dfw_config->caps.caps_size); 1301 dfw_config->caps.caps_size);
1302 mconfig->formats_config.param_id = dfw_config->caps.param_id;
1303 mconfig->formats_config.set_params = dfw_config->caps.set_params;
1219 1304
1220bind_event: 1305bind_event:
1221 if (tplg_w->event_type == 0) { 1306 if (tplg_w->event_type == 0) {
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index 0a66fab59828..51e785424a37 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -206,6 +206,8 @@ struct skl_module_pin {
206}; 206};
207 207
208struct skl_specific_cfg { 208struct skl_specific_cfg {
209 bool set_params;
210 u32 param_id;
209 u32 caps_size; 211 u32 caps_size;
210 u32 *caps; 212 u32 *caps;
211}; 213};
@@ -284,6 +286,13 @@ struct skl_module_cfg {
284 struct skl_specific_cfg formats_config; 286 struct skl_specific_cfg formats_config;
285}; 287};
286 288
289struct skl_algo_data {
290 u32 param_id;
291 bool set_params;
292 u32 max;
293 char *params;
294};
295
287struct skl_pipeline { 296struct skl_pipeline {
288 struct skl_pipe *pipe; 297 struct skl_pipe *pipe;
289 struct list_head node; 298 struct list_head node;