forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/intel/skylake/skl-messages.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * skl-message.c - HDA DSP interface for FW registration, Pipe and Module
34 * configurations
....@@ -6,15 +7,6 @@
67 * Author:Rafal Redzimski <rafal.f.redzimski@intel.com>
78 * Jeeja KP <jeeja.kp@intel.com>
89 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as version 2, as
12
- * published by the Free Software Foundation.
13
- *
14
- * This program is distributed in the hope that it will be useful, but
15
- * WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * General Public License for more details.
1810 */
1911
2012 #include <linux/slab.h>
....@@ -33,29 +25,18 @@
3325 static int skl_alloc_dma_buf(struct device *dev,
3426 struct snd_dma_buffer *dmab, size_t size)
3527 {
36
- struct hdac_bus *bus = dev_get_drvdata(dev);
37
-
38
- if (!bus)
39
- return -ENODEV;
40
-
41
- return bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV, size, dmab);
28
+ return snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, dmab);
4229 }
4330
4431 static int skl_free_dma_buf(struct device *dev, struct snd_dma_buffer *dmab)
4532 {
46
- struct hdac_bus *bus = dev_get_drvdata(dev);
47
-
48
- if (!bus)
49
- return -ENODEV;
50
-
51
- bus->io_ops->dma_free_pages(bus, dmab);
52
-
33
+ snd_dma_free_pages(dmab);
5334 return 0;
5435 }
5536
5637 #define SKL_ASTATE_PARAM_ID 4
5738
58
-void skl_dsp_set_astate_cfg(struct skl_sst *ctx, u32 cnt, void *data)
39
+void skl_dsp_set_astate_cfg(struct skl_dev *skl, u32 cnt, void *data)
5940 {
6041 struct skl_ipc_large_config_msg msg = {0};
6142
....@@ -63,25 +44,7 @@
6344 msg.param_data_size = (cnt * sizeof(struct skl_astate_param) +
6445 sizeof(cnt));
6546
66
- skl_ipc_set_large_config(&ctx->ipc, &msg, data);
67
-}
68
-
69
-#define NOTIFICATION_PARAM_ID 3
70
-#define NOTIFICATION_MASK 0xf
71
-
72
-/* disable notfication for underruns/overruns from firmware module */
73
-void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable)
74
-{
75
- struct notification_mask mask;
76
- struct skl_ipc_large_config_msg msg = {0};
77
-
78
- mask.notify = NOTIFICATION_MASK;
79
- mask.enable = enable;
80
-
81
- msg.large_param_id = NOTIFICATION_PARAM_ID;
82
- msg.param_data_size = sizeof(mask);
83
-
84
- skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)&mask);
47
+ skl_ipc_set_large_config(&skl->ipc, &msg, data);
8548 }
8649
8750 static int skl_dsp_setup_spib(struct device *dev, unsigned int size,
....@@ -247,6 +210,30 @@
247210 .init_fw = cnl_sst_init_fw,
248211 .cleanup = cnl_sst_dsp_cleanup
249212 },
213
+ {
214
+ .id = 0xa348,
215
+ .num_cores = 4,
216
+ .loader_ops = bxt_get_loader_ops,
217
+ .init = cnl_sst_dsp_init,
218
+ .init_fw = cnl_sst_init_fw,
219
+ .cleanup = cnl_sst_dsp_cleanup
220
+ },
221
+ {
222
+ .id = 0x02c8,
223
+ .num_cores = 4,
224
+ .loader_ops = bxt_get_loader_ops,
225
+ .init = cnl_sst_dsp_init,
226
+ .init_fw = cnl_sst_init_fw,
227
+ .cleanup = cnl_sst_dsp_cleanup
228
+ },
229
+ {
230
+ .id = 0x06c8,
231
+ .num_cores = 4,
232
+ .loader_ops = bxt_get_loader_ops,
233
+ .init = cnl_sst_dsp_init,
234
+ .init_fw = cnl_sst_init_fw,
235
+ .cleanup = cnl_sst_dsp_cleanup
236
+ },
250237 };
251238
252239 const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id)
....@@ -261,7 +248,7 @@
261248 return NULL;
262249 }
263250
264
-int skl_init_dsp(struct skl *skl)
251
+int skl_init_dsp(struct skl_dev *skl)
265252 {
266253 void __iomem *mmio_base;
267254 struct hdac_bus *bus = skl_to_bus(skl);
....@@ -291,13 +278,13 @@
291278 loader_ops = ops->loader_ops();
292279 ret = ops->init(bus->dev, mmio_base, irq,
293280 skl->fw_name, loader_ops,
294
- &skl->skl_sst);
281
+ &skl);
295282
296283 if (ret < 0)
297284 goto unmap_mmio;
298285
299
- skl->skl_sst->dsp_ops = ops;
300
- cores = &skl->skl_sst->cores;
286
+ skl->dsp_ops = ops;
287
+ cores = &skl->cores;
301288 cores->count = ops->num_cores;
302289
303290 cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL);
....@@ -326,21 +313,20 @@
326313 return ret;
327314 }
328315
329
-int skl_free_dsp(struct skl *skl)
316
+int skl_free_dsp(struct skl_dev *skl)
330317 {
331318 struct hdac_bus *bus = skl_to_bus(skl);
332
- struct skl_sst *ctx = skl->skl_sst;
333319
334320 /* disable ppcap interrupt */
335321 snd_hdac_ext_bus_ppcap_int_enable(bus, false);
336322
337
- ctx->dsp_ops->cleanup(bus->dev, ctx);
323
+ skl->dsp_ops->cleanup(bus->dev, skl);
338324
339
- kfree(ctx->cores.state);
340
- kfree(ctx->cores.usage_count);
325
+ kfree(skl->cores.state);
326
+ kfree(skl->cores.usage_count);
341327
342
- if (ctx->dsp->addr.lpe)
343
- iounmap(ctx->dsp->addr.lpe);
328
+ if (skl->dsp->addr.lpe)
329
+ iounmap(skl->dsp->addr.lpe);
344330
345331 return 0;
346332 }
....@@ -352,15 +338,14 @@
352338 * mode during system suspend. In the case of normal suspend, cancel
353339 * any pending D0i3 work.
354340 */
355
-int skl_suspend_late_dsp(struct skl *skl)
341
+int skl_suspend_late_dsp(struct skl_dev *skl)
356342 {
357
- struct skl_sst *ctx = skl->skl_sst;
358343 struct delayed_work *dwork;
359344
360
- if (!ctx)
345
+ if (!skl)
361346 return 0;
362347
363
- dwork = &ctx->d0i3.work;
348
+ dwork = &skl->d0i3.work;
364349
365350 if (dwork->work.func) {
366351 if (skl->supend_active)
....@@ -372,9 +357,8 @@
372357 return 0;
373358 }
374359
375
-int skl_suspend_dsp(struct skl *skl)
360
+int skl_suspend_dsp(struct skl_dev *skl)
376361 {
377
- struct skl_sst *ctx = skl->skl_sst;
378362 struct hdac_bus *bus = skl_to_bus(skl);
379363 int ret;
380364
....@@ -382,7 +366,7 @@
382366 if (!bus->ppcap)
383367 return 0;
384368
385
- ret = skl_dsp_sleep(ctx->dsp);
369
+ ret = skl_dsp_sleep(skl->dsp);
386370 if (ret < 0)
387371 return ret;
388372
....@@ -393,9 +377,8 @@
393377 return 0;
394378 }
395379
396
-int skl_resume_dsp(struct skl *skl)
380
+int skl_resume_dsp(struct skl_dev *skl)
397381 {
398
- struct skl_sst *ctx = skl->skl_sst;
399382 struct hdac_bus *bus = skl_to_bus(skl);
400383 int ret;
401384
....@@ -408,26 +391,24 @@
408391 snd_hdac_ext_bus_ppcap_int_enable(bus, true);
409392
410393 /* check if DSP 1st boot is done */
411
- if (skl->skl_sst->is_first_boot == true)
394
+ if (skl->is_first_boot)
412395 return 0;
413396
414397 /*
415398 * Disable dynamic clock and power gating during firmware
416399 * and library download
417400 */
418
- ctx->enable_miscbdcge(ctx->dev, false);
419
- ctx->clock_power_gating(ctx->dev, false);
401
+ skl->enable_miscbdcge(skl->dev, false);
402
+ skl->clock_power_gating(skl->dev, false);
420403
421
- ret = skl_dsp_wake(ctx->dsp);
422
- ctx->enable_miscbdcge(ctx->dev, true);
423
- ctx->clock_power_gating(ctx->dev, true);
404
+ ret = skl_dsp_wake(skl->dsp);
405
+ skl->enable_miscbdcge(skl->dev, true);
406
+ skl->clock_power_gating(skl->dev, true);
424407 if (ret < 0)
425408 return ret;
426409
427
- skl_dsp_enable_notification(skl->skl_sst, false);
428
-
429410 if (skl->cfg.astate_cfg != NULL) {
430
- skl_dsp_set_astate_cfg(skl->skl_sst, skl->cfg.astate_cfg->count,
411
+ skl_dsp_set_astate_cfg(skl, skl->cfg.astate_cfg->count,
431412 skl->cfg.astate_cfg);
432413 }
433414 return ret;
....@@ -460,7 +441,7 @@
460441 * which are read from widget information passed through topology binary
461442 * This is send when we create a module with INIT_INSTANCE IPC msg
462443 */
463
-static void skl_set_base_module_format(struct skl_sst *ctx,
444
+static void skl_set_base_module_format(struct skl_dev *skl,
464445 struct skl_module_cfg *mconfig,
465446 struct skl_base_cfg *base_cfg)
466447 {
....@@ -475,8 +456,9 @@
475456 base_cfg->audio_fmt.bit_depth = format->bit_depth;
476457 base_cfg->audio_fmt.valid_bit_depth = format->valid_bit_depth;
477458 base_cfg->audio_fmt.ch_cfg = format->ch_cfg;
459
+ base_cfg->audio_fmt.sample_type = format->sample_type;
478460
479
- dev_dbg(ctx->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n",
461
+ dev_dbg(skl->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n",
480462 format->bit_depth, format->valid_bit_depth,
481463 format->ch_cfg);
482464
....@@ -484,7 +466,7 @@
484466
485467 base_cfg->audio_fmt.interleaving = format->interleaving_style;
486468
487
- base_cfg->cps = res->cps;
469
+ base_cfg->cpc = res->cpc;
488470 base_cfg->ibs = res->ibs;
489471 base_cfg->obs = res->obs;
490472 base_cfg->is_pages = res->is_pages;
....@@ -513,7 +495,7 @@
513495 * Calculate the gatewat settings required for copier module, type of
514496 * gateway and index of gateway to use
515497 */
516
-static u32 skl_get_node_id(struct skl_sst *ctx,
498
+static u32 skl_get_node_id(struct skl_dev *skl,
517499 struct skl_module_cfg *mconfig)
518500 {
519501 union skl_connector_node_id node_id = {0};
....@@ -570,16 +552,15 @@
570552 return node_id.val;
571553 }
572554
573
-static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx,
555
+static void skl_setup_cpr_gateway_cfg(struct skl_dev *skl,
574556 struct skl_module_cfg *mconfig,
575557 struct skl_cpr_cfg *cpr_mconfig)
576558 {
577559 u32 dma_io_buf;
578560 struct skl_module_res *res;
579561 int res_idx = mconfig->res_idx;
580
- struct skl *skl = get_skl_ctx(ctx->dev);
581562
582
- cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(ctx, mconfig);
563
+ cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(skl, mconfig);
583564
584565 if (cpr_mconfig->gtw_cfg.node_id == SKL_NON_GATEWAY_CPR_NODE_ID) {
585566 cpr_mconfig->cpr_feature_mask = 0;
....@@ -610,7 +591,7 @@
610591 break;
611592
612593 default:
613
- dev_warn(ctx->dev, "wrong connection type: %d\n",
594
+ dev_warn(skl->dev, "wrong connection type: %d\n",
614595 mconfig->hw_conn_type);
615596 return;
616597 }
....@@ -636,7 +617,7 @@
636617 #define DMA_CONTROL_ID 5
637618 #define DMA_I2S_BLOB_SIZE 21
638619
639
-int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps,
620
+int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps,
640621 u32 caps_size, u32 node_id)
641622 {
642623 struct skl_dma_control *dma_ctrl;
....@@ -669,14 +650,14 @@
669650
670651 memcpy(dma_ctrl->config_data, caps, caps_size);
671652
672
- err = skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)dma_ctrl);
653
+ err = skl_ipc_set_large_config(&skl->ipc, &msg, (u32 *)dma_ctrl);
673654
674655 kfree(dma_ctrl);
675656 return err;
676657 }
677658 EXPORT_SYMBOL_GPL(skl_dsp_set_dma_control);
678659
679
-static void skl_setup_out_format(struct skl_sst *ctx,
660
+static void skl_setup_out_format(struct skl_dev *skl,
680661 struct skl_module_cfg *mconfig,
681662 struct skl_audio_data_format *out_fmt)
682663 {
....@@ -694,7 +675,7 @@
694675 out_fmt->interleaving = format->interleaving_style;
695676 out_fmt->sample_type = format->sample_type;
696677
697
- dev_dbg(ctx->dev, "copier out format chan=%d fre=%d bitdepth=%d\n",
678
+ dev_dbg(skl->dev, "copier out format chan=%d fre=%d bitdepth=%d\n",
698679 out_fmt->number_of_channels, format->s_freq, format->bit_depth);
699680 }
700681
....@@ -703,7 +684,7 @@
703684 * configuration and the target frequency as extra parameter passed as src
704685 * config
705686 */
706
-static void skl_set_src_format(struct skl_sst *ctx,
687
+static void skl_set_src_format(struct skl_dev *skl,
707688 struct skl_module_cfg *mconfig,
708689 struct skl_src_module_cfg *src_mconfig)
709690 {
....@@ -711,7 +692,7 @@
711692 struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx];
712693 struct skl_module_fmt *fmt = &iface->outputs[0].fmt;
713694
714
- skl_set_base_module_format(ctx, mconfig,
695
+ skl_set_base_module_format(skl, mconfig,
715696 (struct skl_base_cfg *)src_mconfig);
716697
717698 src_mconfig->src_cfg = fmt->s_freq;
....@@ -722,7 +703,7 @@
722703 * module configuration and channel configuration
723704 * It also take coefficients and now we have defaults applied here
724705 */
725
-static void skl_set_updown_mixer_format(struct skl_sst *ctx,
706
+static void skl_set_updown_mixer_format(struct skl_dev *skl,
726707 struct skl_module_cfg *mconfig,
727708 struct skl_up_down_mixer_cfg *mixer_mconfig)
728709 {
....@@ -730,7 +711,7 @@
730711 struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx];
731712 struct skl_module_fmt *fmt = &iface->outputs[0].fmt;
732713
733
- skl_set_base_module_format(ctx, mconfig,
714
+ skl_set_base_module_format(skl, mconfig,
734715 (struct skl_base_cfg *)mixer_mconfig);
735716 mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
736717 mixer_mconfig->ch_map = fmt->ch_map;
....@@ -743,17 +724,17 @@
743724 * format, gateway settings
744725 * copier_module_config is sent as input buffer with INIT_INSTANCE IPC msg
745726 */
746
-static void skl_set_copier_format(struct skl_sst *ctx,
727
+static void skl_set_copier_format(struct skl_dev *skl,
747728 struct skl_module_cfg *mconfig,
748729 struct skl_cpr_cfg *cpr_mconfig)
749730 {
750731 struct skl_audio_data_format *out_fmt = &cpr_mconfig->out_fmt;
751732 struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)cpr_mconfig;
752733
753
- skl_set_base_module_format(ctx, mconfig, base_cfg);
734
+ skl_set_base_module_format(skl, mconfig, base_cfg);
754735
755
- skl_setup_out_format(ctx, mconfig, out_fmt);
756
- skl_setup_cpr_gateway_cfg(ctx, mconfig, cpr_mconfig);
736
+ skl_setup_out_format(skl, mconfig, out_fmt);
737
+ skl_setup_cpr_gateway_cfg(skl, mconfig, cpr_mconfig);
757738 }
758739
759740 /*
....@@ -761,13 +742,13 @@
761742 * configuration and params
762743 */
763744
764
-static void skl_set_algo_format(struct skl_sst *ctx,
745
+static void skl_set_algo_format(struct skl_dev *skl,
765746 struct skl_module_cfg *mconfig,
766747 struct skl_algo_cfg *algo_mcfg)
767748 {
768749 struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)algo_mcfg;
769750
770
- skl_set_base_module_format(ctx, mconfig, base_cfg);
751
+ skl_set_base_module_format(skl, mconfig, base_cfg);
771752
772753 if (mconfig->formats_config.caps_size == 0)
773754 return;
....@@ -785,7 +766,7 @@
785766 * Mic select module take base module configuration and out-format
786767 * configuration
787768 */
788
-static void skl_set_base_outfmt_format(struct skl_sst *ctx,
769
+static void skl_set_base_outfmt_format(struct skl_dev *skl,
789770 struct skl_module_cfg *mconfig,
790771 struct skl_base_outfmt_cfg *base_outfmt_mcfg)
791772 {
....@@ -793,11 +774,11 @@
793774 struct skl_base_cfg *base_cfg =
794775 (struct skl_base_cfg *)base_outfmt_mcfg;
795776
796
- skl_set_base_module_format(ctx, mconfig, base_cfg);
797
- skl_setup_out_format(ctx, mconfig, out_fmt);
777
+ skl_set_base_module_format(skl, mconfig, base_cfg);
778
+ skl_setup_out_format(skl, mconfig, out_fmt);
798779 }
799780
800
-static u16 skl_get_module_param_size(struct skl_sst *ctx,
781
+static u16 skl_get_module_param_size(struct skl_dev *skl,
801782 struct skl_module_cfg *mconfig)
802783 {
803784 u16 param_size;
....@@ -821,8 +802,11 @@
821802
822803 case SKL_MODULE_TYPE_BASE_OUTFMT:
823804 case SKL_MODULE_TYPE_MIC_SELECT:
824
- case SKL_MODULE_TYPE_KPB:
825805 return sizeof(struct skl_base_outfmt_cfg);
806
+
807
+ case SKL_MODULE_TYPE_MIXER:
808
+ case SKL_MODULE_TYPE_KPB:
809
+ return sizeof(struct skl_base_cfg);
826810
827811 default:
828812 /*
....@@ -842,14 +826,14 @@
842826 * base module format configuration
843827 */
844828
845
-static int skl_set_module_format(struct skl_sst *ctx,
829
+static int skl_set_module_format(struct skl_dev *skl,
846830 struct skl_module_cfg *module_config,
847831 u16 *module_config_size,
848832 void **param_data)
849833 {
850834 u16 param_size;
851835
852
- param_size = skl_get_module_param_size(ctx, module_config);
836
+ param_size = skl_get_module_param_size(skl, module_config);
853837
854838 *param_data = kzalloc(param_size, GFP_KERNEL);
855839 if (NULL == *param_data)
....@@ -859,35 +843,40 @@
859843
860844 switch (module_config->m_type) {
861845 case SKL_MODULE_TYPE_COPIER:
862
- skl_set_copier_format(ctx, module_config, *param_data);
846
+ skl_set_copier_format(skl, module_config, *param_data);
863847 break;
864848
865849 case SKL_MODULE_TYPE_SRCINT:
866
- skl_set_src_format(ctx, module_config, *param_data);
850
+ skl_set_src_format(skl, module_config, *param_data);
867851 break;
868852
869853 case SKL_MODULE_TYPE_UPDWMIX:
870
- skl_set_updown_mixer_format(ctx, module_config, *param_data);
854
+ skl_set_updown_mixer_format(skl, module_config, *param_data);
871855 break;
872856
873857 case SKL_MODULE_TYPE_ALGO:
874
- skl_set_algo_format(ctx, module_config, *param_data);
858
+ skl_set_algo_format(skl, module_config, *param_data);
875859 break;
876860
877861 case SKL_MODULE_TYPE_BASE_OUTFMT:
878862 case SKL_MODULE_TYPE_MIC_SELECT:
863
+ skl_set_base_outfmt_format(skl, module_config, *param_data);
864
+ break;
865
+
866
+ case SKL_MODULE_TYPE_MIXER:
879867 case SKL_MODULE_TYPE_KPB:
880
- skl_set_base_outfmt_format(ctx, module_config, *param_data);
868
+ skl_set_base_module_format(skl, module_config, *param_data);
881869 break;
882870
883871 default:
884
- skl_set_base_module_format(ctx, module_config, *param_data);
872
+ skl_set_base_module_format(skl, module_config, *param_data);
885873 break;
886874
887875 }
888876
889
- dev_dbg(ctx->dev, "Module type=%d config size: %d bytes\n",
890
- module_config->id.module_id, param_size);
877
+ dev_dbg(skl->dev, "Module type=%d id=%d config size: %d bytes\n",
878
+ module_config->m_type, module_config->id.module_id,
879
+ param_size);
891880 print_hex_dump_debug("Module params:", DUMP_PREFIX_OFFSET, 8, 4,
892881 *param_data, param_size, false);
893882 return 0;
....@@ -987,7 +976,7 @@
987976 * We first calculate the module format, based on module type and then
988977 * invoke the DSP by sending IPC INIT_INSTANCE using ipc helper
989978 */
990
-int skl_init_module(struct skl_sst *ctx,
979
+int skl_init_module(struct skl_dev *skl,
991980 struct skl_module_cfg *mconfig)
992981 {
993982 u16 module_config_size = 0;
....@@ -995,19 +984,19 @@
995984 int ret;
996985 struct skl_ipc_init_instance_msg msg;
997986
998
- dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__,
987
+ dev_dbg(skl->dev, "%s: module_id = %d instance=%d\n", __func__,
999988 mconfig->id.module_id, mconfig->id.pvt_id);
1000989
1001990 if (mconfig->pipe->state != SKL_PIPE_CREATED) {
1002
- dev_err(ctx->dev, "Pipe not created state= %d pipe_id= %d\n",
991
+ dev_err(skl->dev, "Pipe not created state= %d pipe_id= %d\n",
1003992 mconfig->pipe->state, mconfig->pipe->ppl_id);
1004993 return -EIO;
1005994 }
1006995
1007
- ret = skl_set_module_format(ctx, mconfig,
996
+ ret = skl_set_module_format(skl, mconfig,
1008997 &module_config_size, &param_data);
1009998 if (ret < 0) {
1010
- dev_err(ctx->dev, "Failed to set module format ret=%d\n", ret);
999
+ dev_err(skl->dev, "Failed to set module format ret=%d\n", ret);
10111000 return ret;
10121001 }
10131002
....@@ -1018,9 +1007,9 @@
10181007 msg.core_id = mconfig->core_id;
10191008 msg.domain = mconfig->domain;
10201009
1021
- ret = skl_ipc_init_instance(&ctx->ipc, &msg, param_data);
1010
+ ret = skl_ipc_init_instance(&skl->ipc, &msg, param_data);
10221011 if (ret < 0) {
1023
- dev_err(ctx->dev, "Failed to init instance ret=%d\n", ret);
1012
+ dev_err(skl->dev, "Failed to init instance ret=%d\n", ret);
10241013 kfree(param_data);
10251014 return ret;
10261015 }
....@@ -1029,15 +1018,15 @@
10291018 return ret;
10301019 }
10311020
1032
-static void skl_dump_bind_info(struct skl_sst *ctx, struct skl_module_cfg
1021
+static void skl_dump_bind_info(struct skl_dev *skl, struct skl_module_cfg
10331022 *src_module, struct skl_module_cfg *dst_module)
10341023 {
1035
- dev_dbg(ctx->dev, "%s: src module_id = %d src_instance=%d\n",
1024
+ dev_dbg(skl->dev, "%s: src module_id = %d src_instance=%d\n",
10361025 __func__, src_module->id.module_id, src_module->id.pvt_id);
1037
- dev_dbg(ctx->dev, "%s: dst_module=%d dst_instance=%d\n", __func__,
1026
+ dev_dbg(skl->dev, "%s: dst_module=%d dst_instance=%d\n", __func__,
10381027 dst_module->id.module_id, dst_module->id.pvt_id);
10391028
1040
- dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n",
1029
+ dev_dbg(skl->dev, "src_module state = %d dst module state = %d\n",
10411030 src_module->m_state, dst_module->m_state);
10421031 }
10431032
....@@ -1046,7 +1035,7 @@
10461035 * it is already bind.
10471036 * Find the pin allocated and unbind then using bind_unbind IPC
10481037 */
1049
-int skl_unbind_modules(struct skl_sst *ctx,
1038
+int skl_unbind_modules(struct skl_dev *skl,
10501039 struct skl_module_cfg *src_mcfg,
10511040 struct skl_module_cfg *dst_mcfg)
10521041 {
....@@ -1058,7 +1047,7 @@
10581047 int out_max = src_mcfg->module->max_output_pins;
10591048 int src_index, dst_index, src_pin_state, dst_pin_state;
10601049
1061
- skl_dump_bind_info(ctx, src_mcfg, dst_mcfg);
1050
+ skl_dump_bind_info(skl, src_mcfg, dst_mcfg);
10621051
10631052 /* get src queue index */
10641053 src_index = skl_get_queue_index(src_mcfg->m_out_pin, dst_id, out_max);
....@@ -1087,7 +1076,7 @@
10871076 msg.dst_instance_id = dst_mcfg->id.pvt_id;
10881077 msg.bind = false;
10891078
1090
- ret = skl_ipc_bind_unbind(&ctx->ipc, &msg);
1079
+ ret = skl_ipc_bind_unbind(&skl->ipc, &msg);
10911080 if (!ret) {
10921081 /* free queue only if unbind is success */
10931082 skl_free_queue(src_mcfg->m_out_pin, src_index);
....@@ -1125,7 +1114,7 @@
11251114 * This function finds the pins and then sends bund_unbind IPC message to
11261115 * DSP using IPC helper
11271116 */
1128
-int skl_bind_modules(struct skl_sst *ctx,
1117
+int skl_bind_modules(struct skl_dev *skl,
11291118 struct skl_module_cfg *src_mcfg,
11301119 struct skl_module_cfg *dst_mcfg)
11311120 {
....@@ -1139,7 +1128,7 @@
11391128 struct skl_module *module;
11401129 struct skl_module_iface *fmt;
11411130
1142
- skl_dump_bind_info(ctx, src_mcfg, dst_mcfg);
1131
+ skl_dump_bind_info(skl, src_mcfg, dst_mcfg);
11431132
11441133 if (src_mcfg->m_state < SKL_MODULE_INIT_DONE ||
11451134 dst_mcfg->m_state < SKL_MODULE_INIT_DONE)
....@@ -1171,7 +1160,7 @@
11711160
11721161 format = &fmt->outputs[src_index].fmt;
11731162 fill_pin_params(&(pin_fmt.dst_fmt), format);
1174
- ret = skl_set_module_params(ctx, (void *)&pin_fmt,
1163
+ ret = skl_set_module_params(skl, (void *)&pin_fmt,
11751164 sizeof(struct skl_cpr_pin_fmt),
11761165 CPR_SINK_FMT_PARAM_ID, src_mcfg);
11771166
....@@ -1181,7 +1170,7 @@
11811170
11821171 msg.dst_queue = dst_index;
11831172
1184
- dev_dbg(ctx->dev, "src queue = %d dst queue =%d\n",
1173
+ dev_dbg(skl->dev, "src queue = %d dst queue =%d\n",
11851174 msg.src_queue, msg.dst_queue);
11861175
11871176 msg.module_id = src_mcfg->id.module_id;
....@@ -1190,7 +1179,7 @@
11901179 msg.dst_instance_id = dst_mcfg->id.pvt_id;
11911180 msg.bind = true;
11921181
1193
- ret = skl_ipc_bind_unbind(&ctx->ipc, &msg);
1182
+ ret = skl_ipc_bind_unbind(&skl->ipc, &msg);
11941183
11951184 if (!ret) {
11961185 src_mcfg->m_state = SKL_MODULE_BIND_DONE;
....@@ -1206,12 +1195,12 @@
12061195 return ret;
12071196 }
12081197
1209
-static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe,
1198
+static int skl_set_pipe_state(struct skl_dev *skl, struct skl_pipe *pipe,
12101199 enum skl_ipc_pipeline_state state)
12111200 {
1212
- dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state);
1201
+ dev_dbg(skl->dev, "%s: pipe_state = %d\n", __func__, state);
12131202
1214
- return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state);
1203
+ return skl_ipc_set_pipeline_state(&skl->ipc, pipe->ppl_id, state);
12151204 }
12161205
12171206 /*
....@@ -1220,17 +1209,17 @@
12201209 * This function creates pipeline, by sending create pipeline IPC messages
12211210 * to FW
12221211 */
1223
-int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe)
1212
+int skl_create_pipeline(struct skl_dev *skl, struct skl_pipe *pipe)
12241213 {
12251214 int ret;
12261215
1227
- dev_dbg(ctx->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id);
1216
+ dev_dbg(skl->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id);
12281217
1229
- ret = skl_ipc_create_pipeline(&ctx->ipc, pipe->memory_pages,
1218
+ ret = skl_ipc_create_pipeline(&skl->ipc, pipe->memory_pages,
12301219 pipe->pipe_priority, pipe->ppl_id,
12311220 pipe->lp_mode);
12321221 if (ret < 0) {
1233
- dev_err(ctx->dev, "Failed to create pipeline\n");
1222
+ dev_err(skl->dev, "Failed to create pipeline\n");
12341223 return ret;
12351224 }
12361225
....@@ -1240,35 +1229,44 @@
12401229 }
12411230
12421231 /*
1243
- * A pipeline needs to be deleted on cleanup. If a pipeline is running, then
1244
- * pause the pipeline first and then delete it
1245
- * The pipe delete is done by sending delete pipeline IPC. DSP will stop the
1246
- * DMA engines and releases resources
1232
+ * A pipeline needs to be deleted on cleanup. If a pipeline is running,
1233
+ * then pause it first. Before actual deletion, pipeline should enter
1234
+ * reset state. Finish the procedure by sending delete pipeline IPC.
1235
+ * DSP will stop the DMA engines and release resources
12471236 */
1248
-int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1237
+int skl_delete_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
12491238 {
12501239 int ret;
12511240
1252
- dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
1241
+ dev_dbg(skl->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
1242
+
1243
+ /* If pipe was not created in FW, do not try to delete it */
1244
+ if (pipe->state < SKL_PIPE_CREATED)
1245
+ return 0;
12531246
12541247 /* If pipe is started, do stop the pipe in FW. */
12551248 if (pipe->state >= SKL_PIPE_STARTED) {
1256
- ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED);
1249
+ ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED);
12571250 if (ret < 0) {
1258
- dev_err(ctx->dev, "Failed to stop pipeline\n");
1251
+ dev_err(skl->dev, "Failed to stop pipeline\n");
12591252 return ret;
12601253 }
12611254
12621255 pipe->state = SKL_PIPE_PAUSED;
12631256 }
12641257
1265
- /* If pipe was not created in FW, do not try to delete it */
1266
- if (pipe->state < SKL_PIPE_CREATED)
1267
- return 0;
1268
-
1269
- ret = skl_ipc_delete_pipeline(&ctx->ipc, pipe->ppl_id);
1258
+ /* reset pipe state before deletion */
1259
+ ret = skl_set_pipe_state(skl, pipe, PPL_RESET);
12701260 if (ret < 0) {
1271
- dev_err(ctx->dev, "Failed to delete pipeline\n");
1261
+ dev_err(skl->dev, "Failed to reset pipe ret=%d\n", ret);
1262
+ return ret;
1263
+ }
1264
+
1265
+ pipe->state = SKL_PIPE_RESET;
1266
+
1267
+ ret = skl_ipc_delete_pipeline(&skl->ipc, pipe->ppl_id);
1268
+ if (ret < 0) {
1269
+ dev_err(skl->dev, "Failed to delete pipeline\n");
12721270 return ret;
12731271 }
12741272
....@@ -1282,28 +1280,28 @@
12821280 * For processing data the pipe need to be run by sending IPC set pipe state
12831281 * to DSP
12841282 */
1285
-int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1283
+int skl_run_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
12861284 {
12871285 int ret;
12881286
1289
- dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
1287
+ dev_dbg(skl->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
12901288
12911289 /* If pipe was not created in FW, do not try to pause or delete */
12921290 if (pipe->state < SKL_PIPE_CREATED)
12931291 return 0;
12941292
12951293 /* Pipe has to be paused before it is started */
1296
- ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED);
1294
+ ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED);
12971295 if (ret < 0) {
1298
- dev_err(ctx->dev, "Failed to pause pipe\n");
1296
+ dev_err(skl->dev, "Failed to pause pipe\n");
12991297 return ret;
13001298 }
13011299
13021300 pipe->state = SKL_PIPE_PAUSED;
13031301
1304
- ret = skl_set_pipe_state(ctx, pipe, PPL_RUNNING);
1302
+ ret = skl_set_pipe_state(skl, pipe, PPL_RUNNING);
13051303 if (ret < 0) {
1306
- dev_err(ctx->dev, "Failed to start pipe\n");
1304
+ dev_err(skl->dev, "Failed to start pipe\n");
13071305 return ret;
13081306 }
13091307
....@@ -1316,19 +1314,19 @@
13161314 * Stop the pipeline by sending set pipe state IPC
13171315 * DSP doesnt implement stop so we always send pause message
13181316 */
1319
-int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1317
+int skl_stop_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
13201318 {
13211319 int ret;
13221320
1323
- dev_dbg(ctx->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id);
1321
+ dev_dbg(skl->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id);
13241322
13251323 /* If pipe was not created in FW, do not try to pause or delete */
13261324 if (pipe->state < SKL_PIPE_PAUSED)
13271325 return 0;
13281326
1329
- ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED);
1327
+ ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED);
13301328 if (ret < 0) {
1331
- dev_dbg(ctx->dev, "Failed to stop pipe\n");
1329
+ dev_dbg(skl->dev, "Failed to stop pipe\n");
13321330 return ret;
13331331 }
13341332
....@@ -1341,7 +1339,7 @@
13411339 * Reset the pipeline by sending set pipe state IPC this will reset the DMA
13421340 * from the DSP side
13431341 */
1344
-int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1342
+int skl_reset_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
13451343 {
13461344 int ret;
13471345
....@@ -1349,9 +1347,9 @@
13491347 if (pipe->state < SKL_PIPE_PAUSED)
13501348 return 0;
13511349
1352
- ret = skl_set_pipe_state(ctx, pipe, PPL_RESET);
1350
+ ret = skl_set_pipe_state(skl, pipe, PPL_RESET);
13531351 if (ret < 0) {
1354
- dev_dbg(ctx->dev, "Failed to reset pipe ret=%d\n", ret);
1352
+ dev_dbg(skl->dev, "Failed to reset pipe ret=%d\n", ret);
13551353 return ret;
13561354 }
13571355
....@@ -1361,7 +1359,7 @@
13611359 }
13621360
13631361 /* Algo parameter set helper function */
1364
-int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size,
1362
+int skl_set_module_params(struct skl_dev *skl, u32 *params, int size,
13651363 u32 param_id, struct skl_module_cfg *mcfg)
13661364 {
13671365 struct skl_ipc_large_config_msg msg;
....@@ -1371,18 +1369,19 @@
13711369 msg.param_data_size = size;
13721370 msg.large_param_id = param_id;
13731371
1374
- return skl_ipc_set_large_config(&ctx->ipc, &msg, params);
1372
+ return skl_ipc_set_large_config(&skl->ipc, &msg, params);
13751373 }
13761374
1377
-int skl_get_module_params(struct skl_sst *ctx, u32 *params, int size,
1375
+int skl_get_module_params(struct skl_dev *skl, u32 *params, int size,
13781376 u32 param_id, struct skl_module_cfg *mcfg)
13791377 {
13801378 struct skl_ipc_large_config_msg msg;
1379
+ size_t bytes = size;
13811380
13821381 msg.module_id = mcfg->id.module_id;
13831382 msg.instance_id = mcfg->id.pvt_id;
13841383 msg.param_data_size = size;
13851384 msg.large_param_id = param_id;
13861385
1387
- return skl_ipc_get_large_config(&ctx->ipc, &msg, params);
1386
+ return skl_ipc_get_large_config(&skl->ipc, &msg, &params, &bytes);
13881387 }