From 199f7978730a4bbd88038fd84212b30759579f1a Mon Sep 17 00:00:00 2001 From: Krzysztof Helt Date: Fri, 9 Jan 2009 23:10:52 +0100 Subject: ALSA: wss-lib: move AD1845 frequency setting into wss-lib This is required to allow the sscape driver to autodetect installed codec. Also, do not create a timer if detected codec has no hardware timer (e.g. AD1848). Signed-off-by: Krzysztof Helt Cc: Rene Herman Signed-off-by: Takashi Iwai --- sound/isa/wss/wss_lib.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'sound/isa/wss') diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 3d6c5f2838a..13299aebd07 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -646,6 +646,24 @@ static void snd_wss_playback_format(struct snd_wss *chip, full_calib = 0; } spin_unlock_irqrestore(&chip->reg_lock, flags); + } else if (chip->hardware == WSS_HW_AD1845) { + unsigned rate = params_rate(params); + + /* + * Program the AD1845 correctly for the playback stream. + * Note that we do NOT need to toggle the MCE bit because + * the PLAYBACK_ENABLE bit of the Interface Configuration + * register is set. + * + * NOTE: We seem to need to write to the MSB before the LSB + * to get the correct sample frequency. + */ + spin_lock_irqsave(&chip->reg_lock, flags); + snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (pdfr & 0xf0)); + snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff); + snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff); + full_calib = 0; + spin_unlock_irqrestore(&chip->reg_lock, flags); } if (full_calib) { snd_wss_mce_up(chip); @@ -690,6 +708,24 @@ static void snd_wss_capture_format(struct snd_wss *chip, full_calib = 0; } spin_unlock_irqrestore(&chip->reg_lock, flags); + } else if (chip->hardware == WSS_HW_AD1845) { + unsigned rate = params_rate(params); + + /* + * Program the AD1845 correctly for the capture stream. + * Note that we do NOT need to toggle the MCE bit because + * the PLAYBACK_ENABLE bit of the Interface Configuration + * register is set. + * + * NOTE: We seem to need to write to the MSB before the LSB + * to get the correct sample frequency. + */ + spin_lock_irqsave(&chip->reg_lock, flags); + snd_wss_out(chip, CS4231_REC_FORMAT, (cdfr & 0xf0)); + snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff); + snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff); + full_calib = 0; + spin_unlock_irqrestore(&chip->reg_lock, flags); } if (full_calib) { snd_wss_mce_up(chip); @@ -1314,6 +1350,10 @@ static int snd_wss_probe(struct snd_wss *chip) chip->image[CS4231_ALT_FEATURE_2] = chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01; } + /* enable fine grained frequency selection */ + if (chip->hardware == WSS_HW_AD1845) + chip->image[AD1845_PWR_DOWN] = 8; + ptr = (unsigned char *) &chip->image; regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32; snd_wss_mce_down(chip); -- cgit v1.2.3 From 9ef344f89ac41116d4ab138b0941c784a3ab8cf4 Mon Sep 17 00:00:00 2001 From: Krzysztof Helt Date: Fri, 16 Jan 2009 22:47:30 +0100 Subject: ALSA: wss-lib: remove "pops" before each played sound A WSS codec is autocalibrated each time before playing sound. Do only one calibration during codec initialization. Complete snd_wss_calibrate_mute to mute loopback volume as well. Signed-off-by: Krzysztof Helt Signed-off-by: Takashi Iwai --- sound/isa/wss/wss_lib.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) (limited to 'sound/isa/wss') diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 13299aebd07..f0c0be5bb68 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) udelay(100); } -static void snd_wss_outm(struct snd_wss *chip, unsigned char reg, - unsigned char mask, unsigned char value) -{ - unsigned char tmp = (chip->image[reg] & mask) | value; - - snd_wss_wait(chip); -#ifdef CONFIG_SND_DEBUG - if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) - snd_printk("outm: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value); -#endif - chip->image[reg] = tmp; - if (!chip->calibrate_mute) { - wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); - wmb(); - wss_outb(chip, CS4231P(REG), tmp); - mb(); - } -} - static void snd_wss_dout(struct snd_wss *chip, unsigned char reg, unsigned char value) { @@ -587,7 +568,15 @@ static void snd_wss_calibrate_mute(struct snd_wss *chip, int mute) chip->image[CS4231_RIGHT_INPUT]); snd_wss_dout(chip, CS4231_LOOPBACK, chip->image[CS4231_LOOPBACK]); + } else { + snd_wss_dout(chip, CS4231_LEFT_INPUT, + 0); + snd_wss_dout(chip, CS4231_RIGHT_INPUT, + 0); + snd_wss_dout(chip, CS4231_LOOPBACK, + 0xfd); } + snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT, mute | chip->image[CS4231_AUX1_LEFT_INPUT]); snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT, @@ -630,7 +619,6 @@ static void snd_wss_playback_format(struct snd_wss *chip, int full_calib = 1; mutex_lock(&chip->mce_mutex); - snd_wss_calibrate_mute(chip, 1); if (chip->hardware == WSS_HW_CS4231A || (chip->hardware & WSS_HW_CS4232_MASK)) { spin_lock_irqsave(&chip->reg_lock, flags); @@ -681,7 +669,6 @@ static void snd_wss_playback_format(struct snd_wss *chip, udelay(100); /* this seems to help */ snd_wss_mce_down(chip); } - snd_wss_calibrate_mute(chip, 0); mutex_unlock(&chip->mce_mutex); } @@ -693,7 +680,6 @@ static void snd_wss_capture_format(struct snd_wss *chip, int full_calib = 1; mutex_lock(&chip->mce_mutex); - snd_wss_calibrate_mute(chip, 1); if (chip->hardware == WSS_HW_CS4231A || (chip->hardware & WSS_HW_CS4232_MASK)) { spin_lock_irqsave(&chip->reg_lock, flags); @@ -750,7 +736,6 @@ static void snd_wss_capture_format(struct snd_wss *chip, spin_unlock_irqrestore(&chip->reg_lock, flags); snd_wss_mce_down(chip); } - snd_wss_calibrate_mute(chip, 0); mutex_unlock(&chip->mce_mutex); } @@ -807,6 +792,7 @@ static void snd_wss_init(struct snd_wss *chip) { unsigned long flags; + snd_wss_calibrate_mute(chip, 1); snd_wss_mce_down(chip); #ifdef SNDRV_DEBUG_MCE @@ -830,6 +816,8 @@ static void snd_wss_init(struct snd_wss *chip) snd_wss_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); + chip->image[CS4231_IFACE_CTRL] &= ~CS4231_AUTOCALIB; + snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); snd_wss_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); spin_unlock_irqrestore(&chip->reg_lock, flags); @@ -863,6 +851,7 @@ static void snd_wss_init(struct snd_wss *chip) chip->image[CS4231_REC_FORMAT]); spin_unlock_irqrestore(&chip->reg_lock, flags); snd_wss_mce_down(chip); + snd_wss_calibrate_mute(chip, 0); #ifdef SNDRV_DEBUG_MCE snd_printk("init: (5)\n"); @@ -921,8 +910,6 @@ static void snd_wss_close(struct snd_wss *chip, unsigned int mode) mutex_unlock(&chip->open_mutex); return; } - snd_wss_calibrate_mute(chip, 1); - /* disable IRQ */ spin_lock_irqsave(&chip->reg_lock, flags); if (!(chip->hardware & WSS_HW_AD1848_MASK)) @@ -955,8 +942,6 @@ static void snd_wss_close(struct snd_wss *chip, unsigned int mode) wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ spin_unlock_irqrestore(&chip->reg_lock, flags); - snd_wss_calibrate_mute(chip, 0); - chip->mode = 0; mutex_unlock(&chip->open_mutex); } @@ -1149,7 +1134,7 @@ irqreturn_t snd_wss_interrupt(int irq, void *dev_id) if (chip->hardware & WSS_HW_AD1848_MASK) wss_outb(chip, CS4231P(STATUS), 0); else - snd_wss_outm(chip, CS4231_IRQ_STATUS, status, 0); + snd_wss_out(chip, CS4231_IRQ_STATUS, status); spin_unlock(&chip->reg_lock); return IRQ_HANDLED; } -- cgit v1.2.3