forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/cx88/cx88-alsa.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Support for audio capture
34 * PCI function #1 of the cx2388x.
....@@ -7,16 +8,6 @@
78 * (c) 2005 Mauro Carvalho Chehab <mchehab@kernel.org>
89 * Based on a dummy cx88 module by Gerd Knorr <kraxel@bytesex.org>
910 * Based on dummy.c by Jaroslav Kysela <perex@perex.cz>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
2011 */
2112
2213 #include "cx88.h"
....@@ -51,12 +42,12 @@
5142 */
5243
5344 struct cx88_audio_buffer {
54
- unsigned int bpl;
55
- struct cx88_riscmem risc;
45
+ unsigned int bpl;
46
+ struct cx88_riscmem risc;
5647 void *vaddr;
5748 struct scatterlist *sglist;
5849 int sglen;
59
- int nr_pages;
50
+ unsigned long nr_pages;
6051 };
6152
6253 struct cx88_audio_dev {
....@@ -104,7 +95,7 @@
10495 MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards");
10596 MODULE_AUTHOR("Ricardo Cerqueira");
10697 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@kernel.org>");
107
-MODULE_LICENSE("GPL");
98
+MODULE_LICENSE("GPL v2");
10899 MODULE_VERSION(CX88_VERSION);
109100
110101 MODULE_SUPPORTED_DEVICE("{{Conexant,23881},{{Conexant,23882},{{Conexant,23883}");
....@@ -280,7 +271,8 @@
280271 return IRQ_RETVAL(handled);
281272 }
282273
283
-static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages)
274
+static int cx88_alsa_dma_init(struct cx88_audio_dev *chip,
275
+ unsigned long nr_pages)
284276 {
285277 struct cx88_audio_buffer *buf = chip->buf;
286278 struct page *pg;
....@@ -288,11 +280,11 @@
288280
289281 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
290282 if (!buf->vaddr) {
291
- dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
283
+ dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages);
292284 return -ENOMEM;
293285 }
294286
295
- dprintk(1, "vmalloc is at addr %p, size=%d\n",
287
+ dprintk(1, "vmalloc is at addr %p, size=%lu\n",
296288 buf->vaddr, nr_pages << PAGE_SHIFT);
297289
298290 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
....@@ -325,7 +317,7 @@
325317 struct cx88_audio_buffer *buf = dev->buf;
326318
327319 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
328
- buf->nr_pages, PCI_DMA_FROMDEVICE);
320
+ buf->nr_pages, DMA_FROM_DEVICE);
329321
330322 if (buf->sglen == 0) {
331323 pr_warn("%s: cx88_alsa_map_sg failed\n", __func__);
....@@ -341,8 +333,8 @@
341333 if (!buf->sglen)
342334 return 0;
343335
344
- dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen,
345
- PCI_DMA_FROMDEVICE);
336
+ dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages,
337
+ DMA_FROM_DEVICE);
346338 buf->sglen = 0;
347339 return 0;
348340 }
....@@ -594,7 +586,6 @@
594586 static const struct snd_pcm_ops snd_cx88_pcm_ops = {
595587 .open = snd_cx88_pcm_open,
596588 .close = snd_cx88_close,
597
- .ioctl = snd_pcm_lib_ioctl,
598589 .hw_params = snd_cx88_hw_params,
599590 .hw_free = snd_cx88_hw_free,
600591 .prepare = snd_cx88_prepare,
....@@ -616,7 +607,7 @@
616607 if (err < 0)
617608 return err;
618609 pcm->private_data = chip;
619
- strcpy(pcm->name, name);
610
+ strscpy(pcm->name, name, sizeof(pcm->name));
620611 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx88_pcm_ops);
621612
622613 return 0;
....@@ -968,12 +959,12 @@
968959 goto error;
969960 }
970961
971
- strcpy(card->driver, "CX88x");
962
+ strscpy(card->driver, "CX88x", sizeof(card->driver));
972963 sprintf(card->shortname, "Conexant CX%x", pci->device);
973964 sprintf(card->longname, "%s at %#llx",
974965 card->shortname,
975966 (unsigned long long)pci_resource_start(pci, 0));
976
- strcpy(card->mixername, "CX88");
967
+ strscpy(card->mixername, "CX88", sizeof(card->mixername));
977968
978969 dprintk(0, "%s/%i: ALSA support for cx2388x boards\n",
979970 card->driver, devno);