NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/45778: sysbeep cannot be heard after hdaudio attaches



>Number:         45778
>Category:       kern
>Synopsis:       sysbeep cannot be heard after hdaudio attaches
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 04 16:15:00 +0000 2012
>Originator:     Nat Sloss
>Release:        NetBSD 5.0.1
>Organization:
>Environment:
NetBSD  5.99.58 NetBSD 5.99.58 (GENERIC) #0: Wed Jan 04 20:47:27 EST 2012  build
@beast:/home/build/NetBSD-Current_source_tree/src/sys/arch/i386/compile/obj/GENE
RIC i386

>Description:
When hdaudio attaches (I have a sigmatel STAC9200) sysbeep or speaker can not 
be heard.  They work fine if hdaudio is disabled.

The problem is that sigmatel chips input the audio from the analog source and 
must be enabled in order for the analog pc beep/speaker to be heard.  I'm not 
sure if this affects other manufacturers of hdaudio chips.
>How-To-Repeat:
Use /dev/speaker with hdaudio disabled and it will work or type nonsense in the 
shell and press tab and the speaker will be heard.

Repeat with hdaudio enabled (I believe this only affects sigmatel chips) and 
you will hear nothing.  When performing these tests ensure that the speaker is 
not muted and appropriate volume etc.

>Fix:
I've patched hdafg.c from sources as of the first of Jan 2012.  As I noticed 
there was a commit for the system speaker but it only pertains to analog 
devices chips.  

So I found data sheets for the STAC9200 from IDT but they did not contain 
information on how to enable analog pc beep input.  I did however find data 
from the 9204/9205 IDT hdaudio chip and tried that on a hunch and it worked.

I patched hdafg.c as follows:  I believe it works for all the sigmatel/IDT 
chips listed but it may also work for others.  Other sigmatel chips use 
different enable sequences so this patch could be expanded to encompass those.

 --- hdafg.c.orig        2012-01-01 15:46:52.000000000 +1100
+++ hdafg.c     2012-01-03 00:58:01.000000000 +1100
@@ -338,6 +338,7 @@
                                        prop_dictionary_t);
 static int     hdafg_codec_info(void *, prop_dictionary_t,
                                       prop_dictionary_t);
+static void    hdafg_enable_analogue_beep(struct hdafg_softc *);

 CFATTACH_DECL2_NEW(
     hdafg,
@@ -3681,6 +3682,9 @@
        if (1) hdafg_widget_pin_dump(sc);
        hdafg_assoc_dump(sc);

+       hda_debug(sc, "enabling analogue beep\n");
+       hdafg_enable_analogue_beep(sc);
+
        hda_debug(sc, "configuring encodings\n");
        sc->sc_audiodev.ad_sc = sc;
        hdafg_configure_encodings(sc);
@@ -4356,3 +4360,49 @@
                return ENOTTY;
        }
 }
+
+static void
+hdafg_enable_analogue_beep(struct hdafg_softc *sc)
+{
+       int nid;
+       uint32_t response;
+
+       switch (sc->sc_vendor) {
+           case HDA_VENDOR_SIGMATEL:
+               switch (sc->sc_product) {
+                   case 0x7632:        /* STAC9202 */
+                   case 0x7633:        /* STAC9202D */
+                   case 0x7690:        /* STAC9200 */
+                   case 0x7691:        /* STAC9200D */
+                   case 0x7698:        /* STAC9205 */
+                   case 0x76a0:        /* STAC9205 */
+                   case 0x76a1:        /* STAC9205D */
+                   case 0x76a2:        /* STAC9204 */
+                   case 0x76a3:        /* STAC9204D */
+
+#define AFG_GET_ANACTRL 0xFe0
+#define AFG_SET_ANACTRL 0x7e0
+#define AnalogBeepEn 0x20              /* bit 5 = 1 */
+
+                       nid = 0x01;
+
+                       response = hdaudio_command(sc->sc_codec, nid,
+                           AFG_GET_ANACTRL, 0x00);
+                       hda_delay(100);
+
+                       response |= AnalogBeepEn;
+
+                       hdaudio_command(sc->sc_codec, nid, AFG_SET_ANACTRL,
+                           response);
+                       hda_delay(100);
+                       break;
+
+                   default:
+                       break;
+               }
+               break;
+
+           default:
+               break;
+       }
+}


I hope this helps, although I'm not sure it works for the 9202 it also isn't 
stated in the data sheet, but I think it will work.

Regards,

Nat.



Home | Main Index | Thread Index | Old Index