Changeset 679 for GPL/trunk/alsa-kernel/pci/bt87x.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/bt87x.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * bt87x.c - Brooktree Bt878/Bt879 driver for ALSA … … 5 6 * 6 7 * based on btaudio.c by Gerd Knorr <kraxel@bytesex.org> 7 *8 *9 * This driver is free software; you can redistribute it and/or modify10 * it under the terms of the GNU General Public License as published by11 * the Free Software Foundation; either version 2 of the License, or12 * (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 of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU General Public License for more details.18 *19 * You should have received a copy of the GNU General Public License20 * along with this program; if not, write to the Free Software21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA22 8 */ 9 10 #ifdef TARGET_OS2 11 #define KBUILD_MODNAME "bt87x" 12 #endif 23 13 24 14 #include <linux/init.h> … … 26 16 #include <linux/pci.h> 27 17 #include <linux/slab.h> 28 #include <linux/module param.h>18 #include <linux/module.h> 29 19 #include <linux/bitops.h> 30 #include < asm/io.h>20 #include <linux/io.h> 31 21 #include <sound/core.h> 32 22 #include <sound/pcm.h> … … 48 38 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 49 39 #endif 50 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */40 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 51 41 static int digital_rate[SNDRV_CARDS]; /* digital input rate */ 52 static int load_all; /* allow to load the non-whitelisted cards*/42 static bool load_all; /* allow to load cards not the allowlist */ 53 43 54 44 module_param_array(index, int, NULL, 0444); … … 61 51 MODULE_PARM_DESC(digital_rate, "Digital input rate for Bt87x soundcard"); 62 52 module_param(load_all, bool, 0444); 63 MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards");53 MODULE_PARM_DESC(load_all, "Allow to load cards not on the allowlist"); 64 54 65 55 … … 170 160 }; 171 161 172 static __devinitdatastruct snd_bt87x_board snd_bt87x_boards[] = {162 static const struct snd_bt87x_board snd_bt87x_boards[] = { 173 163 [SND_BT87X_BOARD_UNKNOWN] = { 174 164 .dig_rate = 32000, /* just a guess */ … … 234 224 { 235 225 unsigned int i, offset; 236 u32 *risc;226 __le32 *risc; 237 227 238 228 if (chip->dma_risc.area == NULL) { 239 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),229 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, 240 230 PAGE_ALIGN(MAX_RISC_SIZE), &chip->dma_risc) < 0) 241 231 return -ENOMEM; 242 232 } 243 risc = ( u32 *)chip->dma_risc.area;233 risc = (__le32 *)chip->dma_risc.area; 244 234 offset = 0; 245 235 *risc++ = cpu_to_le32(RISC_SYNC | RISC_SYNC_FM1); … … 291 281 static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status) 292 282 { 293 u16 pci_status; 294 295 pci_read_config_word(chip->pci, PCI_STATUS, &pci_status); 296 pci_status &= PCI_STATUS_PARITY | PCI_STATUS_SIG_TARGET_ABORT | 297 PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_REC_MASTER_ABORT | 298 PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY; 299 pci_write_config_word(chip->pci, PCI_STATUS, pci_status); 283 int pci_status = pci_status_get_and_clear_errors(chip->pci); 284 300 285 if (pci_status != PCI_STATUS_DETECTED_PARITY) 301 snd_printk(KERN_ERR "Aieee - PCI error! status %#08x, PCI status %#04x\n", 286 dev_err(chip->card->dev, 287 "Aieee - PCI error! status %#08x, PCI status %#04x\n", 302 288 status & ERROR_INTERRUPTS, pci_status); 303 289 else { 304 snd_printk(KERN_ERR "Aieee - PCI parity error detected!\n"); 290 dev_err(chip->card->dev, 291 "Aieee - PCI parity error detected!\n"); 305 292 /* error 'handling' similar to aic7xxx_pci.c: */ 306 293 chip->pci_parity_errors++; 307 294 if (chip->pci_parity_errors > 20) { 308 snd_printk(KERN_ERR "Too many PCI parity errors observed.\n"); 309 snd_printk(KERN_ERR "Some device on this bus is generating bad parity.\n"); 310 snd_printk(KERN_ERR "This is an error *observed by*, not *generated by*, this card.\n"); 311 snd_printk(KERN_ERR "PCI parity error checking has been disabled.\n"); 295 dev_err(chip->card->dev, 296 "Too many PCI parity errors observed.\n"); 297 dev_err(chip->card->dev, 298 "Some device on this bus is generating bad parity.\n"); 299 dev_err(chip->card->dev, 300 "This is an error *observed by*, not *generated by*, this card.\n"); 301 dev_err(chip->card->dev, 302 "PCI parity error checking has been disabled.\n"); 312 303 chip->interrupt_mask &= ~(INT_PPERR | INT_RIPERR); 313 304 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask); … … 329 320 if (irq_status & ERROR_INTERRUPTS) { 330 321 if (irq_status & (INT_FBUS | INT_FTRGT)) 331 snd_printk(KERN_WARNING "FIFO overrun, status %#08x\n", status); 322 dev_warn(chip->card->dev, 323 "FIFO overrun, status %#08x\n", status); 332 324 if (irq_status & INT_OCERR) 333 snd_printk(KERN_ERR "internal RISC error, status %#08x\n", status); 325 dev_err(chip->card->dev, 326 "internal RISC error, status %#08x\n", status); 334 327 if (irq_status & (INT_PPERR | INT_RIPERR | INT_PABORT)) 335 328 snd_bt87x_pci_error(chip, irq_status); … … 351 344 } 352 345 353 static struct snd_pcm_hardware snd_bt87x_digital_hw = {346 static const struct snd_pcm_hardware snd_bt87x_digital_hw = { 354 347 .info = SNDRV_PCM_INFO_MMAP | 355 348 SNDRV_PCM_INFO_INTERLEAVED | … … 368 361 }; 369 362 370 static struct snd_pcm_hardware snd_bt87x_analog_hw = {363 static const struct snd_pcm_hardware snd_bt87x_analog_hw = { 371 364 .info = SNDRV_PCM_INFO_MMAP | 372 365 SNDRV_PCM_INFO_INTERLEAVED | … … 399 392 static int snd_bt87x_set_analog_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) 400 393 { 401 static struct snd_ratnum analog_clock = {394 static const struct snd_ratnum analog_clock = { 402 395 .num = ANALOG_CLOCK, 403 396 .den_min = CLOCK_DIV_MIN, … … 405 398 .den_step = 1 406 399 }; 407 static struct snd_pcm_hw_constraint_ratnums constraint_rates = {400 static const struct snd_pcm_hw_constraint_ratnums constraint_rates = { 408 401 .nrats = 1, 409 402 .rats = &analog_clock … … 441 434 _error: 442 435 clear_bit(0, &chip->opened); 443 smp_mb__after_ clear_bit();436 smp_mb__after_atomic(); 444 437 return err; 445 438 } … … 456 449 chip->substream = NULL; 457 450 clear_bit(0, &chip->opened); 458 smp_mb__after_ clear_bit();451 smp_mb__after_atomic(); 459 452 return 0; 460 453 } … … 464 457 { 465 458 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); 466 int err; 467 468 err = snd_pcm_lib_malloc_pages(substream, 469 params_buffer_bytes(hw_params)); 470 if (err < 0) 471 return err; 459 472 460 return snd_bt87x_create_risc(chip, substream, 473 461 params_periods(hw_params), … … 480 468 481 469 snd_bt87x_free_risc(chip); 482 snd_pcm_lib_free_pages(substream);483 470 return 0; 484 471 } … … 548 535 } 549 536 550 static struct snd_pcm_ops snd_bt87x_pcm_ops = {537 static const struct snd_pcm_ops snd_bt87x_pcm_ops = { 551 538 .open = snd_bt87x_pcm_open, 552 539 .close = snd_bt87x_close, 553 .ioctl = snd_pcm_lib_ioctl,554 540 .hw_params = snd_bt87x_hw_params, 555 541 .hw_free = snd_bt87x_hw_free, … … 557 543 .trigger = snd_bt87x_trigger, 558 544 .pointer = snd_bt87x_pointer, 559 .page = snd_pcm_sgbuf_ops_page,560 545 }; 561 546 … … 596 581 } 597 582 598 static struct snd_kcontrol_new snd_bt87x_capture_volume = {583 static const struct snd_kcontrol_new snd_bt87x_capture_volume = { 599 584 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 600 585 .name = "Capture Volume", … … 632 617 } 633 618 634 static struct snd_kcontrol_new snd_bt87x_capture_boost = {619 static const struct snd_kcontrol_new snd_bt87x_capture_boost = { 635 620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 636 621 .name = "Capture Boost", … … 674 659 } 675 660 676 static struct snd_kcontrol_new snd_bt87x_capture_source = {661 static const struct snd_kcontrol_new snd_bt87x_capture_source = { 677 662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 678 663 .name = "Capture Source", … … 688 673 if (chip->irq >= 0) 689 674 free_irq(chip->irq, chip); 690 if (chip->mmio) 691 iounmap(chip->mmio); 675 iounmap(chip->mmio); 692 676 pci_release_regions(chip->pci); 693 677 pci_disable_device(chip->pci); … … 702 686 } 703 687 704 static int __devinitsnd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name)688 static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name) 705 689 { 706 690 int err; … … 713 697 strcpy(pcm->name, name); 714 698 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); 715 return snd_pcm_lib_preallocate_pages_for_all(pcm,716 SNDRV_DMA_TYPE_DEV_SG,717 snd_dma_pci_data(chip->pci),718 128 * 1024,719 ALIGN(255 * 4092, 1024));720 } 721 722 static int __devinitsnd_bt87x_create(struct snd_card *card,723 724 699 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 700 &chip->pci->dev, 701 128 * 1024, 702 ALIGN(255 * 4092, 1024)); 703 return 0; 704 } 705 706 static int snd_bt87x_create(struct snd_card *card, 707 struct pci_dev *pci, 708 struct snd_bt87x **rchip) 725 709 { 726 710 struct snd_bt87x *chip; 727 711 int err; 728 static struct snd_device_ops ops = {712 static const struct snd_device_ops ops = { 729 713 .dev_free = snd_bt87x_dev_free 730 714 }; … … 753 737 chip->mmio = pci_ioremap_bar(pci, 0); 754 738 if (!chip->mmio) { 755 snd_printk(KERN_ERR"cannot remap io memory\n");739 dev_err(card->dev, "cannot remap io memory\n"); 756 740 err = -ENOMEM; 757 741 goto fail; … … 766 750 767 751 err = request_irq(pci->irq, snd_bt87x_interrupt, IRQF_SHARED, 768 "Bt87x audio", chip);752 KBUILD_MODNAME, chip); 769 753 if (err < 0) { 770 snd_printk(KERN_ERR"cannot grab irq %d\n", pci->irq);754 dev_err(card->dev, "cannot grab irq %d\n", pci->irq); 771 755 goto fail; 772 756 } 773 757 chip->irq = pci->irq; 758 card->sync_irq = chip->irq; 774 759 pci_set_master(pci); 775 synchronize_irq(chip->irq);776 760 777 761 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); … … 779 763 goto fail; 780 764 781 snd_card_set_dev(card, &pci->dev);782 765 *rchip = chip; 783 766 return 0; … … 795 778 /* driver_data is the card id for that device */ 796 779 797 static DEFINE_PCI_DEVICE_TABLE(snd_bt87x_ids)= {780 static const struct pci_device_id snd_bt87x_ids[] = { 798 781 /* Hauppauge WinTV series */ 799 782 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0x13eb, GENERIC), … … 828 811 static struct { 829 812 unsigned short subvendor, subdevice; 830 } blacklist[] __devinitdata= {813 } denylist[] = { 831 814 {0x0071, 0x0101}, /* Nebula Electronics DigiTV */ 832 815 {0x11bd, 0x001c}, /* Pinnacle PCTV Sat */ … … 844 827 static struct pci_driver driver; 845 828 846 /* return the id of the card, or a negative value if it's blacklisted*/847 static int __devinitsnd_bt87x_detect_card(struct pci_dev *pci)829 /* return the id of the card, or a negative value if it's on the denylist */ 830 static int snd_bt87x_detect_card(struct pci_dev *pci) 848 831 { 849 832 int i; 850 833 const struct pci_device_id *supported; 851 #ifdef TARGET_OS2 852 u16 subsystem_vendor, subsystem_device; 853 #endif 854 855 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13) 834 856 835 supported = pci_match_id(snd_bt87x_ids, pci); 857 #else858 supported = pci_match_device(snd_bt87x_ids, pci);859 #endif860 836 if (supported && supported->driver_data > 0) 861 837 return supported->driver_data; 862 838 863 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 0) 864 subsystem_vendor = pci->subsystem_vendor; 865 subsystem_device = pci->subsystem_device; 866 #else 867 pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 868 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); 869 #endif 870 for (i = 0; i < ARRAY_SIZE(blacklist); ++i) 871 #ifndef TARGET_OS2 872 if (blacklist[i].subvendor == pci->subsystem_vendor && 873 blacklist[i].subdevice == pci->subsystem_device) { 874 #else 875 if (blacklist[i].subvendor == subsystem_vendor && 876 blacklist[i].subdevice == subsystem_device) { 877 #endif 878 snd_printdd(KERN_INFO "card %#04x-%#04x:%#04x has no audio\n", 879 #ifndef TARGET_OS2 839 for (i = 0; i < ARRAY_SIZE(denylist); ++i) 840 if (denylist[i].subvendor == pci->subsystem_vendor && 841 denylist[i].subdevice == pci->subsystem_device) { 842 dev_dbg(&pci->dev, 843 "card %#04x-%#04x:%#04x has no audio\n", 880 844 pci->device, pci->subsystem_vendor, pci->subsystem_device); 881 #else882 pci->device, subsystem_vendor, subsystem_device);883 #endif884 845 return -EBUSY; 885 846 } 886 847 887 snd_printk(KERN_INFO "unknown card %#04x-%#04x:%#04x\n", 888 #ifndef TARGET_OS2 848 dev_info(&pci->dev, "unknown card %#04x-%#04x:%#04x\n", 889 849 pci->device, pci->subsystem_vendor, pci->subsystem_device); 890 #else 891 pci->device, subsystem_vendor, subsystem_device); 892 #endif 893 snd_printk(KERN_DEBUG "please mail id, board name, and, " 850 dev_info(&pci->dev, "please mail id, board name, and, " 894 851 "if it works, the correct digital_rate option to " 895 852 "<alsa-devel@alsa-project.org>\n"); … … 897 854 } 898 855 899 static int __devinitsnd_bt87x_probe(struct pci_dev *pci,900 856 static int snd_bt87x_probe(struct pci_dev *pci, 857 const struct pci_device_id *pci_id) 901 858 { 902 859 static int dev; … … 921 878 } 922 879 923 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 880 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 881 0, &card); 924 882 if (err < 0) 925 883 return err; … … 958 916 goto _error; 959 917 } 960 snd_printk(KERN_INFO"bt87x%d: Using board %d, %sanalog, %sdigital "918 dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital " 961 919 "(rate %d Hz)\n", dev, boardid, 962 920 chip->board.no_analog ? "no " : "", … … 983 941 } 984 942 985 static void __devexitsnd_bt87x_remove(struct pci_dev *pci)943 static void snd_bt87x_remove(struct pci_dev *pci) 986 944 { 987 945 snd_card_free(pci_get_drvdata(pci)); 988 pci_set_drvdata(pci, NULL);989 946 } 990 947 991 948 /* default entries for all Bt87x cards - it's not exported */ 992 949 /* driver_data is set to 0 to call detection */ 993 static DEFINE_PCI_DEVICE_TABLE(snd_bt87x_default_ids)= {950 static const struct pci_device_id snd_bt87x_default_ids[] = { 994 951 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), 995 952 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), … … 998 955 999 956 static struct pci_driver driver = { 1000 .name = "Bt87x",957 .name = KBUILD_MODNAME, 1001 958 .id_table = snd_bt87x_ids, 1002 959 .probe = snd_bt87x_probe, 1003 .remove = __devexit_p(snd_bt87x_remove),960 .remove = snd_bt87x_remove, 1004 961 }; 1005 962
Note:
See TracChangeset
for help on using the changeset viewer.