diff options
Diffstat (limited to 'sound/pci/via82xx_modem.c')
-rw-r--r-- | sound/pci/via82xx_modem.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 7eac6f6ac737..011f0fb63bf9 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c | |||
@@ -26,7 +26,7 @@ | |||
26 | /* | 26 | /* |
27 | * Changes: | 27 | * Changes: |
28 | * | 28 | * |
29 | * Sep. 2, 2004 Sasha Khapyorsky <sashak@smlink.com> | 29 | * Sep. 2, 2004 Sasha Khapyorsky <sashak@alsa-project.org> |
30 | * Modified from original audio driver 'via82xx.c' to support AC97 | 30 | * Modified from original audio driver 'via82xx.c' to support AC97 |
31 | * modems. | 31 | * modems. |
32 | */ | 32 | */ |
@@ -55,20 +55,21 @@ MODULE_DESCRIPTION("VIA VT82xx modem"); | |||
55 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
56 | MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C modem,pci}}"); | 56 | MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C modem,pci}}"); |
57 | 57 | ||
58 | static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */ | 58 | static int index = -2; /* Exclude the first card */ |
59 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 59 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ |
60 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ | 60 | static int ac97_clock = 48000; |
61 | static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; | ||
62 | 61 | ||
63 | module_param_array(index, int, NULL, 0444); | 62 | module_param(index, int, 0444); |
64 | MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); | 63 | MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); |
65 | module_param_array(id, charp, NULL, 0444); | 64 | module_param(id, charp, 0444); |
66 | MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); | 65 | MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); |
67 | module_param_array(enable, bool, NULL, 0444); | 66 | module_param(ac97_clock, int, 0444); |
68 | MODULE_PARM_DESC(enable, "Enable modem part of VIA 82xx bridge."); | ||
69 | module_param_array(ac97_clock, int, NULL, 0444); | ||
70 | MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); | 67 | MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); |
71 | 68 | ||
69 | /* just for backward compatibility */ | ||
70 | static int enable; | ||
71 | module_param(enable, bool, 0444); | ||
72 | |||
72 | 73 | ||
73 | /* | 74 | /* |
74 | * Direct registers | 75 | * Direct registers |
@@ -569,7 +570,7 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u | |||
569 | res = viadev->lastpos; | 570 | res = viadev->lastpos; |
570 | } else if (check_invalid_pos(viadev, res)) { | 571 | } else if (check_invalid_pos(viadev, res)) { |
571 | #ifdef POINTER_DEBUG | 572 | #ifdef POINTER_DEBUG |
572 | printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); | 573 | printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); |
573 | #endif | 574 | #endif |
574 | if (count && size < count) { | 575 | if (count && size < count) { |
575 | snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); | 576 | snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); |
@@ -832,6 +833,7 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip) | |||
832 | return err; | 833 | return err; |
833 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via686_playback_ops); | 834 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via686_playback_ops); |
834 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops); | 835 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops); |
836 | pcm->dev_class = SNDRV_PCM_CLASS_MODEM; | ||
835 | pcm->private_data = chip; | 837 | pcm->private_data = chip; |
836 | strcpy(pcm->name, chip->card->shortname); | 838 | strcpy(pcm->name, chip->card->shortname); |
837 | chip->pcms[0] = pcm; | 839 | chip->pcms[0] = pcm; |
@@ -878,7 +880,6 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip) | |||
878 | return err; | 880 | return err; |
879 | chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; | 881 | chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; |
880 | chip->ac97_bus->clock = chip->ac97_clock; | 882 | chip->ac97_bus->clock = chip->ac97_clock; |
881 | chip->ac97_bus->shared_type = AC97_SHARED_TYPE_VIA; | ||
882 | 883 | ||
883 | memset(&ac97, 0, sizeof(ac97)); | 884 | memset(&ac97, 0, sizeof(ac97)); |
884 | ac97.private_data = chip; | 885 | ac97.private_data = chip; |
@@ -967,12 +968,11 @@ static int snd_via82xx_chip_init(via82xx_t *chip) | |||
967 | pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); | 968 | pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); |
968 | if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ | 969 | if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ |
969 | break; | 970 | break; |
970 | set_current_state(TASK_UNINTERRUPTIBLE); | 971 | schedule_timeout_uninterruptible(1); |
971 | schedule_timeout(1); | ||
972 | } while (time_before(jiffies, end_time)); | 972 | } while (time_before(jiffies, end_time)); |
973 | 973 | ||
974 | if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) | 974 | if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) |
975 | snd_printk("AC'97 codec is not ready [0x%x]\n", val); | 975 | snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val); |
976 | 976 | ||
977 | snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | | 977 | snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | |
978 | VIA_REG_AC97_SECONDARY_VALID | | 978 | VIA_REG_AC97_SECONDARY_VALID | |
@@ -986,8 +986,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip) | |||
986 | chip->ac97_secondary = 1; | 986 | chip->ac97_secondary = 1; |
987 | goto __ac97_ok2; | 987 | goto __ac97_ok2; |
988 | } | 988 | } |
989 | set_current_state(TASK_INTERRUPTIBLE); | 989 | schedule_timeout_interruptible(1); |
990 | schedule_timeout(1); | ||
991 | } while (time_before(jiffies, end_time)); | 990 | } while (time_before(jiffies, end_time)); |
992 | /* This is ok, the most of motherboards have only one codec */ | 991 | /* This is ok, the most of motherboards have only one codec */ |
993 | 992 | ||
@@ -1101,7 +1100,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card, | |||
1101 | chip->port = pci_resource_start(pci, 0); | 1100 | chip->port = pci_resource_start(pci, 0); |
1102 | if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ, | 1101 | if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ, |
1103 | card->driver, (void *)chip)) { | 1102 | card->driver, (void *)chip)) { |
1104 | snd_printk("unable to grab IRQ %d\n", pci->irq); | 1103 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); |
1105 | snd_via82xx_free(chip); | 1104 | snd_via82xx_free(chip); |
1106 | return -EBUSY; | 1105 | return -EBUSY; |
1107 | } | 1106 | } |
@@ -1135,7 +1134,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card, | |||
1135 | static int __devinit snd_via82xx_probe(struct pci_dev *pci, | 1134 | static int __devinit snd_via82xx_probe(struct pci_dev *pci, |
1136 | const struct pci_device_id *pci_id) | 1135 | const struct pci_device_id *pci_id) |
1137 | { | 1136 | { |
1138 | static int dev; | ||
1139 | snd_card_t *card; | 1137 | snd_card_t *card; |
1140 | via82xx_t *chip; | 1138 | via82xx_t *chip; |
1141 | unsigned char revision; | 1139 | unsigned char revision; |
@@ -1143,14 +1141,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
1143 | unsigned int i; | 1141 | unsigned int i; |
1144 | int err; | 1142 | int err; |
1145 | 1143 | ||
1146 | if (dev >= SNDRV_CARDS) | 1144 | card = snd_card_new(index, id, THIS_MODULE, 0); |
1147 | return -ENODEV; | ||
1148 | if (!enable[dev]) { | ||
1149 | dev++; | ||
1150 | return -ENOENT; | ||
1151 | } | ||
1152 | |||
1153 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | ||
1154 | if (card == NULL) | 1145 | if (card == NULL) |
1155 | return -ENOMEM; | 1146 | return -ENOMEM; |
1156 | 1147 | ||
@@ -1167,7 +1158,8 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
1167 | goto __error; | 1158 | goto __error; |
1168 | } | 1159 | } |
1169 | 1160 | ||
1170 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0) | 1161 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, |
1162 | ac97_clock, &chip)) < 0) | ||
1171 | goto __error; | 1163 | goto __error; |
1172 | if ((err = snd_via82xx_mixer_new(chip)) < 0) | 1164 | if ((err = snd_via82xx_mixer_new(chip)) < 0) |
1173 | goto __error; | 1165 | goto __error; |
@@ -1191,7 +1183,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
1191 | return err; | 1183 | return err; |
1192 | } | 1184 | } |
1193 | pci_set_drvdata(pci, card); | 1185 | pci_set_drvdata(pci, card); |
1194 | dev++; | ||
1195 | return 0; | 1186 | return 0; |
1196 | 1187 | ||
1197 | __error: | 1188 | __error: |