Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Dec 2004 23:22:18 +0900 (JST)
From:      Kazuhito HONDA <kazuhito@ph.noda.tus.ac.jp>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        kazuhito@ph.noda.tus.ac.jp
Subject:   kern/75311: Enable to record with USB audio (uaudio)
Message-ID:  <20041220.232218.730550289.kazuhito@ph.noda.tus.ac.jp>
Resent-Message-ID: <200412201430.iBKEUadF081485@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         75311
>Category:       kern
>Synopsis:       Enable to record with USB audio (uaudio)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 20 14:30:35 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Kazuhito HONDA
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD kaoru 6.0-CURRENT FreeBSD 6.0-CURRENT #194: Mon Dec 20 23:01:00 JST 2004 root@kaoru:/usr/obj/src/sys/i386/compile/KAORU.6.0B.0 i386

USB device: Sound Blaster Digital Music (SBDM, Creative Labs.)

>Description:
USB devices couldn't record on FreeBSD, at least SBDM.

>How-To-Repeat:

>Fix:
1. At first, apply the patch in `kern/75274'
2. apply the patch below, `F_r.diff'

But I haven't tested this codes except with SBDM.

--- F_r.diff begins here ---
--- src/sys/dev/sound/usb/uaudio.c	Mon Dec 20 22:56:41 2004
+++ src/sys/dev/sound/usb/uaudio-91-r.c	Mon Dec 20 22:49:44 2004
@@ -1,5 +1,5 @@
 /*	$NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $	*/
-/*	$FreeBSD: src/sys/dev/sound/usb/uaudio-91.c,v $: */
+/*	$FreeBSD: src/sys/dev/sound/usb/uaudio-91-r.c,v $: */
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -3524,6 +3524,9 @@ uaudio_init_params(struct uaudio_softc *
 	int i, j, enc;
 	int samples_per_frame, sample_size;
 
+	if ((sc->sc_playchan.pipe != NULL) || (sc->sc_recchan.pipe != NULL))
+		return (-1);
+
 	switch(ch->format & 0x0000FFFF) {
 	case AFMT_U8:
 		enc = AUDIO_ENCODING_ULINEAR_LE;
@@ -3570,7 +3573,6 @@ uaudio_init_params(struct uaudio_softc *
 	}
 
 /*	for (mode =  ......	 */
-/*But this function is used for output only */
 		for (i = 0; i < sc->sc_nalts; i++) {
 			const struct usb_audio_streaming_type1_descriptor *a1d =
 				sc->sc_alts[i].asf1desc;
@@ -3612,7 +3614,10 @@ uaudio_init_params(struct uaudio_softc *
 			}
 		}
 		/* return (EINVAL); */
-		printf("uaudio: This device can't play in rate=%d.\n", ch->sample_rate);
+		if (mode == AUMODE_PLAY) 
+			printf("uaudio: This device can't play in rate=%d.\n", ch->sample_rate);
+		else
+			printf("uaudio: This device can't record in rate=%d.\n", ch->sample_rate);
 		return (-1);
 
 	found:
@@ -3840,6 +3845,65 @@ uaudio_halt_out_dma(device_t dev)
 		uaudio_chan_free_buffers(sc, &sc->sc_playchan);
 	}
         return (0);
+}
+
+int
+uaudio_halt_in_dma(device_t dev)
+{
+	struct uaudio_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	if (sc->sc_dying)
+		return (EIO);
+
+	DPRINTF(("uaudio_halt_in_dma: enter\n"));
+	if (sc->sc_recchan.pipe != NULL) {
+		uaudio_chan_close(sc, &sc->sc_recchan);
+		sc->sc_recchan.pipe = NULL;
+		uaudio_chan_free_buffers(sc, &sc->sc_recchan);
+/*		sc->sc_recchan.intr = NULL; */
+	}
+	return (0);
+}
+
+int
+uaudio_trigger_input(device_t dev)
+{
+	struct uaudio_softc *sc;
+	struct chan *ch;
+	usbd_status err;
+	int i, s;
+
+	sc = device_get_softc(dev);
+	ch = &sc->sc_recchan;
+
+	if (sc->sc_dying)
+		return (EIO);
+
+/*	uaudio_chan_set_param(ch, start, end, blksize) */
+	if (uaudio_init_params(sc, ch, AUMODE_RECORD))
+		return (EIO);
+
+	err = uaudio_chan_alloc_buffers(sc, ch);
+	if (err)
+		return (EIO);
+
+	err = uaudio_chan_open(sc, ch);
+	if (err) {
+		uaudio_chan_free_buffers(sc, ch);
+		return (EIO);
+	}
+
+/*	ch->intr = intr;
+	ch->arg = arg; */
+
+	s = splusb();
+	for (i = 0; i < UAUDIO_NCHANBUFS-1; i++) /* XXX -1 shouldn't be needed */
+		uaudio_chan_rtransfer(ch);
+	splx(s);
+
+	return (0);
 }
 
 int
--- src/sys/dev/sound/usb/uaudio.h	Mon Dec 20 22:56:41 2004
+++ src/sys/dev/sound/usb/uaudio-91-r.h	Mon Dec 20 22:49:55 2004
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/sound/usb/uaudio-91.h,v $ */
+/* $FreeBSD: src/sys/dev/sound/usb/uaudio-91-r.h,v $ */
 
 /*
  * Copyright (c) 2000-2002 Hiroyuki Aizu <aizu@navi.org>
@@ -25,7 +25,9 @@
  * SUCH DAMAGE.
  */
 
+#if 0
 #define NO_RECORDING /* XXX: some routines missing from uaudio.c */
+#endif
 
 /* Defined in uaudio.c, used in uaudio_pcm,c */
 
--- src/sys/dev/sound/usb/uaudio_pcm.c	Mon Dec 20 22:56:41 2004
+++ src/sys/dev/sound/usb/uaudio_pcm-91-r.c	Mon Dec 20 22:50:07 2004
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/sound/usb/uaudio_pcm-91.c,v $ */
+/* $FreeBSD: src/sys/dev/sound/usb/uaudio_pcm-91-r.c,v $ */
 
 /*
  * Copyright (c) 2000-2002 Hiroyuki Aizu <aizu@navi.org>
@@ -73,6 +73,7 @@ ua_chan_init(kobj_t obj, void *devinfo, 
 	ch->parent = sc;
 	ch->channel = c;
 	ch->buffer = b;
+	ch->dir = dir;
 
 	pa_dev = device_get_parent(sc->sc_dev);
      	/* Create ua_playfmt[] & ua_recfmt[] */
@@ -320,7 +321,11 @@ ua_attach(device_t dev)
 
 	snprintf(status, SND_STATUSLEN, "at addr ?");
 
+#ifndef NO_RECORDING
+	if (pcm_register(dev, ua, 1, 1)) {
+#else
 	if (pcm_register(dev, ua, 1, 0)) {
+#endif
 		return(ENXIO);
 	}
 
--- F_r.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041220.232218.730550289.kazuhito>