Changeset 679 for GPL/trunk/alsa-kernel/pci/als4000.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/als4000.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * card-als4000.c - driver for Avance Logic ALS4000 based soundcards. … … 6 7 * 7 8 * Framework borrowed from Massimo Piccioni's card-als100.c. 8 *9 *10 * This program is free software; you can redistribute it and/or modify11 * it under the terms of the GNU General Public License as published by12 * the Free Software Foundation; either version 2 of the License, or13 * (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 of17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18 * GNU General Public License for more details.19 20 * You should have received a copy of the GNU General Public License21 * along with this program; if not, write to the Free Software22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA23 9 * 24 10 * NOTES … … 66 52 */ 67 53 68 #include < asm/io.h>54 #include <linux/io.h> 69 55 #include <linux/init.h> 70 56 #include <linux/pci.h> 71 57 #include <linux/gameport.h> 72 #include <linux/module param.h>58 #include <linux/module.h> 73 59 #include <linux/dma-mapping.h> 74 60 #include <sound/core.h> … … 80 66 #include <sound/initval.h> 81 67 68 #ifdef TARGET_OS2 69 #define KBUILD_MODNAME "als4000" 70 #endif 82 71 MODULE_AUTHOR("Bart Hartgers <bart@etpmod.phys.tue.nl>, Andreas Mohr"); 83 72 MODULE_DESCRIPTION("Avance Logic ALS4000"); … … 85 74 MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}"); 86 75 87 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))76 #if IS_REACHABLE(CONFIG_GAMEPORT) 88 77 #define SUPPORT_JOYSTICK 1 89 78 #endif … … 91 80 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 92 81 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 93 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */82 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 94 83 #ifdef SUPPORT_JOYSTICK 95 84 static int joystick_port[SNDRV_CARDS]; … … 103 92 MODULE_PARM_DESC(enable, "Enable ALS4000 soundcard."); 104 93 #ifdef SUPPORT_JOYSTICK 105 module_param_ array(joystick_port, int, NULL, 0444);94 module_param_hw_array(joystick_port, int, ioport, NULL, 0444); 106 95 MODULE_PARM_DESC(joystick_port, "Joystick port address for ALS4000 soundcard. (0 = disabled)"); 107 96 #endif … … 117 106 }; 118 107 119 static DEFINE_PCI_DEVICE_TABLE(snd_als4000_ids)= {108 static const struct pci_device_id snd_als4000_ids[] = { 120 109 { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */ 121 110 { 0, } … … 369 358 #define capture_cmd(chip) (capture_cmd_vals[(chip)->capture_format]) 370 359 371 static int snd_als4000_hw_params(struct snd_pcm_substream *substream,372 struct snd_pcm_hw_params *hw_params)373 {374 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));375 }376 377 static int snd_als4000_hw_free(struct snd_pcm_substream *substream)378 {379 snd_pcm_lib_free_pages(substream);380 return 0;381 }382 383 360 static int snd_als4000_capture_prepare(struct snd_pcm_substream *substream) 384 361 { … … 579 556 ALS4K_IOB_16_ACK_FOR_CR1E); 580 557 581 /* printk(KERN_INFO"als4000: irq 0x%04x 0x%04x\n",558 /* dev_dbg(chip->card->dev, "als4000: irq 0x%04x 0x%04x\n", 582 559 pci_irqstatus, sb_irqstatus); */ 583 560 … … 593 570 /*****************************************************************/ 594 571 595 static struct snd_pcm_hardware snd_als4000_playback =572 static const struct snd_pcm_hardware snd_als4000_playback = 596 573 { 597 574 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 612 589 }; 613 590 614 static struct snd_pcm_hardware snd_als4000_capture =591 static const struct snd_pcm_hardware snd_als4000_capture = 615 592 { 616 593 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 648 625 649 626 chip->playback_substream = NULL; 650 snd_pcm_lib_free_pages(substream);651 627 return 0; 652 628 } … … 667 643 668 644 chip->capture_substream = NULL; 669 snd_pcm_lib_free_pages(substream);670 645 return 0; 671 646 } … … 673 648 /******************************************************************/ 674 649 675 static struct snd_pcm_ops snd_als4000_playback_ops = {650 static const struct snd_pcm_ops snd_als4000_playback_ops = { 676 651 .open = snd_als4000_playback_open, 677 652 .close = snd_als4000_playback_close, 678 .ioctl = snd_pcm_lib_ioctl,679 .hw_params = snd_als4000_hw_params,680 .hw_free = snd_als4000_hw_free,681 653 .prepare = snd_als4000_playback_prepare, 682 654 .trigger = snd_als4000_playback_trigger, … … 684 656 }; 685 657 686 static struct snd_pcm_ops snd_als4000_capture_ops = {658 static const struct snd_pcm_ops snd_als4000_capture_ops = { 687 659 .open = snd_als4000_capture_open, 688 660 .close = snd_als4000_capture_close, 689 .ioctl = snd_pcm_lib_ioctl,690 .hw_params = snd_als4000_hw_params,691 .hw_free = snd_als4000_hw_free,692 661 .prepare = snd_als4000_capture_prepare, 693 662 .trigger = snd_als4000_capture_trigger, … … 695 664 }; 696 665 697 static int __devinitsnd_als4000_pcm(struct snd_sb *chip, int device)666 static int snd_als4000_pcm(struct snd_sb *chip, int device) 698 667 { 699 668 struct snd_pcm *pcm; … … 708 677 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_als4000_capture_ops); 709 678 710 snd_pcm_ lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),711 679 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 680 &chip->pci->dev, 64*1024, 64*1024); 712 681 713 682 chip->pcm = pcm; … … 771 740 772 741 #ifdef SUPPORT_JOYSTICK 773 static int __devinitsnd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev)742 static int snd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev) 774 743 { 775 744 struct gameport *gp; … … 792 761 793 762 if (!r) { 794 printk(KERN_WARNING "als4000:cannot reserve joystick ports\n");763 dev_warn(&acard->pci->dev, "cannot reserve joystick ports\n"); 795 764 return -EBUSY; 796 765 } … … 798 767 acard->gameport = gp = gameport_allocate_port(); 799 768 if (!gp) { 800 printk(KERN_ERR "als4000:cannot allocate memory for gameport\n");769 dev_err(&acard->pci->dev, "cannot allocate memory for gameport\n"); 801 770 release_and_free_resource(r); 802 771 return -ENOMEM; … … 848 817 } 849 818 850 static int __devinitsnd_card_als4000_probe(struct pci_dev *pci,851 819 static int snd_card_als4000_probe(struct pci_dev *pci, 820 const struct pci_device_id *pci_id) 852 821 { 853 822 static int dev; … … 872 841 } 873 842 /* check, if we can restrict PCI DMA transfers to 24 bits */ 874 if ( pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||875 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {876 snd_printk(KERN_ERR"architecture does not support 24bit PCI busmaster DMA\n");843 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 || 844 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) { 845 dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n"); 877 846 pci_disable_device(pci); 878 847 return -ENXIO; … … 889 858 pci_set_master(pci); 890 859 891 err = snd_card_ create(index[dev], id[dev], THIS_MODULE,892 893 860 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 861 sizeof(*acard) /* private_data: acard */, 862 &card); 894 863 if (err < 0) { 895 864 pci_release_regions(pci); … … 921 890 chip->pci = pci; 922 891 chip->alt_port = iobase; 923 snd_card_set_dev(card, &pci->dev);924 892 925 893 snd_als4000_configure(chip); … … 932 900 if ((err = snd_mpu401_uart_new( card, 0, MPU401_HW_ALS4000, 933 901 iobase + ALS4K_IOB_30_MIDI_DATA, 934 MPU401_INFO_INTEGRATED, 935 pci->irq, 0, &chip->rmidi)) < 0) { 936 printk(KERN_ERR "als4000: no MPU-401 device at 0x%lx?\n", 902 MPU401_INFO_INTEGRATED | 903 MPU401_INFO_IRQ_HOOK, 904 -1, &chip->rmidi)) < 0) { 905 dev_err(&pci->dev, "no MPU-401 device at 0x%lx?\n", 937 906 iobase + ALS4K_IOB_30_MIDI_DATA); 938 907 goto out_err; … … 955 924 iobase + ALS4K_IOB_12_ADLIB_ADDR2, 956 925 OPL3_HW_AUTO, 1, &opl3) < 0) { 957 printk(KERN_ERR "als4000:no OPL device at 0x%lx-0x%lx?\n",926 dev_err(&pci->dev, "no OPL device at 0x%lx-0x%lx?\n", 958 927 iobase + ALS4K_IOB_10_ADLIB_ADDR0, 959 928 iobase + ALS4K_IOB_12_ADLIB_ADDR2); … … 981 950 } 982 951 983 static void __devexitsnd_card_als4000_remove(struct pci_dev *pci)952 static void snd_card_als4000_remove(struct pci_dev *pci) 984 953 { 985 954 snd_card_free(pci_get_drvdata(pci)); 986 pci_set_drvdata(pci, NULL); 987 } 988 989 #ifdef CONFIG_PM 990 static int snd_als4000_suspend(struct pci_dev *pci, pm_message_t state) 991 { 992 struct snd_card *card = pci_get_drvdata(pci); 955 } 956 957 #ifdef CONFIG_PM_SLEEP 958 static int snd_als4000_suspend(struct device *dev) 959 { 960 struct snd_card *card = dev_get_drvdata(dev); 993 961 struct snd_card_als4000 *acard = card->private_data; 994 962 struct snd_sb *chip = acard->chip; … … 996 964 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 997 965 998 snd_pcm_suspend_all(chip->pcm);999 966 snd_sbmixer_suspend(chip); 1000 1001 pci_disable_device(pci);1002 pci_save_state(pci);1003 pci_set_power_state(pci, pci_choose_state(pci, state));1004 967 return 0; 1005 968 } 1006 969 1007 static int snd_als4000_resume(struct pci_dev *pci)1008 { 1009 struct snd_card *card = pci_get_drvdata(pci);970 static int snd_als4000_resume(struct device *dev) 971 { 972 struct snd_card *card = dev_get_drvdata(dev); 1010 973 struct snd_card_als4000 *acard = card->private_data; 1011 974 struct snd_sb *chip = acard->chip; 1012 1013 pci_set_power_state(pci, PCI_D0);1014 pci_restore_state(pci);1015 if (pci_enable_device(pci) < 0) {1016 printk(KERN_ERR "als4000: pci_enable_device failed, "1017 "disabling device\n");1018 snd_card_disconnect(card);1019 return -EIO;1020 }1021 pci_set_master(pci);1022 975 1023 976 snd_als4000_configure(chip); … … 1033 986 return 0; 1034 987 } 1035 #endif /* CONFIG_PM */ 1036 1037 1038 static struct pci_driver driver = { 1039 .name = "ALS4000", 988 989 static SIMPLE_DEV_PM_OPS(snd_als4000_pm, snd_als4000_suspend, snd_als4000_resume); 990 #define SND_ALS4000_PM_OPS &snd_als4000_pm 991 #else 992 #define SND_ALS4000_PM_OPS NULL 993 #endif /* CONFIG_PM_SLEEP */ 994 995 static struct pci_driver als4000_driver = { 996 .name = KBUILD_MODNAME, 1040 997 .id_table = snd_als4000_ids, 1041 998 .probe = snd_card_als4000_probe, 1042 .remove = __devexit_p(snd_card_als4000_remove), 1043 #ifdef CONFIG_PM 1044 .suspend = snd_als4000_suspend, 1045 .resume = snd_als4000_resume, 1046 #endif 1047 }; 1048 1049 static int __init alsa_card_als4000_init(void) 1050 { 1051 return pci_register_driver(&driver); 1052 } 1053 1054 static void __exit alsa_card_als4000_exit(void) 1055 { 1056 pci_unregister_driver(&driver); 1057 } 1058 1059 module_init(alsa_card_als4000_init) 1060 module_exit(alsa_card_als4000_exit) 999 .remove = snd_card_als4000_remove, 1000 .driver = { 1001 .pm = SND_ALS4000_PM_OPS, 1002 }, 1003 }; 1004 1005 module_pci_driver(als4000_driver);
Note:
See TracChangeset
for help on using the changeset viewer.