forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA PCM device for the
34 * ALSA interface to ivtv PCM capture streams
....@@ -6,16 +7,6 @@
67 * Copyright (C) 2009 Devin Heitmueller <dheitmueller@kernellabs.com>
78 *
89 * Portions of this work were sponsored by ONELAN Limited for the cx18 driver
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 published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
1910 */
2011
2112 #include "ivtv-driver.h"
....@@ -24,8 +15,6 @@
2415 #include "ivtv-fileops.h"
2516 #include "ivtv-alsa.h"
2617 #include "ivtv-alsa-pcm.h"
27
-
28
-#include <linux/vmalloc.h>
2918
3019 #include <sound/core.h>
3120 #include <sound/pcm.h>
....@@ -215,67 +204,6 @@
215204 return 0;
216205 }
217206
218
-static int snd_ivtv_pcm_ioctl(struct snd_pcm_substream *substream,
219
- unsigned int cmd, void *arg)
220
-{
221
- struct snd_ivtv_card *itvsc = snd_pcm_substream_chip(substream);
222
- int ret;
223
-
224
- snd_ivtv_lock(itvsc);
225
- ret = snd_pcm_lib_ioctl(substream, cmd, arg);
226
- snd_ivtv_unlock(itvsc);
227
- return ret;
228
-}
229
-
230
-
231
-static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
232
- size_t size)
233
-{
234
- struct snd_pcm_runtime *runtime = subs->runtime;
235
-
236
- dprintk("Allocating vbuffer\n");
237
- if (runtime->dma_area) {
238
- if (runtime->dma_bytes > size)
239
- return 0;
240
-
241
- vfree(runtime->dma_area);
242
- }
243
- runtime->dma_area = vmalloc(size);
244
- if (!runtime->dma_area)
245
- return -ENOMEM;
246
-
247
- runtime->dma_bytes = size;
248
-
249
- return 0;
250
-}
251
-
252
-static int snd_ivtv_pcm_hw_params(struct snd_pcm_substream *substream,
253
- struct snd_pcm_hw_params *params)
254
-{
255
- dprintk("%s called\n", __func__);
256
-
257
- return snd_pcm_alloc_vmalloc_buffer(substream,
258
- params_buffer_bytes(params));
259
-}
260
-
261
-static int snd_ivtv_pcm_hw_free(struct snd_pcm_substream *substream)
262
-{
263
- struct snd_ivtv_card *itvsc = snd_pcm_substream_chip(substream);
264
- unsigned long flags;
265
- unsigned char *dma_area = NULL;
266
-
267
- spin_lock_irqsave(&itvsc->slock, flags);
268
- if (substream->runtime->dma_area) {
269
- dprintk("freeing pcm capture region\n");
270
- dma_area = substream->runtime->dma_area;
271
- substream->runtime->dma_area = NULL;
272
- }
273
- spin_unlock_irqrestore(&itvsc->slock, flags);
274
- vfree(dma_area);
275
-
276
- return 0;
277
-}
278
-
279207 static int snd_ivtv_pcm_prepare(struct snd_pcm_substream *substream)
280208 {
281209 struct snd_ivtv_card *itvsc = snd_pcm_substream_chip(substream);
....@@ -305,24 +233,12 @@
305233 return hwptr_done;
306234 }
307235
308
-static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
309
- unsigned long offset)
310
-{
311
- void *pageptr = subs->runtime->dma_area + offset;
312
-
313
- return vmalloc_to_page(pageptr);
314
-}
315
-
316236 static const struct snd_pcm_ops snd_ivtv_pcm_capture_ops = {
317237 .open = snd_ivtv_pcm_capture_open,
318238 .close = snd_ivtv_pcm_capture_close,
319
- .ioctl = snd_ivtv_pcm_ioctl,
320
- .hw_params = snd_ivtv_pcm_hw_params,
321
- .hw_free = snd_ivtv_pcm_hw_free,
322239 .prepare = snd_ivtv_pcm_prepare,
323240 .trigger = snd_ivtv_pcm_trigger,
324241 .pointer = snd_ivtv_pcm_pointer,
325
- .page = snd_pcm_get_vmalloc_page,
326242 };
327243
328244 int snd_ivtv_pcm_create(struct snd_ivtv_card *itvsc)
....@@ -348,9 +264,10 @@
348264
349265 snd_pcm_set_ops(sp, SNDRV_PCM_STREAM_CAPTURE,
350266 &snd_ivtv_pcm_capture_ops);
267
+ snd_pcm_set_managed_buffer_all(sp, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
351268 sp->info_flags = 0;
352269 sp->private_data = itvsc;
353
- strlcpy(sp->name, itv->card_name, sizeof(sp->name));
270
+ strscpy(sp->name, itv->card_name, sizeof(sp->name));
354271
355272 return 0;
356273