From owner-svn-src-head@FreeBSD.ORG Wed May 27 19:45:04 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B72A51065AF6; Wed, 27 May 2009 19:45:04 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A5A448FC20; Wed, 27 May 2009 19:45:04 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4RJj4WC009912; Wed, 27 May 2009 19:45:04 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4RJj4Fo009911; Wed, 27 May 2009 19:45:04 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200905271945.n4RJj4Fo009911@svn.freebsd.org> From: Andrew Thompson Date: Wed, 27 May 2009 19:45:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192929 - head/sys/dev/sound/usb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2009 19:45:05 -0000 Author: thompsa Date: Wed May 27 19:45:04 2009 New Revision: 192929 URL: http://svn.freebsd.org/changeset/base/192929 Log: Provide a workaround for USB devices that do not support mono or stereo operation by overriding the channel count. Submitted by: Hans Petter Selasky Reported by: MIHIRA Sanpei Yoshiro Modified: head/sys/dev/sound/usb/uaudio.c Modified: head/sys/dev/sound/usb/uaudio.c ============================================================================== --- head/sys/dev/sound/usb/uaudio.c Wed May 27 19:41:29 2009 (r192928) +++ head/sys/dev/sound/usb/uaudio.c Wed May 27 19:45:04 2009 (r192929) @@ -97,6 +97,7 @@ SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, def #define MAKE_WORD(h,l) (((h) << 8) | (l)) #define BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1) +#define UAUDIO_MAX_CHAN(x) (((x) < 2) ? (x) : 2) /* XXX fixme later */ struct uaudio_mixer_node { int32_t minval; @@ -936,7 +937,7 @@ uaudio_chan_fill_info_sub(struct uaudio_ #endif wFormat = UGETW(asid->wFormatTag); - bChannels = asf1d->bNrChannels; + bChannels = UAUDIO_MAX_CHAN(asf1d->bNrChannels); bBitResolution = asf1d->bBitResolution; if (asf1d->bSamFreqType == 0) { @@ -1020,7 +1021,8 @@ uaudio_chan_fill_info_sub(struct uaudio_ chan->usb2_cfg = uaudio_cfg_play; - sample_size = ((chan->p_asf1d->bNrChannels * + sample_size = (( + UAUDIO_MAX_CHAN(chan->p_asf1d->bNrChannels) * chan->p_asf1d->bBitResolution) / 8); /* @@ -1334,7 +1336,7 @@ uaudio_chan_init(struct uaudio_softc *sc ch->pcm_cap.fmtlist[0] = ch->p_fmt->freebsd_fmt; - if (ch->p_asf1d->bNrChannels == 2) { + if (ch->p_asf1d->bNrChannels >= 2) { ch->pcm_cap.fmtlist[0] |= AFMT_STEREO; } ch->pcm_cap.fmtlist[1] = 0;