aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/ice1724.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-10-11 15:39:35 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-11 15:39:35 -0400
commit56c5d900dbb8e042bfad035d18433476931d8f93 (patch)
tree00b793965beeef10db03e0ff021d2d965c410759 /sound/pci/ice1712/ice1724.c
parent4dd95b63ae25c5cad6986829b5e8788e9faa0330 (diff)
parentead9d23d803ea3a73766c3cb27bf7563ac8d7266 (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: sound/core/memalloc.c
Diffstat (limited to 'sound/pci/ice1712/ice1724.c')
-rw-r--r--sound/pci/ice1712/ice1724.c188
1 files changed, 101 insertions, 87 deletions
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index e596d777d9dd..1b3f11702713 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -20,9 +20,9 @@
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 22 *
23 */ 23 */
24 24
25#include <asm/io.h> 25#include <linux/io.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/init.h> 28#include <linux/init.h>
@@ -105,7 +105,7 @@ static unsigned int PRO_RATE_DEFAULT = 44100;
105/* 105/*
106 * Basic I/O 106 * Basic I/O
107 */ 107 */
108 108
109/* 109/*
110 * default rates, default clock routines 110 * default rates, default clock routines
111 */ 111 */
@@ -198,7 +198,7 @@ static void snd_vt1724_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data)
198static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) 198static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data)
199{ 199{
200 outw(data, ICEREG1724(ice, GPIO_WRITE_MASK)); 200 outw(data, ICEREG1724(ice, GPIO_WRITE_MASK));
201 if (! ice->vt1720) /* VT1720 supports only 16 GPIO bits */ 201 if (!ice->vt1720) /* VT1720 supports only 16 GPIO bits */
202 outb((data >> 16) & 0xff, ICEREG1724(ice, GPIO_WRITE_MASK_22)); 202 outb((data >> 16) & 0xff, ICEREG1724(ice, GPIO_WRITE_MASK_22));
203 inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */ 203 inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */
204} 204}
@@ -206,7 +206,7 @@ static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data)
206static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data) 206static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data)
207{ 207{
208 outw(data, ICEREG1724(ice, GPIO_DATA)); 208 outw(data, ICEREG1724(ice, GPIO_DATA));
209 if (! ice->vt1720) 209 if (!ice->vt1720)
210 outb(data >> 16, ICEREG1724(ice, GPIO_DATA_22)); 210 outb(data >> 16, ICEREG1724(ice, GPIO_DATA_22));
211 inw(ICEREG1724(ice, GPIO_DATA)); /* dummy read for pci-posting */ 211 inw(ICEREG1724(ice, GPIO_DATA)); /* dummy read for pci-posting */
212} 212}
@@ -214,7 +214,7 @@ static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data)
214static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712 *ice) 214static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712 *ice)
215{ 215{
216 unsigned int data; 216 unsigned int data;
217 if (! ice->vt1720) 217 if (!ice->vt1720)
218 data = (unsigned int)inb(ICEREG1724(ice, GPIO_DATA_22)); 218 data = (unsigned int)inb(ICEREG1724(ice, GPIO_DATA_22));
219 else 219 else
220 data = 0; 220 data = 0;
@@ -399,7 +399,7 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
399 break; 399 break;
400 } 400 }
401#endif 401#endif
402 handled = 1; 402 handled = 1;
403 if (status & VT1724_IRQ_MPU_TX) { 403 if (status & VT1724_IRQ_MPU_TX) {
404 spin_lock(&ice->reg_lock); 404 spin_lock(&ice->reg_lock);
405 if (ice->midi_output) 405 if (ice->midi_output)
@@ -468,8 +468,8 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
468 /* ought to really handle this properly */ 468 /* ought to really handle this properly */
469 if (mtstat & VT1724_MULTI_FIFO_ERR) { 469 if (mtstat & VT1724_MULTI_FIFO_ERR) {
470 unsigned char fstat = inb(ICEMT1724(ice, DMA_FIFO_ERR)); 470 unsigned char fstat = inb(ICEMT1724(ice, DMA_FIFO_ERR));
471 outb(fstat, ICEMT1724(ice, DMA_FIFO_ERR)); 471 outb(fstat, ICEMT1724(ice, DMA_FIFO_ERR));
472 outb(VT1724_MULTI_FIFO_ERR | inb(ICEMT1724(ice, DMA_INT_MASK)), ICEMT1724(ice, DMA_INT_MASK)); 472 outb(VT1724_MULTI_FIFO_ERR | inb(ICEMT1724(ice, DMA_INT_MASK)), ICEMT1724(ice, DMA_INT_MASK));
473 /* If I don't do this, I get machine lockup due to continual interrupts */ 473 /* If I don't do this, I get machine lockup due to continual interrupts */
474 } 474 }
475 475
@@ -733,17 +733,17 @@ static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream)
733 outl(substream->runtime->dma_addr, ICEMT1724(ice, PLAYBACK_ADDR)); 733 outl(substream->runtime->dma_addr, ICEMT1724(ice, PLAYBACK_ADDR));
734 734
735 size = (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1; 735 size = (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1;
736 // outl(size, ICEMT1724(ice, PLAYBACK_SIZE)); 736 /* outl(size, ICEMT1724(ice, PLAYBACK_SIZE)); */
737 outw(size, ICEMT1724(ice, PLAYBACK_SIZE)); 737 outw(size, ICEMT1724(ice, PLAYBACK_SIZE));
738 outb(size >> 16, ICEMT1724(ice, PLAYBACK_SIZE) + 2); 738 outb(size >> 16, ICEMT1724(ice, PLAYBACK_SIZE) + 2);
739 size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1; 739 size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1;
740 // outl(size, ICEMT1724(ice, PLAYBACK_COUNT)); 740 /* outl(size, ICEMT1724(ice, PLAYBACK_COUNT)); */
741 outw(size, ICEMT1724(ice, PLAYBACK_COUNT)); 741 outw(size, ICEMT1724(ice, PLAYBACK_COUNT));
742 outb(size >> 16, ICEMT1724(ice, PLAYBACK_COUNT) + 2); 742 outb(size >> 16, ICEMT1724(ice, PLAYBACK_COUNT) + 2);
743 743
744 spin_unlock_irq(&ice->reg_lock); 744 spin_unlock_irq(&ice->reg_lock);
745 745
746 // printk("pro prepare: ch = %d, addr = 0x%x, buffer = 0x%x, period = 0x%x\n", substream->runtime->channels, (unsigned int)substream->runtime->dma_addr, snd_pcm_lib_buffer_bytes(substream), snd_pcm_lib_period_bytes(substream)); 746 /* printk("pro prepare: ch = %d, addr = 0x%x, buffer = 0x%x, period = 0x%x\n", substream->runtime->channels, (unsigned int)substream->runtime->dma_addr, snd_pcm_lib_buffer_bytes(substream), snd_pcm_lib_period_bytes(substream)); */
747 return 0; 747 return 0;
748} 748}
749 749
@@ -771,7 +771,7 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substrea
771 ptr = inl(ICEMT1724(ice, PLAYBACK_SIZE)) & 0xffffff; 771 ptr = inl(ICEMT1724(ice, PLAYBACK_SIZE)) & 0xffffff;
772 ptr = (ptr + 1) << 2; 772 ptr = (ptr + 1) << 2;
773 ptr = bytes_to_frames(substream->runtime, ptr); 773 ptr = bytes_to_frames(substream->runtime, ptr);
774 if (! ptr) 774 if (!ptr)
775 ; 775 ;
776 else if (ptr <= substream->runtime->buffer_size) 776 else if (ptr <= substream->runtime->buffer_size)
777 ptr = substream->runtime->buffer_size - ptr; 777 ptr = substream->runtime->buffer_size - ptr;
@@ -815,7 +815,7 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substr
815 ptr = inw(ice->profi_port + reg->size); 815 ptr = inw(ice->profi_port + reg->size);
816 ptr = (ptr + 1) << 2; 816 ptr = (ptr + 1) << 2;
817 ptr = bytes_to_frames(substream->runtime, ptr); 817 ptr = bytes_to_frames(substream->runtime, ptr);
818 if (! ptr) 818 if (!ptr)
819 ; 819 ;
820 else if (ptr <= substream->runtime->buffer_size) 820 else if (ptr <= substream->runtime->buffer_size)
821 ptr = substream->runtime->buffer_size - ptr; 821 ptr = substream->runtime->buffer_size - ptr;
@@ -842,8 +842,7 @@ static const struct vt1724_pcm_reg vt1724_capture_pro_reg = {
842 .start = VT1724_RDMA0_START, 842 .start = VT1724_RDMA0_START,
843}; 843};
844 844
845static const struct snd_pcm_hardware snd_vt1724_playback_pro = 845static const struct snd_pcm_hardware snd_vt1724_playback_pro = {
846{
847 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 846 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
848 SNDRV_PCM_INFO_BLOCK_TRANSFER | 847 SNDRV_PCM_INFO_BLOCK_TRANSFER |
849 SNDRV_PCM_INFO_MMAP_VALID | 848 SNDRV_PCM_INFO_MMAP_VALID |
@@ -861,8 +860,7 @@ static const struct snd_pcm_hardware snd_vt1724_playback_pro =
861 .periods_max = 1024, 860 .periods_max = 1024,
862}; 861};
863 862
864static const struct snd_pcm_hardware snd_vt1724_spdif = 863static const struct snd_pcm_hardware snd_vt1724_spdif = {
865{
866 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 864 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
867 SNDRV_PCM_INFO_BLOCK_TRANSFER | 865 SNDRV_PCM_INFO_BLOCK_TRANSFER |
868 SNDRV_PCM_INFO_MMAP_VALID | 866 SNDRV_PCM_INFO_MMAP_VALID |
@@ -883,8 +881,7 @@ static const struct snd_pcm_hardware snd_vt1724_spdif =
883 .periods_max = 1024, 881 .periods_max = 1024,
884}; 882};
885 883
886static const struct snd_pcm_hardware snd_vt1724_2ch_stereo = 884static const struct snd_pcm_hardware snd_vt1724_2ch_stereo = {
887{
888 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 885 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
889 SNDRV_PCM_INFO_BLOCK_TRANSFER | 886 SNDRV_PCM_INFO_BLOCK_TRANSFER |
890 SNDRV_PCM_INFO_MMAP_VALID | 887 SNDRV_PCM_INFO_MMAP_VALID |
@@ -942,7 +939,7 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
942{ 939{
943 struct snd_pcm_runtime *runtime = substream->runtime; 940 struct snd_pcm_runtime *runtime = substream->runtime;
944 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 941 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
945 int chs; 942 int chs, num_indeps;
946 943
947 runtime->private_data = (void *)&vt1724_playback_pro_reg; 944 runtime->private_data = (void *)&vt1724_playback_pro_reg;
948 ice->playback_pro_substream = substream; 945 ice->playback_pro_substream = substream;
@@ -952,7 +949,8 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
952 set_rate_constraints(ice, substream); 949 set_rate_constraints(ice, substream);
953 mutex_lock(&ice->open_mutex); 950 mutex_lock(&ice->open_mutex);
954 /* calculate the currently available channels */ 951 /* calculate the currently available channels */
955 for (chs = 0; chs < 3; chs++) { 952 num_indeps = ice->num_total_dacs / 2 - 1;
953 for (chs = 0; chs < num_indeps; chs++) {
956 if (ice->pcm_reserved[chs]) 954 if (ice->pcm_reserved[chs])
957 break; 955 break;
958 } 956 }
@@ -1029,7 +1027,7 @@ static struct snd_pcm_ops snd_vt1724_capture_pro_ops = {
1029 .pointer = snd_vt1724_pcm_pointer, 1027 .pointer = snd_vt1724_pcm_pointer,
1030}; 1028};
1031 1029
1032static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 * ice, int device) 1030static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device)
1033{ 1031{
1034 struct snd_pcm *pcm; 1032 struct snd_pcm *pcm;
1035 int err; 1033 int err;
@@ -1114,7 +1112,7 @@ static void update_spdif_rate(struct snd_ice1712 *ice, unsigned int rate)
1114static int snd_vt1724_playback_spdif_prepare(struct snd_pcm_substream *substream) 1112static int snd_vt1724_playback_spdif_prepare(struct snd_pcm_substream *substream)
1115{ 1113{
1116 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1114 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1117 if (! ice->force_pdma4) 1115 if (!ice->force_pdma4)
1118 update_spdif_rate(ice, substream->runtime->rate); 1116 update_spdif_rate(ice, substream->runtime->rate);
1119 return snd_vt1724_pcm_prepare(substream); 1117 return snd_vt1724_pcm_prepare(substream);
1120} 1118}
@@ -1214,7 +1212,7 @@ static struct snd_pcm_ops snd_vt1724_capture_spdif_ops = {
1214}; 1212};
1215 1213
1216 1214
1217static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 * ice, int device) 1215static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 *ice, int device)
1218{ 1216{
1219 char *name; 1217 char *name;
1220 struct snd_pcm *pcm; 1218 struct snd_pcm *pcm;
@@ -1233,7 +1231,7 @@ static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 * ice, int device)
1233 ice->has_spdif = 1; 1231 ice->has_spdif = 1;
1234 } else 1232 } else
1235 capt = 0; 1233 capt = 0;
1236 if (! play && ! capt) 1234 if (!play && !capt)
1237 return 0; /* no spdif device */ 1235 return 0; /* no spdif device */
1238 1236
1239 if (ice->force_pdma4 || ice->force_rdma1) 1237 if (ice->force_pdma4 || ice->force_rdma1)
@@ -1348,7 +1346,7 @@ static struct snd_pcm_ops snd_vt1724_playback_indep_ops = {
1348}; 1346};
1349 1347
1350 1348
1351static int __devinit snd_vt1724_pcm_indep(struct snd_ice1712 * ice, int device) 1349static int __devinit snd_vt1724_pcm_indep(struct snd_ice1712 *ice, int device)
1352{ 1350{
1353 struct snd_pcm *pcm; 1351 struct snd_pcm *pcm;
1354 int play; 1352 int play;
@@ -1383,11 +1381,11 @@ static int __devinit snd_vt1724_pcm_indep(struct snd_ice1712 * ice, int device)
1383 * Mixer section 1381 * Mixer section
1384 */ 1382 */
1385 1383
1386static int __devinit snd_vt1724_ac97_mixer(struct snd_ice1712 * ice) 1384static int __devinit snd_vt1724_ac97_mixer(struct snd_ice1712 *ice)
1387{ 1385{
1388 int err; 1386 int err;
1389 1387
1390 if (! (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) { 1388 if (!(ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) {
1391 struct snd_ac97_bus *pbus; 1389 struct snd_ac97_bus *pbus;
1392 struct snd_ac97_template ac97; 1390 struct snd_ac97_template ac97;
1393 static struct snd_ac97_bus_ops ops = { 1391 static struct snd_ac97_bus_ops ops = {
@@ -1400,11 +1398,13 @@ static int __devinit snd_vt1724_ac97_mixer(struct snd_ice1712 * ice)
1400 mdelay(5); /* FIXME */ 1398 mdelay(5); /* FIXME */
1401 outb(inb(ICEMT1724(ice, AC97_CMD)) & ~0x80, ICEMT1724(ice, AC97_CMD)); 1399 outb(inb(ICEMT1724(ice, AC97_CMD)) & ~0x80, ICEMT1724(ice, AC97_CMD));
1402 1400
1403 if ((err = snd_ac97_bus(ice->card, 0, &ops, NULL, &pbus)) < 0) 1401 err = snd_ac97_bus(ice->card, 0, &ops, NULL, &pbus);
1402 if (err < 0)
1404 return err; 1403 return err;
1405 memset(&ac97, 0, sizeof(ac97)); 1404 memset(&ac97, 0, sizeof(ac97));
1406 ac97.private_data = ice; 1405 ac97.private_data = ice;
1407 if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0) 1406 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1407 if (err < 0)
1408 printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n"); 1408 printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n");
1409 else 1409 else
1410 return 0; 1410 return 0;
@@ -1425,7 +1425,7 @@ static inline unsigned int eeprom_triple(struct snd_ice1712 *ice, int idx)
1425 ((unsigned int)ice->eeprom.data[idx + 2] << 16); 1425 ((unsigned int)ice->eeprom.data[idx + 2] << 16);
1426} 1426}
1427 1427
1428static void snd_vt1724_proc_read(struct snd_info_entry *entry, 1428static void snd_vt1724_proc_read(struct snd_info_entry *entry,
1429 struct snd_info_buffer *buffer) 1429 struct snd_info_buffer *buffer)
1430{ 1430{
1431 struct snd_ice1712 *ice = entry->private_data; 1431 struct snd_ice1712 *ice = entry->private_data;
@@ -1467,11 +1467,11 @@ static void snd_vt1724_proc_read(struct snd_info_entry *entry,
1467 idx, inb(ice->profi_port+idx)); 1467 idx, inb(ice->profi_port+idx));
1468} 1468}
1469 1469
1470static void __devinit snd_vt1724_proc_init(struct snd_ice1712 * ice) 1470static void __devinit snd_vt1724_proc_init(struct snd_ice1712 *ice)
1471{ 1471{
1472 struct snd_info_entry *entry; 1472 struct snd_info_entry *entry;
1473 1473
1474 if (! snd_card_proc_new(ice->card, "ice1724", &entry)) 1474 if (!snd_card_proc_new(ice->card, "ice1724", &entry))
1475 snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read); 1475 snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read);
1476} 1476}
1477 1477
@@ -1491,7 +1491,7 @@ static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol,
1491 struct snd_ctl_elem_value *ucontrol) 1491 struct snd_ctl_elem_value *ucontrol)
1492{ 1492{
1493 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1493 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1494 1494
1495 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); 1495 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom));
1496 return 0; 1496 return 0;
1497} 1497}
@@ -1606,13 +1606,13 @@ static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol,
1606 if (val != old) 1606 if (val != old)
1607 update_spdif_bits(ice, val); 1607 update_spdif_bits(ice, val);
1608 spin_unlock_irq(&ice->reg_lock); 1608 spin_unlock_irq(&ice->reg_lock);
1609 return (val != old); 1609 return val != old;
1610} 1610}
1611 1611
1612static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata = 1612static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata =
1613{ 1613{
1614 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1614 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1615 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1615 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
1616 .info = snd_vt1724_spdif_info, 1616 .info = snd_vt1724_spdif_info,
1617 .get = snd_vt1724_spdif_default_get, 1617 .get = snd_vt1724_spdif_default_get,
1618 .put = snd_vt1724_spdif_default_put 1618 .put = snd_vt1724_spdif_default_put
@@ -1645,7 +1645,7 @@ static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1645{ 1645{
1646 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1646 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1647 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1647 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1648 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), 1648 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK),
1649 .info = snd_vt1724_spdif_info, 1649 .info = snd_vt1724_spdif_info,
1650 .get = snd_vt1724_spdif_maskc_get, 1650 .get = snd_vt1724_spdif_maskc_get,
1651}; 1651};
@@ -1654,7 +1654,7 @@ static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata =
1654{ 1654{
1655 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1655 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1656 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1656 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1657 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), 1657 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK),
1658 .info = snd_vt1724_spdif_info, 1658 .info = snd_vt1724_spdif_info,
1659 .get = snd_vt1724_spdif_maskp_get, 1659 .get = snd_vt1724_spdif_maskp_get,
1660}; 1660};
@@ -1691,8 +1691,8 @@ static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata =
1691{ 1691{
1692 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1692 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1693 /* FIXME: the following conflict with IEC958 Playback Route */ 1693 /* FIXME: the following conflict with IEC958 Playback Route */
1694 // .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 1694 /* .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH), */
1695 .name = SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), 1695 .name = SNDRV_CTL_NAME_IEC958("Output ", NONE, SWITCH),
1696 .info = snd_vt1724_spdif_sw_info, 1696 .info = snd_vt1724_spdif_sw_info,
1697 .get = snd_vt1724_spdif_sw_get, 1697 .get = snd_vt1724_spdif_sw_get,
1698 .put = snd_vt1724_spdif_sw_put 1698 .put = snd_vt1724_spdif_sw_put
@@ -1712,7 +1712,7 @@ int snd_vt1724_gpio_get(struct snd_kcontrol *kcontrol,
1712 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1712 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1713 int shift = kcontrol->private_value & 0xff; 1713 int shift = kcontrol->private_value & 0xff;
1714 int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0; 1714 int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0;
1715 1715
1716 snd_ice1712_save_gpio_status(ice); 1716 snd_ice1712_save_gpio_status(ice);
1717 ucontrol->value.integer.value[0] = 1717 ucontrol->value.integer.value[0] =
1718 (snd_ice1712_gpio_read(ice) & (1 << shift) ? 1 : 0) ^ invert; 1718 (snd_ice1712_gpio_read(ice) & (1 << shift) ? 1 : 0) ^ invert;
@@ -1767,7 +1767,7 @@ static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
1767{ 1767{
1768 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1768 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1769 unsigned int i, rate; 1769 unsigned int i, rate;
1770 1770
1771 spin_lock_irq(&ice->reg_lock); 1771 spin_lock_irq(&ice->reg_lock);
1772 if (ice->is_spdif_master(ice)) { 1772 if (ice->is_spdif_master(ice)) {
1773 ucontrol->value.enumerated.item[0] = ice->hw_rates->count; 1773 ucontrol->value.enumerated.item[0] = ice->hw_rates->count;
@@ -1923,7 +1923,7 @@ static int snd_vt1724_pro_route_info(struct snd_kcontrol *kcontrol,
1923 "H/W In 0", "H/W In 1", /* 1-2 */ 1923 "H/W In 0", "H/W In 1", /* 1-2 */
1924 "IEC958 In L", "IEC958 In R", /* 3-4 */ 1924 "IEC958 In L", "IEC958 In R", /* 3-4 */
1925 }; 1925 };
1926 1926
1927 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1927 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1928 uinfo->count = 1; 1928 uinfo->count = 1;
1929 uinfo->value.enumerated.items = 5; 1929 uinfo->value.enumerated.items = 5;
@@ -1953,7 +1953,7 @@ static int get_route_val(struct snd_ice1712 *ice, int shift)
1953 1953
1954 val = inl(ICEMT1724(ice, ROUTE_PLAYBACK)); 1954 val = inl(ICEMT1724(ice, ROUTE_PLAYBACK));
1955 val >>= shift; 1955 val >>= shift;
1956 val &= 7; //we now have 3 bits per output 1956 val &= 7; /* we now have 3 bits per output */
1957 eitem = xlate[val]; 1957 eitem = xlate[val];
1958 if (eitem == 255) { 1958 if (eitem == 255) {
1959 snd_BUG(); 1959 snd_BUG();
@@ -2032,7 +2032,7 @@ static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata =
2032 2032
2033static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = { 2033static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
2034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2035 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 2035 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, NONE) "Route",
2036 .info = snd_vt1724_pro_route_info, 2036 .info = snd_vt1724_pro_route_info,
2037 .get = snd_vt1724_pro_route_spdif_get, 2037 .get = snd_vt1724_pro_route_spdif_get,
2038 .put = snd_vt1724_pro_route_spdif_put, 2038 .put = snd_vt1724_pro_route_spdif_put,
@@ -2055,7 +2055,7 @@ static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol,
2055{ 2055{
2056 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 2056 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2057 int idx; 2057 int idx;
2058 2058
2059 spin_lock_irq(&ice->reg_lock); 2059 spin_lock_irq(&ice->reg_lock);
2060 for (idx = 0; idx < 22; idx++) { 2060 for (idx = 0; idx < 22; idx++) {
2061 outb(idx, ICEMT1724(ice, MONITOR_PEAKINDEX)); 2061 outb(idx, ICEMT1724(ice, MONITOR_PEAKINDEX));
@@ -2082,7 +2082,7 @@ static struct snd_ice1712_card_info no_matched __devinitdata;
2082 2082
2083static struct snd_ice1712_card_info *card_tables[] __devinitdata = { 2083static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2084 snd_vt1724_revo_cards, 2084 snd_vt1724_revo_cards,
2085 snd_vt1724_amp_cards, 2085 snd_vt1724_amp_cards,
2086 snd_vt1724_aureon_cards, 2086 snd_vt1724_aureon_cards,
2087 snd_vt1720_mobo_cards, 2087 snd_vt1720_mobo_cards,
2088 snd_vt1720_pontis_cards, 2088 snd_vt1720_pontis_cards,
@@ -2120,7 +2120,7 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
2120 wait_i2c_busy(ice); 2120 wait_i2c_busy(ice);
2121 val = inb(ICEREG1724(ice, I2C_DATA)); 2121 val = inb(ICEREG1724(ice, I2C_DATA));
2122 mutex_unlock(&ice->i2c_mutex); 2122 mutex_unlock(&ice->i2c_mutex);
2123 //printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); 2123 /* printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); */
2124 return val; 2124 return val;
2125} 2125}
2126 2126
@@ -2129,7 +2129,7 @@ void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
2129{ 2129{
2130 mutex_lock(&ice->i2c_mutex); 2130 mutex_lock(&ice->i2c_mutex);
2131 wait_i2c_busy(ice); 2131 wait_i2c_busy(ice);
2132 //printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); 2132 /* printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); */
2133 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 2133 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
2134 outb(data, ICEREG1724(ice, I2C_DATA)); 2134 outb(data, ICEREG1724(ice, I2C_DATA));
2135 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR)); 2135 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR));
@@ -2144,13 +2144,13 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2144 unsigned int i, size; 2144 unsigned int i, size;
2145 struct snd_ice1712_card_info * const *tbl, *c; 2145 struct snd_ice1712_card_info * const *tbl, *c;
2146 2146
2147 if (! modelname || ! *modelname) { 2147 if (!modelname || !*modelname) {
2148 ice->eeprom.subvendor = 0; 2148 ice->eeprom.subvendor = 0;
2149 if ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_EEPROM) != 0) 2149 if ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_EEPROM) != 0)
2150 ice->eeprom.subvendor = 2150 ice->eeprom.subvendor =
2151 (snd_vt1724_read_i2c(ice, dev, 0x00) << 0) | 2151 (snd_vt1724_read_i2c(ice, dev, 0x00) << 0) |
2152 (snd_vt1724_read_i2c(ice, dev, 0x01) << 8) | 2152 (snd_vt1724_read_i2c(ice, dev, 0x01) << 8) |
2153 (snd_vt1724_read_i2c(ice, dev, 0x02) << 16) | 2153 (snd_vt1724_read_i2c(ice, dev, 0x02) << 16) |
2154 (snd_vt1724_read_i2c(ice, dev, 0x03) << 24); 2154 (snd_vt1724_read_i2c(ice, dev, 0x03) << 24);
2155 if (ice->eeprom.subvendor == 0 || 2155 if (ice->eeprom.subvendor == 0 ||
2156 ice->eeprom.subvendor == (unsigned int)-1) { 2156 ice->eeprom.subvendor == (unsigned int)-1) {
@@ -2173,13 +2173,13 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2173 for (tbl = card_tables; *tbl; tbl++) { 2173 for (tbl = card_tables; *tbl; tbl++) {
2174 for (c = *tbl; c->subvendor; c++) { 2174 for (c = *tbl; c->subvendor; c++) {
2175 if (modelname && c->model && 2175 if (modelname && c->model &&
2176 ! strcmp(modelname, c->model)) { 2176 !strcmp(modelname, c->model)) {
2177 printk(KERN_INFO "ice1724: Using board model %s\n", 2177 printk(KERN_INFO "ice1724: Using board model %s\n",
2178 c->name); 2178 c->name);
2179 ice->eeprom.subvendor = c->subvendor; 2179 ice->eeprom.subvendor = c->subvendor;
2180 } else if (c->subvendor != ice->eeprom.subvendor) 2180 } else if (c->subvendor != ice->eeprom.subvendor)
2181 continue; 2181 continue;
2182 if (! c->eeprom_size || ! c->eeprom_data) 2182 if (!c->eeprom_size || !c->eeprom_data)
2183 goto found; 2183 goto found;
2184 /* if the EEPROM is given by the driver, use it */ 2184 /* if the EEPROM is given by the driver, use it */
2185 snd_printdd("using the defined eeprom..\n"); 2185 snd_printdd("using the defined eeprom..\n");
@@ -2250,7 +2250,8 @@ static int __devinit snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice)
2250 int err; 2250 int err;
2251 struct snd_kcontrol *kctl; 2251 struct snd_kcontrol *kctl;
2252 2252
2253 snd_assert(ice->pcm != NULL, return -EIO); 2253 if (snd_BUG_ON(!ice->pcm))
2254 return -EIO;
2254 2255
2255 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice)); 2256 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice));
2256 if (err < 0) 2257 if (err < 0)
@@ -2320,13 +2321,13 @@ static int __devinit snd_vt1724_build_controls(struct snd_ice1712 *ice)
2320 2321
2321static int snd_vt1724_free(struct snd_ice1712 *ice) 2322static int snd_vt1724_free(struct snd_ice1712 *ice)
2322{ 2323{
2323 if (! ice->port) 2324 if (!ice->port)
2324 goto __hw_end; 2325 goto __hw_end;
2325 /* mask all interrupts */ 2326 /* mask all interrupts */
2326 outb(0xff, ICEMT1724(ice, DMA_INT_MASK)); 2327 outb(0xff, ICEMT1724(ice, DMA_INT_MASK));
2327 outb(0xff, ICEREG1724(ice, IRQMASK)); 2328 outb(0xff, ICEREG1724(ice, IRQMASK));
2328 /* --- */ 2329 /* --- */
2329 __hw_end: 2330__hw_end:
2330 if (ice->irq >= 0) 2331 if (ice->irq >= 0)
2331 free_irq(ice->irq, ice); 2332 free_irq(ice->irq, ice);
2332 pci_release_regions(ice->pci); 2333 pci_release_regions(ice->pci);
@@ -2346,7 +2347,7 @@ static int snd_vt1724_dev_free(struct snd_device *device)
2346static int __devinit snd_vt1724_create(struct snd_card *card, 2347static int __devinit snd_vt1724_create(struct snd_card *card,
2347 struct pci_dev *pci, 2348 struct pci_dev *pci,
2348 const char *modelname, 2349 const char *modelname,
2349 struct snd_ice1712 ** r_ice1712) 2350 struct snd_ice1712 **r_ice1712)
2350{ 2351{
2351 struct snd_ice1712 *ice; 2352 struct snd_ice1712 *ice;
2352 int err; 2353 int err;
@@ -2357,8 +2358,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2357 2358
2358 *r_ice1712 = NULL; 2359 *r_ice1712 = NULL;
2359 2360
2360 /* enable PCI device */ 2361 /* enable PCI device */
2361 if ((err = pci_enable_device(pci)) < 0) 2362 err = pci_enable_device(pci);
2363 if (err < 0)
2362 return err; 2364 return err;
2363 2365
2364 ice = kzalloc(sizeof(*ice), GFP_KERNEL); 2366 ice = kzalloc(sizeof(*ice), GFP_KERNEL);
@@ -2382,7 +2384,8 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2382 snd_vt1724_proc_init(ice); 2384 snd_vt1724_proc_init(ice);
2383 synchronize_irq(pci->irq); 2385 synchronize_irq(pci->irq);
2384 2386
2385 if ((err = pci_request_regions(pci, "ICE1724")) < 0) { 2387 err = pci_request_regions(pci, "ICE1724");
2388 if (err < 0) {
2386 kfree(ice); 2389 kfree(ice);
2387 pci_disable_device(pci); 2390 pci_disable_device(pci);
2388 return err; 2391 return err;
@@ -2417,9 +2420,10 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2417 */ 2420 */
2418 outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK)); 2421 outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK));
2419 2422
2420 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops)) < 0) { 2423 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops);
2424 if (err < 0) {
2421 snd_vt1724_free(ice); 2425 snd_vt1724_free(ice);
2422 return err; 2426 return err;
2423 } 2427 }
2424 2428
2425 snd_card_set_dev(card, &pci->dev); 2429 snd_card_set_dev(card, &pci->dev);
@@ -2457,8 +2461,9 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2457 2461
2458 strcpy(card->driver, "ICE1724"); 2462 strcpy(card->driver, "ICE1724");
2459 strcpy(card->shortname, "ICEnsemble ICE1724"); 2463 strcpy(card->shortname, "ICEnsemble ICE1724");
2460 2464
2461 if ((err = snd_vt1724_create(card, pci, model[dev], &ice)) < 0) { 2465 err = snd_vt1724_create(card, pci, model[dev], &ice);
2466 if (err < 0) {
2462 snd_card_free(card); 2467 snd_card_free(card);
2463 return err; 2468 return err;
2464 } 2469 }
@@ -2470,7 +2475,8 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2470 if (c->driver) /* specific driver? */ 2475 if (c->driver) /* specific driver? */
2471 strcpy(card->driver, c->driver); 2476 strcpy(card->driver, c->driver);
2472 if (c->chip_init) { 2477 if (c->chip_init) {
2473 if ((err = c->chip_init(ice)) < 0) { 2478 err = c->chip_init(ice);
2479 if (err < 0) {
2474 snd_card_free(card); 2480 snd_card_free(card);
2475 return err; 2481 return err;
2476 } 2482 }
@@ -2480,15 +2486,15 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2480 } 2486 }
2481 } 2487 }
2482 c = &no_matched; 2488 c = &no_matched;
2483 __found: 2489__found:
2484 /* 2490 /*
2485 * VT1724 has separate DMAs for the analog and the SPDIF streams while 2491 * VT1724 has separate DMAs for the analog and the SPDIF streams while
2486 * ICE1712 has only one for both (mixed up). 2492 * ICE1712 has only one for both (mixed up).
2487 * 2493 *
2488 * Confusingly the analog PCM is named "professional" here because it 2494 * Confusingly the analog PCM is named "professional" here because it
2489 * was called so in ice1712 driver, and vt1724 driver is derived from 2495 * was called so in ice1712 driver, and vt1724 driver is derived from
2490 * ice1712 driver. 2496 * ice1712 driver.
2491 */ 2497 */
2492 ice->pro_rate_default = PRO_RATE_DEFAULT; 2498 ice->pro_rate_default = PRO_RATE_DEFAULT;
2493 if (!ice->is_spdif_master) 2499 if (!ice->is_spdif_master)
2494 ice->is_spdif_master = stdclock_is_spdif_master; 2500 ice->is_spdif_master = stdclock_is_spdif_master;
@@ -2503,46 +2509,53 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2503 if (!ice->hw_rates) 2509 if (!ice->hw_rates)
2504 set_std_hw_rates(ice); 2510 set_std_hw_rates(ice);
2505 2511
2506 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) { 2512 err = snd_vt1724_pcm_profi(ice, pcm_dev++);
2513 if (err < 0) {
2507 snd_card_free(card); 2514 snd_card_free(card);
2508 return err; 2515 return err;
2509 } 2516 }
2510 2517
2511 if ((err = snd_vt1724_pcm_spdif(ice, pcm_dev++)) < 0) { 2518 err = snd_vt1724_pcm_spdif(ice, pcm_dev++);
2519 if (err < 0) {
2512 snd_card_free(card); 2520 snd_card_free(card);
2513 return err; 2521 return err;
2514 } 2522 }
2515 2523
2516 if ((err = snd_vt1724_pcm_indep(ice, pcm_dev++)) < 0) { 2524 err = snd_vt1724_pcm_indep(ice, pcm_dev++);
2525 if (err < 0) {
2517 snd_card_free(card); 2526 snd_card_free(card);
2518 return err; 2527 return err;
2519 } 2528 }
2520 2529
2521 if ((err = snd_vt1724_ac97_mixer(ice)) < 0) { 2530 err = snd_vt1724_ac97_mixer(ice);
2531 if (err < 0) {
2522 snd_card_free(card); 2532 snd_card_free(card);
2523 return err; 2533 return err;
2524 } 2534 }
2525 2535
2526 if ((err = snd_vt1724_build_controls(ice)) < 0) { 2536 err = snd_vt1724_build_controls(ice);
2537 if (err < 0) {
2527 snd_card_free(card); 2538 snd_card_free(card);
2528 return err; 2539 return err;
2529 } 2540 }
2530 2541
2531 if (ice->pcm && ice->has_spdif) { /* has SPDIF I/O */ 2542 if (ice->pcm && ice->has_spdif) { /* has SPDIF I/O */
2532 if ((err = snd_vt1724_spdif_build_controls(ice)) < 0) { 2543 err = snd_vt1724_spdif_build_controls(ice);
2544 if (err < 0) {
2533 snd_card_free(card); 2545 snd_card_free(card);
2534 return err; 2546 return err;
2535 } 2547 }
2536 } 2548 }
2537 2549
2538 if (c->build_controls) { 2550 if (c->build_controls) {
2539 if ((err = c->build_controls(ice)) < 0) { 2551 err = c->build_controls(ice);
2552 if (err < 0) {
2540 snd_card_free(card); 2553 snd_card_free(card);
2541 return err; 2554 return err;
2542 } 2555 }
2543 } 2556 }
2544 2557
2545 if (! c->no_mpu401) { 2558 if (!c->no_mpu401) {
2546 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) { 2559 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) {
2547 struct snd_rawmidi *rmidi; 2560 struct snd_rawmidi *rmidi;
2548 2561
@@ -2574,7 +2587,8 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2574 sprintf(card->longname, "%s at 0x%lx, irq %i", 2587 sprintf(card->longname, "%s at 0x%lx, irq %i",
2575 card->shortname, ice->port, ice->irq); 2588 card->shortname, ice->port, ice->irq);
2576 2589
2577 if ((err = snd_card_register(card)) < 0) { 2590 err = snd_card_register(card);
2591 if (err < 0) {
2578 snd_card_free(card); 2592 snd_card_free(card);
2579 return err; 2593 return err;
2580 } 2594 }