Project

General

Profile

Submit #2682 » uaudio.patch

shamaz, 06/08/2014 11:19 AM

View differences:

sys/bus/u4b/audio/Makefile
KMOD= uaudio
SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h \
mixer_if.h feeder_if.h channel_if.h uaudio.c
mixer_if.h feeder_if.h channel_if.h uaudio.c uaudio_pcm.c
.include <bsd.kmod.mk>
sys/bus/u4b/audio/uaudio.c
struct usb_interface_descriptor *id;
device_t child;
lockinit(&sc->sc_lock, "uaudio", 0, 0);
lockinit(&sc->sc_lock, "uaudio", 0, LK_CANRECURSE);
sc->sc_play_chan.priv_sc = sc;
sc->sc_rec_chan.priv_sc = sc;
......
break;
}
#endif
/*
* KLUDGE:
* Add support at least for 2 channels
*/
if (ch->p_asf1d->bNrChannels == 2) format |= AFMT_STEREO;
ch->pcm_cap.fmtlist[0] = format;
ch->pcm_cap.fmtlist[1] = 0;
......
/* start the transfer, if not already started */
lockmgr(&sc->sc_lock, LK_EXCLUSIVE);
usbd_transfer_start(sc->sc_mixer_xfer[0]);
lockmgr(&sc->sc_lock, LK_RELEASE);
}
static void
sys/bus/u4b/audio/uaudio_pcm.c
static int
ua_mixer_set(struct snd_mixer *m, unsigned type, unsigned left, unsigned right)
{
struct lock *lock = mixer_get_lock(m);
uint8_t do_unlock;
if (lockstatus(lock, curthread)) {
do_unlock = 0;
} else {
do_unlock = 1;
lockmgr(lock, LK_EXCLUSIVE);
}
uaudio_mixer_set(mix_getdevinfo(m), type, left, right);
if (do_unlock) {
lockmgr(lock, LK_RELEASE);
}
return (left | (right << 8));
}
static uint32_t
ua_mixer_setrecsrc(struct snd_mixer *m, uint32_t src)
{
struct lock *lock = mixer_get_lock(m);
int retval;
uint8_t do_unlock;
if (lockstatus(lock, curthread)) {
do_unlock = 0;
} else {
do_unlock = 1;
lockmgr(lock, LK_EXCLUSIVE);
}
retval = uaudio_mixer_setrecsrc(mix_getdevinfo(m), src);
if (do_unlock) {
lockmgr(lock, LK_RELEASE);
}
return (retval);
}
sys/dev/sound/pcm/channel.c
return r;
}
/*
* given a bufsz value, round it to a power of 2 in the min-max range
* XXX only works if min and max are powers of 2
*/
static int
round_bufsz(int bufsz, int min, int max)
static unsigned int
round_bufsz (unsigned int bufsz, unsigned int min, unsigned int max)
{
int tmp = min * 2;
KASSERT((min & (min-1)) == 0, ("min %d must be power of 2", min));
KASSERT((max & (max-1)) == 0, ("max %d must be power of 2", max));
while (tmp <= bufsz)
tmp <<= 1;
tmp >>= 1;
if (tmp > max)
tmp = max;
return tmp;
int pow=1, res;
if (bufsz < min) bufsz = min;
else if (bufsz > max) bufsz = max;
if (bufsz & (bufsz-1)) {
while (bufsz >> pow) pow++;
res = 1<<pow;
}
else res = bufsz;
if (res > max) return res>>1;
else return res;
}
/*
(1-1/3)