forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/intel/skylake/skl-pcm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * skl-pcm.c -ASoC HDA Platform driver file implementing PCM functionality
34 *
....@@ -6,17 +7,7 @@
67 *
78 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
89 *
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 published by
11
- * the Free Software Foundation; version 2 of the License.
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * General Public License for more details.
17
- *
1810 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19
- *
2011 */
2112
2213 #include <linux/pci.h>
....@@ -32,6 +23,7 @@
3223 #define HDA_MONO 1
3324 #define HDA_STEREO 2
3425 #define HDA_QUAD 4
26
+#define HDA_MAX 8
3527
3628 static const struct snd_pcm_hardware azx_pcm_hw = {
3729 .info = (SNDRV_PCM_INFO_MMAP |
....@@ -85,13 +77,7 @@
8577 hdac_stream(stream)->period_bytes = 0;
8678 hdac_stream(stream)->format_val = 0;
8779
88
- return snd_pcm_lib_malloc_pages(substream, size);
89
-}
90
-
91
-static int skl_substream_free_pages(struct hdac_bus *bus,
92
- struct snd_pcm_substream *substream)
93
-{
94
- return snd_pcm_lib_free_pages(substream);
80
+ return 0;
9581 }
9682
9783 static void skl_set_pcm_constrains(struct hdac_bus *bus,
....@@ -124,12 +110,9 @@
124110 {
125111 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
126112 struct snd_soc_dapm_widget *w;
127
- struct skl *skl = bus_to_skl(bus);
113
+ struct skl_dev *skl = bus_to_skl(bus);
128114
129
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
130
- w = dai->playback_widget;
131
- else
132
- w = dai->capture_widget;
115
+ w = snd_soc_dai_get_widget(dai, substream->stream);
133116
134117 if (w->ignore_suspend && enable)
135118 skl->supend_active++;
....@@ -140,6 +123,7 @@
140123 int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params)
141124 {
142125 struct hdac_bus *bus = dev_get_drvdata(dev);
126
+ struct skl_dev *skl = bus_to_skl(bus);
143127 unsigned int format_val;
144128 struct hdac_stream *hstream;
145129 struct hdac_ext_stream *stream;
....@@ -164,7 +148,18 @@
164148 if (err < 0)
165149 return err;
166150
167
- err = snd_hdac_stream_setup(hdac_stream(stream));
151
+ /*
152
+ * The recommended SDxFMT programming sequence for BXT
153
+ * platforms is to couple the stream before writing the format
154
+ */
155
+ if (IS_BXT(skl->pci)) {
156
+ snd_hdac_ext_stream_decouple(bus, stream, false);
157
+ err = snd_hdac_stream_setup(hdac_stream(stream));
158
+ snd_hdac_ext_stream_decouple(bus, stream, true);
159
+ } else {
160
+ err = snd_hdac_stream_setup(hdac_stream(stream));
161
+ }
162
+
168163 if (err < 0)
169164 return err;
170165
....@@ -220,7 +215,7 @@
220215 struct hdac_ext_stream *stream;
221216 struct snd_pcm_runtime *runtime = substream->runtime;
222217 struct skl_dma_params *dma_params;
223
- struct skl *skl = get_skl_ctx(dai->dev);
218
+ struct skl_dev *skl = get_skl_ctx(dai->dev);
224219 struct skl_module_cfg *mconfig;
225220
226221 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
....@@ -267,7 +262,7 @@
267262 static int skl_pcm_prepare(struct snd_pcm_substream *substream,
268263 struct snd_soc_dai *dai)
269264 {
270
- struct skl *skl = get_skl_ctx(dai->dev);
265
+ struct skl_dev *skl = get_skl_ctx(dai->dev);
271266 struct skl_module_cfg *mconfig;
272267 int ret;
273268
....@@ -284,7 +279,7 @@
284279 mconfig->pipe->state == SKL_PIPE_CREATED ||
285280 mconfig->pipe->state == SKL_PIPE_PAUSED)) {
286281
287
- ret = skl_reset_pipe(skl->skl_sst, mconfig->pipe);
282
+ ret = skl_reset_pipe(skl, mconfig->pipe);
288283
289284 if (ret < 0)
290285 return ret;
....@@ -346,7 +341,7 @@
346341 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
347342 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
348343 struct skl_dma_params *dma_params = NULL;
349
- struct skl *skl = bus_to_skl(bus);
344
+ struct skl_dev *skl = bus_to_skl(bus);
350345 struct skl_module_cfg *mconfig;
351346
352347 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
....@@ -366,9 +361,9 @@
366361 * CGCTL.MISCBDCGE if disabled by driver
367362 */
368363 if (!strncmp(dai->name, "Reference Pin", 13) &&
369
- skl->skl_sst->miscbdcg_disabled) {
370
- skl->skl_sst->enable_miscbdcge(dai->dev, true);
371
- skl->skl_sst->miscbdcg_disabled = false;
364
+ skl->miscbdcg_disabled) {
365
+ skl->enable_miscbdcge(dai->dev, true);
366
+ skl->miscbdcg_disabled = false;
372367 }
373368
374369 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
....@@ -381,9 +376,8 @@
381376 static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
382377 struct snd_soc_dai *dai)
383378 {
384
- struct hdac_bus *bus = dev_get_drvdata(dai->dev);
385379 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
386
- struct skl *skl = get_skl_ctx(dai->dev);
380
+ struct skl_dev *skl = get_skl_ctx(dai->dev);
387381 struct skl_module_cfg *mconfig;
388382 int ret;
389383
....@@ -392,7 +386,7 @@
392386 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
393387
394388 if (mconfig) {
395
- ret = skl_reset_pipe(skl->skl_sst, mconfig->pipe);
389
+ ret = skl_reset_pipe(skl, mconfig->pipe);
396390 if (ret < 0)
397391 dev_err(dai->dev, "%s:Reset failed ret =%d",
398392 __func__, ret);
....@@ -401,7 +395,7 @@
401395 snd_hdac_stream_cleanup(hdac_stream(stream));
402396 hdac_stream(stream)->prepared = 0;
403397
404
- return skl_substream_free_pages(bus, substream);
398
+ return 0;
405399 }
406400
407401 static int skl_be_hw_params(struct snd_pcm_substream *substream,
....@@ -467,8 +461,7 @@
467461 static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
468462 struct snd_soc_dai *dai)
469463 {
470
- struct skl *skl = get_skl_ctx(dai->dev);
471
- struct skl_sst *ctx = skl->skl_sst;
464
+ struct skl_dev *skl = get_skl_ctx(dai->dev);
472465 struct skl_module_cfg *mconfig;
473466 struct hdac_bus *bus = get_bus_ctx(substream);
474467 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
....@@ -479,10 +472,7 @@
479472 if (!mconfig)
480473 return -EIO;
481474
482
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
483
- w = dai->playback_widget;
484
- else
485
- w = dai->capture_widget;
475
+ w = snd_soc_dai_get_widget(dai, substream->stream);
486476
487477 switch (cmd) {
488478 case SNDRV_PCM_TRIGGER_RESUME:
....@@ -498,6 +488,7 @@
498488 stream->lpib);
499489 snd_hdac_ext_stream_set_lpib(stream, stream->lpib);
500490 }
491
+ fallthrough;
501492
502493 case SNDRV_PCM_TRIGGER_START:
503494 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
....@@ -510,7 +501,7 @@
510501 ret = skl_decoupled_trigger(substream, cmd);
511502 if (ret < 0)
512503 return ret;
513
- return skl_run_pipe(ctx, mconfig->pipe);
504
+ return skl_run_pipe(skl, mconfig->pipe);
514505 break;
515506
516507 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
....@@ -521,7 +512,7 @@
521512 * there are no underrun/overrun in the case if there is a delay
522513 * between the two operations.
523514 */
524
- ret = skl_stop_pipe(ctx, mconfig->pipe);
515
+ ret = skl_stop_pipe(skl, mconfig->pipe);
525516 if (ret < 0)
526517 return ret;
527518
....@@ -553,8 +544,8 @@
553544 {
554545 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
555546 struct hdac_ext_stream *link_dev;
556
- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
557
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
547
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
548
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
558549 struct skl_pipe_params p_params = {0};
559550 struct hdac_ext_link *link;
560551 int stream_tag;
....@@ -573,7 +564,10 @@
573564 stream_tag = hdac_stream(link_dev)->stream_tag;
574565
575566 /* set the stream tag in the codec dai dma params */
576
- snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
567
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
568
+ snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
569
+ else
570
+ snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
577571
578572 p_params.s_fmt = snd_pcm_format_width(params_format(params));
579573 p_params.ch = params_channels(params);
....@@ -594,14 +588,14 @@
594588 static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
595589 struct snd_soc_dai *dai)
596590 {
597
- struct skl *skl = get_skl_ctx(dai->dev);
591
+ struct skl_dev *skl = get_skl_ctx(dai->dev);
598592 struct skl_module_cfg *mconfig = NULL;
599593
600594 /* In case of XRUN recovery, reset the FW pipe to clean state */
601595 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
602596 if (mconfig && !mconfig->pipe->passthru &&
603597 (substream->runtime->status->state == SNDRV_PCM_STATE_XRUN))
604
- skl_reset_pipe(skl->skl_sst, mconfig->pipe);
598
+ skl_reset_pipe(skl, mconfig->pipe);
605599
606600 return 0;
607601 }
....@@ -640,7 +634,7 @@
640634 struct snd_soc_dai *dai)
641635 {
642636 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
643
- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
637
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
644638 struct hdac_ext_stream *link_dev =
645639 snd_soc_dai_get_dma_data(dai, substream);
646640 struct hdac_ext_link *link;
....@@ -650,7 +644,7 @@
650644
651645 link_dev->link_prepared = 0;
652646
653
- link = snd_hdac_ext_bus_get_link(bus, rtd->codec_dai->component->name);
647
+ link = snd_hdac_ext_bus_get_link(bus, asoc_rtd_to_codec(rtd, 0)->component->name);
654648 if (!link)
655649 return -EINVAL;
656650
....@@ -1004,21 +998,63 @@
1004998 },
1005999 },
10061000 {
1007
- .name = "HD-Codec Pin",
1001
+ .name = "Analog CPU DAI",
10081002 .ops = &skl_link_dai_ops,
10091003 .playback = {
1010
- .stream_name = "HD-Codec Tx",
1011
- .channels_min = HDA_STEREO,
1012
- .channels_max = HDA_STEREO,
1013
- .rates = SNDRV_PCM_RATE_48000,
1014
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
1004
+ .stream_name = "Analog CPU Playback",
1005
+ .channels_min = HDA_MONO,
1006
+ .channels_max = HDA_MAX,
1007
+ .rates = SNDRV_PCM_RATE_8000_192000,
1008
+ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1009
+ SNDRV_PCM_FMTBIT_S32_LE,
10151010 },
10161011 .capture = {
1017
- .stream_name = "HD-Codec Rx",
1018
- .channels_min = HDA_STEREO,
1019
- .channels_max = HDA_STEREO,
1020
- .rates = SNDRV_PCM_RATE_48000,
1021
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
1012
+ .stream_name = "Analog CPU Capture",
1013
+ .channels_min = HDA_MONO,
1014
+ .channels_max = HDA_MAX,
1015
+ .rates = SNDRV_PCM_RATE_8000_192000,
1016
+ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1017
+ SNDRV_PCM_FMTBIT_S32_LE,
1018
+ },
1019
+},
1020
+{
1021
+ .name = "Alt Analog CPU DAI",
1022
+ .ops = &skl_link_dai_ops,
1023
+ .playback = {
1024
+ .stream_name = "Alt Analog CPU Playback",
1025
+ .channels_min = HDA_MONO,
1026
+ .channels_max = HDA_MAX,
1027
+ .rates = SNDRV_PCM_RATE_8000_192000,
1028
+ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1029
+ SNDRV_PCM_FMTBIT_S32_LE,
1030
+ },
1031
+ .capture = {
1032
+ .stream_name = "Alt Analog CPU Capture",
1033
+ .channels_min = HDA_MONO,
1034
+ .channels_max = HDA_MAX,
1035
+ .rates = SNDRV_PCM_RATE_8000_192000,
1036
+ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1037
+ SNDRV_PCM_FMTBIT_S32_LE,
1038
+ },
1039
+},
1040
+{
1041
+ .name = "Digital CPU DAI",
1042
+ .ops = &skl_link_dai_ops,
1043
+ .playback = {
1044
+ .stream_name = "Digital CPU Playback",
1045
+ .channels_min = HDA_MONO,
1046
+ .channels_max = HDA_MAX,
1047
+ .rates = SNDRV_PCM_RATE_8000_192000,
1048
+ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1049
+ SNDRV_PCM_FMTBIT_S32_LE,
1050
+ },
1051
+ .capture = {
1052
+ .stream_name = "Digital CPU Capture",
1053
+ .channels_min = HDA_MONO,
1054
+ .channels_max = HDA_MAX,
1055
+ .rates = SNDRV_PCM_RATE_8000_192000,
1056
+ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
1057
+ SNDRV_PCM_FMTBIT_S32_LE,
10221058 },
10231059 },
10241060 };
....@@ -1032,13 +1068,14 @@
10321068 return 0;
10331069 }
10341070
1035
-static int skl_platform_open(struct snd_pcm_substream *substream)
1071
+static int skl_platform_soc_open(struct snd_soc_component *component,
1072
+ struct snd_pcm_substream *substream)
10361073 {
1037
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
1074
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
10381075 struct snd_soc_dai_link *dai_link = rtd->dai_link;
10391076
1040
- dev_dbg(rtd->cpu_dai->dev, "In %s:%s\n", __func__,
1041
- dai_link->cpu_dai_name);
1077
+ dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "In %s:%s\n", __func__,
1078
+ dai_link->cpus->dai_name);
10421079
10431080 snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
10441081
....@@ -1118,8 +1155,9 @@
11181155 return 0;
11191156 }
11201157
1121
-static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream,
1122
- int cmd)
1158
+static int skl_platform_soc_trigger(struct snd_soc_component *component,
1159
+ struct snd_pcm_substream *substream,
1160
+ int cmd)
11231161 {
11241162 struct hdac_bus *bus = get_bus_ctx(substream);
11251163
....@@ -1129,8 +1167,9 @@
11291167 return 0;
11301168 }
11311169
1132
-static snd_pcm_uframes_t skl_platform_pcm_pointer
1133
- (struct snd_pcm_substream *substream)
1170
+static snd_pcm_uframes_t skl_platform_soc_pointer(
1171
+ struct snd_soc_component *component,
1172
+ struct snd_pcm_substream *substream)
11341173 {
11351174 struct hdac_ext_stream *hstream = get_hdac_ext_stream(substream);
11361175 struct hdac_bus *bus = get_bus_ctx(substream);
....@@ -1176,11 +1215,18 @@
11761215 return bytes_to_frames(substream->runtime, pos);
11771216 }
11781217
1218
+static int skl_platform_soc_mmap(struct snd_soc_component *component,
1219
+ struct snd_pcm_substream *substream,
1220
+ struct vm_area_struct *area)
1221
+{
1222
+ return snd_pcm_lib_default_mmap(substream, area);
1223
+}
1224
+
11791225 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
11801226 u64 nsec)
11811227 {
1182
- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
1183
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
1228
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1229
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
11841230 u64 codec_frames, codec_nsecs;
11851231
11861232 if (!codec_dai->driver->ops->delay)
....@@ -1196,8 +1242,10 @@
11961242 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
11971243 }
11981244
1199
-static int skl_get_time_info(struct snd_pcm_substream *substream,
1200
- struct timespec *system_ts, struct timespec *audio_ts,
1245
+static int skl_platform_soc_get_time_info(
1246
+ struct snd_soc_component *component,
1247
+ struct snd_pcm_substream *substream,
1248
+ struct timespec64 *system_ts, struct timespec64 *audio_ts,
12011249 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
12021250 struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
12031251 {
....@@ -1215,7 +1263,7 @@
12151263 if (audio_tstamp_config->report_delay)
12161264 nsec = skl_adjust_codec_delay(substream, nsec);
12171265
1218
- *audio_ts = ns_to_timespec(nsec);
1266
+ *audio_ts = ns_to_timespec64(nsec);
12191267
12201268 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
12211269 audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */
....@@ -1228,31 +1276,16 @@
12281276 return 0;
12291277 }
12301278
1231
-static const struct snd_pcm_ops skl_platform_ops = {
1232
- .open = skl_platform_open,
1233
- .ioctl = snd_pcm_lib_ioctl,
1234
- .trigger = skl_platform_pcm_trigger,
1235
- .pointer = skl_platform_pcm_pointer,
1236
- .get_time_info = skl_get_time_info,
1237
- .mmap = snd_pcm_lib_default_mmap,
1238
- .page = snd_pcm_sgbuf_ops_page,
1239
-};
1240
-
1241
-static void skl_pcm_free(struct snd_pcm *pcm)
1242
-{
1243
- snd_pcm_lib_preallocate_free_for_all(pcm);
1244
-}
1245
-
12461279 #define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
12471280
1248
-static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1281
+static int skl_platform_soc_new(struct snd_soc_component *component,
1282
+ struct snd_soc_pcm_runtime *rtd)
12491283 {
1250
- struct snd_soc_dai *dai = rtd->cpu_dai;
1284
+ struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
12511285 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
12521286 struct snd_pcm *pcm = rtd->pcm;
12531287 unsigned int size;
1254
- int retval = 0;
1255
- struct skl *skl = bus_to_skl(bus);
1288
+ struct skl_dev *skl = bus_to_skl(bus);
12561289
12571290 if (dai->driver->playback.channels_min ||
12581291 dai->driver->capture.channels_min) {
....@@ -1260,80 +1293,69 @@
12601293 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
12611294 if (size > MAX_PREALLOC_SIZE)
12621295 size = MAX_PREALLOC_SIZE;
1263
- retval = snd_pcm_lib_preallocate_pages_for_all(pcm,
1264
- SNDRV_DMA_TYPE_DEV_SG,
1265
- snd_dma_pci_data(skl->pci),
1266
- size, MAX_PREALLOC_SIZE);
1267
- if (retval) {
1268
- dev_err(dai->dev, "dma buffer allocation fail\n");
1269
- return retval;
1270
- }
1271
- }
1272
-
1273
- return retval;
1274
-}
1275
-
1276
-static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
1277
-{
1278
- struct skl_sst *ctx = skl->skl_sst;
1279
- struct skl_module_inst_id *pin_id;
1280
- uuid_le *uuid_mod, *uuid_tplg;
1281
- struct skl_module *skl_module;
1282
- struct uuid_module *module;
1283
- int i, ret = -EIO;
1284
-
1285
- uuid_mod = (uuid_le *)mconfig->guid;
1286
-
1287
- if (list_empty(&ctx->uuid_list)) {
1288
- dev_err(ctx->dev, "Module list is empty\n");
1289
- return -EIO;
1290
- }
1291
-
1292
- list_for_each_entry(module, &ctx->uuid_list, list) {
1293
- if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
1294
- mconfig->id.module_id = module->id;
1295
- if (mconfig->module)
1296
- mconfig->module->loadable = module->is_loadable;
1297
- ret = 0;
1298
- break;
1299
- }
1300
- }
1301
-
1302
- if (ret)
1303
- return ret;
1304
-
1305
- uuid_mod = &module->uuid;
1306
- ret = -EIO;
1307
- for (i = 0; i < skl->nr_modules; i++) {
1308
- skl_module = skl->modules[i];
1309
- uuid_tplg = &skl_module->uuid;
1310
- if (!uuid_le_cmp(*uuid_mod, *uuid_tplg)) {
1311
- mconfig->module = skl_module;
1312
- ret = 0;
1313
- break;
1314
- }
1315
- }
1316
- if (skl->nr_modules && ret)
1317
- return ret;
1318
-
1319
- list_for_each_entry(module, &ctx->uuid_list, list) {
1320
- for (i = 0; i < MAX_IN_QUEUE; i++) {
1321
- pin_id = &mconfig->m_in_pin[i].id;
1322
- if (!uuid_le_cmp(pin_id->mod_uuid, module->uuid))
1323
- pin_id->module_id = module->id;
1324
- }
1325
-
1326
- for (i = 0; i < MAX_OUT_QUEUE; i++) {
1327
- pin_id = &mconfig->m_out_pin[i].id;
1328
- if (!uuid_le_cmp(pin_id->mod_uuid, module->uuid))
1329
- pin_id->module_id = module->id;
1330
- }
1296
+ snd_pcm_set_managed_buffer_all(pcm,
1297
+ SNDRV_DMA_TYPE_DEV_SG,
1298
+ &skl->pci->dev,
1299
+ size, MAX_PREALLOC_SIZE);
13311300 }
13321301
13331302 return 0;
13341303 }
13351304
1336
-static int skl_populate_modules(struct skl *skl)
1305
+static int skl_get_module_info(struct skl_dev *skl,
1306
+ struct skl_module_cfg *mconfig)
1307
+{
1308
+ struct skl_module_inst_id *pin_id;
1309
+ guid_t *uuid_mod, *uuid_tplg;
1310
+ struct skl_module *skl_module;
1311
+ struct uuid_module *module;
1312
+ int i, ret = -EIO;
1313
+
1314
+ uuid_mod = (guid_t *)mconfig->guid;
1315
+
1316
+ if (list_empty(&skl->uuid_list)) {
1317
+ dev_err(skl->dev, "Module list is empty\n");
1318
+ return -EIO;
1319
+ }
1320
+
1321
+ for (i = 0; i < skl->nr_modules; i++) {
1322
+ skl_module = skl->modules[i];
1323
+ uuid_tplg = &skl_module->uuid;
1324
+ if (guid_equal(uuid_mod, uuid_tplg)) {
1325
+ mconfig->module = skl_module;
1326
+ ret = 0;
1327
+ break;
1328
+ }
1329
+ }
1330
+
1331
+ if (skl->nr_modules && ret)
1332
+ return ret;
1333
+
1334
+ ret = -EIO;
1335
+ list_for_each_entry(module, &skl->uuid_list, list) {
1336
+ if (guid_equal(uuid_mod, &module->uuid)) {
1337
+ mconfig->id.module_id = module->id;
1338
+ mconfig->module->loadable = module->is_loadable;
1339
+ ret = 0;
1340
+ }
1341
+
1342
+ for (i = 0; i < MAX_IN_QUEUE; i++) {
1343
+ pin_id = &mconfig->m_in_pin[i].id;
1344
+ if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1345
+ pin_id->module_id = module->id;
1346
+ }
1347
+
1348
+ for (i = 0; i < MAX_OUT_QUEUE; i++) {
1349
+ pin_id = &mconfig->m_out_pin[i].id;
1350
+ if (guid_equal(&pin_id->mod_uuid, &module->uuid))
1351
+ pin_id->module_id = module->id;
1352
+ }
1353
+ }
1354
+
1355
+ return ret;
1356
+}
1357
+
1358
+static int skl_populate_modules(struct skl_dev *skl)
13371359 {
13381360 struct skl_pipeline *p;
13391361 struct skl_pipe_module *m;
....@@ -1348,7 +1370,7 @@
13481370
13491371 ret = skl_get_module_info(skl, mconfig);
13501372 if (ret < 0) {
1351
- dev_err(skl->skl_sst->dev,
1373
+ dev_err(skl->dev,
13521374 "query module info failed\n");
13531375 return ret;
13541376 }
....@@ -1363,7 +1385,7 @@
13631385 static int skl_platform_soc_probe(struct snd_soc_component *component)
13641386 {
13651387 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1366
- struct skl *skl = bus_to_skl(bus);
1388
+ struct skl_dev *skl = bus_to_skl(bus);
13671389 const struct skl_dsp_ops *ops;
13681390 int ret;
13691391
....@@ -1385,31 +1407,25 @@
13851407 if (!ops)
13861408 return -EIO;
13871409
1388
- if (skl->skl_sst->is_first_boot == false) {
1389
- dev_err(component->dev, "DSP reports first boot done!!!\n");
1390
- return -EIO;
1391
- }
1392
-
13931410 /*
13941411 * Disable dynamic clock and power gating during firmware
13951412 * and library download
13961413 */
1397
- skl->skl_sst->enable_miscbdcge(component->dev, false);
1398
- skl->skl_sst->clock_power_gating(component->dev, false);
1414
+ skl->enable_miscbdcge(component->dev, false);
1415
+ skl->clock_power_gating(component->dev, false);
13991416
1400
- ret = ops->init_fw(component->dev, skl->skl_sst);
1401
- skl->skl_sst->enable_miscbdcge(component->dev, true);
1402
- skl->skl_sst->clock_power_gating(component->dev, true);
1417
+ ret = ops->init_fw(component->dev, skl);
1418
+ skl->enable_miscbdcge(component->dev, true);
1419
+ skl->clock_power_gating(component->dev, true);
14031420 if (ret < 0) {
14041421 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
14051422 return ret;
14061423 }
14071424 skl_populate_modules(skl);
1408
- skl->skl_sst->update_d0i3c = skl_update_d0i3c;
1409
- skl_dsp_enable_notification(skl->skl_sst, false);
1425
+ skl->update_d0i3c = skl_update_d0i3c;
14101426
14111427 if (skl->cfg.astate_cfg != NULL) {
1412
- skl_dsp_set_astate_cfg(skl->skl_sst,
1428
+ skl_dsp_set_astate_cfg(skl,
14131429 skl->cfg.astate_cfg->count,
14141430 skl->cfg.astate_cfg);
14151431 }
....@@ -1420,12 +1436,27 @@
14201436 return 0;
14211437 }
14221438
1439
+static void skl_platform_soc_remove(struct snd_soc_component *component)
1440
+{
1441
+ struct hdac_bus *bus = dev_get_drvdata(component->dev);
1442
+ struct skl_dev *skl = bus_to_skl(bus);
1443
+
1444
+ skl_tplg_exit(component, bus);
1445
+
1446
+ skl_debugfs_exit(skl);
1447
+}
1448
+
14231449 static const struct snd_soc_component_driver skl_component = {
14241450 .name = "pcm",
14251451 .probe = skl_platform_soc_probe,
1426
- .ops = &skl_platform_ops,
1427
- .pcm_new = skl_pcm_new,
1428
- .pcm_free = skl_pcm_free,
1452
+ .remove = skl_platform_soc_remove,
1453
+ .open = skl_platform_soc_open,
1454
+ .trigger = skl_platform_soc_trigger,
1455
+ .pointer = skl_platform_soc_pointer,
1456
+ .get_time_info = skl_platform_soc_get_time_info,
1457
+ .mmap = skl_platform_soc_mmap,
1458
+ .pcm_construct = skl_platform_soc_new,
1459
+ .module_get_upon_open = 1, /* increment refcount when a pcm is opened */
14291460 };
14301461
14311462 int skl_platform_register(struct device *dev)
....@@ -1434,10 +1465,7 @@
14341465 struct snd_soc_dai_driver *dais;
14351466 int num_dais = ARRAY_SIZE(skl_platform_dai);
14361467 struct hdac_bus *bus = dev_get_drvdata(dev);
1437
- struct skl *skl = bus_to_skl(bus);
1438
-
1439
- INIT_LIST_HEAD(&skl->ppl_list);
1440
- INIT_LIST_HEAD(&skl->bind_list);
1468
+ struct skl_dev *skl = bus_to_skl(bus);
14411469
14421470 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
14431471 GFP_KERNEL);
....@@ -1471,14 +1499,12 @@
14711499 int skl_platform_unregister(struct device *dev)
14721500 {
14731501 struct hdac_bus *bus = dev_get_drvdata(dev);
1474
- struct skl *skl = bus_to_skl(bus);
1502
+ struct skl_dev *skl = bus_to_skl(bus);
14751503 struct skl_module_deferred_bind *modules, *tmp;
14761504
1477
- if (!list_empty(&skl->bind_list)) {
1478
- list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1479
- list_del(&modules->node);
1480
- kfree(modules);
1481
- }
1505
+ list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) {
1506
+ list_del(&modules->node);
1507
+ kfree(modules);
14821508 }
14831509
14841510 kfree(skl->dais);