summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2008-11-04 02:31:03 +0000
committeralfred <alfred@FreeBSD.org>2008-11-04 02:31:03 +0000
commiteffcf5d59c063e4380b3ca7098356d4bfa8b6633 (patch)
treef7c8289a089d1c56007a55463a568b1ccd445e5c /sys/dev/sound
parentc472e6126ea8321c622e67625e038abef748b7d3 (diff)
downloadFreeBSD-src-effcf5d59c063e4380b3ca7098356d4bfa8b6633.zip
FreeBSD-src-effcf5d59c063e4380b3ca7098356d4bfa8b6633.tar.gz
Bring in USB4BSD, Hans Petter Selasky rework of the USB stack
that includes significant features and SMP safety. This commit includes a more or less complete rewrite of the *BSD USB stack, including Host Controller and Device Controller drivers and updating all existing USB drivers to use the new USB API: 1) A brief feature list: - A new and mutex enabled USB API. - Many USB drivers are now running Giant free. - Linux USB kernel compatibility layer. - New UGEN backend and libusb library, finally solves the "driver unloading" problem. The new BSD licensed libusb20 library is fully compatible with libusb-0.1.12 from sourceforge. - New "usbconfig" utility, for easy configuration of USB. - Full support for Split transactions, which means you can use your full speed USB audio device on a high speed USB HUB. - Full support for HS ISOC transactions, which makes writing drivers for various HS webcams possible, for example. - Full support for USB on embedded platforms, mostly cache flushing and buffer invalidating stuff. - Safer parsing of USB descriptors. - Autodetect of annoying USB install disks. - Support for USB device side mode, also called USB gadget mode, using the same API like the USB host side. In other words the new USB stack is symmetric with regard to host and device side. - Support for USB transfers like I/O vectors, means more throughput and less interrupts. - ... see the FreeBSD quarterly status reports under "USB project" 2) To enable the driver in the default kernel build: 2.a) Remove all existing USB device options from your kernel config file. 2.b) Add the following USB device options to your kernel configuration file: # USB core support device usb2_core # USB controller support device usb2_controller device usb2_controller_ehci device usb2_controller_ohci device usb2_controller_uhci # USB mass storage support device usb2_storage device usb2_storage_mass # USB ethernet support, requires miibus device usb2_ethernet device usb2_ethernet_aue device usb2_ethernet_axe device usb2_ethernet_cdce device usb2_ethernet_cue device usb2_ethernet_kue device usb2_ethernet_rue device usb2_ethernet_dav # USB wireless LAN support device usb2_wlan device usb2_wlan_rum device usb2_wlan_ral device usb2_wlan_zyd # USB serial device support device usb2_serial device usb2_serial_ark device usb2_serial_bsa device usb2_serial_bser device usb2_serial_chcom device usb2_serial_cycom device usb2_serial_foma device usb2_serial_ftdi device usb2_serial_gensa device usb2_serial_ipaq device usb2_serial_lpt device usb2_serial_mct device usb2_serial_modem device usb2_serial_moscom device usb2_serial_plcom device usb2_serial_visor device usb2_serial_vscom # USB bluetooth support device usb2_bluetooth device usb2_bluetooth_ng # USB input device support device usb2_input device usb2_input_hid device usb2_input_kbd device usb2_input_ms # USB sound and MIDI device support device usb2_sound 2) To enable the driver at runtime: 2.a) Unload all existing USB modules. If USB is compiled into the kernel then you might have to build a new kernel. 2.b) Load the "usb2_xxx.ko" modules under /boot/kernel having the same base name like the kernel device option. Submitted by: Hans Petter Selasky hselasky at c2i dot net Reviewed by: imp, alfred
Diffstat (limited to 'sys/dev/sound')
-rw-r--r--sys/dev/sound/pcm/channel.c17
-rw-r--r--sys/dev/sound/pcm/channel.h2
-rw-r--r--sys/dev/sound/pcm/mixer.c25
-rw-r--r--sys/dev/sound/pcm/mixer.h1
4 files changed, 42 insertions, 3 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index ffc0ffe..464330a 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -570,13 +570,26 @@ chn_read(struct pcm_channel *c, struct uio *buf)
void
chn_intr(struct pcm_channel *c)
{
- CHN_LOCK(c);
+ uint8_t do_unlock;
+ if (CHN_LOCK_OWNED(c)) {
+ /*
+ * Allow sound drivers to call this function with
+ * "CHN_LOCK()" locked:
+ */
+ do_unlock = 0;
+ } else {
+ do_unlock = 1;
+ CHN_LOCK(c);
+ }
c->interrupts++;
if (c->direction == PCMDIR_PLAY)
chn_wrintr(c);
else
chn_rdintr(c);
- CHN_UNLOCK(c);
+ if (do_unlock) {
+ CHN_UNLOCK(c);
+ }
+ return;
}
u_int32_t
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
index 65175a3..8f9f8f6 100644
--- a/sys/dev/sound/pcm/channel.h
+++ b/sys/dev/sound/pcm/channel.h
@@ -258,11 +258,13 @@ int chn_getpeaks(struct pcm_channel *c, int *lpeak, int *rpeak);
#endif
#ifdef USING_MUTEX
+#define CHN_LOCK_OWNED(c) mtx_owned((struct mtx *)((c)->lock))
#define CHN_LOCK(c) mtx_lock((struct mtx *)((c)->lock))
#define CHN_UNLOCK(c) mtx_unlock((struct mtx *)((c)->lock))
#define CHN_TRYLOCK(c) mtx_trylock((struct mtx *)((c)->lock))
#define CHN_LOCKASSERT(c) mtx_assert((struct mtx *)((c)->lock), MA_OWNED)
#else
+#define CHN_LOCK_OWNED(c) 0
#define CHN_LOCK(c)
#define CHN_UNLOCK(c)
#define CHN_TRYLOCK(c)
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
index c3ca4f0..dd3b7bb 100644
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -589,7 +589,7 @@ mixer_delete(struct snd_mixer *m)
KASSERT(m->type == MIXER_TYPE_SECONDARY,
("%s(): illegal mixer type=%d", __func__, m->type));
- snd_mtxlock(m->lock);
+ /* mixer uninit can sleep --hps */
MIXER_UNINIT(m);
@@ -704,14 +704,24 @@ mixer_uninit(device_t dev)
return EBUSY;
}
+ /* destroy dev can sleep --hps */
+
+ snd_mtxunlock(m->lock);
+
pdev->si_drv1 = NULL;
destroy_dev(pdev);
+ snd_mtxlock(m->lock);
+
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
mixer_set(m, i, 0);
mixer_setrecsrc(m, SOUND_MASK_MIC);
+ snd_mtxunlock(m->lock);
+
+ /* mixer uninit can sleep --hps */
+
MIXER_UNINIT(m);
snd_mtxfree(m->lock);
@@ -1280,3 +1290,16 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi)
return (EINVAL);
}
+
+/*
+ * Allow the sound driver to use the mixer lock to protect its mixer
+ * data:
+ */
+struct mtx *
+mixer_get_lock(struct snd_mixer *m)
+{
+ if (m->lock == NULL) {
+ return (&Giant);
+ }
+ return (m->lock);
+}
diff --git a/sys/dev/sound/pcm/mixer.h b/sys/dev/sound/pcm/mixer.h
index bcded4b..d03338b 100644
--- a/sys/dev/sound/pcm/mixer.h
+++ b/sys/dev/sound/pcm/mixer.h
@@ -56,6 +56,7 @@ void mix_setrealdev(struct snd_mixer *m, u_int32_t dev, u_int32_t realdev);
u_int32_t mix_getparent(struct snd_mixer *m, u_int32_t dev);
u_int32_t mix_getchild(struct snd_mixer *m, u_int32_t dev);
void *mix_getdevinfo(struct snd_mixer *m);
+struct mtx *mixer_get_lock(struct snd_mixer *m);
extern int mixer_count;
OpenPOWER on IntegriCloud