PATCH: Via audio rate lock, for testing

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Wed Feb 21 2001 - 11:47:51 EST


Can you guys test this patch, and let me know if it fixes Via audio
problems on your kernel?

It should apply against 2.4.1 or 2.4.1-acXX kernels. Note that it
should be applied with "patch -p0" while in the linux kernel source
directory, not applied with "patch -p1".

Regards,

        Jeff

Index: drivers/sound/via82cxxx_audio.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/sound/via82cxxx_audio.c,v
retrieving revision 1.1.1.13.22.1
diff -u -r1.1.1.13.22.1 via82cxxx_audio.c
--- drivers/sound/via82cxxx_audio.c 2001/02/18 23:58:28 1.1.1.13.22.1
+++ drivers/sound/via82cxxx_audio.c 2001/02/21 16:36:23
@@ -281,6 +281,8 @@
 
         int dev_dsp; /* /dev/dsp index from register_sound_dsp() */
 
+ int locked_rate : 1;
+
         struct semaphore syscall_sem;
         struct semaphore open_sem;
 
@@ -503,10 +505,16 @@
 static int via_set_rate (struct ac97_codec *ac97,
                          struct via_channel *chan, unsigned rate)
 {
+ struct via_info *card = ac97->private_data;
         int rate_reg;
 
         DPRINTK ("ENTER, rate = %d\n", rate);
 
+ if (card->locked_rate) {
+ chan->rate = 48000;
+ goto out;
+ }
+
         if (rate > 48000) rate = 48000;
         if (rate < 4000) rate = 4000;
 
@@ -530,6 +538,13 @@
          */
         chan->rate = via_ac97_read_reg (ac97, rate_reg);
 
+ if (chan->rate == 0) {
+ card->locked_rate = 1;
+ chan->rate = 48000;
+ printk (KERN_WARNING PFX "Codec rate locked at 48Khz\n");
+ }
+
+out:
         DPRINTK ("EXIT, returning rate %d Hz\n", chan->rate);
         return chan->rate;
 }
@@ -1438,7 +1453,7 @@
  * via_ac97_reset - Reset Via AC97 hardware
  * @card: Private info for specified board
  *
- * Reset Via AC97 hardware.
+ * Reset Via AC97 codec, controller, and hardware.
  */
 
 static int __init via_ac97_reset (struct via_info *card)
@@ -1512,8 +1527,8 @@
          */
 
         /* enable variable rate, variable rate MIC ADC */
- tmp16 = via_ac97_read_reg (&card->ac97, 0x2A);
- via_ac97_write_reg (&card->ac97, 0x2A, tmp16 | (1<<0));
+ tmp16 = via_ac97_read_reg (&card->ac97, AC97_EXTENDED_STATUS);
+ via_ac97_write_reg (&card->ac97, AC97_EXTENDED_STATUS, tmp16 | 1);
 
         pci_read_config_byte (pdev, VIA_ACLINK_CTRL, &tmp8);
         if ((tmp8 & (VIA_CR41_AC97_ENABLE | VIA_CR41_AC97_RESET)) == 0) {
@@ -1588,8 +1603,22 @@
         }
 
         /* enable variable rate, variable rate MIC ADC */
- tmp16 = via_ac97_read_reg (&card->ac97, 0x2A);
- via_ac97_write_reg (&card->ac97, 0x2A, tmp16 | (1<<0));
+ tmp16 = via_ac97_read_reg (&card->ac97, AC97_EXTENDED_STATUS);
+ via_ac97_write_reg (&card->ac97, AC97_EXTENDED_STATUS, tmp16 | 1);
+
+ /*
+ * If we cannot enable VRA, we have a locked-rate codec.
+ * We try again to enable VRA before assuming so, however.
+ */
+ tmp16 = via_ac97_read_reg (&card->ac97, AC97_EXTENDED_STATUS);
+ if ((tmp16 & 1) == 0) {
+ via_ac97_write_reg (&card->ac97, AC97_EXTENDED_STATUS, tmp16 | 1);
+ tmp16 = via_ac97_read_reg (&card->ac97, AC97_EXTENDED_STATUS);
+ if ((tmp16 & 1) == 0) {
+ card->locked_rate = 1;
+ printk (KERN_WARNING PFX "Codec rate locked at 48Khz\n");
+ }
+ }
 
         DPRINTK ("EXIT, returning 0\n");
         return 0;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Feb 23 2001 - 21:00:25 EST