forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
....@@ -9,7 +9,6 @@
99
1010 #include <linux/init.h>
1111 #include <linux/kernel.h>
12
-#include <linux/vmalloc.h>
1312 #include <linux/delay.h>
1413
1514 #include <media/v4l2-device.h>
....@@ -238,54 +237,6 @@
238237 return 0;
239238 }
240239
241
-static int snd_cobalt_pcm_ioctl(struct snd_pcm_substream *substream,
242
- unsigned int cmd, void *arg)
243
-{
244
- return snd_pcm_lib_ioctl(substream, cmd, arg);
245
-}
246
-
247
-
248
-static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
249
- size_t size)
250
-{
251
- struct snd_pcm_runtime *runtime = subs->runtime;
252
-
253
- dprintk("Allocating vbuffer\n");
254
- if (runtime->dma_area) {
255
- if (runtime->dma_bytes > size)
256
- return 0;
257
-
258
- vfree(runtime->dma_area);
259
- }
260
- runtime->dma_area = vmalloc(size);
261
- if (!runtime->dma_area)
262
- return -ENOMEM;
263
-
264
- runtime->dma_bytes = size;
265
-
266
- return 0;
267
-}
268
-
269
-static int snd_cobalt_pcm_hw_params(struct snd_pcm_substream *substream,
270
- struct snd_pcm_hw_params *params)
271
-{
272
- dprintk("%s called\n", __func__);
273
-
274
- return snd_pcm_alloc_vmalloc_buffer(substream,
275
- params_buffer_bytes(params));
276
-}
277
-
278
-static int snd_cobalt_pcm_hw_free(struct snd_pcm_substream *substream)
279
-{
280
- if (substream->runtime->dma_area) {
281
- dprintk("freeing pcm capture region\n");
282
- vfree(substream->runtime->dma_area);
283
- substream->runtime->dma_area = NULL;
284
- }
285
-
286
- return 0;
287
-}
288
-
289240 static int snd_cobalt_pcm_prepare(struct snd_pcm_substream *substream)
290241 {
291242 struct snd_cobalt_card *cobsc = snd_pcm_substream_chip(substream);
....@@ -490,36 +441,20 @@
490441 substream->runtime->buffer_size;
491442 }
492443
493
-static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
494
- unsigned long offset)
495
-{
496
- void *pageptr = subs->runtime->dma_area + offset;
497
-
498
- return vmalloc_to_page(pageptr);
499
-}
500
-
501444 static const struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
502445 .open = snd_cobalt_pcm_capture_open,
503446 .close = snd_cobalt_pcm_capture_close,
504
- .ioctl = snd_cobalt_pcm_ioctl,
505
- .hw_params = snd_cobalt_pcm_hw_params,
506
- .hw_free = snd_cobalt_pcm_hw_free,
507447 .prepare = snd_cobalt_pcm_prepare,
508448 .trigger = snd_cobalt_pcm_trigger,
509449 .pointer = snd_cobalt_pcm_pointer,
510
- .page = snd_pcm_get_vmalloc_page,
511450 };
512451
513452 static const struct snd_pcm_ops snd_cobalt_pcm_playback_ops = {
514453 .open = snd_cobalt_pcm_playback_open,
515454 .close = snd_cobalt_pcm_playback_close,
516
- .ioctl = snd_cobalt_pcm_ioctl,
517
- .hw_params = snd_cobalt_pcm_hw_params,
518
- .hw_free = snd_cobalt_pcm_hw_free,
519455 .prepare = snd_cobalt_pcm_pb_prepare,
520456 .trigger = snd_cobalt_pcm_pb_trigger,
521457 .pointer = snd_cobalt_pcm_pb_pointer,
522
- .page = snd_pcm_get_vmalloc_page,
523458 };
524459
525460 int snd_cobalt_pcm_create(struct snd_cobalt_card *cobsc)
....@@ -555,9 +490,11 @@
555490
556491 snd_pcm_set_ops(sp, SNDRV_PCM_STREAM_CAPTURE,
557492 &snd_cobalt_pcm_capture_ops);
493
+ snd_pcm_set_managed_buffer_all(sp, SNDRV_DMA_TYPE_VMALLOC,
494
+ NULL, 0, 0);
558495 sp->info_flags = 0;
559496 sp->private_data = cobsc;
560
- strlcpy(sp->name, "cobalt", sizeof(sp->name));
497
+ strscpy(sp->name, "cobalt", sizeof(sp->name));
561498 } else {
562499 cobalt_s_bit_sysctrl(cobalt,
563500 COBALT_SYS_CTRL_AUDIO_OPP_RESETN_BIT, 0);
....@@ -579,9 +516,11 @@
579516
580517 snd_pcm_set_ops(sp, SNDRV_PCM_STREAM_PLAYBACK,
581518 &snd_cobalt_pcm_playback_ops);
519
+ snd_pcm_set_managed_buffer_all(sp, SNDRV_DMA_TYPE_VMALLOC,
520
+ NULL, 0, 0);
582521 sp->info_flags = 0;
583522 sp->private_data = cobsc;
584
- strlcpy(sp->name, "cobalt", sizeof(sp->name));
523
+ strscpy(sp->name, "cobalt", sizeof(sp->name));
585524 }
586525
587526 return 0;