NetBSD Problem Report #44670

From campbell@mumble.net  Wed Mar  2 20:33:00 2011
Return-Path: <campbell@mumble.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CA9BE63B84D
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  2 Mar 2011 20:32:59 +0000 (UTC)
Message-Id: <20110302203130.5862C98298@pluto.mumble.net>
Date: Wed,  2 Mar 2011 20:31:30 +0000 (UTC)
From: Taylor R Campbell <campbell+netbsd@mumble.net>
Reply-To: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@gnats.NetBSD.org
Subject: audio output doesn't work on my MacBook1,1
X-Send-Pr-Version: 3.95

>Number:         44670
>Category:       kern
>Synopsis:       audio output doesn't work on my MacBook1,1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 02 20:35:00 +0000 2011
>Last-Modified:  Thu Mar 03 21:25:01 +0000 2011
>Originator:     Taylor R Campbell <campbell+netbsd@mumble.net>
>Release:        NetBSD 5.99.47
>Organization:
>Environment:
System: NetBSD oberon.local 5.99.47 NetBSD 5.99.47 (RIAMONODEBUG) #31: Mon Feb 28 05:14:15 UTC 2011  root@smalltalk.local:/home/riastradh/netbsd/current/obj/sys/arch/i386/compile/RIAMONODEBUG i386
Architecture: i386
Machine: i386
>Description:

	I can't coax my MacBook into producing audio output --
	`audioplay -d /dev/audio foo' produces output neither in the
	internal speakers nor through the headphone jack.  I have also
	tried a NetBSD 5.1 kernel with azalia(4), to no avail.  (I may
	have needed to wire up mixerctl in some hairy way to make it
	work with azalia(4), and I didn't try very hard to do that.)

	Here's some relevant information from the -current kernel.  Let
	me know if you want more -- e.g., any kind of debugging output
	from the hdaudio(4) driver.

% egrep -i '(audio|hdafg)' < /var/run/dmesg.boot
hdaudio0 at pci0 dev 27 function 0: HD Audio Controller
hdaudio0: interrupting at ioapic0 pin 22
hdafg0 at hdaudio0: Sigmatel STAC9221 A1
hdafg0: ADC00 2ch: Mic In [Built-In]
hdafg0: DAC01 6ch: Speaker [Jack] [Built-In], SPDIF Out [Jack]
hdafg0: 6ch/2ch 44100Hz 48000Hz 88200Hz 96000Hz 192000Hz 16/16 20/32 24/32
audio0 at hdafg0: full duplex, playback, capture, independent
audio1 at pad0: half duplex, playback, capture
% mixerctl -av
outputs.master=254,254 volume delta=2
outputs.master.mute=off  [ off on ]
outputs.master2=254,254 volume delta=2
outputs.master2.mute=off  [ off on ]
record.monitor=0,0 volume delta=51
inputs.beep=255,255 volume delta=64
inputs.reclvl=0,0 volume delta=17
inputs.reclvl.mute=off  [ off on ]
outputs.dacsel=DAC01  { DAC01 }
record.source=ADC00  { ADC00 }
% audioctl -a
name=Sigmatel
version=STAC9221 A1
config=01h
encodings=slinear_le:16,slinear_be:16*,ulinear_le:16*,ulinear_be:16*,mulaw:8*,alaw:8*,slinear_le:32,slinear_be:32*,ulinear_le:32*,ulinear_be:32*
properties=full_duplex,independent
full_duplex=0
fullduplex=0
blocksize=9600
hiwat=6
lowat=1
monitor_gain=0
mode=
play.rate=8000
play.channels=1
play.precision=8
play.encoding=mulaw
play.gain=254
play.balance=32
play.port=0x0
play.avail_ports=0x0
play.seek=0
play.samples=7421
play.eof=0
play.pause=0
play.error=1
play.waiting=0
play.open=0
play.active=0
play.buffer_size=65536
record.rate=8000
record.channels=1
record.precision=8
record.encoding=mulaw
record.gain=0
record.balance=32
record.port=0x0
record.avail_ports=0x0
record.seek=0
record.samples=0
record.eof=0
record.pause=0
record.error=0
record.waiting=0
record.open=0
record.active=0
record.buffer_size=65536
record.errors=0

>How-To-Repeat:

	Install NetBSD on a MacBook1,1.  Attempt to make audio output.
	Watch the little red light in the headphone jack with chagrin.

>Fix:

	Yes, please!  Unfortunately, the solution to PR kern/44484
	doesn't solve my problem.

>Audit-Trail:
From: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/44670: audio output doesn't work on my MacBook1,1
Date: Thu, 3 Mar 2011 21:13:53 +0000

 By parroting the Linux driver, I have been able to get audio to work,
 sort of.  It seems a bit crackly, which I don't remember before in the
 recording of Beethoven's Appassionata which I'm using to test it.

 I hacked up hdaudio.c so that `hdaudioctl set' wouldn't immediately
 trigger a lockdebug panic, cargo-culted gpio stuff from the Linux
 driver, and then used `hdaudioctl set' to set the pin configuration to
 what I found in the Linux driver.

 Obviously this is totally mega-kludgerific, and I have no idea what
 I'm doing, so I don't know what the right thing is, but maybe someone
 who does know what he's doing can derive from this kludgerosity a
 proper fix.

 Pin configuration:

 nid config
 10  0x0121e21f
 11  0x400000ff
 12  0x9017e110
 13  0xf00000fd
 14  0x400000fe
 15  0x0181e020
 16  0x1145e030
 17  0x11c5e240
 21  0x400000fc
 27  0x400000fb

 Patch:

 Index: hdafg.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/pci/hdaudio/hdafg.c,v
 retrieving revision 1.2
 diff -p -u -r1.2 hdafg.c
 --- hdafg.c	12 Feb 2011 15:15:34 -0000	1.2
 +++ hdafg.c	3 Mar 2011 21:07:24 -0000
 @@ -2970,13 +2970,27 @@ hdafg_commit(struct hdafg_softc *sc)
  	}
  #endif

 +	/* [TRC 20110303: XXX Horrible hack for my MacBook1,1.]  */
 +	gdata = 0x03 | hdaudio_command(sc->sc_codec, sc->sc_nid,
 +	    CORB_GET_GPIO_DATA, 0);
 +	gmask = 0x03 | hdaudio_command(sc->sc_codec, sc->sc_nid,
 +	    CORB_GET_GPIO_ENABLE_MASK, 0);
 +	gdir = 0x03 | hdaudio_command(sc->sc_codec, sc->sc_nid,
 +	    CORB_GET_GPIO_DIRECTION, 0);
 +	commitgpio = 1;
 +
  	if (commitgpio) {
  		hda_trace(sc, "GPIO commit: data=%08X mask=%08X dir=%08X\n",
  		    gdata, gmask, gdir);
 +		/* [TRC 20110303: XXX Super-secret magic 0x7e7 stolen
 +		 * from Linux.]  */
 +		hdaudio_command(sc->sc_codec, sc->sc_nid, 0x7e7, 0);
  		hdaudio_command(sc->sc_codec, sc->sc_nid,
  		    CORB_SET_GPIO_ENABLE_MASK, gmask);
  		hdaudio_command(sc->sc_codec, sc->sc_nid,
  		    CORB_SET_GPIO_DIRECTION, gdir);
 +		/* [TRC 20110303: XXX Cargo-culted from Linux.]  */
 +		hda_delay(1000);
  		hdaudio_command(sc->sc_codec, sc->sc_nid,
  		    CORB_SET_GPIO_DATA, gdata);
  	}
 Index: hdaudio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/pci/hdaudio/hdaudio.c,v
 retrieving revision 1.11
 diff -p -u -r1.11 hdaudio.c
 --- hdaudio.c	13 Feb 2011 17:49:12 -0000	1.11
 +++ hdaudio.c	3 Mar 2011 21:07:24 -0000
 @@ -1034,6 +1034,7 @@ void
  hdaudio_stream_disestablish(struct hdaudio_stream *st)
  {
  	struct hdaudio_softc *sc = st->st_host;
 +	struct hdaudio_dma dma;

  	KASSERT(sc->sc_stream_mask & (1 << st->st_shift));

 @@ -1041,8 +1042,12 @@ hdaudio_stream_disestablish(struct hdaud
  	sc->sc_stream_mask &= ~(1 << st->st_shift);
  	st->st_intr = NULL;
  	st->st_cookie = NULL;
 -	hdaudio_dma_free(sc, &st->st_bdl);
 +	dma = st->st_bdl;
 +	st->st_bdl.dma_valid = false;
  	mutex_exit(&sc->sc_stream_mtx);
 +
 +	/* Can't bus_dmamem_unmap while holding a mutex.  */
 +	hdaudio_dma_free(sc, &dma);
  }

  /*

From: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/44670: audio output doesn't work on my MacBook1,1
Date: Thu, 3 Mar 2011 21:21:43 +0000

 I ought to have added that the original pin configuration reported by
 `hdaudioctl get 0x00 0x01' was (without the XML verbiage):

 10 0x0101e022
 11 0x90afe112
 12 0x9017e121
 13 0x4180e100
 14 0x41f0e032
 15 0x0181e031
 16 0x1145f023
 17 0x11c5c032
 21 0x4180e100
 27 0x4180e100

 And here's what `hdaudioctl list' shows:

 # hdaudioctl list
 codecid 0x00 nid 0x01 vendor 0x8384 product 0x7680 subsystem 0x76808384 dev=
 ice hdafg0

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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.