From owner-p4-projects@FreeBSD.ORG Wed Nov 26 16:05:47 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B69E71065676; Wed, 26 Nov 2008 16:05:47 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A3EC1065673 for ; Wed, 26 Nov 2008 16:05:47 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 63CEB8FC16 for ; Wed, 26 Nov 2008 16:05:47 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mAQG5l3t030360 for ; Wed, 26 Nov 2008 16:05:47 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mAQG5lbb030358 for perforce@freebsd.org; Wed, 26 Nov 2008 16:05:47 GMT (envelope-from hselasky@FreeBSD.org) Date: Wed, 26 Nov 2008 16:05:47 GMT Message-Id: <200811261605.mAQG5lbb030358@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 153612 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Nov 2008 16:05:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=153612 Change 153612 by hselasky@hselasky_laptop001 on 2008/11/26 16:05:27 Make default sample rate, bits and channels tunable. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/sound/uaudio2.c#20 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/sound/uaudio2.c#20 (text+ko) ==== @@ -80,18 +80,24 @@ #include #include "feeder_if.h" +static int uaudio_default_rate = 96000; +static int uaudio_default_bits = 32; +static int uaudio_default_channels = 2; + #if USB_DEBUG static int uaudio_debug = 0; SYSCTL_NODE(_hw_usb2, OID_AUTO, uaudio, CTLFLAG_RW, 0, "USB uaudio"); SYSCTL_INT(_hw_usb2_uaudio, OID_AUTO, debug, CTLFLAG_RW, &uaudio_debug, 0, "uaudio debug level"); +SYSCTL_INT(_hw_usb2_uaudio, OID_AUTO, default_rate, CTLFLAG_RW, + &uaudio_default_rate, 0, "uaudio default sample rate"); +SYSCTL_INT(_hw_usb2_uaudio, OID_AUTO, default_bits, CTLFLAG_RW, + &uaudio_default_bits, 0, "uaudio default sample bits"); +SYSCTL_INT(_hw_usb2_uaudio, OID_AUTO, default_channels, CTLFLAG_RW, + &uaudio_default_channels, 0, "uaudio default sample channels"); #endif -static uint32_t uaudio_default_rate = 96000; -static uint8_t uaudio_default_bits = 32; -static uint8_t uaudio_default_channels = 2; - #define UAUDIO_MINFRAMES 16 /* must be factor of 8 due HS-USB */ #define UAUDIO_NCHANBUFS 2 /* number of outstanding request */ #define UAUDIO_RECURSE_LIMIT 24 /* rounds */ @@ -1043,15 +1049,26 @@ { uint32_t rate = uaudio_default_rate; uint32_t z; - uint16_t fps = (usb2_get_speed(udev) == USB_SPEED_HIGH) ? 8000 : 1000; + uint16_t fps = usb2_get_isoc_fps(udev); uint8_t bits = uaudio_default_bits; uint8_t y; uint8_t channels = uaudio_default_channels; uint8_t x; bits -= (bits % 8); + if ((bits == 0) || (bits > 32)) { + /* set a valid value */ + bits = 32; + } rate -= (rate % fps); - + if ((rate == 0) || (rate > 192000)) { + /* set a valid value */ + rate = 192000 - (192000 % fps); + } + if ((channels == 0) || (channels > 2)) { + /* set a valid value */ + channels = 2; + } if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND)) { sc->sc_sndstat_valid = 1; }