Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Jan 2005 14:48:44 +0100 (CET)
From:      Barry Bouwsma <freebsd-misuser@remove-NOSPAM-to-reply.NOSPAM.dyndns.dk>
To:        freebsd-usb@freebsd.org
Subject:   Re: Hacking usb/uaudio code
Message-ID:  <200501011348.j01Dmi180455@Mail.NOSPAM.DynDNS.dK>
References:  <41B8C7A9.3080306@elischer.org> <20041224.182917.607958849.kazuhito@ph.noda.tus.ac.jp> <41CD00B1.9040502@elischer.org> <20041225.230115.422452498.kazuhito@ph.noda.tus.ac.jp> <41CE5C91.5060104@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> >>>kern/75274 for merging
> >>>kern/75276 for volumes
> >>>kern/75311 for recording
> >>>kern/75316 for selection of a recording sound source
> >>
> >>how much have you tested these patches?
> >>do they break other audio devices?
> >
> > I usually use those patches almost every day.
> > But I have tested those patches by `Sound Blaster Digital Music' only.
> > So those patches require many test, test, test, and test
> > by various USB audio devices.
> >
> > I'm afraid that those patches have problems with simple devices e.g.
> > USB microphone or with complicated devices
> > which have add-processing or extension units.

> I am led to believe that those cases were not well supported
> before your patches and that your patches probably do not break
> them more than they were already broken.


Hi,

Sorry for the delay in giving my feedback to this.  I just want to
say that I applied your patches to my usb audio source in 4.x, and
it works without greater problems than the original 4.x code.


I've done this as follows:

1)  Take the mid-december -current uaudio source files.

2)  Apply the following patches to make -current source compile
    with my 4.x  (no guarantees that I don't have patches elsewhere
    to make this work for me, so please try it out first)


--- /stand/FreeBSD4-src/source-hacks/sys/dev/sound/usb/uaudio_pcm.c-current	Thu Dec  9 22:35:41 2004
+++ /stand/FreeBSD4-src/source-hacks/sys/dev/sound/usb/uaudio_pcm.c-built-from-current	Thu Dec 30 23:06:53 2004
@@ -307,8 +307,10 @@
 				/*filter*/NULL, /*filterarg*/NULL,
 				/*maxsize*/bufsz, /*nsegments*/1,
 				/*maxsegz*/0x3fff, /*flags*/0,
+#if __FreeBSD_version >= 500000  /* XXXX HACK */
 				/*lockfunc*/busdma_lock_mutex,
 				/*lockarg*/&Giant,
+#endif
 				&ua->parent_dmat) != 0) {
 		device_printf(dev, "unable to create dma tag\n");
 		goto bad;
@@ -373,8 +375,15 @@
 	PCM_SOFTC_SIZE,
 };
 
+#if __FreeBSD_version < 500000 /* XXX HACK */
+static devclass_t pcm_devclass;
+#endif
 
 DRIVER_MODULE(ua_pcm, uaudio, ua_pcm_driver, pcm_devclass, 0, 0);
 MODULE_DEPEND(ua_pcm, uaudio, 1, 1, 1);
+#if __FreeBSD_version < 500000 /* XXX HACK  --  should be something else */
+MODULE_DEPEND(ua_pcm, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
+#else
 MODULE_DEPEND(ua_pcm, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
+#endif /* XXXX HACK */
 MODULE_VERSION(ua_pcm, 1);



--- /stand/FreeBSD4-src/source-hacks/sys/dev/sound/usb/uaudio.c-current	Thu Dec  9 22:35:36 2004
+++ /stand/FreeBSD4-src/source-hacks/sys/dev/sound/usb/uaudio.c-built-from-current	Thu Dec 30 23:01:40 2004
@@ -57,7 +57,9 @@
 #include <sys/reboot.h>		/* for bootverbose */
 #include <sys/select.h>
 #include <sys/proc.h>
+#if __FreeBSD_version >= 500000 /* XXX HACK */
 #include <sys/vnode.h>
+#endif
 #if defined(__NetBSD__) || defined(__OpenBSD__)
 #include <sys/device.h>
 #elif defined(__FreeBSD__)



3)  At this point, I built the kernel module to verify -current source
    would still work with 4.x, loaded it, and played with success.

4)  Then apply the four patches you submitted as PRs.


I don't recall any failures which had to be fixed by hand, apart from
the first unimportant part of the patch (the RCS IDs).


Then I've built a module (also I built modules at each step of applying
the four patches), and loaded that, and used it with my simple uaudio
soundcard (HID plus playback/record).

Playback is no problem at 48kHz; now if I try to playback at a different
rate, I get an error, when earlier the device played back with noted
distortion, but did play back.  This is to be expected from what you
wrote.

Recording seems to work with no source, giving me hum on the mic input
and the sound of connecting to the line input.  No panics or crashes.
All my recording or playback is done at the professional 48kHz sample
rate.


The mixer device now has something:

bash-2.05a$ mixer  -f /dev/mixer1 
Mixer speaker  is currently set to  75:75
Mixer line     is currently set to   0:0
Mixer mic      is currently set to   0:0

There is no default device to be set, but the `speaker' control
adjusts both line-out and speaker-out playback levels.
bash-2.05a$ mixer  -f /dev/mixer1  90
Setting the mixer vol to 90:90.
mixer: WRITE_MIXER: Device not configured
bash-2.05a$ mixer  -f /dev/mixer1  speaker  90
Setting the mixer speaker to 90:90.

Recording source input selection now works (yay), as does setting
levels for them.  (This sound hardware is somewhat noisy, as usual)


So far, no problems noted in playback.  With the code I had been
using, I would experience that after some time, starting a new
playback, that the device would go silent for no obvious reason --
usually after a few dozen times starting/stopping playback, although
it appeared that data was being sent to the device, from what little
I could see.  Unplugging and replugging the USB connector would be
enough to make the device play again.

Obviously, I need to try quite a bit more to see if this recurs,
and also check again whether NetBSD suffers the same, if it does.

This is the only USB audio device I have at the moment, but now it
is very tempting for me to break down and acquire more.

I also see that `mpg123' includes the option to set an output sample
rate, so I'm able to playback layer 3 audio files which have a different
sample rate without the need for any external assistance.  (mpg123
starts *fast* here as only a single sample rate is supported, and
it's not spending all its time going through a list of them as it
is with a different soundcard.)  Not every playback program I've
tried has gracefully handled the return code it gets when the output
rate doesn't match the device capabilities.



Thanks!
barry bouwsma



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