hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/sound/soc/sh/dma-sh7760.c
....@@ -115,10 +115,11 @@
115115 snd_pcm_period_elapsed(cam->rx_ss);
116116 }
117117
118
-static int camelot_pcm_open(struct snd_pcm_substream *substream)
118
+static int camelot_pcm_open(struct snd_soc_component *component,
119
+ struct snd_pcm_substream *substream)
119120 {
120
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
121
- struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
121
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
122
+ struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
122123 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
123124 int ret, dmairq;
124125
....@@ -131,7 +132,7 @@
131132 ret = dmabrg_request_irq(dmairq, camelot_rxdma, cam);
132133 if (unlikely(ret)) {
133134 pr_debug("audio unit %d irqs already taken!\n",
134
- rtd->cpu_dai->id);
135
+ asoc_rtd_to_cpu(rtd, 0)->id);
135136 return -EBUSY;
136137 }
137138 (void)dmabrg_request_irq(dmairq + 1,camelot_rxdma, cam);
....@@ -140,7 +141,7 @@
140141 ret = dmabrg_request_irq(dmairq, camelot_txdma, cam);
141142 if (unlikely(ret)) {
142143 pr_debug("audio unit %d irqs already taken!\n",
143
- rtd->cpu_dai->id);
144
+ asoc_rtd_to_cpu(rtd, 0)->id);
144145 return -EBUSY;
145146 }
146147 (void)dmabrg_request_irq(dmairq + 1, camelot_txdma, cam);
....@@ -148,10 +149,11 @@
148149 return 0;
149150 }
150151
151
-static int camelot_pcm_close(struct snd_pcm_substream *substream)
152
+static int camelot_pcm_close(struct snd_soc_component *component,
153
+ struct snd_pcm_substream *substream)
152154 {
153
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
154
- struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
155
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
156
+ struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
155157 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
156158 int dmairq;
157159
....@@ -168,18 +170,14 @@
168170 return 0;
169171 }
170172
171
-static int camelot_hw_params(struct snd_pcm_substream *substream,
173
+static int camelot_hw_params(struct snd_soc_component *component,
174
+ struct snd_pcm_substream *substream,
172175 struct snd_pcm_hw_params *hw_params)
173176 {
174
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
175
- struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
177
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
178
+ struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
176179 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
177180 int ret;
178
-
179
- ret = snd_pcm_lib_malloc_pages(substream,
180
- params_buffer_bytes(hw_params));
181
- if (ret < 0)
182
- return ret;
183181
184182 if (recv) {
185183 cam->rx_period_size = params_period_bytes(hw_params);
....@@ -191,18 +189,14 @@
191189 return 0;
192190 }
193191
194
-static int camelot_hw_free(struct snd_pcm_substream *substream)
195
-{
196
- return snd_pcm_lib_free_pages(substream);
197
-}
198
-
199
-static int camelot_prepare(struct snd_pcm_substream *substream)
192
+static int camelot_prepare(struct snd_soc_component *component,
193
+ struct snd_pcm_substream *substream)
200194 {
201195 struct snd_pcm_runtime *runtime = substream->runtime;
202
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
203
- struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
196
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
197
+ struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
204198
205
- pr_debug("PCM data: addr 0x%08ulx len %d\n",
199
+ pr_debug("PCM data: addr 0x%08lx len %d\n",
206200 (u32)runtime->dma_addr, runtime->dma_bytes);
207201
208202 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
....@@ -244,10 +238,11 @@
244238 BRGREG(BRGACR) = acr | ACR_RDS;
245239 }
246240
247
-static int camelot_trigger(struct snd_pcm_substream *substream, int cmd)
241
+static int camelot_trigger(struct snd_soc_component *component,
242
+ struct snd_pcm_substream *substream, int cmd)
248243 {
249
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
250
- struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
244
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
245
+ struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
251246 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
252247
253248 switch (cmd) {
....@@ -270,11 +265,12 @@
270265 return 0;
271266 }
272267
273
-static snd_pcm_uframes_t camelot_pos(struct snd_pcm_substream *substream)
268
+static snd_pcm_uframes_t camelot_pos(struct snd_soc_component *component,
269
+ struct snd_pcm_substream *substream)
274270 {
275271 struct snd_pcm_runtime *runtime = substream->runtime;
276
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
277
- struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id];
272
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
273
+ struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
278274 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
279275 unsigned long pos;
280276
....@@ -292,35 +288,30 @@
292288 return bytes_to_frames(runtime, pos);
293289 }
294290
295
-static const struct snd_pcm_ops camelot_pcm_ops = {
296
- .open = camelot_pcm_open,
297
- .close = camelot_pcm_close,
298
- .ioctl = snd_pcm_lib_ioctl,
299
- .hw_params = camelot_hw_params,
300
- .hw_free = camelot_hw_free,
301
- .prepare = camelot_prepare,
302
- .trigger = camelot_trigger,
303
- .pointer = camelot_pos,
304
-};
305
-
306
-static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd)
291
+static int camelot_pcm_new(struct snd_soc_component *component,
292
+ struct snd_soc_pcm_runtime *rtd)
307293 {
308294 struct snd_pcm *pcm = rtd->pcm;
309295
310296 /* dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel
311297 * in MMAP mode (i.e. aplay -M)
312298 */
313
- snd_pcm_lib_preallocate_pages_for_all(pcm,
299
+ snd_pcm_set_managed_buffer_all(pcm,
314300 SNDRV_DMA_TYPE_CONTINUOUS,
315
- snd_dma_continuous_data(GFP_KERNEL),
301
+ NULL,
316302 DMABRG_PREALLOC_BUFFER, DMABRG_PREALLOC_BUFFER_MAX);
317303
318304 return 0;
319305 }
320306
321307 static const struct snd_soc_component_driver sh7760_soc_component = {
322
- .ops = &camelot_pcm_ops,
323
- .pcm_new = camelot_pcm_new,
308
+ .open = camelot_pcm_open,
309
+ .close = camelot_pcm_close,
310
+ .hw_params = camelot_hw_params,
311
+ .prepare = camelot_prepare,
312
+ .trigger = camelot_trigger,
313
+ .pointer = camelot_pos,
314
+ .pcm_construct = camelot_pcm_new,
324315 };
325316
326317 static int sh7760_soc_platform_probe(struct platform_device *pdev)