From 89245df9b8f5969800dcd0d4646d6b3f4e95fc8e Mon Sep 17 00:00:00 2001 From: jmcneill Date: Wed, 7 Sep 2011 00:16:40 +0000 Subject: [PATCH] hdafg_stream_connect: if connecting a non-PCM stream, make sure only converters that support non-PCM formats are configured to decode it --- sys/dev/pci/hdaudio/hdafg.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/hdaudio/hdafg.c b/sys/dev/pci/hdaudio/hdafg.c index 6198c251c15e..dca9a436fd4f 100644 --- a/sys/dev/pci/hdaudio/hdafg.c +++ b/sys/dev/pci/hdaudio/hdafg.c @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.4 2011/09/06 11:14:17 jmcneill Exp $ */ +/* $NetBSD: hdafg.c,v 1.5 2011/09/07 00:16:40 jmcneill Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.4 2011/09/06 11:14:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.5 2011/09/07 00:16:40 jmcneill Exp $"); #include #include @@ -3100,6 +3100,15 @@ hdafg_stream_connect(struct hdafg_softc *sc, int mode) if (as[i].as_activated == false) c = 0; + /* + * If a non-PCM stream is being connected, and the + * converter doesn't support non-PCM streams, then + * don't decode it + */ + if ((fmt & HDAUDIO_FMT_TYPE_NONPCM) && + !(w->w_p.stream_format & COP_STREAM_FORMAT_AC3)) + c = 0; + hdaudio_command(sc->sc_codec, w->w_nid, CORB_SET_CONVERTER_FORMAT, fmt); if (w->w_p.aw_cap & COP_AWCAP_DIGITAL) { @@ -3118,7 +3127,8 @@ hdafg_stream_connect(struct hdafg_softc *sc, int mode) } hdaudio_command(sc->sc_codec, w->w_nid, CORB_SET_CONVERTER_STREAM_CHANNEL, c); - chn += COP_AWCAP_CHANNEL_COUNT(w->w_p.aw_cap); + if (c != 0) + chn += COP_AWCAP_CHANNEL_COUNT(w->w_p.aw_cap); } for (j = 0; j < HDAUDIO_MAXPINS; j++) {