hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/au1x/dma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Au1000/Au1500/Au1100 Audio DMA support.
34 *
....@@ -173,27 +174,28 @@
173174 .fifo_size = 16,
174175 };
175176
176
-static inline struct alchemy_pcm_ctx *ss_to_ctx(struct snd_pcm_substream *ss)
177
+static inline struct alchemy_pcm_ctx *ss_to_ctx(struct snd_pcm_substream *ss,
178
+ struct snd_soc_component *component)
177179 {
178
- struct snd_soc_pcm_runtime *rtd = ss->private_data;
179
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
180180 return snd_soc_component_get_drvdata(component);
181181 }
182182
183
-static inline struct audio_stream *ss_to_as(struct snd_pcm_substream *ss)
183
+static inline struct audio_stream *ss_to_as(struct snd_pcm_substream *ss,
184
+ struct snd_soc_component *component)
184185 {
185
- struct alchemy_pcm_ctx *ctx = ss_to_ctx(ss);
186
+ struct alchemy_pcm_ctx *ctx = ss_to_ctx(ss, component);
186187 return &(ctx->stream[ss->stream]);
187188 }
188189
189
-static int alchemy_pcm_open(struct snd_pcm_substream *substream)
190
+static int alchemy_pcm_open(struct snd_soc_component *component,
191
+ struct snd_pcm_substream *substream)
190192 {
191
- struct alchemy_pcm_ctx *ctx = ss_to_ctx(substream);
192
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
193
+ struct alchemy_pcm_ctx *ctx = ss_to_ctx(substream, component);
194
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
193195 int *dmaids, s = substream->stream;
194196 char *name;
195197
196
- dmaids = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
198
+ dmaids = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream);
197199 if (!dmaids)
198200 return -ENODEV; /* whoa, has ordering changed? */
199201
....@@ -212,9 +214,10 @@
212214 return 0;
213215 }
214216
215
-static int alchemy_pcm_close(struct snd_pcm_substream *substream)
217
+static int alchemy_pcm_close(struct snd_soc_component *component,
218
+ struct snd_pcm_substream *substream)
216219 {
217
- struct alchemy_pcm_ctx *ctx = ss_to_ctx(substream);
220
+ struct alchemy_pcm_ctx *ctx = ss_to_ctx(substream, component);
218221 int stype = substream->stream;
219222
220223 ctx->stream[stype].substream = NULL;
....@@ -223,35 +226,29 @@
223226 return 0;
224227 }
225228
226
-static int alchemy_pcm_hw_params(struct snd_pcm_substream *substream,
229
+static int alchemy_pcm_hw_params(struct snd_soc_component *component,
230
+ struct snd_pcm_substream *substream,
227231 struct snd_pcm_hw_params *hw_params)
228232 {
229
- struct audio_stream *stream = ss_to_as(substream);
230
- int err;
233
+ struct audio_stream *stream = ss_to_as(substream, component);
231234
232
- err = snd_pcm_lib_malloc_pages(substream,
233
- params_buffer_bytes(hw_params));
234
- if (err < 0)
235
- return err;
236
- err = au1000_setup_dma_link(stream,
237
- params_period_bytes(hw_params),
238
- params_periods(hw_params));
239
- if (err)
240
- snd_pcm_lib_free_pages(substream);
241
-
242
- return err;
235
+ return au1000_setup_dma_link(stream,
236
+ params_period_bytes(hw_params),
237
+ params_periods(hw_params));
243238 }
244239
245
-static int alchemy_pcm_hw_free(struct snd_pcm_substream *substream)
240
+static int alchemy_pcm_hw_free(struct snd_soc_component *component,
241
+ struct snd_pcm_substream *substream)
246242 {
247
- struct audio_stream *stream = ss_to_as(substream);
243
+ struct audio_stream *stream = ss_to_as(substream, component);
248244 au1000_release_dma_link(stream);
249
- return snd_pcm_lib_free_pages(substream);
245
+ return 0;
250246 }
251247
252
-static int alchemy_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
248
+static int alchemy_pcm_trigger(struct snd_soc_component *component,
249
+ struct snd_pcm_substream *substream, int cmd)
253250 {
254
- struct audio_stream *stream = ss_to_as(substream);
251
+ struct audio_stream *stream = ss_to_as(substream, component);
255252 int err = 0;
256253
257254 switch (cmd) {
....@@ -268,9 +265,10 @@
268265 return err;
269266 }
270267
271
-static snd_pcm_uframes_t alchemy_pcm_pointer(struct snd_pcm_substream *ss)
268
+static snd_pcm_uframes_t alchemy_pcm_pointer(struct snd_soc_component *component,
269
+ struct snd_pcm_substream *ss)
272270 {
273
- struct audio_stream *stream = ss_to_as(ss);
271
+ struct audio_stream *stream = ss_to_as(ss, component);
274272 long location;
275273
276274 location = get_dma_residue(stream->dma);
....@@ -280,30 +278,26 @@
280278 return bytes_to_frames(ss->runtime, location);
281279 }
282280
283
-static const struct snd_pcm_ops alchemy_pcm_ops = {
284
- .open = alchemy_pcm_open,
285
- .close = alchemy_pcm_close,
286
- .ioctl = snd_pcm_lib_ioctl,
287
- .hw_params = alchemy_pcm_hw_params,
288
- .hw_free = alchemy_pcm_hw_free,
289
- .trigger = alchemy_pcm_trigger,
290
- .pointer = alchemy_pcm_pointer,
291
-};
292
-
293
-static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd)
281
+static int alchemy_pcm_new(struct snd_soc_component *component,
282
+ struct snd_soc_pcm_runtime *rtd)
294283 {
295284 struct snd_pcm *pcm = rtd->pcm;
296285
297
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
298
- snd_dma_continuous_data(GFP_KERNEL), 65536, (4096 * 1024) - 1);
286
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
287
+ NULL, 65536, (4096 * 1024) - 1);
299288
300289 return 0;
301290 }
302291
303292 static struct snd_soc_component_driver alchemy_pcm_soc_component = {
304293 .name = DRV_NAME,
305
- .ops = &alchemy_pcm_ops,
306
- .pcm_new = alchemy_pcm_new,
294
+ .open = alchemy_pcm_open,
295
+ .close = alchemy_pcm_close,
296
+ .hw_params = alchemy_pcm_hw_params,
297
+ .hw_free = alchemy_pcm_hw_free,
298
+ .trigger = alchemy_pcm_trigger,
299
+ .pointer = alchemy_pcm_pointer,
300
+ .pcm_construct = alchemy_pcm_new,
307301 };
308302
309303 static int alchemy_pcm_drvprobe(struct platform_device *pdev)