Subject: kern/20368: ac97 audio codec patch for ad1981
To: None <gnats-bugs@gnats.netbsd.org>
From: None <lars@heidieker.de>
List: netbsd-bugs
Date: 02/16/2003 07:20:28
>Number:         20368
>Category:       kern
>Synopsis:       ac97 audio codec patch for ad1981
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 16 07:21:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Lars Heidieker
>Release:        1.6N
>Organization:
>Environment:
>Description:
This patches the ac97 codec ad1981 to work properly.
This codec is found on ASUS P4PE mainboards etc.
The problem before was silent output as the analogue
channels weren't connect to the output.
There is probably room for improvment as the volume is
controlled by surround and not master (or is that correct
for a surround codec?)
>How-To-Repeat:
Just every ad1981 codec should have silent output.
>Fix:
Need to set 0x76h register in codec to connect mixer channels to output

patch given:

--- ac97.c.orig 2003-02-16 15:57:38.000000000 +0100
+++ ac97.c      2003-02-16 16:14:41.000000000 +0100
@@ -324,6 +324,7 @@
 u_int16_t ac97_get_extcaps(struct ac97_codec_if *codec_if);
 int ac97_add_port(struct ac97_softc *as, const struct ac97_source_info *src);
 
+static void ac97_ad1981_init(struct ac97_softc *);
 static void ac97_alc650_init(struct ac97_softc *);
 static void ac97_vt1616_init(struct ac97_softc *);
 
@@ -365,7 +366,7 @@
        { AC97_CODEC_ID('A', 'D', 'S', 0x63),
          0xffffffff,                   "Analog Devices AD1886A" },
        { AC97_CODEC_ID('A', 'D', 'S', 0x70),
-         0xffffffff,                   "Analog Devices AD1981" },
+         0xffffffff,                   "Analog Devices AD1981", ac97_ad1981_init },
        { AC97_CODEC_ID('A', 'D', 'S', 0x72),
          0xffffffff,                   "Analog Devices AD1981A" },
        { AC97_CODEC_ID('A', 'D', 'S', 0x74),
@@ -1438,6 +1439,31 @@
        return 0;
 }
 
+#define AC97_AD_MISC_REG       0x76
+#define AC97_AD_MISC_MBG       0x0001  /* 0 */
+#define AC97_AD_MISC_VREFD     0x0002  /* 1 */
+#define AC97_AD_MISC_VREFH     0x0004  /* 2 */
+#define AC97_AD_MISC_MADST     0x0008  /* 3 */
+#define AC97_AD_MISC_UNUSED1   0x0010  /* 4 */
+#define AC97_AD_MISC_MADPD     0x0020  /* 5 */
+#define AC97_AD_MISC_UNUSED2   0x0040  /* 6 */
+#define AC97_AD_MISC_UNUSED3   0x0080  /* 7 */
+#define AC97_AD_MISC_FMXE      0x0100  /* 8 */
+#define AC97_AD_MISC_UNUSED4   0x0200  /* 9 */
+#define AC97_AD_MISC_DAM       0x0400  /*10 */
+#define AC97_AD_MISC_UNUSED5   0x0800  /*11 */
+#define AC97_AD_MISC_MSPLT     0x1000  /*12 */
+#define AC97_AD_MISC_UNUSED6   0x2000  /*13 */
+#define AC97_AD_MISC_DACZ      0x4000  /*14 */
+static void
+ac97_ad1981_init(struct ac97_softc *as)
+{
+       unsigned short misc;
+
+       ac97_read(as, AC97_AD_MISC, &misc);
+       ac97_write(as, AC97_AD_MISC, misc|AC97_AD_MISC_DAM|AC97_AD_MISC_MADPD);
+}
+
 #define ALC650_REG_MULTI_CHANNEL_CONTROL       0x6a
 #define                ALC650_MCC_SLOT_MODIFY_MASK             0xc000
 #define                ALC650_MCC_FRONTDAC_FROM_SPDIFIN        0x2000 /* 13 */

>Release-Note:
>Audit-Trail:
>Unformatted: