aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/isa/Kconfig7
-rw-r--r--sound/isa/sscape.c189
-rw-r--r--sound/isa/wss/wss_lib.c81
3 files changed, 96 insertions, 181 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 2df20e403f24..c5c9a9218ff6 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -368,14 +368,17 @@ config SND_SGALAXY
368 will be called snd-sgalaxy. 368 will be called snd-sgalaxy.
369 369
370config SND_SSCAPE 370config SND_SSCAPE
371 tristate "Ensoniq SoundScape PnP driver" 371 tristate "Ensoniq SoundScape driver"
372 select SND_HWDEP 372 select SND_HWDEP
373 select SND_MPU401_UART 373 select SND_MPU401_UART
374 select SND_WSS_LIB 374 select SND_WSS_LIB
375 help 375 help
376 Say Y here to include support for Ensoniq SoundScape PnP 376 Say Y here to include support for Ensoniq SoundScape
377 soundcards. 377 soundcards.
378 378
379 The PCM audio is supported on SoundScape Classic, Elite, PnP
380 and VIVO cards. The MIDI support is very experimental.
381
379 To compile this driver as a module, choose M here: the module 382 To compile this driver as a module, choose M here: the module
380 will be called snd-sscape. 383 will be called snd-sscape.
381 384
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 4025fb558c50..66187122377c 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -89,9 +89,6 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
89#endif 89#endif
90 90
91 91
92#define MPU401_IO(i) ((i) + 0)
93#define MIDI_DATA_IO(i) ((i) + 0)
94#define MIDI_CTRL_IO(i) ((i) + 1)
95#define HOST_CTRL_IO(i) ((i) + 2) 92#define HOST_CTRL_IO(i) ((i) + 2)
96#define HOST_DATA_IO(i) ((i) + 3) 93#define HOST_DATA_IO(i) ((i) + 3)
97#define ODIE_ADDR_IO(i) ((i) + 4) 94#define ODIE_ADDR_IO(i) ((i) + 4)
@@ -129,9 +126,6 @@ enum GA_REG {
129#define DMA_8BIT 0x80 126#define DMA_8BIT 0x80
130 127
131 128
132#define AD1845_FREQ_SEL_MSB 0x16
133#define AD1845_FREQ_SEL_LSB 0x17
134
135enum card_type { 129enum card_type {
136 SSCAPE, 130 SSCAPE,
137 SSCAPE_PNP, 131 SSCAPE_PNP,
@@ -141,8 +135,6 @@ enum card_type {
141struct soundscape { 135struct soundscape {
142 spinlock_t lock; 136 spinlock_t lock;
143 unsigned io_base; 137 unsigned io_base;
144 unsigned wss_base;
145 int codec_type;
146 int ic_type; 138 int ic_type;
147 enum card_type type; 139 enum card_type type;
148 struct resource *io_res; 140 struct resource *io_res;
@@ -330,7 +322,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
330 */ 322 */
331static inline int verify_mpu401(const struct snd_mpu401 * mpu) 323static inline int verify_mpu401(const struct snd_mpu401 * mpu)
332{ 324{
333 return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80); 325 return ((inb(MPU401C(mpu)) & 0xc0) == 0x80);
334} 326}
335 327
336/* 328/*
@@ -338,7 +330,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu)
338 */ 330 */
339static inline void initialise_mpu401(const struct snd_mpu401 * mpu) 331static inline void initialise_mpu401(const struct snd_mpu401 * mpu)
340{ 332{
341 outb(0, MIDI_DATA_IO(mpu->port)); 333 outb(0, MPU401D(mpu));
342} 334}
343 335
344/* 336/*
@@ -396,20 +388,20 @@ static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned ti
396 */ 388 */
397static int obp_startup_ack(struct soundscape *s, unsigned timeout) 389static int obp_startup_ack(struct soundscape *s, unsigned timeout)
398{ 390{
399 while (timeout != 0) { 391 unsigned long end_time = jiffies + msecs_to_jiffies(timeout);
392
393 do {
400 unsigned long flags; 394 unsigned long flags;
401 unsigned char x; 395 unsigned char x;
402 396
403 schedule_timeout_uninterruptible(1);
404
405 spin_lock_irqsave(&s->lock, flags); 397 spin_lock_irqsave(&s->lock, flags);
406 x = inb(HOST_DATA_IO(s->io_base)); 398 x = inb(HOST_DATA_IO(s->io_base));
407 spin_unlock_irqrestore(&s->lock, flags); 399 spin_unlock_irqrestore(&s->lock, flags);
408 if ((x & 0xfe) == 0xfe) 400 if ((x & 0xfe) == 0xfe)
409 return 1; 401 return 1;
410 402
411 --timeout; 403 msleep(10);
412 } /* while */ 404 } while (time_before(jiffies, end_time));
413 405
414 return 0; 406 return 0;
415} 407}
@@ -423,20 +415,20 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout)
423 */ 415 */
424static int host_startup_ack(struct soundscape *s, unsigned timeout) 416static int host_startup_ack(struct soundscape *s, unsigned timeout)
425{ 417{
426 while (timeout != 0) { 418 unsigned long end_time = jiffies + msecs_to_jiffies(timeout);
419
420 do {
427 unsigned long flags; 421 unsigned long flags;
428 unsigned char x; 422 unsigned char x;
429 423
430 schedule_timeout_uninterruptible(1);
431
432 spin_lock_irqsave(&s->lock, flags); 424 spin_lock_irqsave(&s->lock, flags);
433 x = inb(HOST_DATA_IO(s->io_base)); 425 x = inb(HOST_DATA_IO(s->io_base));
434 spin_unlock_irqrestore(&s->lock, flags); 426 spin_unlock_irqrestore(&s->lock, flags);
435 if (x == 0xfe) 427 if (x == 0xfe)
436 return 1; 428 return 1;
437 429
438 --timeout; 430 msleep(10);
439 } /* while */ 431 } while (time_before(jiffies, end_time));
440 432
441 return 0; 433 return 0;
442} 434}
@@ -532,10 +524,10 @@ static int upload_dma_data(struct soundscape *s,
532 * give it 5 seconds (max) ... 524 * give it 5 seconds (max) ...
533 */ 525 */
534 ret = 0; 526 ret = 0;
535 if (!obp_startup_ack(s, 5)) { 527 if (!obp_startup_ack(s, 5000)) {
536 snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); 528 snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n");
537 ret = -EAGAIN; 529 ret = -EAGAIN;
538 } else if (!host_startup_ack(s, 5)) { 530 } else if (!host_startup_ack(s, 5000)) {
539 snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); 531 snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n");
540 ret = -EAGAIN; 532 ret = -EAGAIN;
541 } 533 }
@@ -732,13 +724,7 @@ static int sscape_midi_get(struct snd_kcontrol *kctl,
732 unsigned long flags; 724 unsigned long flags;
733 725
734 spin_lock_irqsave(&s->lock, flags); 726 spin_lock_irqsave(&s->lock, flags);
735 set_host_mode_unsafe(s->io_base); 727 uctl->value.integer.value[0] = s->midi_vol;
736
737 if (host_write_ctrl_unsafe(s->io_base, CMD_GET_MIDI_VOL, 100)) {
738 uctl->value.integer.value[0] = host_read_ctrl_unsafe(s->io_base, 100);
739 }
740
741 set_midi_mode_unsafe(s->io_base);
742 spin_unlock_irqrestore(&s->lock, flags); 728 spin_unlock_irqrestore(&s->lock, flags);
743 return 0; 729 return 0;
744} 730}
@@ -773,6 +759,7 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
773 change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) 759 change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
774 && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100) 760 && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100)
775 && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)); 761 && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100));
762 s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127;
776 __skip_change: 763 __skip_change:
777 764
778 /* 765 /*
@@ -815,12 +802,11 @@ static unsigned __devinit get_irq_config(int irq)
815 * Perform certain arcane port-checks to see whether there 802 * Perform certain arcane port-checks to see whether there
816 * is a SoundScape board lurking behind the given ports. 803 * is a SoundScape board lurking behind the given ports.
817 */ 804 */
818static int __devinit detect_sscape(struct soundscape *s) 805static int __devinit detect_sscape(struct soundscape *s, long wss_io)
819{ 806{
820 unsigned long flags; 807 unsigned long flags;
821 unsigned d; 808 unsigned d;
822 int retval = 0; 809 int retval = 0;
823 int codec = s->wss_base;
824 810
825 spin_lock_irqsave(&s->lock, flags); 811 spin_lock_irqsave(&s->lock, flags);
826 812
@@ -836,13 +822,11 @@ static int __devinit detect_sscape(struct soundscape *s)
836 if ((d & 0x80) != 0) 822 if ((d & 0x80) != 0)
837 goto _done; 823 goto _done;
838 824
839 if (d == 0) { 825 if (d == 0)
840 s->codec_type = 1;
841 s->ic_type = IC_ODIE; 826 s->ic_type = IC_ODIE;
842 } else if ((d & 0x60) != 0) { 827 else if ((d & 0x60) != 0)
843 s->codec_type = 2;
844 s->ic_type = IC_OPUS; 828 s->ic_type = IC_OPUS;
845 } else 829 else
846 goto _done; 830 goto _done;
847 831
848 outb(0xfa, ODIE_ADDR_IO(s->io_base)); 832 outb(0xfa, ODIE_ADDR_IO(s->io_base));
@@ -862,10 +846,10 @@ static int __devinit detect_sscape(struct soundscape *s)
862 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); 846 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
863 847
864 if (s->type == SSCAPE_VIVO) 848 if (s->type == SSCAPE_VIVO)
865 codec += 4; 849 wss_io += 4;
866 /* wait for WSS codec */ 850 /* wait for WSS codec */
867 for (d = 0; d < 500; d++) { 851 for (d = 0; d < 500; d++) {
868 if ((inb(codec) & 0x80) == 0) 852 if ((inb(wss_io) & 0x80) == 0)
869 break; 853 break;
870 spin_unlock_irqrestore(&s->lock, flags); 854 spin_unlock_irqrestore(&s->lock, flags);
871 msleep(1); 855 msleep(1);
@@ -955,82 +939,6 @@ static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned l
955 939
956 940
957/* 941/*
958 * Override for the CS4231 playback format function.
959 * The AD1845 has much simpler format and rate selection.
960 */
961static void ad1845_playback_format(struct snd_wss *chip,
962 struct snd_pcm_hw_params *params,
963 unsigned char format)
964{
965 unsigned long flags;
966 unsigned rate = params_rate(params);
967
968 /*
969 * The AD1845 can't handle sample frequencies
970 * outside of 4 kHZ to 50 kHZ
971 */
972 if (rate > 50000)
973 rate = 50000;
974 else if (rate < 4000)
975 rate = 4000;
976
977 spin_lock_irqsave(&chip->reg_lock, flags);
978
979 /*
980 * Program the AD1845 correctly for the playback stream.
981 * Note that we do NOT need to toggle the MCE bit because
982 * the PLAYBACK_ENABLE bit of the Interface Configuration
983 * register is set.
984 *
985 * NOTE: We seem to need to write to the MSB before the LSB
986 * to get the correct sample frequency.
987 */
988 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (format & 0xf0));
989 snd_wss_out(chip, AD1845_FREQ_SEL_MSB, (unsigned char) (rate >> 8));
990 snd_wss_out(chip, AD1845_FREQ_SEL_LSB, (unsigned char) rate);
991
992 spin_unlock_irqrestore(&chip->reg_lock, flags);
993}
994
995/*
996 * Override for the CS4231 capture format function.
997 * The AD1845 has much simpler format and rate selection.
998 */
999static void ad1845_capture_format(struct snd_wss *chip,
1000 struct snd_pcm_hw_params *params,
1001 unsigned char format)
1002{
1003 unsigned long flags;
1004 unsigned rate = params_rate(params);
1005
1006 /*
1007 * The AD1845 can't handle sample frequencies
1008 * outside of 4 kHZ to 50 kHZ
1009 */
1010 if (rate > 50000)
1011 rate = 50000;
1012 else if (rate < 4000)
1013 rate = 4000;
1014
1015 spin_lock_irqsave(&chip->reg_lock, flags);
1016
1017 /*
1018 * Program the AD1845 correctly for the playback stream.
1019 * Note that we do NOT need to toggle the MCE bit because
1020 * the CAPTURE_ENABLE bit of the Interface Configuration
1021 * register is set.
1022 *
1023 * NOTE: We seem to need to write to the MSB before the LSB
1024 * to get the correct sample frequency.
1025 */
1026 snd_wss_out(chip, CS4231_REC_FORMAT, (format & 0xf0));
1027 snd_wss_out(chip, AD1845_FREQ_SEL_MSB, (unsigned char) (rate >> 8));
1028 snd_wss_out(chip, AD1845_FREQ_SEL_LSB, (unsigned char) rate);
1029
1030 spin_unlock_irqrestore(&chip->reg_lock, flags);
1031}
1032
1033/*
1034 * Create an AD1845 PCM subdevice on the SoundScape. The AD1845 942 * Create an AD1845 PCM subdevice on the SoundScape. The AD1845
1035 * is very much like a CS4231, with a few extra bits. We will 943 * is very much like a CS4231, with a few extra bits. We will
1036 * try to support at least some of the extra bits by overriding 944 * try to support at least some of the extra bits by overriding
@@ -1055,11 +963,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1055 unsigned long flags; 963 unsigned long flags;
1056 struct snd_pcm *pcm; 964 struct snd_pcm *pcm;
1057 965
1058#define AD1845_FREQ_SEL_ENABLE 0x08
1059
1060#define AD1845_PWR_DOWN_CTRL 0x1b
1061#define AD1845_CRYS_CLOCK_SEL 0x1d
1062
1063/* 966/*
1064 * It turns out that the PLAYBACK_ENABLE bit is set 967 * It turns out that the PLAYBACK_ENABLE bit is set
1065 * by the lowlevel driver ... 968 * by the lowlevel driver ...
@@ -1074,7 +977,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1074 */ 977 */
1075 978
1076 if (sscape->type != SSCAPE_VIVO) { 979 if (sscape->type != SSCAPE_VIVO) {
1077 int val;
1078 /* 980 /*
1079 * The input clock frequency on the SoundScape must 981 * The input clock frequency on the SoundScape must
1080 * be 14.31818 MHz, because we must set this register 982 * be 14.31818 MHz, because we must set this register
@@ -1082,22 +984,10 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1082 */ 984 */
1083 snd_wss_mce_up(chip); 985 snd_wss_mce_up(chip);
1084 spin_lock_irqsave(&chip->reg_lock, flags); 986 spin_lock_irqsave(&chip->reg_lock, flags);
1085 snd_wss_out(chip, AD1845_CRYS_CLOCK_SEL, 0x20); 987 snd_wss_out(chip, AD1845_CLOCK, 0x20);
1086 spin_unlock_irqrestore(&chip->reg_lock, flags); 988 spin_unlock_irqrestore(&chip->reg_lock, flags);
1087 snd_wss_mce_down(chip); 989 snd_wss_mce_down(chip);
1088 990
1089 /*
1090 * More custom configuration:
1091 * a) select "mode 2" and provide a current drive of 8mA
1092 * b) enable frequency selection (for capture/playback)
1093 */
1094 spin_lock_irqsave(&chip->reg_lock, flags);
1095 snd_wss_out(chip, CS4231_MISC_INFO,
1096 CS4231_MODE2 | 0x10);
1097 val = snd_wss_in(chip, AD1845_PWR_DOWN_CTRL);
1098 snd_wss_out(chip, AD1845_PWR_DOWN_CTRL,
1099 val | AD1845_FREQ_SEL_ENABLE);
1100 spin_unlock_irqrestore(&chip->reg_lock, flags);
1101 } 991 }
1102 992
1103 err = snd_wss_pcm(chip, 0, &pcm); 993 err = snd_wss_pcm(chip, 0, &pcm);
@@ -1113,11 +1003,13 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1113 "for AD1845 chip\n"); 1003 "for AD1845 chip\n");
1114 goto _error; 1004 goto _error;
1115 } 1005 }
1116 err = snd_wss_timer(chip, 0, NULL); 1006 if (chip->hardware != WSS_HW_AD1848) {
1117 if (err < 0) { 1007 err = snd_wss_timer(chip, 0, NULL);
1118 snd_printk(KERN_ERR "sscape: No timer device " 1008 if (err < 0) {
1119 "for AD1845 chip\n"); 1009 snd_printk(KERN_ERR "sscape: No timer device "
1120 goto _error; 1010 "for AD1845 chip\n");
1011 goto _error;
1012 }
1121 } 1013 }
1122 1014
1123 if (sscape->type != SSCAPE_VIVO) { 1015 if (sscape->type != SSCAPE_VIVO) {
@@ -1128,8 +1020,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1128 "MIDI mixer control\n"); 1020 "MIDI mixer control\n");
1129 goto _error; 1021 goto _error;
1130 } 1022 }
1131 chip->set_playback_format = ad1845_playback_format;
1132 chip->set_capture_format = ad1845_capture_format;
1133 } 1023 }
1134 1024
1135 strcpy(card->driver, "SoundScape"); 1025 strcpy(card->driver, "SoundScape");
@@ -1157,7 +1047,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1157 unsigned dma_cfg; 1047 unsigned dma_cfg;
1158 unsigned irq_cfg; 1048 unsigned irq_cfg;
1159 unsigned mpu_irq_cfg; 1049 unsigned mpu_irq_cfg;
1160 unsigned xport;
1161 struct resource *io_res; 1050 struct resource *io_res;
1162 struct resource *wss_res; 1051 struct resource *wss_res;
1163 unsigned long flags; 1052 unsigned long flags;
@@ -1177,15 +1066,15 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1177 printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); 1066 printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
1178 return -ENXIO; 1067 return -ENXIO;
1179 } 1068 }
1180 xport = port[dev];
1181 1069
1182 /* 1070 /*
1183 * Grab IO ports that we will need to probe so that we 1071 * Grab IO ports that we will need to probe so that we
1184 * can detect and control this hardware ... 1072 * can detect and control this hardware ...
1185 */ 1073 */
1186 io_res = request_region(xport, 8, "SoundScape"); 1074 io_res = request_region(port[dev], 8, "SoundScape");
1187 if (!io_res) { 1075 if (!io_res) {
1188 snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport); 1076 snd_printk(KERN_ERR
1077 "sscape: can't grab port 0x%lx\n", port[dev]);
1189 return -EBUSY; 1078 return -EBUSY;
1190 } 1079 }
1191 wss_res = NULL; 1080 wss_res = NULL;
@@ -1212,10 +1101,9 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1212 spin_lock_init(&sscape->fwlock); 1101 spin_lock_init(&sscape->fwlock);
1213 sscape->io_res = io_res; 1102 sscape->io_res = io_res;
1214 sscape->wss_res = wss_res; 1103 sscape->wss_res = wss_res;
1215 sscape->io_base = xport; 1104 sscape->io_base = port[dev];
1216 sscape->wss_base = wss_port[dev];
1217 1105
1218 if (!detect_sscape(sscape)) { 1106 if (!detect_sscape(sscape, wss_port[dev])) {
1219 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); 1107 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base);
1220 err = -ENODEV; 1108 err = -ENODEV;
1221 goto _release_dma; 1109 goto _release_dma;
@@ -1288,12 +1176,11 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1288 } 1176 }
1289#define MIDI_DEVNUM 0 1177#define MIDI_DEVNUM 0
1290 if (sscape->type != SSCAPE_VIVO) { 1178 if (sscape->type != SSCAPE_VIVO) {
1291 err = create_mpu401(card, MIDI_DEVNUM, 1179 err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]);
1292 MPU401_IO(xport), mpu_irq[dev]);
1293 if (err < 0) { 1180 if (err < 0) {
1294 printk(KERN_ERR "sscape: Failed to create " 1181 printk(KERN_ERR "sscape: Failed to create "
1295 "MPU-401 device at 0x%x\n", 1182 "MPU-401 device at 0x%lx\n",
1296 MPU401_IO(xport)); 1183 port[dev]);
1297 goto _release_dma; 1184 goto _release_dma;
1298 } 1185 }
1299 1186
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index ac27832b2c6f..5d2ba1b749ab 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -181,25 +181,6 @@ static void snd_wss_wait(struct snd_wss *chip)
181 udelay(100); 181 udelay(100);
182} 182}
183 183
184static void snd_wss_outm(struct snd_wss *chip, unsigned char reg,
185 unsigned char mask, unsigned char value)
186{
187 unsigned char tmp = (chip->image[reg] & mask) | value;
188
189 snd_wss_wait(chip);
190#ifdef CONFIG_SND_DEBUG
191 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT)
192 snd_printk("outm: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value);
193#endif
194 chip->image[reg] = tmp;
195 if (!chip->calibrate_mute) {
196 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg);
197 wmb();
198 wss_outb(chip, CS4231P(REG), tmp);
199 mb();
200 }
201}
202
203static void snd_wss_dout(struct snd_wss *chip, unsigned char reg, 184static void snd_wss_dout(struct snd_wss *chip, unsigned char reg,
204 unsigned char value) 185 unsigned char value)
205{ 186{
@@ -597,7 +578,15 @@ static void snd_wss_calibrate_mute(struct snd_wss *chip, int mute)
597 chip->image[CS4231_RIGHT_INPUT]); 578 chip->image[CS4231_RIGHT_INPUT]);
598 snd_wss_dout(chip, CS4231_LOOPBACK, 579 snd_wss_dout(chip, CS4231_LOOPBACK,
599 chip->image[CS4231_LOOPBACK]); 580 chip->image[CS4231_LOOPBACK]);
581 } else {
582 snd_wss_dout(chip, CS4231_LEFT_INPUT,
583 0);
584 snd_wss_dout(chip, CS4231_RIGHT_INPUT,
585 0);
586 snd_wss_dout(chip, CS4231_LOOPBACK,
587 0xfd);
600 } 588 }
589
601 snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT, 590 snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT,
602 mute | chip->image[CS4231_AUX1_LEFT_INPUT]); 591 mute | chip->image[CS4231_AUX1_LEFT_INPUT]);
603 snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT, 592 snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT,
@@ -640,7 +629,6 @@ static void snd_wss_playback_format(struct snd_wss *chip,
640 int full_calib = 1; 629 int full_calib = 1;
641 630
642 mutex_lock(&chip->mce_mutex); 631 mutex_lock(&chip->mce_mutex);
643 snd_wss_calibrate_mute(chip, 1);
644 if (chip->hardware == WSS_HW_CS4231A || 632 if (chip->hardware == WSS_HW_CS4231A ||
645 (chip->hardware & WSS_HW_CS4232_MASK)) { 633 (chip->hardware & WSS_HW_CS4232_MASK)) {
646 spin_lock_irqsave(&chip->reg_lock, flags); 634 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -656,6 +644,24 @@ static void snd_wss_playback_format(struct snd_wss *chip,
656 full_calib = 0; 644 full_calib = 0;
657 } 645 }
658 spin_unlock_irqrestore(&chip->reg_lock, flags); 646 spin_unlock_irqrestore(&chip->reg_lock, flags);
647 } else if (chip->hardware == WSS_HW_AD1845) {
648 unsigned rate = params_rate(params);
649
650 /*
651 * Program the AD1845 correctly for the playback stream.
652 * Note that we do NOT need to toggle the MCE bit because
653 * the PLAYBACK_ENABLE bit of the Interface Configuration
654 * register is set.
655 *
656 * NOTE: We seem to need to write to the MSB before the LSB
657 * to get the correct sample frequency.
658 */
659 spin_lock_irqsave(&chip->reg_lock, flags);
660 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (pdfr & 0xf0));
661 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff);
662 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff);
663 full_calib = 0;
664 spin_unlock_irqrestore(&chip->reg_lock, flags);
659 } 665 }
660 if (full_calib) { 666 if (full_calib) {
661 snd_wss_mce_up(chip); 667 snd_wss_mce_up(chip);
@@ -673,7 +679,6 @@ static void snd_wss_playback_format(struct snd_wss *chip,
673 udelay(100); /* this seems to help */ 679 udelay(100); /* this seems to help */
674 snd_wss_mce_down(chip); 680 snd_wss_mce_down(chip);
675 } 681 }
676 snd_wss_calibrate_mute(chip, 0);
677 mutex_unlock(&chip->mce_mutex); 682 mutex_unlock(&chip->mce_mutex);
678} 683}
679 684
@@ -685,7 +690,6 @@ static void snd_wss_capture_format(struct snd_wss *chip,
685 int full_calib = 1; 690 int full_calib = 1;
686 691
687 mutex_lock(&chip->mce_mutex); 692 mutex_lock(&chip->mce_mutex);
688 snd_wss_calibrate_mute(chip, 1);
689 if (chip->hardware == WSS_HW_CS4231A || 693 if (chip->hardware == WSS_HW_CS4231A ||
690 (chip->hardware & WSS_HW_CS4232_MASK)) { 694 (chip->hardware & WSS_HW_CS4232_MASK)) {
691 spin_lock_irqsave(&chip->reg_lock, flags); 695 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -700,6 +704,24 @@ static void snd_wss_capture_format(struct snd_wss *chip,
700 full_calib = 0; 704 full_calib = 0;
701 } 705 }
702 spin_unlock_irqrestore(&chip->reg_lock, flags); 706 spin_unlock_irqrestore(&chip->reg_lock, flags);
707 } else if (chip->hardware == WSS_HW_AD1845) {
708 unsigned rate = params_rate(params);
709
710 /*
711 * Program the AD1845 correctly for the capture stream.
712 * Note that we do NOT need to toggle the MCE bit because
713 * the PLAYBACK_ENABLE bit of the Interface Configuration
714 * register is set.
715 *
716 * NOTE: We seem to need to write to the MSB before the LSB
717 * to get the correct sample frequency.
718 */
719 spin_lock_irqsave(&chip->reg_lock, flags);
720 snd_wss_out(chip, CS4231_REC_FORMAT, (cdfr & 0xf0));
721 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff);
722 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff);
723 full_calib = 0;
724 spin_unlock_irqrestore(&chip->reg_lock, flags);
703 } 725 }
704 if (full_calib) { 726 if (full_calib) {
705 snd_wss_mce_up(chip); 727 snd_wss_mce_up(chip);
@@ -724,7 +746,6 @@ static void snd_wss_capture_format(struct snd_wss *chip,
724 spin_unlock_irqrestore(&chip->reg_lock, flags); 746 spin_unlock_irqrestore(&chip->reg_lock, flags);
725 snd_wss_mce_down(chip); 747 snd_wss_mce_down(chip);
726 } 748 }
727 snd_wss_calibrate_mute(chip, 0);
728 mutex_unlock(&chip->mce_mutex); 749 mutex_unlock(&chip->mce_mutex);
729} 750}
730 751
@@ -781,6 +802,7 @@ static void snd_wss_init(struct snd_wss *chip)
781{ 802{
782 unsigned long flags; 803 unsigned long flags;
783 804
805 snd_wss_calibrate_mute(chip, 1);
784 snd_wss_mce_down(chip); 806 snd_wss_mce_down(chip);
785 807
786#ifdef SNDRV_DEBUG_MCE 808#ifdef SNDRV_DEBUG_MCE
@@ -804,6 +826,8 @@ static void snd_wss_init(struct snd_wss *chip)
804 826
805 snd_wss_mce_up(chip); 827 snd_wss_mce_up(chip);
806 spin_lock_irqsave(&chip->reg_lock, flags); 828 spin_lock_irqsave(&chip->reg_lock, flags);
829 chip->image[CS4231_IFACE_CTRL] &= ~CS4231_AUTOCALIB;
830 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]);
807 snd_wss_out(chip, 831 snd_wss_out(chip,
808 CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); 832 CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]);
809 spin_unlock_irqrestore(&chip->reg_lock, flags); 833 spin_unlock_irqrestore(&chip->reg_lock, flags);
@@ -837,6 +861,7 @@ static void snd_wss_init(struct snd_wss *chip)
837 chip->image[CS4231_REC_FORMAT]); 861 chip->image[CS4231_REC_FORMAT]);
838 spin_unlock_irqrestore(&chip->reg_lock, flags); 862 spin_unlock_irqrestore(&chip->reg_lock, flags);
839 snd_wss_mce_down(chip); 863 snd_wss_mce_down(chip);
864 snd_wss_calibrate_mute(chip, 0);
840 865
841#ifdef SNDRV_DEBUG_MCE 866#ifdef SNDRV_DEBUG_MCE
842 snd_printk(KERN_DEBUG "init: (5)\n"); 867 snd_printk(KERN_DEBUG "init: (5)\n");
@@ -895,8 +920,6 @@ static void snd_wss_close(struct snd_wss *chip, unsigned int mode)
895 mutex_unlock(&chip->open_mutex); 920 mutex_unlock(&chip->open_mutex);
896 return; 921 return;
897 } 922 }
898 snd_wss_calibrate_mute(chip, 1);
899
900 /* disable IRQ */ 923 /* disable IRQ */
901 spin_lock_irqsave(&chip->reg_lock, flags); 924 spin_lock_irqsave(&chip->reg_lock, flags);
902 if (!(chip->hardware & WSS_HW_AD1848_MASK)) 925 if (!(chip->hardware & WSS_HW_AD1848_MASK))
@@ -929,8 +952,6 @@ static void snd_wss_close(struct snd_wss *chip, unsigned int mode)
929 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ 952 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */
930 spin_unlock_irqrestore(&chip->reg_lock, flags); 953 spin_unlock_irqrestore(&chip->reg_lock, flags);
931 954
932 snd_wss_calibrate_mute(chip, 0);
933
934 chip->mode = 0; 955 chip->mode = 0;
935 mutex_unlock(&chip->open_mutex); 956 mutex_unlock(&chip->open_mutex);
936} 957}
@@ -1123,7 +1144,7 @@ irqreturn_t snd_wss_interrupt(int irq, void *dev_id)
1123 if (chip->hardware & WSS_HW_AD1848_MASK) 1144 if (chip->hardware & WSS_HW_AD1848_MASK)
1124 wss_outb(chip, CS4231P(STATUS), 0); 1145 wss_outb(chip, CS4231P(STATUS), 0);
1125 else 1146 else
1126 snd_wss_outm(chip, CS4231_IRQ_STATUS, status, 0); 1147 snd_wss_out(chip, CS4231_IRQ_STATUS, status);
1127 spin_unlock(&chip->reg_lock); 1148 spin_unlock(&chip->reg_lock);
1128 return IRQ_HANDLED; 1149 return IRQ_HANDLED;
1129} 1150}
@@ -1325,6 +1346,10 @@ static int snd_wss_probe(struct snd_wss *chip)
1325 chip->image[CS4231_ALT_FEATURE_2] = 1346 chip->image[CS4231_ALT_FEATURE_2] =
1326 chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01; 1347 chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01;
1327 } 1348 }
1349 /* enable fine grained frequency selection */
1350 if (chip->hardware == WSS_HW_AD1845)
1351 chip->image[AD1845_PWR_DOWN] = 8;
1352
1328 ptr = (unsigned char *) &chip->image; 1353 ptr = (unsigned char *) &chip->image;
1329 regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32; 1354 regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32;
1330 snd_wss_mce_down(chip); 1355 snd_wss_mce_down(chip);