hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/sound/pci/bt87x.c
....@@ -1,24 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * bt87x.c - Brooktree Bt878/Bt879 driver for ALSA
34 *
45 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
56 *
67 * based on btaudio.c by Gerd Knorr <kraxel@bytesex.org>
7
- *
8
- *
9
- * This driver 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 driver 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.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
228 */
239
2410 #include <linux/init.h>
....@@ -44,7 +30,7 @@
4430 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
4531 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
4632 static int digital_rate[SNDRV_CARDS]; /* digital input rate */
47
-static bool load_all; /* allow to load the non-whitelisted cards */
33
+static bool load_all; /* allow to load cards not the allowlist */
4834
4935 module_param_array(index, int, NULL, 0444);
5036 MODULE_PARM_DESC(index, "Index value for Bt87x soundcard");
....@@ -55,7 +41,7 @@
5541 module_param_array(digital_rate, int, NULL, 0444);
5642 MODULE_PARM_DESC(digital_rate, "Digital input rate for Bt87x soundcard");
5743 module_param(load_all, bool, 0444);
58
-MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards");
44
+MODULE_PARM_DESC(load_all, "Allow to load cards not on the allowlist");
5945
6046
6147 /* register offsets */
....@@ -164,7 +150,7 @@
164150 unsigned no_digital:1; /* No digital input */
165151 };
166152
167
-static struct snd_bt87x_board snd_bt87x_boards[] = {
153
+static const struct snd_bt87x_board snd_bt87x_boards[] = {
168154 [SND_BT87X_BOARD_UNKNOWN] = {
169155 .dig_rate = 32000, /* just a guess */
170156 },
....@@ -231,7 +217,7 @@
231217 __le32 *risc;
232218
233219 if (chip->dma_risc.area == NULL) {
234
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
220
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
235221 PAGE_ALIGN(MAX_RISC_SIZE), &chip->dma_risc) < 0)
236222 return -ENOMEM;
237223 }
....@@ -285,13 +271,8 @@
285271
286272 static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status)
287273 {
288
- u16 pci_status;
274
+ int pci_status = pci_status_get_and_clear_errors(chip->pci);
289275
290
- pci_read_config_word(chip->pci, PCI_STATUS, &pci_status);
291
- pci_status &= PCI_STATUS_PARITY | PCI_STATUS_SIG_TARGET_ABORT |
292
- PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_REC_MASTER_ABORT |
293
- PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY;
294
- pci_write_config_word(chip->pci, PCI_STATUS, pci_status);
295276 if (pci_status != PCI_STATUS_DETECTED_PARITY)
296277 dev_err(chip->card->dev,
297278 "Aieee - PCI error! status %#08x, PCI status %#04x\n",
....@@ -466,12 +447,7 @@
466447 struct snd_pcm_hw_params *hw_params)
467448 {
468449 struct snd_bt87x *chip = snd_pcm_substream_chip(substream);
469
- int err;
470450
471
- err = snd_pcm_lib_malloc_pages(substream,
472
- params_buffer_bytes(hw_params));
473
- if (err < 0)
474
- return err;
475451 return snd_bt87x_create_risc(chip, substream,
476452 params_periods(hw_params),
477453 params_period_bytes(hw_params));
....@@ -482,7 +458,6 @@
482458 struct snd_bt87x *chip = snd_pcm_substream_chip(substream);
483459
484460 snd_bt87x_free_risc(chip);
485
- snd_pcm_lib_free_pages(substream);
486461 return 0;
487462 }
488463
....@@ -553,13 +528,11 @@
553528 static const struct snd_pcm_ops snd_bt87x_pcm_ops = {
554529 .open = snd_bt87x_pcm_open,
555530 .close = snd_bt87x_close,
556
- .ioctl = snd_pcm_lib_ioctl,
557531 .hw_params = snd_bt87x_hw_params,
558532 .hw_free = snd_bt87x_hw_free,
559533 .prepare = snd_bt87x_prepare,
560534 .trigger = snd_bt87x_trigger,
561535 .pointer = snd_bt87x_pointer,
562
- .page = snd_pcm_sgbuf_ops_page,
563536 };
564537
565538 static int snd_bt87x_capture_volume_info(struct snd_kcontrol *kcontrol,
....@@ -714,11 +687,11 @@
714687 pcm->private_data = chip;
715688 strcpy(pcm->name, name);
716689 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops);
717
- return snd_pcm_lib_preallocate_pages_for_all(pcm,
718
- SNDRV_DMA_TYPE_DEV_SG,
719
- snd_dma_pci_data(chip->pci),
720
- 128 * 1024,
721
- ALIGN(255 * 4092, 1024));
690
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
691
+ &chip->pci->dev,
692
+ 128 * 1024,
693
+ ALIGN(255 * 4092, 1024));
694
+ return 0;
722695 }
723696
724697 static int snd_bt87x_create(struct snd_card *card,
....@@ -727,7 +700,7 @@
727700 {
728701 struct snd_bt87x *chip;
729702 int err;
730
- static struct snd_device_ops ops = {
703
+ static const struct snd_device_ops ops = {
731704 .dev_free = snd_bt87x_dev_free
732705 };
733706
....@@ -773,8 +746,8 @@
773746 goto fail;
774747 }
775748 chip->irq = pci->irq;
749
+ card->sync_irq = chip->irq;
776750 pci_set_master(pci);
777
- synchronize_irq(chip->irq);
778751
779752 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
780753 if (err < 0)
....@@ -828,7 +801,7 @@
828801 * (DVB cards use the audio function to transfer MPEG data) */
829802 static struct {
830803 unsigned short subvendor, subdevice;
831
-} blacklist[] = {
804
+} denylist[] = {
832805 {0x0071, 0x0101}, /* Nebula Electronics DigiTV */
833806 {0x11bd, 0x001c}, /* Pinnacle PCTV Sat */
834807 {0x11bd, 0x0026}, /* Pinnacle PCTV SAT CI */
....@@ -844,7 +817,7 @@
844817
845818 static struct pci_driver driver;
846819
847
-/* return the id of the card, or a negative value if it's blacklisted */
820
+/* return the id of the card, or a negative value if it's on the denylist */
848821 static int snd_bt87x_detect_card(struct pci_dev *pci)
849822 {
850823 int i;
....@@ -854,9 +827,9 @@
854827 if (supported && supported->driver_data > 0)
855828 return supported->driver_data;
856829
857
- for (i = 0; i < ARRAY_SIZE(blacklist); ++i)
858
- if (blacklist[i].subvendor == pci->subsystem_vendor &&
859
- blacklist[i].subdevice == pci->subsystem_device) {
830
+ for (i = 0; i < ARRAY_SIZE(denylist); ++i)
831
+ if (denylist[i].subvendor == pci->subsystem_vendor &&
832
+ denylist[i].subdevice == pci->subsystem_device) {
860833 dev_dbg(&pci->dev,
861834 "card %#04x-%#04x:%#04x has no audio\n",
862835 pci->device, pci->subsystem_vendor, pci->subsystem_device);