NetBSD Problem Report #56980

From khorben@reapr.station.defora  Fri Aug 26 08:51:21 2022
Return-Path: <khorben@reapr.station.defora>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 33EFA1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 26 Aug 2022 08:51:21 +0000 (UTC)
Message-Id: <20220826040345.1856740E4E@reapr.station.defora>
Date: Fri, 26 Aug 2022 06:03:45 +0200 (CEST)
From: Pierre Pronchery <khorben@defora.org>
Reply-To:
To: gnats-bugs@NetBSD.org
Subject: Support missing for Sound Blaster Audigy Rx audio card
X-Send-Pr-Version: 3.95

>Number:         56980
>Category:       kern
>Synopsis:       The Sound Blaster Audigy Rx is not supported by NetBSD
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 26 08:55:00 +0000 2022
>Closed-Date:    Tue Aug 30 17:08:16 +0000 2022
>Last-Modified:  Tue Aug 30 17:08:16 +0000 2022
>Originator:     Pierre Pronchery <khorben@defora.org>
>Release:        NetBSD 9.3_STABLE
>Organization:
>Environment:
System: NetBSD Insomniac 9.3_STABLE NetBSD 9.3_STABLE (GENERIC) #0: Mon Aug 22 06:20:14 UTC 2022 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
The NetBSD kernel does not support the Sound Blaster Audigy Rx. It is
not recognised at all by the emuxki(4) driver, which should be the one
responsible for implementing it: its hardware is very close to that of
the Audigy 2.
>How-To-Repeat:
Insert a Sound Blaster Audigy Rx into a PCIe port, and boot NetBSD.
>Fix:
The following patch modifies the emuxki(4) driver to recognise the card.
However, more changes are required in order to actually be able to
output audio, which could not be confirmed with this patch alone.

emuxki0 at pci6 dev 0 function 0: vendor 1102 product 0008 (rev. 0x00)
emuxki0: interrupting at ioapic3 pin 0
emuxki0: ac97: SigmaTel STAC9750/51 codec; headphone, 20 bit DAC, 20 bit ADC, SigmaTel 3D
emuxki0: ac97: ext id 0x605<AC97_22,AMAP,SPDIF,VRA>
audio0 at emuxki0: playback, capture, full duplex, independent

diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c
index 6a700e20f31c..43d1bb747764 100644
--- a/sys/dev/pci/emuxki.c
+++ b/sys/dev/pci/emuxki.c
@@ -139,7 +139,8 @@ struct emuxki_softc {
 		EMUXKI_SBLIVE = 0x00,
 		EMUXKI_AUDIGY = 0x01,
 		EMUXKI_AUDIGY2 = 0x02,
-		EMUXKI_LIVE_5_1 = 0x04,
+		EMUXKI_AUDIGY2_VALUE = 0x04,
+		EMUXKI_LIVE_5_1 = 0x08,
 		EMUXKI_APS = 0x08
 	} sc_type;
 	audio_device_t		sc_audv;	/* for GETDEV */
@@ -479,6 +480,7 @@ emuxki_match(device_t parent, cfdata_t match, void *aux)
 	case PCI_PRODUCT_CREATIVELABS_SBLIVE:
 	case PCI_PRODUCT_CREATIVELABS_SBLIVE2:
 	case PCI_PRODUCT_CREATIVELABS_AUDIGY:
+	case PCI_PRODUCT_CREATIVELABS_SBAUDIGY4:
 		return 1;
 	default:
 		return 0;
@@ -538,7 +540,13 @@ emuxki_attach(device_t parent, device_t self, void *aux)
 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);

 	/* XXX it's unknown whether APS is made from Audigy as well */
-	if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_AUDIGY) {
+	if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_SBAUDIGY4) {
+		sc->sc_type = EMUXKI_AUDIGY;
+		sc->sc_type |= EMUXKI_AUDIGY2;
+		sc->sc_type |= EMUXKI_AUDIGY2_VALUE;
+		strlcpy(sc->sc_audv.name, "Audigy2 (value)",
+		    sizeof(sc->sc_audv.name));
+	} else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_AUDIGY) {
 		sc->sc_type = EMUXKI_AUDIGY;
 		if (PCI_REVISION(pa->pa_class) == 0x04) {
 			sc->sc_type |= EMUXKI_AUDIGY2;
@@ -707,7 +715,20 @@ emuxki_init(struct emuxki_softc *sc)
 	emuxki_write(sc, 0, EMU_SPCS1, spcs);
 	emuxki_write(sc, 0, EMU_SPCS2, spcs);

-	if (sc->sc_type & EMUXKI_AUDIGY2) {
+	if (sc->sc_type & EMUXKI_AUDIGY2_VALUE) {
+		emuxki_write(sc, 0, EMU_A2_SPDIF_SAMPLERATE,
+		    EMU_A2_SPDIF_UNKNOWN);
+
+		emuxki_writeptr(sc, EMU_A2_PTR, EMU_A2_DATA, EMU_A2_SRCSEL,
+		    EMU_A2_SRCSEL_ENABLE_SPDIF | EMU_A2_SRCSEL_ENABLE_SRCMULTI);
+
+		emuxki_writeptr(sc, EMU_A2_PTR, EMU_A2_DATA, 0x7a0000, 0xff000000);
+
+		emuxki_writeio_4(sc, EMU_A_IOCFG,
+		    emuxki_readio_4(sc, EMU_A_IOCFG) & ~0x8);
+	} else if (sc->sc_type & EMUXKI_AUDIGY2) {
 		emuxki_write(sc, 0, EMU_A2_SPDIF_SAMPLERATE,
 		    EMU_A2_SPDIF_UNKNOWN);


>Release-Note:

>Audit-Trail:
From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56980: Support missing for Sound Blaster Audigy Rx audio
 card
Date: Fri, 26 Aug 2022 11:07:38 +0200

 After further investigation, I realised that OpenBSD is using NetBSD=E2=80=
 =99s
 driver, and added support for the chipset changes related to the Audigy
 Rx. I have updated the patch to include the corresponding changes.

 Unfortunately, more changes are still required in order to actually be
 able to output audio: I get a constant, faint hissing noise instead at
 the moment.

 Additional information FWIW:

 $ audiocfg list 0
 0: [*] audio0 @ emuxki0: Audigy2 (value) 0x00
        playback: 2ch, 48000Hz
        record:   2ch, 48000Hz
        (PR) slinear_le 16/16, 2ch, { 48000 }
 $ mixerctl -d /dev/mixer0 -av
 outputs.master=3D255,255 volume delta=3D8
 outputs.master.mute=3Doff  [ off on ]
 outputs.mono=3D255 volume delta=3D8
 outputs.mono.mute=3Don  [ off on ]
 outputs.mono.source=3Dmixerout  [ mixerout mic ]
 outputs.headphones=3D255,255 volume delta=3D8
 outputs.headphones.mute=3Doff  [ off on ]
 inputs.speaker=3D255 volume delta=3D16
 inputs.speaker.mute=3Doff  [ off on ]
 inputs.phone=3D191 volume delta=3D8
 inputs.phone.mute=3Don  [ off on ]
 inputs.mic=3D191 volume delta=3D8
 inputs.mic.mute=3Don  [ off on ]
 inputs.mic.preamp=3Doff  [ off on ]
 inputs.mic.source=3Dmic0  [ mic0 mic1 ]
 inputs.line=3D191,191 volume delta=3D8
 inputs.line.mute=3Doff  [ off on ]
 inputs.cd=3D191,191 volume delta=3D8
 inputs.cd.mute=3Doff  [ off on ]
 inputs.video=3D191,191 volume delta=3D8
 inputs.video.mute=3Doff  [ off on ]
 inputs.aux=3D191,191 volume delta=3D8
 inputs.aux.mute=3Doff  [ off on ]
 inputs.dac=3D191,191 volume delta=3D8
 inputs.dac.mute=3Doff  [ off on ]
 record.source=3Dmic  [ mic cd video aux line mixerout mixeroutmono phone =
 ]
 record.volume=3D0,0 volume delta=3D16
 record.volume.mute=3Doff  [ off on ]
 outputs.spatial=3Doff  [ off on ]
 outputs.spatial.center=3D0 volume delta=3D16
 outputs.spatial.depth=3D0 volume delta=3D16
 spdif.enable=3Doff  [ off on ]

 diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c
 index 6a700e20f31c..8376655a70ec 100644
 --- a/sys/dev/pci/emuxki.c
 +++ b/sys/dev/pci/emuxki.c
 @@ -139,7 +139,8 @@ struct emuxki_softc {
                 EMUXKI_SBLIVE =3D 0x00,
                 EMUXKI_AUDIGY =3D 0x01,
                 EMUXKI_AUDIGY2 =3D 0x02,
 -               EMUXKI_LIVE_5_1 =3D 0x04,
 +               EMUXKI_AUDIGY2_VALUE =3D 0x04,
 +               EMUXKI_LIVE_5_1 =3D 0x08,
                 EMUXKI_APS =3D 0x08
         } sc_type;
         audio_device_t          sc_audv;        /* for GETDEV */
 @@ -479,6 +480,7 @@ emuxki_match(device_t parent, cfdata_t match, void =
 *aux)
         case PCI_PRODUCT_CREATIVELABS_SBLIVE:
         case PCI_PRODUCT_CREATIVELABS_SBLIVE2:
         case PCI_PRODUCT_CREATIVELABS_AUDIGY:
 +       case PCI_PRODUCT_CREATIVELABS_SBAUDIGY4:
                 return 1;
         default:
                 return 0;
 @@ -538,7 +540,13 @@ emuxki_attach(device_t parent, device_t self, void =
 *aux)
         aprint_normal_dev(self, "interrupting at %s\n", intrstr);

         /* XXX it's unknown whether APS is made from Audigy as well */
 -       if (PCI_PRODUCT(pa->pa_id) =3D=3D =
 PCI_PRODUCT_CREATIVELABS_AUDIGY) {
 +       if (PCI_PRODUCT(pa->pa_id) =3D=3D =
 PCI_PRODUCT_CREATIVELABS_SBAUDIGY4) {
 +               sc->sc_type =3D EMUXKI_AUDIGY;
 +               sc->sc_type |=3D EMUXKI_AUDIGY2;
 +               sc->sc_type |=3D EMUXKI_AUDIGY2_VALUE;
 +               strlcpy(sc->sc_audv.name, "Audigy2 (value)",
 +                   sizeof(sc->sc_audv.name));
 +       } else if (PCI_PRODUCT(pa->pa_id) =3D=3D =
 PCI_PRODUCT_CREATIVELABS_AUDIGY) {
                 sc->sc_type =3D EMUXKI_AUDIGY;
                 if (PCI_REVISION(pa->pa_class) =3D=3D 0x04) {
                         sc->sc_type |=3D EMUXKI_AUDIGY2;
 @@ -707,7 +715,27 @@ emuxki_init(struct emuxki_softc *sc)
         emuxki_write(sc, 0, EMU_SPCS1, spcs);
         emuxki_write(sc, 0, EMU_SPCS2, spcs);

 -       if (sc->sc_type & EMUXKI_AUDIGY2) {
 +       if (sc->sc_type & EMUXKI_AUDIGY2_VALUE) {
 +               /* Setup SRCMulti_I2S SamplingRate */
 +               emuxki_write(sc, 0, EMU_A2_SPDIF_SAMPLERATE,
 +                   emuxki_read(sc, 0, EMU_A2_SPDIF_SAMPLERATE) & =
 0xfffff1ff);
 +
 +               /* Setup SRCSel (Enable SPDIF, I2S SRCMulti) */
 +               emuxki_writeptr(sc, EMU_A2_PTR, EMU_A2_DATA, =
 EMU_A2_SRCSEL,
 +                   EMU_A2_SRCSEL_ENABLE_SPDIF | =
 EMU_A2_SRCSEL_ENABLE_SRCMULTI);
 +
 +               /* Setup SRCMulti Input Audio Enable */
 +               emuxki_writeptr(sc, EMU_A2_PTR, EMU_A2_DATA,
 +                   0x7b0000, 0xff000000);
 +
 +               /* Setup SPDIF Out Audio Enable
 +                * The Audigy 2 Value has a separate SPDIF out,
 +                * so no need for a mixer switch */
 +               emuxki_writeptr(sc, EMU_A2_PTR, EMU_A2_DATA,
 +                   0x7a0000, 0xff000000);
 +               emuxki_writeio_4(sc, EMU_A_IOCFG,
 +                   emuxki_readio_4(sc, EMU_A_IOCFG) & ~0x8); /* clear =
 bit 3 */
 +       } else if (sc->sc_type & EMUXKI_AUDIGY2) {
                 emuxki_write(sc, 0, EMU_A2_SPDIF_SAMPLERATE,
                     EMU_A2_SPDIF_UNKNOWN);

 @@ -739,10 +767,12 @@ emuxki_init(struct emuxki_softc *sc)
             EMU_INTE_VOLDECRENABLE |
             EMU_INTE_MUTEENABLE);

 -       if (sc->sc_type & EMUXKI_AUDIGY2) {
 +       if (sc->sc_type & EMUXKI_AUDIGY2_VALUE) {
 +               emuxki_writeio_4(sc, EMU_A_IOCFG,
 +                   0x0060 | emuxki_readio_4(sc, EMU_A_IOCFG));
 +       } else if (sc->sc_type & EMUXKI_AUDIGY2) {
                 emuxki_writeio_4(sc, EMU_A_IOCFG,
 -                   emuxki_readio_4(sc, EMU_A_IOCFG) |
 -                       EMU_A_IOCFG_GPOUT0);
 +                   EMU_A_IOCFG_GPOUT0 | emuxki_readio_4(sc, =
 EMU_A_IOCFG));
         }

         /* enable AUDIO bit */

 --=20
 khorben=

State-Changed-From-To: open->closed
State-Changed-By: khorben@NetBSD.org
State-Changed-When: Tue, 30 Aug 2022 17:08:16 +0000
State-Changed-Why:
Patch committed in -current.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.