Changeset 615 for GPL/branches/uniaud32-next/alsa-kernel/pci/cmipci.c
- Timestamp:
- Jan 1, 2021, 5:31:48 AM (5 years ago)
- Location:
- GPL/branches/uniaud32-next
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/alsa-kernel/pci/cmipci.c
r612 r615 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for C-Media CMI8338 and 8738 PCI soundcards. 3 4 * Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de> 4 *5 * This program is free software; you can redistribute it and/or modify6 * it under the terms of the GNU General Public License as published by7 * the Free Software Foundation; either version 2 of the License, or8 * (at your option) any later version.9 *10 * This program is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU General Public License16 * along with this program; if not, write to the Free Software17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18 5 */ 19 6 … … 21 8 /* #define USE_VAR48KRATE */ 22 9 23 #ifdef TARGET_OS2 24 #define KBUILD_MODNAME "cmipci" 25 #endif 26 27 #include <asm/io.h> 10 #include <linux/io.h> 28 11 #include <linux/delay.h> 29 12 #include <linux/interrupt.h> … … 45 28 #include <sound/initval.h> 46 29 30 #ifdef TARGET_OS2 31 #define KBUILD_MODNAME "cmipci" 32 #endif 47 33 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); 48 34 MODULE_DESCRIPTION("C-Media CMI8x38 PCI"); … … 53 39 "{C-Media,CMI8338B}}"); 54 40 55 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))41 #if IS_REACHABLE(CONFIG_GAMEPORT) 56 42 #define SUPPORT_JOYSTICK 1 57 43 #endif … … 59 45 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 60 46 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 61 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */47 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 62 48 static long mpu_port[SNDRV_CARDS]; 63 49 #ifndef TARGET_OS2 64 50 static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; 65 static intsoft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};51 static bool soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; 66 52 #else 67 53 static long fm_port[SNDRV_CARDS] = {0x388, -1,-1,-1,-1,-1,-1,-1}; 68 static intsoft_ac3[SNDRV_CARDS] = {0,1,1,1,1,1,1,1};54 static bool soft_ac3[SNDRV_CARDS] = {0,1,1,1,1,1,1,1}; 69 55 #endif 70 56 #ifdef SUPPORT_JOYSTICK … … 78 64 module_param_array(enable, bool, NULL, 0444); 79 65 MODULE_PARM_DESC(enable, "Enable C-Media PCI soundcard."); 80 module_param_ array(mpu_port, long, NULL, 0444);66 module_param_hw_array(mpu_port, long, ioport, NULL, 0444); 81 67 MODULE_PARM_DESC(mpu_port, "MPU-401 port."); 82 module_param_ array(fm_port, long, NULL, 0444);68 module_param_hw_array(fm_port, long, ioport, NULL, 0444); 83 69 MODULE_PARM_DESC(fm_port, "FM port."); 84 70 module_param_array(soft_ac3, bool, NULL, 0444); 85 71 MODULE_PARM_DESC(soft_ac3, "Software-conversion of raw SPDIF packets (model 033 only)."); 86 72 #ifdef SUPPORT_JOYSTICK 87 module_param_ array(joystick_port, int, NULL, 0444);73 module_param_hw_array(joystick_port, int, ioport, NULL, 0444); 88 74 MODULE_PARM_DESC(joystick_port, "Joystick port address."); 89 75 #endif … … 514 500 spinlock_t reg_lock; 515 501 516 #ifdef CONFIG_PM 502 #ifdef CONFIG_PM_SLEEP 517 503 unsigned int saved_regs[0x20]; 518 504 unsigned char saved_mixers[0x20]; … … 729 715 */ 730 716 731 static unsigned int hw_channels[] = {1, 2, 4, 6, 8};732 static struct snd_pcm_hw_constraint_list hw_constraints_channels_4 = {717 static const unsigned int hw_channels[] = {1, 2, 4, 6, 8}; 718 static const struct snd_pcm_hw_constraint_list hw_constraints_channels_4 = { 733 719 .count = 3, 734 720 .list = hw_channels, 735 721 .mask = 0, 736 722 }; 737 static struct snd_pcm_hw_constraint_list hw_constraints_channels_6 = {723 static const struct snd_pcm_hw_constraint_list hw_constraints_channels_6 = { 738 724 .count = 4, 739 725 .list = hw_channels, 740 726 .mask = 0, 741 727 }; 742 static struct snd_pcm_hw_constraint_list hw_constraints_channels_8 = {728 static const struct snd_pcm_hw_constraint_list hw_constraints_channels_8 = { 743 729 .count = 5, 744 730 .list = hw_channels, … … 806 792 rec->fmt |= 0x01; 807 793 if (rec->is_dac && set_dac_channels(cm, rec, runtime->channels) < 0) { 808 snd_printd("cannot set dac channels\n");794 dev_dbg(cm->card->dev, "cannot set dac channels\n"); 809 795 return -EINVAL; 810 796 } … … 837 823 cm->ctrl |= val; 838 824 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); 839 / /snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl);825 /* dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl); */ 840 826 841 827 /* set sample rate */ … … 860 846 } 861 847 snd_cmipci_write(cm, CM_REG_FUNCTRL1, val); 862 //snd_printd("cmipci:functrl1 = %08x\n", val);848 dev_dbg(cm->card->dev, "functrl1 = %08x\n", val); 863 849 864 850 /* set format */ … … 876 862 } 877 863 snd_cmipci_write(cm, CM_REG_CHFORMAT, val); 878 //snd_printd("cmipci:chformat = %08x\n", val);864 dev_dbg(cm->card->dev, "chformat = %08x\n", val); 879 865 880 866 if (!rec->is_dac && cm->chip_version) { … … 914 900 /* enable channel */ 915 901 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); 916 //snd_printd("cmipci:functrl0 = %08x\n", cm->ctrl);902 dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl); 917 903 break; 918 904 case SNDRV_PCM_TRIGGER_STOP: … … 962 948 goto ok; 963 949 } 964 printk(KERN_ERR "cmipci:invalid PCM pointer: %#x\n", rem);950 dev_err(cm->card->dev, "invalid PCM pointer: %#x\n", rem); 965 951 return SNDRV_PCM_POS_XRUN; 966 952 ok: … … 1055 1041 } 1056 1042 1057 static struct snd_kcontrol_new snd_cmipci_spdif_default __devinitdata=1043 static const struct snd_kcontrol_new snd_cmipci_spdif_default = 1058 1044 { 1059 1045 .iface = SNDRV_CTL_ELEM_IFACE_PCM, … … 1082 1068 } 1083 1069 1084 static struct snd_kcontrol_new snd_cmipci_spdif_mask __devinitdata=1070 static const struct snd_kcontrol_new snd_cmipci_spdif_mask = 1085 1071 { 1086 1072 .access = SNDRV_CTL_ELEM_ACCESS_READ, … … 1129 1115 } 1130 1116 1131 static struct snd_kcontrol_new snd_cmipci_spdif_stream __devinitdata=1117 static const struct snd_kcontrol_new snd_cmipci_spdif_stream = 1132 1118 { 1133 1119 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1149 1135 unsigned int i; 1150 1136 1151 val = kmalloc(sizeof(*val), GFP_ ATOMIC);1137 val = kmalloc(sizeof(*val), GFP_KERNEL); 1152 1138 if (!val) 1153 1139 return -ENOMEM; … … 1487 1473 1488 1474 /* playback on channel A */ 1489 static struct snd_pcm_hardware snd_cmipci_playback =1475 static const struct snd_pcm_hardware snd_cmipci_playback = 1490 1476 { 1491 1477 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1507 1493 1508 1494 /* capture on channel B */ 1509 static struct snd_pcm_hardware snd_cmipci_capture =1495 static const struct snd_pcm_hardware snd_cmipci_capture = 1510 1496 { 1511 1497 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1527 1513 1528 1514 /* playback on channel B - stereo 16bit only? */ 1529 static struct snd_pcm_hardware snd_cmipci_playback2 =1515 static const struct snd_pcm_hardware snd_cmipci_playback2 = 1530 1516 { 1531 1517 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1547 1533 1548 1534 /* spdif playback on channel A */ 1549 static struct snd_pcm_hardware snd_cmipci_playback_spdif =1535 static const struct snd_pcm_hardware snd_cmipci_playback_spdif = 1550 1536 { 1551 1537 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1567 1553 1568 1554 /* spdif playback on channel A (32bit, IEC958 subframes) */ 1569 static struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe =1555 static const struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe = 1570 1556 { 1571 1557 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1587 1573 1588 1574 /* spdif capture on channel B */ 1589 static struct snd_pcm_hardware snd_cmipci_capture_spdif =1575 static const struct snd_pcm_hardware snd_cmipci_capture_spdif = 1590 1576 { 1591 1577 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1607 1593 }; 1608 1594 1609 static unsigned int rate_constraints[] = { 5512, 8000, 11025, 16000, 22050,1595 static const unsigned int rate_constraints[] = { 5512, 8000, 11025, 16000, 22050, 1610 1596 32000, 44100, 48000, 88200, 96000, 128000 }; 1611 static struct snd_pcm_hw_constraint_list hw_constraints_rates = {1597 static const struct snd_pcm_hw_constraint_list hw_constraints_rates = { 1612 1598 .count = ARRAY_SIZE(rate_constraints), 1613 1599 .list = rate_constraints, … … 1848 1834 */ 1849 1835 1850 static struct snd_pcm_ops snd_cmipci_playback_ops = {1836 static const struct snd_pcm_ops snd_cmipci_playback_ops = { 1851 1837 .open = snd_cmipci_playback_open, 1852 1838 .close = snd_cmipci_playback_close, … … 1859 1845 }; 1860 1846 1861 static struct snd_pcm_ops snd_cmipci_capture_ops = {1847 static const struct snd_pcm_ops snd_cmipci_capture_ops = { 1862 1848 .open = snd_cmipci_capture_open, 1863 1849 .close = snd_cmipci_capture_close, … … 1870 1856 }; 1871 1857 1872 static struct snd_pcm_ops snd_cmipci_playback2_ops = {1858 static const struct snd_pcm_ops snd_cmipci_playback2_ops = { 1873 1859 .open = snd_cmipci_playback2_open, 1874 1860 .close = snd_cmipci_playback2_close, … … 1881 1867 }; 1882 1868 1883 static struct snd_pcm_ops snd_cmipci_playback_spdif_ops = {1869 static const struct snd_pcm_ops snd_cmipci_playback_spdif_ops = { 1884 1870 .open = snd_cmipci_playback_spdif_open, 1885 1871 .close = snd_cmipci_playback_spdif_close, … … 1892 1878 }; 1893 1879 1894 static struct snd_pcm_ops snd_cmipci_capture_spdif_ops = {1880 static const struct snd_pcm_ops snd_cmipci_capture_spdif_ops = { 1895 1881 .open = snd_cmipci_capture_spdif_open, 1896 1882 .close = snd_cmipci_capture_spdif_close, … … 1907 1893 */ 1908 1894 1909 static int __devinitsnd_cmipci_pcm_new(struct cmipci *cm, int device)1895 static int snd_cmipci_pcm_new(struct cmipci *cm, int device) 1910 1896 { 1911 1897 struct snd_pcm *pcm; … … 1930 1916 } 1931 1917 1932 static int __devinitsnd_cmipci_pcm2_new(struct cmipci *cm, int device)1918 static int snd_cmipci_pcm2_new(struct cmipci *cm, int device) 1933 1919 { 1934 1920 struct snd_pcm *pcm; … … 1952 1938 } 1953 1939 1954 static int __devinitsnd_cmipci_pcm_spdif_new(struct cmipci *cm, int device)1940 static int snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device) 1955 1941 { 1956 1942 struct snd_pcm *pcm; … … 1971 1957 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1972 1958 snd_dma_pci_data(cm->pci), 64*1024, 128*1024); 1959 1960 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1961 snd_pcm_alt_chmaps, cm->max_channels, 0, 1962 NULL); 1963 if (err < 0) 1964 return err; 1973 1965 1974 1966 return 0; … … 2066 2058 if (reg.invert) 2067 2059 val = reg.mask - val; 2068 2060 ucontrol->value.integer.value[1] = val; 2069 2061 } 2070 2062 spin_unlock_irq(&cm->reg_lock); … … 2294 2286 2295 2287 2296 static struct snd_kcontrol_new snd_cmipci_mixers[] __devinitdata= {2288 static struct snd_kcontrol_new snd_cmipci_mixers[] = { 2297 2289 CMIPCI_SB_VOL_STEREO("Master Playback Volume", SB_DSP4_MASTER_DEV, 3, 31), 2298 2290 CMIPCI_MIXER_SW_MONO("3D Control - Switch", CM_REG_MIXER1, CM_X3DEN_SHIFT, 0), … … 2616 2608 2617 2609 /* both for CM8338/8738 */ 2618 static struct snd_kcontrol_new snd_cmipci_mixer_switches[] __devinitdata= {2610 static struct snd_kcontrol_new snd_cmipci_mixer_switches[] = { 2619 2611 DEFINE_MIXER_SWITCH("Four Channel Mode", fourch), 2620 2612 { … … 2628 2620 2629 2621 /* for non-multichannel chips */ 2630 static struct snd_kcontrol_new snd_cmipci_nomulti_switch __devinitdata=2622 static struct snd_kcontrol_new snd_cmipci_nomulti_switch = 2631 2623 DEFINE_MIXER_SWITCH("Exchange DAC", exchange_dac); 2632 2624 2633 2625 /* only for CM8738 */ 2634 static struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] __devinitdata= {2626 static struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] = { 2635 2627 #if 0 /* controlled in pcm device */ 2636 2628 DEFINE_MIXER_SWITCH("IEC958 In Record", spdif_in), … … 2654 2646 2655 2647 /* only for model 033/037 */ 2656 static struct snd_kcontrol_new snd_cmipci_old_mixer_switches[] __devinitdata= {2648 static struct snd_kcontrol_new snd_cmipci_old_mixer_switches[] = { 2657 2649 DEFINE_MIXER_SWITCH("IEC958 Mix Analog", spdif_dac_out), 2658 2650 DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase), … … 2661 2653 2662 2654 /* only for model 039 or later */ 2663 static struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] __devinitdata= {2655 static struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] = { 2664 2656 DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2), 2665 2657 DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2), … … 2674 2666 2675 2667 /* card control switches */ 2676 static struct snd_kcontrol_new snd_cmipci_modem_switch __devinitdata=2668 static struct snd_kcontrol_new snd_cmipci_modem_switch = 2677 2669 DEFINE_CARD_SWITCH("Modem", modem); 2678 2670 2679 2671 2680 static int __devinitsnd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device)2672 static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) 2681 2673 { 2682 2674 struct snd_card *card; … … 2787 2779 */ 2788 2780 2789 #ifdef CONFIG_PROC_FS2790 2781 static void snd_cmipci_proc_read(struct snd_info_entry *entry, 2791 2782 struct snd_info_buffer *buffer) … … 2806 2797 } 2807 2798 2808 static void __devinit snd_cmipci_proc_init(struct cmipci *cm) 2809 { 2810 struct snd_info_entry *entry; 2811 2812 if (! snd_card_proc_new(cm->card, "cmipci", &entry)) 2813 snd_info_set_text_ops(entry, cm, snd_cmipci_proc_read); 2814 } 2815 #else /* !CONFIG_PROC_FS */ 2816 static inline void snd_cmipci_proc_init(struct cmipci *cm) {} 2817 #endif 2818 2819 2820 static DEFINE_PCI_DEVICE_TABLE(snd_cmipci_ids) = { 2799 static void snd_cmipci_proc_init(struct cmipci *cm) 2800 { 2801 snd_card_ro_proc_new(cm->card, "cmipci", cm, snd_cmipci_proc_read); 2802 } 2803 2804 static const struct pci_device_id snd_cmipci_ids[] = { 2821 2805 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0}, 2822 2806 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0}, … … 2832 2816 * driver name is modified according to the chip model 2833 2817 */ 2834 static void __devinitquery_chip(struct cmipci *cm)2818 static void query_chip(struct cmipci *cm) 2835 2819 { 2836 2820 unsigned int detect; … … 2881 2865 2882 2866 #ifdef SUPPORT_JOYSTICK 2883 static int __devinitsnd_cmipci_create_gameport(struct cmipci *cm, int dev)2867 static int snd_cmipci_create_gameport(struct cmipci *cm, int dev) 2884 2868 { 2885 2869 static int ports[] = { 0x201, 0x200, 0 }; /* FIXME: majority is 0x201? */ … … 2904 2888 2905 2889 if (!r) { 2906 printk(KERN_WARNING "cmipci:cannot reserve joystick ports\n");2890 dev_warn(cm->card->dev, "cannot reserve joystick ports\n"); 2907 2891 return -EBUSY; 2908 2892 } … … 2910 2894 cm->gameport = gp = gameport_allocate_port(); 2911 2895 if (!gp) { 2912 printk(KERN_ERR "cmipci:cannot allocate memory for gameport\n");2896 dev_err(cm->card->dev, "cannot allocate memory for gameport\n"); 2913 2897 release_and_free_resource(r); 2914 2898 return -ENOMEM; … … 2974 2958 } 2975 2959 2976 static int __devinitsnd_cmipci_create_fm(struct cmipci *cm, long fm_port)2960 static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port) 2977 2961 { 2978 2962 long iosynth; … … 3010 2994 if (snd_opl3_create(cm->card, iosynth, iosynth + 2, 3011 2995 OPL3_HW_OPL3, 0, &opl3) < 0) { 3012 printk(KERN_ERR "cmipci: no OPL device at %#lx, " 3013 "skipping...\n", iosynth); 2996 dev_err(cm->card->dev, 2997 "no OPL device at %#lx, skipping...\n", 2998 iosynth); 3014 2999 goto disable_fm; 3015 3000 } 3016 3001 } 3017 3002 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 3018 printk(KERN_ERR "cmipci:cannot create OPL3 hwdep\n");3003 dev_err(cm->card->dev, "cannot create OPL3 hwdep\n"); 3019 3004 return err; 3020 3005 } … … 3027 3012 } 3028 3013 3029 static int __devinitsnd_cmipci_create(struct snd_card *card, struct pci_dev *pci,3030 3014 static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, 3015 int dev, struct cmipci **rcmipci) 3031 3016 { 3032 3017 struct cmipci *cm; … … 3040 3025 char modelstr[16]; 3041 3026 int pcm_index, pcm_spdif_index; 3042 static DEFINE_PCI_DEVICE_TABLE(intel_82437vx)= {3027 static const struct pci_device_id intel_82437vx[] = { 3043 3028 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) }, 3044 3029 {0}, … … 3075 3060 if (request_irq(pci->irq, snd_cmipci_interrupt, 3076 3061 IRQF_SHARED, KBUILD_MODNAME, cm)) { 3077 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);3062 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 3078 3063 snd_cmipci_free(cm); 3079 3064 return -EBUSY; … … 3207 3192 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN); 3208 3193 if (inb(iomidi + 1) == 0xff) { 3209 snd_printk(KERN_ERR "cannot enable MPU-401 port" 3210 " at %#lx\n", iomidi); 3194 dev_err(cm->card->dev, 3195 "cannot enable MPU-401 port at %#lx\n", 3196 iomidi); 3211 3197 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, 3212 3198 CM_UART_EN); … … 3252 3238 MPU401_INFO_IRQ_HOOK, 3253 3239 -1, &cm->rmidi)) < 0) { 3254 printk(KERN_ERR "cmipci: no UART401 device at 0x%lx\n", iomidi); 3240 dev_err(cm->card->dev, 3241 "no UART401 device at 0x%lx\n", iomidi); 3255 3242 } 3256 3243 } … … 3269 3256 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); 3270 3257 3271 snd_card_set_dev(card, &pci->dev);3272 3273 3258 *rcmipci = cm; 3274 3259 return 0; … … 3280 3265 MODULE_DEVICE_TABLE(pci, snd_cmipci_ids); 3281 3266 3282 static int __devinitsnd_cmipci_probe(struct pci_dev *pci,3283 3267 static int snd_cmipci_probe(struct pci_dev *pci, 3268 const struct pci_device_id *pci_id) 3284 3269 { 3285 3270 static int dev; … … 3295 3280 } 3296 3281 3297 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 3282 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 3283 0, &card); 3298 3284 if (err < 0) 3299 3285 return err; … … 3313 3299 } 3314 3300 3315 if ((err = snd_cmipci_create(card, pci, dev, &cm)) < 0) {3316 snd_card_free(card);3317 return err;3318 } 3301 err = snd_cmipci_create(card, pci, dev, &cm); 3302 if (err < 0) 3303 goto free_card; 3304 3319 3305 card->private_data = cm; 3320 3306 3321 if ((err = snd_card_register(card)) < 0) {3322 snd_card_free(card);3323 return err;3324 } 3307 err = snd_card_register(card); 3308 if (err < 0) 3309 goto free_card; 3310 3325 3311 pci_set_drvdata(pci, card); 3326 3312 dev++; 3327 3313 return 0; 3328 3314 3329 } 3330 3331 static void __devexit snd_cmipci_remove(struct pci_dev *pci) 3315 free_card: 3316 snd_card_free(card); 3317 return err; 3318 } 3319 3320 static void snd_cmipci_remove(struct pci_dev *pci) 3332 3321 { 3333 3322 snd_card_free(pci_get_drvdata(pci)); 3334 pci_set_drvdata(pci, NULL); 3335 } 3336 3337 3338 #ifdef CONFIG_PM 3323 } 3324 3325 3326 #ifdef CONFIG_PM_SLEEP 3339 3327 /* 3340 3328 * power management … … 3359 3347 }; 3360 3348 3361 static int snd_cmipci_suspend(struct pci_dev *pci, pm_message_t state)3362 { 3363 struct snd_card *card = pci_get_drvdata(pci);3349 static int snd_cmipci_suspend(struct device *dev) 3350 { 3351 struct snd_card *card = dev_get_drvdata(dev); 3364 3352 struct cmipci *cm = card->private_data; 3365 3353 int i; … … 3367 3355 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3368 3356 3369 snd_pcm_suspend_all(cm->pcm);3370 snd_pcm_suspend_all(cm->pcm2);3371 snd_pcm_suspend_all(cm->pcm_spdif);3372 3373 3357 /* save registers */ 3374 3358 for (i = 0; i < ARRAY_SIZE(saved_regs); i++) … … 3379 3363 /* disable ints */ 3380 3364 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); 3381 3382 pci_disable_device(pci); 3383 pci_save_state(pci); 3384 pci_set_power_state(pci, pci_choose_state(pci, state)); 3385 return 0; 3386 } 3387 3388 static int snd_cmipci_resume(struct pci_dev *pci) 3389 { 3390 struct snd_card *card = pci_get_drvdata(pci); 3365 return 0; 3366 } 3367 3368 static int snd_cmipci_resume(struct device *dev) 3369 { 3370 struct snd_card *card = dev_get_drvdata(dev); 3391 3371 struct cmipci *cm = card->private_data; 3392 3372 int i; 3393 3394 pci_set_power_state(pci, PCI_D0);3395 pci_restore_state(pci);3396 if (pci_enable_device(pci) < 0) {3397 printk(KERN_ERR "cmipci: pci_enable_device failed, "3398 "disabling device\n");3399 snd_card_disconnect(card);3400 return -EIO;3401 }3402 pci_set_master(pci);3403 3373 3404 3374 /* reset / initialize to a sane state */ … … 3417 3387 return 0; 3418 3388 } 3419 #endif /* CONFIG_PM */ 3420 3421 static struct pci_driver driver = { 3389 3390 static SIMPLE_DEV_PM_OPS(snd_cmipci_pm, snd_cmipci_suspend, snd_cmipci_resume); 3391 #define SND_CMIPCI_PM_OPS &snd_cmipci_pm 3392 #else 3393 #define SND_CMIPCI_PM_OPS NULL 3394 #endif /* CONFIG_PM_SLEEP */ 3395 3396 static struct pci_driver cmipci_driver = { 3422 3397 .name = KBUILD_MODNAME, 3423 3398 .id_table = snd_cmipci_ids, 3424 3399 .probe = snd_cmipci_probe, 3425 .remove = __devexit_p(snd_cmipci_remove), 3426 #ifdef CONFIG_PM 3427 .suspend = snd_cmipci_suspend, 3428 .resume = snd_cmipci_resume, 3429 #endif 3400 .remove = snd_cmipci_remove, 3401 .driver = { 3402 .pm = SND_CMIPCI_PM_OPS, 3403 }, 3430 3404 }; 3431 3405 3432 static int __init alsa_card_cmipci_init(void) 3433 { 3434 return pci_register_driver(&driver); 3435 } 3436 3437 static void __exit alsa_card_cmipci_exit(void) 3438 { 3439 pci_unregister_driver(&driver); 3440 } 3441 3442 module_init(alsa_card_cmipci_init) 3443 module_exit(alsa_card_cmipci_exit) 3406 module_pci_driver(cmipci_driver);
Note:
See TracChangeset
for help on using the changeset viewer.