aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ali5451/ali5451.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ali5451/ali5451.c')
-rw-r--r--sound/pci/ali5451/ali5451.c92
1 files changed, 41 insertions, 51 deletions
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index f35b558c29b2..4e76c4a636d9 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -45,23 +45,25 @@ MODULE_DESCRIPTION("ALI M5451");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}"); 46MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}");
47 47
48static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 48static int index = SNDRV_DEFAULT_IDX1; /* Index */
49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 49static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
50static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 50static int pcm_channels = 32;
51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; 51static int spdif = 0;
52static int spdif[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
53 52
54module_param_array(index, int, NULL, 0444); 53module_param(index, int, 0444);
55MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio."); 54MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio.");
56module_param_array(id, charp, NULL, 0444); 55module_param(id, charp, 0444);
57MODULE_PARM_DESC(id, "ID string for ALI M5451 PCI Audio."); 56MODULE_PARM_DESC(id, "ID string for ALI M5451 PCI Audio.");
58module_param_array(enable, bool, NULL, 0444); 57module_param(pcm_channels, int, 0444);
59MODULE_PARM_DESC(enable, "Enable ALI 5451 PCI Audio.");
60module_param_array(pcm_channels, int, NULL, 0444);
61MODULE_PARM_DESC(pcm_channels, "PCM Channels"); 58MODULE_PARM_DESC(pcm_channels, "PCM Channels");
62module_param_array(spdif, bool, NULL, 0444); 59module_param(spdif, bool, 0444);
63MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); 60MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
64 61
62/* just for backward compatibility */
63static int enable;
64module_param(enable, bool, 0444);
65
66
65/* 67/*
66 * Debug part definitions 68 * Debug part definitions
67 */ 69 */
@@ -396,10 +398,8 @@ static int snd_ali_codec_ready( ali_t *codec,
396 res = snd_ali_5451_peek(codec,port); 398 res = snd_ali_5451_peek(codec,port);
397 if (! (res & 0x8000)) 399 if (! (res & 0x8000))
398 return 0; 400 return 0;
399 if (sched) { 401 if (sched)
400 set_current_state(TASK_UNINTERRUPTIBLE); 402 schedule_timeout_uninterruptible(1);
401 schedule_timeout(1);
402 }
403 } while (time_after_eq(end_time, jiffies)); 403 } while (time_after_eq(end_time, jiffies));
404 snd_ali_5451_poke(codec, port, res & ~0x8000); 404 snd_ali_5451_poke(codec, port, res & ~0x8000);
405 snd_printdd("ali_codec_ready: codec is not ready.\n "); 405 snd_printdd("ali_codec_ready: codec is not ready.\n ");
@@ -419,12 +419,10 @@ static int snd_ali_stimer_ready(ali_t *codec, int sched)
419 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); 419 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
420 if (dwChk2 != dwChk1) 420 if (dwChk2 != dwChk1)
421 return 0; 421 return 0;
422 if (sched) { 422 if (sched)
423 set_current_state(TASK_UNINTERRUPTIBLE); 423 schedule_timeout_uninterruptible(1);
424 schedule_timeout(1);
425 }
426 } while (time_after_eq(end_time, jiffies)); 424 } while (time_after_eq(end_time, jiffies));
427 snd_printk("ali_stimer_read: stimer is not ready.\n"); 425 snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n");
428 return -EIO; 426 return -EIO;
429} 427}
430 428
@@ -436,7 +434,7 @@ static void snd_ali_codec_poke(ali_t *codec,int secondary,
436 unsigned int port = 0; 434 unsigned int port = 0;
437 435
438 if (reg >= 0x80) { 436 if (reg >= 0x80) {
439 snd_printk("ali_codec_poke: reg(%xh) invalid.\n", reg); 437 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg);
440 return; 438 return;
441 } 439 }
442 440
@@ -465,7 +463,7 @@ static unsigned short snd_ali_codec_peek( ali_t *codec,
465 unsigned int port = 0; 463 unsigned int port = 0;
466 464
467 if (reg >= 0x80) { 465 if (reg >= 0x80) {
468 snd_printk("ali_codec_peek: reg(%xh) invalid.\n", reg); 466 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg);
469 return ~0; 467 return ~0;
470 } 468 }
471 469
@@ -669,7 +667,7 @@ static int snd_ali_alloc_pcm_channel(ali_t *codec, int channel)
669 unsigned int idx = channel & 0x1f; 667 unsigned int idx = channel & 0x1f;
670 668
671 if (codec->synth.chcnt >= ALI_CHANNELS){ 669 if (codec->synth.chcnt >= ALI_CHANNELS){
672 snd_printk("ali_alloc_pcm_channel: no free channels.\n"); 670 snd_printk(KERN_ERR "ali_alloc_pcm_channel: no free channels.\n");
673 return -1; 671 return -1;
674 } 672 }
675 673
@@ -700,7 +698,7 @@ static int snd_ali_find_free_channel(ali_t * codec, int rec)
700 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 698 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) {
701 return result; 699 return result;
702 } else { 700 } else {
703 snd_printk("ali_find_free_channel: record channel is busy now.\n"); 701 snd_printk(KERN_ERR "ali_find_free_channel: record channel is busy now.\n");
704 return -1; 702 return -1;
705 } 703 }
706 } 704 }
@@ -712,7 +710,7 @@ static int snd_ali_find_free_channel(ali_t * codec, int rec)
712 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 710 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) {
713 return result; 711 return result;
714 } else { 712 } else {
715 snd_printk("ali_find_free_channel: S/PDIF out channel is in busy now.\n"); 713 snd_printk(KERN_ERR "ali_find_free_channel: S/PDIF out channel is in busy now.\n");
716 } 714 }
717 } 715 }
718 716
@@ -720,7 +718,7 @@ static int snd_ali_find_free_channel(ali_t * codec, int rec)
720 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) 718 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0)
721 return result; 719 return result;
722 } 720 }
723 snd_printk("ali_find_free_channel: no free channels.\n"); 721 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n");
724 return -1; 722 return -1;
725} 723}
726 724
@@ -734,7 +732,7 @@ static void snd_ali_free_channel_pcm(ali_t *codec, int channel)
734 return; 732 return;
735 733
736 if (!(codec->synth.chmap & (1 << idx))) { 734 if (!(codec->synth.chmap & (1 << idx))) {
737 snd_printk("ali_free_channel_pcm: channel %d is not in use.\n",channel); 735 snd_printk(KERN_ERR "ali_free_channel_pcm: channel %d is not in use.\n",channel);
738 return; 736 return;
739 } else { 737 } else {
740 codec->synth.chmap &= ~(1 << idx); 738 codec->synth.chmap &= ~(1 << idx);
@@ -796,7 +794,7 @@ static void snd_ali_detect_spdif_rate(ali_t *codec)
796 } 794 }
797 795
798 if (count > 50000) { 796 if (count > 50000) {
799 snd_printk("ali_detect_spdif_rate: timeout!\n"); 797 snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n");
800 return; 798 return;
801 } 799 }
802 800
@@ -809,7 +807,7 @@ static void snd_ali_detect_spdif_rate(ali_t *codec)
809 } 807 }
810 808
811 if (count > 50000) { 809 if (count > 50000) {
812 snd_printk("ali_detect_spdif_rate: timeout!\n"); 810 snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n");
813 return; 811 return;
814 } 812 }
815 813
@@ -1077,7 +1075,7 @@ static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec, in
1077 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : 1075 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
1078 snd_ali_find_free_channel(codec,rec); 1076 snd_ali_find_free_channel(codec,rec);
1079 if(idx < 0) { 1077 if(idx < 0) {
1080 snd_printk("ali_alloc_voice: err.\n"); 1078 snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
1081 spin_unlock_irqrestore(&codec->voice_alloc, flags); 1079 spin_unlock_irqrestore(&codec->voice_alloc, flags);
1082 return NULL; 1080 return NULL;
1083 } 1081 }
@@ -1479,13 +1477,13 @@ static int snd_ali_prepare(snd_pcm_substream_t * substream)
1479 } 1477 }
1480 rate = snd_ali_get_spdif_in_rate(codec); 1478 rate = snd_ali_get_spdif_in_rate(codec);
1481 if (rate == 0) { 1479 if (rate == 0) {
1482 snd_printk("ali_capture_preapre: spdif rate detect err!\n"); 1480 snd_printk(KERN_WARNING "ali_capture_preapre: spdif rate detect err!\n");
1483 rate = 48000; 1481 rate = 48000;
1484 } 1482 }
1485 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); 1483 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL));
1486 if (bValue & 0x10) { 1484 if (bValue & 0x10) {
1487 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL)); 1485 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL));
1488 printk("clear SPDIF parity error flag.\n"); 1486 printk(KERN_WARNING "clear SPDIF parity error flag.\n");
1489 } 1487 }
1490 1488
1491 if (rate != 48000) 1489 if (rate != 48000)
@@ -1795,6 +1793,7 @@ struct ali_pcm_description {
1795 unsigned int capture_num; 1793 unsigned int capture_num;
1796 snd_pcm_ops_t *playback_ops; 1794 snd_pcm_ops_t *playback_ops;
1797 snd_pcm_ops_t *capture_ops; 1795 snd_pcm_ops_t *capture_ops;
1796 unsigned short class;
1798}; 1797};
1799 1798
1800 1799
@@ -1813,12 +1812,11 @@ static int __devinit snd_ali_pcm(ali_t * codec, int device, struct ali_pcm_descr
1813 err = snd_pcm_new(codec->card, desc->name, device, 1812 err = snd_pcm_new(codec->card, desc->name, device,
1814 desc->playback_num, desc->capture_num, &pcm); 1813 desc->playback_num, desc->capture_num, &pcm);
1815 if (err < 0) { 1814 if (err < 0) {
1816 snd_printk("snd_ali_pcm: err called snd_pcm_new.\n"); 1815 snd_printk(KERN_ERR "snd_ali_pcm: err called snd_pcm_new.\n");
1817 return err; 1816 return err;
1818 } 1817 }
1819 pcm->private_data = codec; 1818 pcm->private_data = codec;
1820 pcm->private_free = snd_ali_pcm_free; 1819 pcm->private_free = snd_ali_pcm_free;
1821 pcm->info_flags = 0;
1822 if (desc->playback_ops) 1820 if (desc->playback_ops)
1823 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops); 1821 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops);
1824 if (desc->capture_ops) 1822 if (desc->capture_ops)
@@ -1828,6 +1826,7 @@ static int __devinit snd_ali_pcm(ali_t * codec, int device, struct ali_pcm_descr
1828 snd_dma_pci_data(codec->pci), 64*1024, 128*1024); 1826 snd_dma_pci_data(codec->pci), 64*1024, 128*1024);
1829 1827
1830 pcm->info_flags = 0; 1828 pcm->info_flags = 0;
1829 pcm->dev_class = desc->class;
1831 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1830 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
1832 strcpy(pcm->name, desc->name); 1831 strcpy(pcm->name, desc->name);
1833 codec->pcm[0] = pcm; 1832 codec->pcm[0] = pcm;
@@ -1836,7 +1835,7 @@ static int __devinit snd_ali_pcm(ali_t * codec, int device, struct ali_pcm_descr
1836 1835
1837static struct ali_pcm_description ali_pcms[] = { 1836static struct ali_pcm_description ali_pcms[] = {
1838 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops }, 1837 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops },
1839 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops } 1838 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops, SNDRV_PCM_CLASS_MODEM }
1840}; 1839};
1841 1840
1842static int __devinit snd_ali_build_pcms(ali_t *codec) 1841static int __devinit snd_ali_build_pcms(ali_t *codec)
@@ -1991,7 +1990,7 @@ static int __devinit snd_ali_mixer(ali_t * codec)
1991 for ( i = 0 ; i < codec->num_of_codecs ; i++) { 1990 for ( i = 0 ; i < codec->num_of_codecs ; i++) {
1992 ac97.num = i; 1991 ac97.num = i;
1993 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { 1992 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) {
1994 snd_printk("ali mixer %d creating error.\n", i); 1993 snd_printk(KERN_ERR "ali mixer %d creating error.\n", i);
1995 if(i == 0) 1994 if(i == 0)
1996 return err; 1995 return err;
1997 codec->num_of_codecs = 1; 1996 codec->num_of_codecs = 1;
@@ -2125,7 +2124,7 @@ static int snd_ali_chip_init(ali_t *codec)
2125 snd_ali_printk("chip initializing ... \n"); 2124 snd_ali_printk("chip initializing ... \n");
2126 2125
2127 if (snd_ali_reset_5451(codec)) { 2126 if (snd_ali_reset_5451(codec)) {
2128 snd_printk("ali_chip_init: reset 5451 error.\n"); 2127 snd_printk(KERN_ERR "ali_chip_init: reset 5451 error.\n");
2129 return -1; 2128 return -1;
2130 } 2129 }
2131 2130
@@ -2200,7 +2199,7 @@ static int __devinit snd_ali_resources(ali_t *codec)
2200 codec->port = pci_resource_start(codec->pci, 0); 2199 codec->port = pci_resource_start(codec->pci, 0);
2201 2200
2202 if (request_irq(codec->pci->irq, snd_ali_card_interrupt, SA_INTERRUPT|SA_SHIRQ, "ALI 5451", (void *)codec)) { 2201 if (request_irq(codec->pci->irq, snd_ali_card_interrupt, SA_INTERRUPT|SA_SHIRQ, "ALI 5451", (void *)codec)) {
2203 snd_printk("Unable to request irq.\n"); 2202 snd_printk(KERN_ERR "Unable to request irq.\n");
2204 return -EBUSY; 2203 return -EBUSY;
2205 } 2204 }
2206 codec->irq = codec->pci->irq; 2205 codec->irq = codec->pci->irq;
@@ -2240,7 +2239,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
2240 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2239 /* check, if we can restrict PCI DMA transfers to 31 bits */
2241 if (pci_set_dma_mask(pci, 0x7fffffff) < 0 || 2240 if (pci_set_dma_mask(pci, 0x7fffffff) < 0 ||
2242 pci_set_consistent_dma_mask(pci, 0x7fffffff) < 0) { 2241 pci_set_consistent_dma_mask(pci, 0x7fffffff) < 0) {
2243 snd_printk("architecture does not support 31bit PCI busmaster DMA\n"); 2242 snd_printk(KERN_ERR "architecture does not support 31bit PCI busmaster DMA\n");
2244 pci_disable_device(pci); 2243 pci_disable_device(pci);
2245 return -ENXIO; 2244 return -ENXIO;
2246 } 2245 }
@@ -2329,7 +2328,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
2329 } 2328 }
2330 2329
2331 if ((err = snd_ali_chip_init(codec)) < 0) { 2330 if ((err = snd_ali_chip_init(codec)) < 0) {
2332 snd_printk("ali create: chip init error.\n"); 2331 snd_printk(KERN_ERR "ali create: chip init error.\n");
2333 return err; 2332 return err;
2334 } 2333 }
2335 2334
@@ -2352,25 +2351,17 @@ static int __devinit snd_ali_create(snd_card_t * card,
2352static int __devinit snd_ali_probe(struct pci_dev *pci, 2351static int __devinit snd_ali_probe(struct pci_dev *pci,
2353 const struct pci_device_id *pci_id) 2352 const struct pci_device_id *pci_id)
2354{ 2353{
2355 static int dev;
2356 snd_card_t *card; 2354 snd_card_t *card;
2357 ali_t *codec; 2355 ali_t *codec;
2358 int err; 2356 int err;
2359 2357
2360 snd_ali_printk("probe ...\n"); 2358 snd_ali_printk("probe ...\n");
2361 2359
2362 if (dev >= SNDRV_CARDS) 2360 card = snd_card_new(index, id, THIS_MODULE, 0);
2363 return -ENODEV;
2364 if (!enable[dev]) {
2365 dev++;
2366 return -ENOENT;
2367 }
2368
2369 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
2370 if (card == NULL) 2361 if (card == NULL)
2371 return -ENOMEM; 2362 return -ENOMEM;
2372 2363
2373 if ((err = snd_ali_create(card, pci, pcm_channels[dev], spdif[dev], &codec)) < 0) { 2364 if ((err = snd_ali_create(card, pci, pcm_channels, spdif, &codec)) < 0) {
2374 snd_card_free(card); 2365 snd_card_free(card);
2375 return err; 2366 return err;
2376 } 2367 }
@@ -2401,7 +2392,6 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2401 return err; 2392 return err;
2402 } 2393 }
2403 pci_set_drvdata(pci, card); 2394 pci_set_drvdata(pci, card);
2404 dev++;
2405 return 0; 2395 return 0;
2406} 2396}
2407 2397