diff options
Diffstat (limited to 'sound/pci/ice1712/ice1712.c')
-rw-r--r-- | sound/pci/ice1712/ice1712.c | 240 |
1 files changed, 127 insertions, 113 deletions
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 29d449d73c98..5b442383fcda 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | NOTES: | 23 | NOTES: |
@@ -35,7 +35,7 @@ | |||
35 | * | 35 | * |
36 | * 2002.11.26 James Stafford <jstafford@ampltd.com> | 36 | * 2002.11.26 James Stafford <jstafford@ampltd.com> |
37 | * Added support for VT1724 (Envy24HT) | 37 | * Added support for VT1724 (Envy24HT) |
38 | * I have left out support for 176.4 and 192 KHz for the moment. | 38 | * I have left out support for 176.4 and 192 KHz for the moment. |
39 | * I also haven't done anything with the internal S/PDIF transmitter or the MPU-401 | 39 | * I also haven't done anything with the internal S/PDIF transmitter or the MPU-401 |
40 | * | 40 | * |
41 | * 2003.02.20 Taksahi Iwai <tiwai@suse.de> | 41 | * 2003.02.20 Taksahi Iwai <tiwai@suse.de> |
@@ -47,7 +47,7 @@ | |||
47 | */ | 47 | */ |
48 | 48 | ||
49 | 49 | ||
50 | #include <asm/io.h> | 50 | #include <linux/io.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/interrupt.h> | 52 | #include <linux/interrupt.h> |
53 | #include <linux/init.h> | 53 | #include <linux/init.h> |
@@ -123,7 +123,7 @@ static unsigned int PRO_RATE_DEFAULT = 44100; | |||
123 | /* | 123 | /* |
124 | * Basic I/O | 124 | * Basic I/O |
125 | */ | 125 | */ |
126 | 126 | ||
127 | /* check whether the clock mode is spdif-in */ | 127 | /* check whether the clock mode is spdif-in */ |
128 | static inline int is_spdif_master(struct snd_ice1712 *ice) | 128 | static inline int is_spdif_master(struct snd_ice1712 *ice) |
129 | { | 129 | { |
@@ -135,13 +135,13 @@ static inline int is_pro_rate_locked(struct snd_ice1712 *ice) | |||
135 | return is_spdif_master(ice) || PRO_RATE_LOCKED; | 135 | return is_spdif_master(ice) || PRO_RATE_LOCKED; |
136 | } | 136 | } |
137 | 137 | ||
138 | static inline void snd_ice1712_ds_write(struct snd_ice1712 * ice, u8 channel, u8 addr, u32 data) | 138 | static inline void snd_ice1712_ds_write(struct snd_ice1712 *ice, u8 channel, u8 addr, u32 data) |
139 | { | 139 | { |
140 | outb((channel << 4) | addr, ICEDS(ice, INDEX)); | 140 | outb((channel << 4) | addr, ICEDS(ice, INDEX)); |
141 | outl(data, ICEDS(ice, DATA)); | 141 | outl(data, ICEDS(ice, DATA)); |
142 | } | 142 | } |
143 | 143 | ||
144 | static inline u32 snd_ice1712_ds_read(struct snd_ice1712 * ice, u8 channel, u8 addr) | 144 | static inline u32 snd_ice1712_ds_read(struct snd_ice1712 *ice, u8 channel, u8 addr) |
145 | { | 145 | { |
146 | outb((channel << 4) | addr, ICEDS(ice, INDEX)); | 146 | outb((channel << 4) | addr, ICEDS(ice, INDEX)); |
147 | return inl(ICEDS(ice, DATA)); | 147 | return inl(ICEDS(ice, DATA)); |
@@ -260,7 +260,7 @@ static unsigned short snd_ice1712_pro_ac97_read(struct snd_ac97 *ac97, | |||
260 | static int snd_ice1712_digmix_route_ac97_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 260 | static int snd_ice1712_digmix_route_ac97_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
261 | { | 261 | { |
262 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 262 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
263 | 263 | ||
264 | ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0; | 264 | ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0; |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
@@ -269,11 +269,12 @@ static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, stru | |||
269 | { | 269 | { |
270 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 270 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
271 | unsigned char val, nval; | 271 | unsigned char val, nval; |
272 | 272 | ||
273 | spin_lock_irq(&ice->reg_lock); | 273 | spin_lock_irq(&ice->reg_lock); |
274 | val = inb(ICEMT(ice, MONITOR_ROUTECTRL)); | 274 | val = inb(ICEMT(ice, MONITOR_ROUTECTRL)); |
275 | nval = val & ~ICE1712_ROUTE_AC97; | 275 | nval = val & ~ICE1712_ROUTE_AC97; |
276 | if (ucontrol->value.integer.value[0]) nval |= ICE1712_ROUTE_AC97; | 276 | if (ucontrol->value.integer.value[0]) |
277 | nval |= ICE1712_ROUTE_AC97; | ||
277 | outb(nval, ICEMT(ice, MONITOR_ROUTECTRL)); | 278 | outb(nval, ICEMT(ice, MONITOR_ROUTECTRL)); |
278 | spin_unlock_irq(&ice->reg_lock); | 279 | spin_unlock_irq(&ice->reg_lock); |
279 | return val != nval; | 280 | return val != nval; |
@@ -329,7 +330,7 @@ static int snd_ice1712_cs8427_set_input_clock(struct snd_ice1712 *ice, int spdif | |||
329 | unsigned char reg[2] = { 0x80 | 4, 0 }; /* CS8427 auto increment | register number 4 + data */ | 330 | unsigned char reg[2] = { 0x80 | 4, 0 }; /* CS8427 auto increment | register number 4 + data */ |
330 | unsigned char val, nval; | 331 | unsigned char val, nval; |
331 | int res = 0; | 332 | int res = 0; |
332 | 333 | ||
333 | snd_i2c_lock(ice->i2c); | 334 | snd_i2c_lock(ice->i2c); |
334 | if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) { | 335 | if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) { |
335 | snd_i2c_unlock(ice->i2c); | 336 | snd_i2c_unlock(ice->i2c); |
@@ -381,9 +382,9 @@ int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr) | |||
381 | { | 382 | { |
382 | int err; | 383 | int err; |
383 | 384 | ||
384 | if ((err = snd_cs8427_create(ice->i2c, addr, | 385 | err = snd_cs8427_create(ice->i2c, addr, |
385 | (ice->cs8427_timeout * HZ) / 1000, | 386 | (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427); |
386 | &ice->cs8427)) < 0) { | 387 | if (err < 0) { |
387 | snd_printk(KERN_ERR "CS8427 initialization failed\n"); | 388 | snd_printk(KERN_ERR "CS8427 initialization failed\n"); |
388 | return err; | 389 | return err; |
389 | } | 390 | } |
@@ -395,9 +396,9 @@ int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr) | |||
395 | 396 | ||
396 | static void snd_ice1712_set_input_clock_source(struct snd_ice1712 *ice, int spdif_is_master) | 397 | static void snd_ice1712_set_input_clock_source(struct snd_ice1712 *ice, int spdif_is_master) |
397 | { | 398 | { |
398 | /* change CS8427 clock source too */ | 399 | /* change CS8427 clock source too */ |
399 | if (ice->cs8427) | 400 | if (ice->cs8427) |
400 | snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master); | 401 | snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master); |
401 | /* notify ak4524 chip as well */ | 402 | /* notify ak4524 chip as well */ |
402 | if (spdif_is_master) { | 403 | if (spdif_is_master) { |
403 | unsigned int i; | 404 | unsigned int i; |
@@ -457,11 +458,12 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id) | |||
457 | u16 pbkstatus; | 458 | u16 pbkstatus; |
458 | struct snd_pcm_substream *substream; | 459 | struct snd_pcm_substream *substream; |
459 | pbkstatus = inw(ICEDS(ice, INTSTAT)); | 460 | pbkstatus = inw(ICEDS(ice, INTSTAT)); |
460 | //printk("pbkstatus = 0x%x\n", pbkstatus); | 461 | /* printk("pbkstatus = 0x%x\n", pbkstatus); */ |
461 | for (idx = 0; idx < 6; idx++) { | 462 | for (idx = 0; idx < 6; idx++) { |
462 | if ((pbkstatus & (3 << (idx * 2))) == 0) | 463 | if ((pbkstatus & (3 << (idx * 2))) == 0) |
463 | continue; | 464 | continue; |
464 | if ((substream = ice->playback_con_substream_ds[idx]) != NULL) | 465 | substream = ice->playback_con_substream_ds[idx]; |
466 | if (substream != NULL) | ||
465 | snd_pcm_period_elapsed(substream); | 467 | snd_pcm_period_elapsed(substream); |
466 | outw(3 << (idx * 2), ICEDS(ice, INTSTAT)); | 468 | outw(3 << (idx * 2), ICEDS(ice, INTSTAT)); |
467 | } | 469 | } |
@@ -507,7 +509,7 @@ static int snd_ice1712_playback_trigger(struct snd_pcm_substream *substream, | |||
507 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); | 509 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); |
508 | int result = 0; | 510 | int result = 0; |
509 | u32 tmp; | 511 | u32 tmp; |
510 | 512 | ||
511 | spin_lock(&ice->reg_lock); | 513 | spin_lock(&ice->reg_lock); |
512 | tmp = snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL); | 514 | tmp = snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL); |
513 | if (cmd == SNDRV_PCM_TRIGGER_START) { | 515 | if (cmd == SNDRV_PCM_TRIGGER_START) { |
@@ -532,7 +534,7 @@ static int snd_ice1712_playback_ds_trigger(struct snd_pcm_substream *substream, | |||
532 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); | 534 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); |
533 | int result = 0; | 535 | int result = 0; |
534 | u32 tmp; | 536 | u32 tmp; |
535 | 537 | ||
536 | spin_lock(&ice->reg_lock); | 538 | spin_lock(&ice->reg_lock); |
537 | tmp = snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL); | 539 | tmp = snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL); |
538 | if (cmd == SNDRV_PCM_TRIGGER_START) { | 540 | if (cmd == SNDRV_PCM_TRIGGER_START) { |
@@ -557,7 +559,7 @@ static int snd_ice1712_capture_trigger(struct snd_pcm_substream *substream, | |||
557 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); | 559 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); |
558 | int result = 0; | 560 | int result = 0; |
559 | u8 tmp; | 561 | u8 tmp; |
560 | 562 | ||
561 | spin_lock(&ice->reg_lock); | 563 | spin_lock(&ice->reg_lock); |
562 | tmp = snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL); | 564 | tmp = snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL); |
563 | if (cmd == SNDRV_PCM_TRIGGER_START) { | 565 | if (cmd == SNDRV_PCM_TRIGGER_START) { |
@@ -711,8 +713,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *s | |||
711 | return bytes_to_frames(substream->runtime, ptr); | 713 | return bytes_to_frames(substream->runtime, ptr); |
712 | } | 714 | } |
713 | 715 | ||
714 | static const struct snd_pcm_hardware snd_ice1712_playback = | 716 | static const struct snd_pcm_hardware snd_ice1712_playback = { |
715 | { | ||
716 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 717 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
717 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 718 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
718 | SNDRV_PCM_INFO_MMAP_VALID | | 719 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -731,8 +732,7 @@ static const struct snd_pcm_hardware snd_ice1712_playback = | |||
731 | .fifo_size = 0, | 732 | .fifo_size = 0, |
732 | }; | 733 | }; |
733 | 734 | ||
734 | static const struct snd_pcm_hardware snd_ice1712_playback_ds = | 735 | static const struct snd_pcm_hardware snd_ice1712_playback_ds = { |
735 | { | ||
736 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 736 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
737 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 737 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
738 | SNDRV_PCM_INFO_MMAP_VALID | | 738 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -751,8 +751,7 @@ static const struct snd_pcm_hardware snd_ice1712_playback_ds = | |||
751 | .fifo_size = 0, | 751 | .fifo_size = 0, |
752 | }; | 752 | }; |
753 | 753 | ||
754 | static const struct snd_pcm_hardware snd_ice1712_capture = | 754 | static const struct snd_pcm_hardware snd_ice1712_capture = { |
755 | { | ||
756 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 755 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
757 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 756 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
758 | SNDRV_PCM_INFO_MMAP_VALID), | 757 | SNDRV_PCM_INFO_MMAP_VALID), |
@@ -788,7 +787,7 @@ static int snd_ice1712_playback_ds_open(struct snd_pcm_substream *substream) | |||
788 | 787 | ||
789 | ice->playback_con_substream_ds[substream->number] = substream; | 788 | ice->playback_con_substream_ds[substream->number] = substream; |
790 | runtime->hw = snd_ice1712_playback_ds; | 789 | runtime->hw = snd_ice1712_playback_ds; |
791 | spin_lock_irq(&ice->reg_lock); | 790 | spin_lock_irq(&ice->reg_lock); |
792 | tmp = inw(ICEDS(ice, INTMASK)) & ~(1 << (substream->number * 2)); | 791 | tmp = inw(ICEDS(ice, INTMASK)) & ~(1 << (substream->number * 2)); |
793 | outw(tmp, ICEDS(ice, INTMASK)); | 792 | outw(tmp, ICEDS(ice, INTMASK)); |
794 | spin_unlock_irq(&ice->reg_lock); | 793 | spin_unlock_irq(&ice->reg_lock); |
@@ -821,7 +820,7 @@ static int snd_ice1712_playback_ds_close(struct snd_pcm_substream *substream) | |||
821 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); | 820 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); |
822 | u32 tmp; | 821 | u32 tmp; |
823 | 822 | ||
824 | spin_lock_irq(&ice->reg_lock); | 823 | spin_lock_irq(&ice->reg_lock); |
825 | tmp = inw(ICEDS(ice, INTMASK)) | (3 << (substream->number * 2)); | 824 | tmp = inw(ICEDS(ice, INTMASK)) | (3 << (substream->number * 2)); |
826 | outw(tmp, ICEDS(ice, INTMASK)); | 825 | outw(tmp, ICEDS(ice, INTMASK)); |
827 | spin_unlock_irq(&ice->reg_lock); | 826 | spin_unlock_irq(&ice->reg_lock); |
@@ -870,7 +869,7 @@ static struct snd_pcm_ops snd_ice1712_capture_ops = { | |||
870 | .pointer = snd_ice1712_capture_pointer, | 869 | .pointer = snd_ice1712_capture_pointer, |
871 | }; | 870 | }; |
872 | 871 | ||
873 | static int __devinit snd_ice1712_pcm(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm) | 872 | static int __devinit snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm) |
874 | { | 873 | { |
875 | struct snd_pcm *pcm; | 874 | struct snd_pcm *pcm; |
876 | int err; | 875 | int err; |
@@ -900,7 +899,7 @@ static int __devinit snd_ice1712_pcm(struct snd_ice1712 * ice, int device, struc | |||
900 | return 0; | 899 | return 0; |
901 | } | 900 | } |
902 | 901 | ||
903 | static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm) | 902 | static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm) |
904 | { | 903 | { |
905 | struct snd_pcm *pcm; | 904 | struct snd_pcm *pcm; |
906 | int err; | 905 | int err; |
@@ -1029,14 +1028,14 @@ static void snd_ice1712_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, | |||
1029 | if (inb(ICEMT(ice, PLAYBACK_CONTROL)) & (ICE1712_CAPTURE_START_SHADOW| | 1028 | if (inb(ICEMT(ice, PLAYBACK_CONTROL)) & (ICE1712_CAPTURE_START_SHADOW| |
1030 | ICE1712_PLAYBACK_PAUSE| | 1029 | ICE1712_PLAYBACK_PAUSE| |
1031 | ICE1712_PLAYBACK_START)) { | 1030 | ICE1712_PLAYBACK_START)) { |
1032 | __out: | 1031 | __out: |
1033 | spin_unlock_irqrestore(&ice->reg_lock, flags); | 1032 | spin_unlock_irqrestore(&ice->reg_lock, flags); |
1034 | return; | 1033 | return; |
1035 | } | 1034 | } |
1036 | if (!force && is_pro_rate_locked(ice)) | 1035 | if (!force && is_pro_rate_locked(ice)) |
1037 | goto __out; | 1036 | goto __out; |
1038 | 1037 | ||
1039 | old = inb(ICEMT(ice, RATE)); | 1038 | old = inb(ICEMT(ice, RATE)); |
1040 | if (!force && old == val) | 1039 | if (!force && old == val) |
1041 | goto __out; | 1040 | goto __out; |
1042 | outb(val, ICEMT(ice, RATE)); | 1041 | outb(val, ICEMT(ice, RATE)); |
@@ -1123,8 +1122,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substrea | |||
1123 | return bytes_to_frames(substream->runtime, ptr); | 1122 | return bytes_to_frames(substream->runtime, ptr); |
1124 | } | 1123 | } |
1125 | 1124 | ||
1126 | static const struct snd_pcm_hardware snd_ice1712_playback_pro = | 1125 | static const struct snd_pcm_hardware snd_ice1712_playback_pro = { |
1127 | { | ||
1128 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 1126 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
1129 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 1127 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
1130 | SNDRV_PCM_INFO_MMAP_VALID | | 1128 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -1143,8 +1141,7 @@ static const struct snd_pcm_hardware snd_ice1712_playback_pro = | |||
1143 | .fifo_size = 0, | 1141 | .fifo_size = 0, |
1144 | }; | 1142 | }; |
1145 | 1143 | ||
1146 | static const struct snd_pcm_hardware snd_ice1712_capture_pro = | 1144 | static const struct snd_pcm_hardware snd_ice1712_capture_pro = { |
1147 | { | ||
1148 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 1145 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
1149 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 1146 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
1150 | SNDRV_PCM_INFO_MMAP_VALID | | 1147 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -1238,7 +1235,7 @@ static struct snd_pcm_ops snd_ice1712_capture_pro_ops = { | |||
1238 | .pointer = snd_ice1712_capture_pro_pointer, | 1235 | .pointer = snd_ice1712_capture_pro_pointer, |
1239 | }; | 1236 | }; |
1240 | 1237 | ||
1241 | static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm) | 1238 | static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm) |
1242 | { | 1239 | { |
1243 | struct snd_pcm *pcm; | 1240 | struct snd_pcm *pcm; |
1244 | int err; | 1241 | int err; |
@@ -1262,7 +1259,7 @@ static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device, | |||
1262 | ice->pcm_pro = pcm; | 1259 | ice->pcm_pro = pcm; |
1263 | if (rpcm) | 1260 | if (rpcm) |
1264 | *rpcm = pcm; | 1261 | *rpcm = pcm; |
1265 | 1262 | ||
1266 | if (ice->cs8427) { | 1263 | if (ice->cs8427) { |
1267 | /* assign channels to iec958 */ | 1264 | /* assign channels to iec958 */ |
1268 | err = snd_cs8427_iec958_build(ice->cs8427, | 1265 | err = snd_cs8427_iec958_build(ice->cs8427, |
@@ -1272,7 +1269,8 @@ static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device, | |||
1272 | return err; | 1269 | return err; |
1273 | } | 1270 | } |
1274 | 1271 | ||
1275 | if ((err = snd_ice1712_build_pro_mixer(ice)) < 0) | 1272 | err = snd_ice1712_build_pro_mixer(ice); |
1273 | if (err < 0) | ||
1276 | return err; | 1274 | return err; |
1277 | return 0; | 1275 | return 0; |
1278 | } | 1276 | } |
@@ -1299,7 +1297,7 @@ static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struc | |||
1299 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1297 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1300 | int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + | 1298 | int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + |
1301 | kcontrol->private_value; | 1299 | kcontrol->private_value; |
1302 | 1300 | ||
1303 | spin_lock_irq(&ice->reg_lock); | 1301 | spin_lock_irq(&ice->reg_lock); |
1304 | ucontrol->value.integer.value[0] = | 1302 | ucontrol->value.integer.value[0] = |
1305 | !((ice->pro_volumes[priv_idx] >> 15) & 1); | 1303 | !((ice->pro_volumes[priv_idx] >> 15) & 1); |
@@ -1341,7 +1339,7 @@ static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struc | |||
1341 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1339 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1342 | int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + | 1340 | int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + |
1343 | kcontrol->private_value; | 1341 | kcontrol->private_value; |
1344 | 1342 | ||
1345 | spin_lock_irq(&ice->reg_lock); | 1343 | spin_lock_irq(&ice->reg_lock); |
1346 | ucontrol->value.integer.value[0] = | 1344 | ucontrol->value.integer.value[0] = |
1347 | (ice->pro_volumes[priv_idx] >> 0) & 127; | 1345 | (ice->pro_volumes[priv_idx] >> 0) & 127; |
@@ -1406,7 +1404,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinit | |||
1406 | 1404 | ||
1407 | static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = { | 1405 | static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = { |
1408 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1406 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1409 | .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH), | 1407 | .name = SNDRV_CTL_NAME_IEC958("Multi ", CAPTURE, SWITCH), |
1410 | .info = snd_ice1712_pro_mixer_switch_info, | 1408 | .info = snd_ice1712_pro_mixer_switch_info, |
1411 | .get = snd_ice1712_pro_mixer_switch_get, | 1409 | .get = snd_ice1712_pro_mixer_switch_get, |
1412 | .put = snd_ice1712_pro_mixer_switch_put, | 1410 | .put = snd_ice1712_pro_mixer_switch_put, |
@@ -1428,7 +1426,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinit | |||
1428 | 1426 | ||
1429 | static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = { | 1427 | static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = { |
1430 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1428 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1431 | .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME), | 1429 | .name = SNDRV_CTL_NAME_IEC958("Multi ", CAPTURE, VOLUME), |
1432 | .info = snd_ice1712_pro_mixer_volume_info, | 1430 | .info = snd_ice1712_pro_mixer_volume_info, |
1433 | .get = snd_ice1712_pro_mixer_volume_get, | 1431 | .get = snd_ice1712_pro_mixer_volume_get, |
1434 | .put = snd_ice1712_pro_mixer_volume_put, | 1432 | .put = snd_ice1712_pro_mixer_volume_put, |
@@ -1448,7 +1446,7 @@ static int __devinit snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice) | |||
1448 | if (err < 0) | 1446 | if (err < 0) |
1449 | return err; | 1447 | return err; |
1450 | } | 1448 | } |
1451 | 1449 | ||
1452 | if (ice->num_total_adcs > 0) { | 1450 | if (ice->num_total_adcs > 0) { |
1453 | struct snd_kcontrol_new tmp = snd_ice1712_multi_capture_analog_switch; | 1451 | struct snd_kcontrol_new tmp = snd_ice1712_multi_capture_analog_switch; |
1454 | tmp.count = ice->num_total_adcs; | 1452 | tmp.count = ice->num_total_adcs; |
@@ -1495,7 +1493,7 @@ static void snd_ice1712_mixer_free_ac97(struct snd_ac97 *ac97) | |||
1495 | ice->ac97 = NULL; | 1493 | ice->ac97 = NULL; |
1496 | } | 1494 | } |
1497 | 1495 | ||
1498 | static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 * ice) | 1496 | static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 *ice) |
1499 | { | 1497 | { |
1500 | int err, bus_num = 0; | 1498 | int err, bus_num = 0; |
1501 | struct snd_ac97_template ac97; | 1499 | struct snd_ac97_template ac97; |
@@ -1510,27 +1508,32 @@ static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 * ice) | |||
1510 | }; | 1508 | }; |
1511 | 1509 | ||
1512 | if (ice_has_con_ac97(ice)) { | 1510 | if (ice_has_con_ac97(ice)) { |
1513 | if ((err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus)) < 0) | 1511 | err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus); |
1512 | if (err < 0) | ||
1514 | return err; | 1513 | return err; |
1515 | memset(&ac97, 0, sizeof(ac97)); | 1514 | memset(&ac97, 0, sizeof(ac97)); |
1516 | ac97.private_data = ice; | 1515 | ac97.private_data = ice; |
1517 | ac97.private_free = snd_ice1712_mixer_free_ac97; | 1516 | ac97.private_free = snd_ice1712_mixer_free_ac97; |
1518 | if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0) | 1517 | err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); |
1518 | if (err < 0) | ||
1519 | printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n"); | 1519 | printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n"); |
1520 | else { | 1520 | else { |
1521 | if ((err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice))) < 0) | 1521 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice)); |
1522 | if (err < 0) | ||
1522 | return err; | 1523 | return err; |
1523 | return 0; | 1524 | return 0; |
1524 | } | 1525 | } |
1525 | } | 1526 | } |
1526 | 1527 | ||
1527 | if (! (ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) { | 1528 | if (!(ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) { |
1528 | if ((err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus)) < 0) | 1529 | err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus); |
1530 | if (err < 0) | ||
1529 | return err; | 1531 | return err; |
1530 | memset(&ac97, 0, sizeof(ac97)); | 1532 | memset(&ac97, 0, sizeof(ac97)); |
1531 | ac97.private_data = ice; | 1533 | ac97.private_data = ice; |
1532 | ac97.private_free = snd_ice1712_mixer_free_ac97; | 1534 | ac97.private_free = snd_ice1712_mixer_free_ac97; |
1533 | if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0) | 1535 | err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); |
1536 | if (err < 0) | ||
1534 | printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n"); | 1537 | printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n"); |
1535 | else | 1538 | else |
1536 | return 0; | 1539 | return 0; |
@@ -1549,7 +1552,7 @@ static inline unsigned int eeprom_double(struct snd_ice1712 *ice, int idx) | |||
1549 | return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8); | 1552 | return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8); |
1550 | } | 1553 | } |
1551 | 1554 | ||
1552 | static void snd_ice1712_proc_read(struct snd_info_entry *entry, | 1555 | static void snd_ice1712_proc_read(struct snd_info_entry *entry, |
1553 | struct snd_info_buffer *buffer) | 1556 | struct snd_info_buffer *buffer) |
1554 | { | 1557 | { |
1555 | struct snd_ice1712 *ice = entry->private_data; | 1558 | struct snd_ice1712 *ice = entry->private_data; |
@@ -1585,15 +1588,15 @@ static void snd_ice1712_proc_read(struct snd_info_entry *entry, | |||
1585 | snd_iprintf(buffer, " SPDOUT : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_SPDOUT))); | 1588 | snd_iprintf(buffer, " SPDOUT : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_SPDOUT))); |
1586 | snd_iprintf(buffer, " RATE : 0x%02x\n", (unsigned)inb(ICEMT(ice, RATE))); | 1589 | snd_iprintf(buffer, " RATE : 0x%02x\n", (unsigned)inb(ICEMT(ice, RATE))); |
1587 | snd_iprintf(buffer, " GPIO_DATA : 0x%02x\n", (unsigned)snd_ice1712_get_gpio_data(ice)); | 1590 | snd_iprintf(buffer, " GPIO_DATA : 0x%02x\n", (unsigned)snd_ice1712_get_gpio_data(ice)); |
1588 | snd_iprintf(buffer, " GPIO_WRITE_MASK : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK)); | 1591 | snd_iprintf(buffer, " GPIO_WRITE_MASK : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK)); |
1589 | snd_iprintf(buffer, " GPIO_DIRECTION : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION)); | 1592 | snd_iprintf(buffer, " GPIO_DIRECTION : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION)); |
1590 | } | 1593 | } |
1591 | 1594 | ||
1592 | static void __devinit snd_ice1712_proc_init(struct snd_ice1712 * ice) | 1595 | static void __devinit snd_ice1712_proc_init(struct snd_ice1712 *ice) |
1593 | { | 1596 | { |
1594 | struct snd_info_entry *entry; | 1597 | struct snd_info_entry *entry; |
1595 | 1598 | ||
1596 | if (! snd_card_proc_new(ice->card, "ice1712", &entry)) | 1599 | if (!snd_card_proc_new(ice->card, "ice1712", &entry)) |
1597 | snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read); | 1600 | snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read); |
1598 | } | 1601 | } |
1599 | 1602 | ||
@@ -1613,7 +1616,7 @@ static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol, | |||
1613 | struct snd_ctl_elem_value *ucontrol) | 1616 | struct snd_ctl_elem_value *ucontrol) |
1614 | { | 1617 | { |
1615 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1618 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1616 | 1619 | ||
1617 | memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); | 1620 | memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); |
1618 | return 0; | 1621 | return 0; |
1619 | } | 1622 | } |
@@ -1641,7 +1644,7 @@ static int snd_ice1712_spdif_default_get(struct snd_kcontrol *kcontrol, | |||
1641 | { | 1644 | { |
1642 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1645 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1643 | if (ice->spdif.ops.default_get) | 1646 | if (ice->spdif.ops.default_get) |
1644 | ice->spdif.ops.default_get(ice, ucontrol); | 1647 | ice->spdif.ops.default_get(ice, ucontrol); |
1645 | return 0; | 1648 | return 0; |
1646 | } | 1649 | } |
1647 | 1650 | ||
@@ -1657,7 +1660,7 @@ static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol, | |||
1657 | static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata = | 1660 | static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata = |
1658 | { | 1661 | { |
1659 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 1662 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
1660 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), | 1663 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), |
1661 | .info = snd_ice1712_spdif_info, | 1664 | .info = snd_ice1712_spdif_info, |
1662 | .get = snd_ice1712_spdif_default_get, | 1665 | .get = snd_ice1712_spdif_default_get, |
1663 | .put = snd_ice1712_spdif_default_put | 1666 | .put = snd_ice1712_spdif_default_put |
@@ -1709,7 +1712,7 @@ static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata = | |||
1709 | { | 1712 | { |
1710 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 1713 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
1711 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 1714 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
1712 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), | 1715 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK), |
1713 | .info = snd_ice1712_spdif_info, | 1716 | .info = snd_ice1712_spdif_info, |
1714 | .get = snd_ice1712_spdif_maskc_get, | 1717 | .get = snd_ice1712_spdif_maskc_get, |
1715 | }; | 1718 | }; |
@@ -1718,7 +1721,7 @@ static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata = | |||
1718 | { | 1721 | { |
1719 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 1722 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
1720 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 1723 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
1721 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), | 1724 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK), |
1722 | .info = snd_ice1712_spdif_info, | 1725 | .info = snd_ice1712_spdif_info, |
1723 | .get = snd_ice1712_spdif_maskp_get, | 1726 | .get = snd_ice1712_spdif_maskp_get, |
1724 | }; | 1727 | }; |
@@ -1746,7 +1749,7 @@ static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata = | |||
1746 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | | 1749 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
1747 | SNDRV_CTL_ELEM_ACCESS_INACTIVE), | 1750 | SNDRV_CTL_ELEM_ACCESS_INACTIVE), |
1748 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 1751 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
1749 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM), | 1752 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM), |
1750 | .info = snd_ice1712_spdif_info, | 1753 | .info = snd_ice1712_spdif_info, |
1751 | .get = snd_ice1712_spdif_stream_get, | 1754 | .get = snd_ice1712_spdif_stream_get, |
1752 | .put = snd_ice1712_spdif_stream_put | 1755 | .put = snd_ice1712_spdif_stream_put |
@@ -1758,7 +1761,7 @@ int snd_ice1712_gpio_get(struct snd_kcontrol *kcontrol, | |||
1758 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1761 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1759 | unsigned char mask = kcontrol->private_value & 0xff; | 1762 | unsigned char mask = kcontrol->private_value & 0xff; |
1760 | int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0; | 1763 | int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0; |
1761 | 1764 | ||
1762 | snd_ice1712_save_gpio_status(ice); | 1765 | snd_ice1712_save_gpio_status(ice); |
1763 | ucontrol->value.integer.value[0] = | 1766 | ucontrol->value.integer.value[0] = |
1764 | (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert; | 1767 | (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert; |
@@ -1825,7 +1828,7 @@ static int snd_ice1712_pro_internal_clock_get(struct snd_kcontrol *kcontrol, | |||
1825 | 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 255, 255, 255, 10 | 1828 | 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 255, 255, 255, 10 |
1826 | }; | 1829 | }; |
1827 | unsigned char val; | 1830 | unsigned char val; |
1828 | 1831 | ||
1829 | spin_lock_irq(&ice->reg_lock); | 1832 | spin_lock_irq(&ice->reg_lock); |
1830 | if (is_spdif_master(ice)) { | 1833 | if (is_spdif_master(ice)) { |
1831 | ucontrol->value.enumerated.item[0] = 13; | 1834 | ucontrol->value.enumerated.item[0] = 13; |
@@ -1867,7 +1870,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol, | |||
1867 | 1870 | ||
1868 | if ((oval & ICE1712_SPDIF_MASTER) != | 1871 | if ((oval & ICE1712_SPDIF_MASTER) != |
1869 | (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER)) | 1872 | (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER)) |
1870 | snd_ice1712_set_input_clock_source(ice, is_spdif_master(ice)); | 1873 | snd_ice1712_set_input_clock_source(ice, is_spdif_master(ice)); |
1871 | 1874 | ||
1872 | return change; | 1875 | return change; |
1873 | } | 1876 | } |
@@ -1897,7 +1900,7 @@ static int snd_ice1712_pro_internal_clock_default_info(struct snd_kcontrol *kcon | |||
1897 | "64000", /* 10: 15 */ | 1900 | "64000", /* 10: 15 */ |
1898 | "88200", /* 11: 11 */ | 1901 | "88200", /* 11: 11 */ |
1899 | "96000", /* 12: 7 */ | 1902 | "96000", /* 12: 7 */ |
1900 | // "IEC958 Input", /* 13: -- */ | 1903 | /* "IEC958 Input", 13: -- */ |
1901 | }; | 1904 | }; |
1902 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1905 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
1903 | uinfo->count = 1; | 1906 | uinfo->count = 1; |
@@ -2026,7 +2029,7 @@ static int snd_ice1712_pro_route_info(struct snd_kcontrol *kcontrol, | |||
2026 | "IEC958 In L", "IEC958 In R", /* 9-10 */ | 2029 | "IEC958 In L", "IEC958 In R", /* 9-10 */ |
2027 | "Digital Mixer", /* 11 - optional */ | 2030 | "Digital Mixer", /* 11 - optional */ |
2028 | }; | 2031 | }; |
2029 | 2032 | ||
2030 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 2033 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
2031 | uinfo->count = 1; | 2034 | uinfo->count = 1; |
2032 | uinfo->value.enumerated.items = | 2035 | uinfo->value.enumerated.items = |
@@ -2070,7 +2073,7 @@ static int snd_ice1712_pro_route_analog_put(struct snd_kcontrol *kcontrol, | |||
2070 | int change, shift; | 2073 | int change, shift; |
2071 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 2074 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
2072 | unsigned int val, old_val, nval; | 2075 | unsigned int val, old_val, nval; |
2073 | 2076 | ||
2074 | /* update PSDOUT */ | 2077 | /* update PSDOUT */ |
2075 | if (ucontrol->value.enumerated.item[0] >= 11) | 2078 | if (ucontrol->value.enumerated.item[0] >= 11) |
2076 | nval = idx < 2 ? 1 : 0; /* dig mixer (or pcm) */ | 2079 | nval = idx < 2 ? 1 : 0; /* dig mixer (or pcm) */ |
@@ -2140,7 +2143,7 @@ static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol, | |||
2140 | int change, shift; | 2143 | int change, shift; |
2141 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 2144 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
2142 | unsigned int val, old_val, nval; | 2145 | unsigned int val, old_val, nval; |
2143 | 2146 | ||
2144 | /* update SPDOUT */ | 2147 | /* update SPDOUT */ |
2145 | spin_lock_irq(&ice->reg_lock); | 2148 | spin_lock_irq(&ice->reg_lock); |
2146 | val = old_val = inw(ICEMT(ice, ROUTE_SPDOUT)); | 2149 | val = old_val = inw(ICEMT(ice, ROUTE_SPDOUT)); |
@@ -2182,7 +2185,7 @@ static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata | |||
2182 | 2185 | ||
2183 | static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = { | 2186 | static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = { |
2184 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2187 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2185 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", | 2188 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, NONE) "Route", |
2186 | .info = snd_ice1712_pro_route_info, | 2189 | .info = snd_ice1712_pro_route_info, |
2187 | .get = snd_ice1712_pro_route_spdif_get, | 2190 | .get = snd_ice1712_pro_route_spdif_get, |
2188 | .put = snd_ice1712_pro_route_spdif_put, | 2191 | .put = snd_ice1712_pro_route_spdif_put, |
@@ -2204,7 +2207,7 @@ static int snd_ice1712_pro_volume_rate_get(struct snd_kcontrol *kcontrol, | |||
2204 | struct snd_ctl_elem_value *ucontrol) | 2207 | struct snd_ctl_elem_value *ucontrol) |
2205 | { | 2208 | { |
2206 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 2209 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
2207 | 2210 | ||
2208 | ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE)); | 2211 | ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE)); |
2209 | return 0; | 2212 | return 0; |
2210 | } | 2213 | } |
@@ -2245,7 +2248,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol, | |||
2245 | { | 2248 | { |
2246 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 2249 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
2247 | int idx; | 2250 | int idx; |
2248 | 2251 | ||
2249 | spin_lock_irq(&ice->reg_lock); | 2252 | spin_lock_irq(&ice->reg_lock); |
2250 | for (idx = 0; idx < 22; idx++) { | 2253 | for (idx = 0; idx < 22; idx++) { |
2251 | outb(idx, ICEMT(ice, MONITOR_PEAKINDEX)); | 2254 | outb(idx, ICEMT(ice, MONITOR_PEAKINDEX)); |
@@ -2296,12 +2299,12 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice, | |||
2296 | unsigned int i, size; | 2299 | unsigned int i, size; |
2297 | struct snd_ice1712_card_info * const *tbl, *c; | 2300 | struct snd_ice1712_card_info * const *tbl, *c; |
2298 | 2301 | ||
2299 | if (! modelname || ! *modelname) { | 2302 | if (!modelname || !*modelname) { |
2300 | ice->eeprom.subvendor = 0; | 2303 | ice->eeprom.subvendor = 0; |
2301 | if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) != 0) | 2304 | if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) != 0) |
2302 | ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) | | 2305 | ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) | |
2303 | (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) | | 2306 | (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) | |
2304 | (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) | | 2307 | (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) | |
2305 | (snd_ice1712_read_i2c(ice, dev, 0x03) << 24); | 2308 | (snd_ice1712_read_i2c(ice, dev, 0x03) << 24); |
2306 | if (ice->eeprom.subvendor == 0 || | 2309 | if (ice->eeprom.subvendor == 0 || |
2307 | ice->eeprom.subvendor == (unsigned int)-1) { | 2310 | ice->eeprom.subvendor == (unsigned int)-1) { |
@@ -2318,12 +2321,12 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice, | |||
2318 | } | 2321 | } |
2319 | for (tbl = card_tables; *tbl; tbl++) { | 2322 | for (tbl = card_tables; *tbl; tbl++) { |
2320 | for (c = *tbl; c->subvendor; c++) { | 2323 | for (c = *tbl; c->subvendor; c++) { |
2321 | if (modelname && c->model && ! strcmp(modelname, c->model)) { | 2324 | if (modelname && c->model && !strcmp(modelname, c->model)) { |
2322 | printk(KERN_INFO "ice1712: Using board model %s\n", c->name); | 2325 | printk(KERN_INFO "ice1712: Using board model %s\n", c->name); |
2323 | ice->eeprom.subvendor = c->subvendor; | 2326 | ice->eeprom.subvendor = c->subvendor; |
2324 | } else if (c->subvendor != ice->eeprom.subvendor) | 2327 | } else if (c->subvendor != ice->eeprom.subvendor) |
2325 | continue; | 2328 | continue; |
2326 | if (! c->eeprom_size || ! c->eeprom_data) | 2329 | if (!c->eeprom_size || !c->eeprom_data) |
2327 | goto found; | 2330 | goto found; |
2328 | /* if the EEPROM is given by the driver, use it */ | 2331 | /* if the EEPROM is given by the driver, use it */ |
2329 | snd_printdd("using the defined eeprom..\n"); | 2332 | snd_printdd("using the defined eeprom..\n"); |
@@ -2416,7 +2419,8 @@ int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice) | |||
2416 | int err; | 2419 | int err; |
2417 | struct snd_kcontrol *kctl; | 2420 | struct snd_kcontrol *kctl; |
2418 | 2421 | ||
2419 | snd_assert(ice->pcm_pro != NULL, return -EIO); | 2422 | if (snd_BUG_ON(!ice->pcm_pro)) |
2423 | return -EIO; | ||
2420 | err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice)); | 2424 | err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice)); |
2421 | if (err < 0) | 2425 | if (err < 0) |
2422 | return err; | 2426 | return err; |
@@ -2483,13 +2487,13 @@ static int __devinit snd_ice1712_build_controls(struct snd_ice1712 *ice) | |||
2483 | 2487 | ||
2484 | static int snd_ice1712_free(struct snd_ice1712 *ice) | 2488 | static int snd_ice1712_free(struct snd_ice1712 *ice) |
2485 | { | 2489 | { |
2486 | if (! ice->port) | 2490 | if (!ice->port) |
2487 | goto __hw_end; | 2491 | goto __hw_end; |
2488 | /* mask all interrupts */ | 2492 | /* mask all interrupts */ |
2489 | outb(0xc0, ICEMT(ice, IRQ)); | 2493 | outb(0xc0, ICEMT(ice, IRQ)); |
2490 | outb(0xff, ICEREG(ice, IRQMASK)); | 2494 | outb(0xff, ICEREG(ice, IRQMASK)); |
2491 | /* --- */ | 2495 | /* --- */ |
2492 | __hw_end: | 2496 | __hw_end: |
2493 | if (ice->irq >= 0) | 2497 | if (ice->irq >= 0) |
2494 | free_irq(ice->irq, ice); | 2498 | free_irq(ice->irq, ice); |
2495 | 2499 | ||
@@ -2514,7 +2518,7 @@ static int __devinit snd_ice1712_create(struct snd_card *card, | |||
2514 | int omni, | 2518 | int omni, |
2515 | int cs8427_timeout, | 2519 | int cs8427_timeout, |
2516 | int dxr_enable, | 2520 | int dxr_enable, |
2517 | struct snd_ice1712 ** r_ice1712) | 2521 | struct snd_ice1712 **r_ice1712) |
2518 | { | 2522 | { |
2519 | struct snd_ice1712 *ice; | 2523 | struct snd_ice1712 *ice; |
2520 | int err; | 2524 | int err; |
@@ -2524,8 +2528,9 @@ static int __devinit snd_ice1712_create(struct snd_card *card, | |||
2524 | 2528 | ||
2525 | *r_ice1712 = NULL; | 2529 | *r_ice1712 = NULL; |
2526 | 2530 | ||
2527 | /* enable PCI device */ | 2531 | /* enable PCI device */ |
2528 | if ((err = pci_enable_device(pci)) < 0) | 2532 | err = pci_enable_device(pci); |
2533 | if (err < 0) | ||
2529 | return err; | 2534 | return err; |
2530 | /* check, if we can restrict PCI DMA transfers to 28 bits */ | 2535 | /* check, if we can restrict PCI DMA transfers to 28 bits */ |
2531 | if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || | 2536 | if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || |
@@ -2569,7 +2574,8 @@ static int __devinit snd_ice1712_create(struct snd_card *card, | |||
2569 | snd_ice1712_proc_init(ice); | 2574 | snd_ice1712_proc_init(ice); |
2570 | synchronize_irq(pci->irq); | 2575 | synchronize_irq(pci->irq); |
2571 | 2576 | ||
2572 | if ((err = pci_request_regions(pci, "ICE1712")) < 0) { | 2577 | err = pci_request_regions(pci, "ICE1712"); |
2578 | if (err < 0) { | ||
2573 | kfree(ice); | 2579 | kfree(ice); |
2574 | pci_disable_device(pci); | 2580 | pci_disable_device(pci); |
2575 | return err; | 2581 | return err; |
@@ -2585,7 +2591,7 @@ static int __devinit snd_ice1712_create(struct snd_card *card, | |||
2585 | snd_ice1712_free(ice); | 2591 | snd_ice1712_free(ice); |
2586 | return -EIO; | 2592 | return -EIO; |
2587 | } | 2593 | } |
2588 | 2594 | ||
2589 | ice->irq = pci->irq; | 2595 | ice->irq = pci->irq; |
2590 | 2596 | ||
2591 | if (snd_ice1712_read_eeprom(ice, modelname) < 0) { | 2597 | if (snd_ice1712_read_eeprom(ice, modelname) < 0) { |
@@ -2605,9 +2611,10 @@ static int __devinit snd_ice1712_create(struct snd_card *card, | |||
2605 | ICEREG(ice, IRQMASK)); | 2611 | ICEREG(ice, IRQMASK)); |
2606 | outb(0x00, ICEMT(ice, IRQ)); | 2612 | outb(0x00, ICEMT(ice, IRQ)); |
2607 | 2613 | ||
2608 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops)) < 0) { | 2614 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops); |
2615 | if (err < 0) { | ||
2609 | snd_ice1712_free(ice); | 2616 | snd_ice1712_free(ice); |
2610 | return err; | 2617 | return err; |
2611 | } | 2618 | } |
2612 | 2619 | ||
2613 | snd_card_set_dev(card, &pci->dev); | 2620 | snd_card_set_dev(card, &pci->dev); |
@@ -2647,10 +2654,10 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2647 | 2654 | ||
2648 | strcpy(card->driver, "ICE1712"); | 2655 | strcpy(card->driver, "ICE1712"); |
2649 | strcpy(card->shortname, "ICEnsemble ICE1712"); | 2656 | strcpy(card->shortname, "ICEnsemble ICE1712"); |
2650 | 2657 | ||
2651 | if ((err = snd_ice1712_create(card, pci, model[dev], omni[dev], | 2658 | err = snd_ice1712_create(card, pci, model[dev], omni[dev], |
2652 | cs8427_timeout[dev], dxr_enable[dev], | 2659 | cs8427_timeout[dev], dxr_enable[dev], &ice); |
2653 | &ice)) < 0) { | 2660 | if (err < 0) { |
2654 | snd_card_free(card); | 2661 | snd_card_free(card); |
2655 | return err; | 2662 | return err; |
2656 | } | 2663 | } |
@@ -2662,7 +2669,8 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2662 | if (c->driver) /* specific driver? */ | 2669 | if (c->driver) /* specific driver? */ |
2663 | strcpy(card->driver, c->driver); | 2670 | strcpy(card->driver, c->driver); |
2664 | if (c->chip_init) { | 2671 | if (c->chip_init) { |
2665 | if ((err = c->chip_init(ice)) < 0) { | 2672 | err = c->chip_init(ice); |
2673 | if (err < 0) { | ||
2666 | snd_card_free(card); | 2674 | snd_card_free(card); |
2667 | return err; | 2675 | return err; |
2668 | } | 2676 | } |
@@ -2674,47 +2682,52 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2674 | c = &no_matched; | 2682 | c = &no_matched; |
2675 | __found: | 2683 | __found: |
2676 | 2684 | ||
2677 | if ((err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL)) < 0) { | 2685 | err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL); |
2686 | if (err < 0) { | ||
2678 | snd_card_free(card); | 2687 | snd_card_free(card); |
2679 | return err; | 2688 | return err; |
2680 | } | 2689 | } |
2681 | 2690 | ||
2682 | if (ice_has_con_ac97(ice)) | 2691 | if (ice_has_con_ac97(ice)) |
2683 | if ((err = snd_ice1712_pcm(ice, pcm_dev++, NULL)) < 0) { | 2692 | err = snd_ice1712_pcm(ice, pcm_dev++, NULL); |
2693 | if (err < 0) { | ||
2684 | snd_card_free(card); | 2694 | snd_card_free(card); |
2685 | return err; | 2695 | return err; |
2686 | } | 2696 | } |
2687 | 2697 | ||
2688 | if ((err = snd_ice1712_ac97_mixer(ice)) < 0) { | 2698 | err = snd_ice1712_ac97_mixer(ice); |
2699 | if (err < 0) { | ||
2689 | snd_card_free(card); | 2700 | snd_card_free(card); |
2690 | return err; | 2701 | return err; |
2691 | } | 2702 | } |
2692 | 2703 | ||
2693 | if ((err = snd_ice1712_build_controls(ice)) < 0) { | 2704 | err = snd_ice1712_build_controls(ice); |
2705 | if (err < 0) { | ||
2694 | snd_card_free(card); | 2706 | snd_card_free(card); |
2695 | return err; | 2707 | return err; |
2696 | } | 2708 | } |
2697 | 2709 | ||
2698 | if (c->build_controls) { | 2710 | if (c->build_controls) { |
2699 | if ((err = c->build_controls(ice)) < 0) { | 2711 | err = c->build_controls(ice); |
2712 | if (err < 0) { | ||
2700 | snd_card_free(card); | 2713 | snd_card_free(card); |
2701 | return err; | 2714 | return err; |
2702 | } | 2715 | } |
2703 | } | 2716 | } |
2704 | 2717 | ||
2705 | if (ice_has_con_ac97(ice)) | 2718 | if (ice_has_con_ac97(ice)) |
2706 | if ((err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL)) < 0) { | 2719 | err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL); |
2720 | if (err < 0) { | ||
2707 | snd_card_free(card); | 2721 | snd_card_free(card); |
2708 | return err; | 2722 | return err; |
2709 | } | 2723 | } |
2710 | 2724 | ||
2711 | if (! c->no_mpu401) { | 2725 | if (!c->no_mpu401) { |
2712 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, | 2726 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, |
2713 | ICEREG(ice, MPU1_CTRL), | 2727 | ICEREG(ice, MPU1_CTRL), |
2714 | (c->mpu401_1_info_flags | | 2728 | (c->mpu401_1_info_flags | MPU401_INFO_INTEGRATED), |
2715 | MPU401_INFO_INTEGRATED), | 2729 | ice->irq, 0, &ice->rmidi[0]); |
2716 | ice->irq, 0, | 2730 | if (err < 0) { |
2717 | &ice->rmidi[0])) < 0) { | ||
2718 | snd_card_free(card); | 2731 | snd_card_free(card); |
2719 | return err; | 2732 | return err; |
2720 | } | 2733 | } |
@@ -2726,12 +2739,12 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2726 | 2739 | ||
2727 | if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) { | 2740 | if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) { |
2728 | /* 2nd port used */ | 2741 | /* 2nd port used */ |
2729 | if ((err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712, | 2742 | err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712, |
2730 | ICEREG(ice, MPU2_CTRL), | 2743 | ICEREG(ice, MPU2_CTRL), |
2731 | (c->mpu401_2_info_flags | | 2744 | (c->mpu401_2_info_flags | MPU401_INFO_INTEGRATED), |
2732 | MPU401_INFO_INTEGRATED), | 2745 | ice->irq, 0, &ice->rmidi[1]); |
2733 | ice->irq, 0, | 2746 | |
2734 | &ice->rmidi[1])) < 0) { | 2747 | if (err < 0) { |
2735 | snd_card_free(card); | 2748 | snd_card_free(card); |
2736 | return err; | 2749 | return err; |
2737 | } | 2750 | } |
@@ -2749,7 +2762,8 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2749 | sprintf(card->longname, "%s at 0x%lx, irq %i", | 2762 | sprintf(card->longname, "%s at 0x%lx, irq %i", |
2750 | card->shortname, ice->port, ice->irq); | 2763 | card->shortname, ice->port, ice->irq); |
2751 | 2764 | ||
2752 | if ((err = snd_card_register(card)) < 0) { | 2765 | err = snd_card_register(card); |
2766 | if (err < 0) { | ||
2753 | snd_card_free(card); | 2767 | snd_card_free(card); |
2754 | return err; | 2768 | return err; |
2755 | } | 2769 | } |