NetBSD Problem Report #45778

From www@NetBSD.org  Wed Jan  4 16:14:53 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CE4FD63DD5F
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  4 Jan 2012 16:14:53 +0000 (UTC)
Message-Id: <20120104161452.C24D863DD0D@www.NetBSD.org>
Date: Wed,  4 Jan 2012 16:14:52 +0000 (UTC)
From: nathanialsloss@yahoo.com.au
Reply-To: nathanialsloss@yahoo.com.au
To: gnats-bugs@NetBSD.org
Subject: sysbeep cannot be heard after hdaudio attaches
X-Send-Pr-Version: www-1.0

>Number:         45778
>Category:       kern
>Synopsis:       sysbeep cannot be heard after hdaudio attaches
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 04 16:15:00 +0000 2012
>Closed-Date:    Sun Sep 21 10:52:51 +0000 2014
>Last-Modified:  Sun Sep 21 10:52:51 +0000 2014
>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.

>Release-Note:

>Audit-Trail:
From: "Nathanial Sloss" <nat@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45778 CVS commit: src/sys/dev/pci/hdaudio
Date: Sun, 21 Sep 2014 10:41:23 +0000

 Module Name:	src
 Committed By:	nat
 Date:		Sun Sep 21 10:41:23 UTC 2014

 Modified Files:
 	src/sys/dev/pci/hdaudio: hdafg.c

 Log Message:
 Enable sysbeep(4) to be heard on speakers on Toughbook mk1 and mk5
 computers.  Also on computers with SigmaTel STAC 9200(D), 9202(D)
 9404(D), 9205(D) hdaudio controllers as well as Realtek ALC 231
 hdaudio controllers reporting as ALC 269.

 Addresses PR 45778.
 Addresses PR 48495.

 This commit was approved by christos@


 To generate a diff of this commit:
 cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/hdaudio/hdafg.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: nat@NetBSD.org
State-Changed-When: Sun, 21 Sep 2014 10:52:51 +0000
State-Changed-Why:
Patch from PR 48495 applied.  Should be fixed now.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.