forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/media/pci/cx23885/cx23885-alsa.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * Support for CX23885 analog audio capture
....@@ -5,16 +6,6 @@
56 * (c) 2008 Mijhail Moreyra <mijhail.moreyra@gmail.com>
67 * Adapted from cx88-alsa.c
78 * (c) 2009 Steven Toth <stoth@kernellabs.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
189 */
1910
2011 #include "cx23885.h"
....@@ -59,7 +50,7 @@
5950 MODULE_PARM_DESC(audio_debug, "enable debug messages [analog audio]");
6051
6152 /****************************************************************************
62
- Board specific funtions
53
+ Board specific functions
6354 ****************************************************************************/
6455
6556 /* Constants taken from cx88-reg.h */
....@@ -77,7 +68,8 @@
7768 #define AUD_INT_MCHG_IRQ (1 << 21)
7869 #define GP_COUNT_CONTROL_RESET 0x3
7970
80
-static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, int nr_pages)
71
+static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip,
72
+ unsigned long nr_pages)
8173 {
8274 struct cx23885_audio_buffer *buf = chip->buf;
8375 struct page *pg;
....@@ -85,11 +77,11 @@
8577
8678 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
8779 if (NULL == buf->vaddr) {
88
- dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
80
+ dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages);
8981 return -ENOMEM;
9082 }
9183
92
- dprintk(1, "vmalloc is at addr %p, size=%d\n",
84
+ dprintk(1, "vmalloc is at addr %p, size=%lu\n",
9385 buf->vaddr, nr_pages << PAGE_SHIFT);
9486
9587 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
....@@ -122,7 +114,7 @@
122114 struct cx23885_audio_buffer *buf = dev->buf;
123115
124116 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
125
- buf->nr_pages, PCI_DMA_FROMDEVICE);
117
+ buf->nr_pages, DMA_FROM_DEVICE);
126118
127119 if (0 == buf->sglen) {
128120 pr_warn("%s: cx23885_alsa_map_sg failed\n", __func__);
....@@ -138,7 +130,7 @@
138130 if (!buf->sglen)
139131 return 0;
140132
141
- dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE);
133
+ dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, DMA_FROM_DEVICE);
142134 buf->sglen = 0;
143135 return 0;
144136 }
....@@ -504,7 +496,6 @@
504496 static const struct snd_pcm_ops snd_cx23885_pcm_ops = {
505497 .open = snd_cx23885_pcm_open,
506498 .close = snd_cx23885_close,
507
- .ioctl = snd_pcm_lib_ioctl,
508499 .hw_params = snd_cx23885_hw_params,
509500 .hw_free = snd_cx23885_hw_free,
510501 .prepare = snd_cx23885_prepare,
....@@ -526,7 +517,7 @@
526517 if (err < 0)
527518 return err;
528519 pcm->private_data = chip;
529
- strcpy(pcm->name, name);
520
+ strscpy(pcm->name, name, sizeof(pcm->name));
530521 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx23885_pcm_ops);
531522
532523 return 0;
....@@ -571,7 +562,7 @@
571562 if (err < 0)
572563 goto error;
573564
574
- strcpy(card->driver, "CX23885");
565
+ strscpy(card->driver, "CX23885", sizeof(card->driver));
575566 sprintf(card->shortname, "Conexant CX23885");
576567 sprintf(card->longname, "%s at %s", card->shortname, dev->name);
577568