Deleted Added
full compact
uaudio.c (232039) uaudio.c (233774)
1/* $NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $ */
1/* $NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $ */
2/* $FreeBSD: head/sys/dev/sound/usb/uaudio.c 232039 2012-02-23 07:56:19Z hselasky $ */
2/* $FreeBSD: head/sys/dev/sound/usb/uaudio.c 233774 2012-04-02 10:50:42Z hselasky $ */
3
4/*-
5 * Copyright (c) 1999 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology.

--- 16 unchanged lines hidden (view full) ---

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
3
4/*-
5 * Copyright (c) 1999 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology.

--- 16 unchanged lines hidden (view full) ---

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/sound/usb/uaudio.c 232039 2012-02-23 07:56:19Z hselasky $");
35__FBSDID("$FreeBSD: head/sys/dev/sound/usb/uaudio.c 233774 2012-04-02 10:50:42Z hselasky $");
36
37/*
38 * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf
39 * http://www.usb.org/developers/devclass_docs/frmts10.pdf
40 * http://www.usb.org/developers/devclass_docs/termt10.pdf
41 */
42
43/*

--- 1223 unchanged lines hidden (view full) ---

1267 }
1268}
1269
1270static void
1271uaudio_chan_record_callback(struct usb_xfer *xfer, usb_error_t error)
1272{
1273 struct uaudio_chan *ch = usbd_xfer_softc(xfer);
1274 struct usb_page_cache *pc;
36
37/*
38 * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf
39 * http://www.usb.org/developers/devclass_docs/frmts10.pdf
40 * http://www.usb.org/developers/devclass_docs/termt10.pdf
41 */
42
43/*

--- 1223 unchanged lines hidden (view full) ---

1267 }
1268}
1269
1270static void
1271uaudio_chan_record_callback(struct usb_xfer *xfer, usb_error_t error)
1272{
1273 struct uaudio_chan *ch = usbd_xfer_softc(xfer);
1274 struct usb_page_cache *pc;
1275 uint32_t n;
1276 uint32_t m;
1277 uint32_t blockcount;
1278 uint32_t offset0;
1279 uint32_t offset1;
1280 uint32_t mfl;
1275 uint32_t offset0;
1276 uint32_t offset1;
1277 uint32_t mfl;
1278 int m;
1279 int n;
1281 int len;
1282 int actlen;
1283 int nframes;
1280 int len;
1281 int actlen;
1282 int nframes;
1283 int blockcount;
1284
1285 usbd_xfer_status(xfer, &actlen, NULL, NULL, &nframes);
1286 mfl = usbd_xfer_max_framelen(xfer);
1287
1288 if (ch->end == ch->start) {
1289 DPRINTF("no buffer!\n");
1290 return;
1291 }

--- 10 unchanged lines hidden (view full) ---

1302
1303 offset1 = offset0;
1304 len = usbd_xfer_frame_len(xfer, n);
1305
1306 while (len > 0) {
1307
1308 m = (ch->end - ch->cur);
1309
1284
1285 usbd_xfer_status(xfer, &actlen, NULL, NULL, &nframes);
1286 mfl = usbd_xfer_max_framelen(xfer);
1287
1288 if (ch->end == ch->start) {
1289 DPRINTF("no buffer!\n");
1290 return;
1291 }

--- 10 unchanged lines hidden (view full) ---

1302
1303 offset1 = offset0;
1304 len = usbd_xfer_frame_len(xfer, n);
1305
1306 while (len > 0) {
1307
1308 m = (ch->end - ch->cur);
1309
1310 if (m > len) {
1310 if (m > len)
1311 m = len;
1311 m = len;
1312 }
1312
1313 usbd_copy_out(pc, offset1, ch->cur, m);
1314
1315 len -= m;
1316 offset1 += m;
1317 ch->cur += m;
1318
1319 if (ch->cur >= ch->end) {
1320 ch->cur = ch->start;

--- 558 unchanged lines hidden (view full) ---

1879
1880 mix.class = 0; /* not used */
1881
1882 uaudio_mixer_add_ctl(sc, &mix);
1883}
1884
1885static uint32_t
1886uaudio_mixer_feature_get_bmaControls(const struct usb_audio_feature_unit *d,
1313 usbd_copy_out(pc, offset1, ch->cur, m);
1314
1315 len -= m;
1316 offset1 += m;
1317 ch->cur += m;
1318
1319 if (ch->cur >= ch->end) {
1320 ch->cur = ch->start;

--- 558 unchanged lines hidden (view full) ---

1879
1880 mix.class = 0; /* not used */
1881
1882 uaudio_mixer_add_ctl(sc, &mix);
1883}
1884
1885static uint32_t
1886uaudio_mixer_feature_get_bmaControls(const struct usb_audio_feature_unit *d,
1887 uint8_t index)
1887 uint8_t i)
1888{
1889 uint32_t temp = 0;
1888{
1889 uint32_t temp = 0;
1890 uint32_t offset = (index * d->bControlSize);
1890 uint32_t offset = (i * d->bControlSize);
1891
1892 if (d->bControlSize > 0) {
1893 temp |= d->bmaControls[offset];
1894 if (d->bControlSize > 1) {
1895 temp |= d->bmaControls[offset + 1] << 8;
1896 if (d->bControlSize > 2) {
1897 temp |= d->bmaControls[offset + 2] << 16;
1898 if (d->bControlSize > 3) {

--- 732 unchanged lines hidden (view full) ---

2631
2632 DPRINTF("terminal_type=%s (0x%04x) -> %d\n",
2633 uaudio_mixer_get_terminal_name(terminal_type),
2634 terminal_type, uat->feature);
2635
2636 return (uat->feature);
2637}
2638
1891
1892 if (d->bControlSize > 0) {
1893 temp |= d->bmaControls[offset];
1894 if (d->bControlSize > 1) {
1895 temp |= d->bmaControls[offset + 1] << 8;
1896 if (d->bControlSize > 2) {
1897 temp |= d->bmaControls[offset + 2] << 16;
1898 if (d->bControlSize > 3) {

--- 732 unchanged lines hidden (view full) ---

2631
2632 DPRINTF("terminal_type=%s (0x%04x) -> %d\n",
2633 uaudio_mixer_get_terminal_name(terminal_type),
2634 terminal_type, uat->feature);
2635
2636 return (uat->feature);
2637}
2638
2639const static struct uaudio_terminal_node *
2640uaudio_mixer_get_input(const struct uaudio_terminal_node *iot, uint8_t index)
2639static const struct uaudio_terminal_node *
2640uaudio_mixer_get_input(const struct uaudio_terminal_node *iot, uint8_t i)
2641{
2642 struct uaudio_terminal_node *root = iot->root;
2643 uint8_t n;
2644
2645 n = iot->usr.id_max;
2646 do {
2647 if (iot->usr.bit_input[n / 8] & (1 << (n % 8))) {
2641{
2642 struct uaudio_terminal_node *root = iot->root;
2643 uint8_t n;
2644
2645 n = iot->usr.id_max;
2646 do {
2647 if (iot->usr.bit_input[n / 8] & (1 << (n % 8))) {
2648 if (!index--) {
2648 if (!i--)
2649 return (root + n);
2649 return (root + n);
2650 }
2651 }
2652 } while (n--);
2653
2654 return (NULL);
2655}
2656
2650 }
2651 } while (n--);
2652
2653 return (NULL);
2654}
2655
2657const static struct uaudio_terminal_node *
2658uaudio_mixer_get_output(const struct uaudio_terminal_node *iot, uint8_t index)
2656static const struct uaudio_terminal_node *
2657uaudio_mixer_get_output(const struct uaudio_terminal_node *iot, uint8_t i)
2659{
2660 struct uaudio_terminal_node *root = iot->root;
2661 uint8_t n;
2662
2663 n = iot->usr.id_max;
2664 do {
2665 if (iot->usr.bit_output[n / 8] & (1 << (n % 8))) {
2658{
2659 struct uaudio_terminal_node *root = iot->root;
2660 uint8_t n;
2661
2662 n = iot->usr.id_max;
2663 do {
2664 if (iot->usr.bit_output[n / 8] & (1 << (n % 8))) {
2666 if (!index--) {
2665 if (!i--)
2667 return (root + n);
2666 return (root + n);
2668 }
2669 }
2670 } while (n--);
2671
2672 return (NULL);
2673}
2674
2675static void
2676uaudio_mixer_find_inputs_sub(struct uaudio_terminal_node *root,

--- 1221 unchanged lines hidden ---
2667 }
2668 } while (n--);
2669
2670 return (NULL);
2671}
2672
2673static void
2674uaudio_mixer_find_inputs_sub(struct uaudio_terminal_node *root,

--- 1221 unchanged lines hidden ---