FreeBSD Bugzilla – Attachment 221286 Details for
Bug 252434
for USB audio headset, need do set interface dynamiclly for power save and correct status of headsets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
patch to add set interface dynamicly.
uaudio_set_interface.diff (text/plain), 7.92 KB, created by
Horse Ma
on 2021-01-05 10:46:28 UTC
(
hide
)
Description:
patch to add set interface dynamicly.
Filename:
MIME Type:
Creator:
Horse Ma
Created:
2021-01-05 10:46:28 UTC
Size:
7.92 KB
patch
obsolete
>commit a14cc8e6ec3bfaf201183aecdb51f14a979f1bfd >Author: Shichun_Ma <Shichun_Ma@dell.com> >Date: Tue Jan 5 10:23:56 2021 +0000 > > add interface set 0/alter when start/stop play/record audio > >diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c >index 38c578ba8282..d946ac1f8e1b 100644 >--- a/sys/dev/sound/pcm/channel.c >+++ b/sys/dev/sound/pcm/channel.c >@@ -670,6 +670,15 @@ chn_intr(struct pcm_channel *c) > CHN_UNLOCK(c); > } > >+u_int32_t >+chn_prepare(struct pcm_channel *c, int enable) >+{ >+ int ret = 0; >+ >+ ret = CHANNEL_PREPARE(c->methods, c->devinfo, enable); >+ return ret; >+} >+ > u_int32_t > chn_start(struct pcm_channel *c, int force) > { >diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h >index 34d62f4e15c2..a7afc294a10d 100644 >--- a/sys/dev/sound/pcm/channel.h >+++ b/sys/dev/sound/pcm/channel.h >@@ -258,6 +258,7 @@ struct pcm_channel { > int chn_reinit(struct pcm_channel *c); > int chn_write(struct pcm_channel *c, struct uio *buf); > int chn_read(struct pcm_channel *c, struct uio *buf); >+u_int32_t chn_prepare(struct pcm_channel *c, int enable); > u_int32_t chn_start(struct pcm_channel *c, int force); > int chn_sync(struct pcm_channel *c, int threshold); > int chn_flush(struct pcm_channel *c); >@@ -367,6 +368,7 @@ extern int report_soft_matrix; > #define CHN_F_VCHAN_ADAPTIVE 0x00008000 /* adaptive format/rate selection */ > #define CHN_F_VCHAN_DYNAMIC (CHN_F_VCHAN_PASSTHROUGH | CHN_F_VCHAN_ADAPTIVE) > >+#define CHN_F_READY 0x01000000 > #define CHN_F_VIRTUAL 0x10000000 /* not backed by hardware */ > #define CHN_F_BITPERFECT 0x20000000 /* un-cooked, Heh.. */ > #define CHN_F_PASSTHROUGH 0x40000000 /* passthrough re-config */ >diff --git a/sys/dev/sound/pcm/channel_if.m b/sys/dev/sound/pcm/channel_if.m >index c5c4fffc6730..2a264b5e473b 100644 >--- a/sys/dev/sound/pcm/channel_if.m >+++ b/sys/dev/sound/pcm/channel_if.m >@@ -153,6 +153,12 @@ METHOD int trigger { > int go; > }; > >+METHOD int prepare { >+ kobj_t obj; >+ void *data; >+ int go; >+}; >+ > METHOD u_int32_t getptr { > kobj_t obj; > void *data; >diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c >index 0593a585b0fd..cc0daddce2a4 100644 >--- a/sys/dev/sound/pcm/dsp.c >+++ b/sys/dev/sound/pcm/dsp.c >@@ -1085,7 +1085,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, > ret = 0; > xcmd = 0; > chn = NULL; >- > if (IOCGROUP(cmd) == 'M') { > if (cmd == OSS_GETVERSION) { > *arg_i = SOUND_VERSION; >@@ -1734,28 +1733,34 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, > > case SNDCTL_DSP_SETTRIGGER: > if (rdch) { >- CHN_LOCK(rdch); >- rdch->flags &= ~CHN_F_NOTRIGGER; >- if (*arg_i & PCM_ENABLE_INPUT) >+ if (*arg_i & PCM_ENABLE_INPUT) { >+ chn_prepare(rdch, 1); >+ CHN_LOCK(rdch); > chn_start(rdch, 1); >- else { >+ rdch->flags &= ~CHN_F_NOTRIGGER; >+ CHN_UNLOCK(rdch); >+ } else { >+ CHN_LOCK(rdch); > chn_abort(rdch); > chn_resetbuf(rdch); > rdch->flags |= CHN_F_NOTRIGGER; >+ CHN_UNLOCK(rdch); > } >- CHN_UNLOCK(rdch); > } > if (wrch) { >- CHN_LOCK(wrch); >- wrch->flags &= ~CHN_F_NOTRIGGER; >- if (*arg_i & PCM_ENABLE_OUTPUT) >+ if (*arg_i & PCM_ENABLE_OUTPUT) { >+ chn_prepare(wrch, 1); >+ CHN_LOCK(wrch); > chn_start(wrch, 1); >- else { >+ wrch->flags &= ~CHN_F_NOTRIGGER; >+ CHN_UNLOCK(wrch); >+ } else { >+ CHN_LOCK(wrch); > chn_abort(wrch); > chn_resetbuf(wrch); > wrch->flags |= CHN_F_NOTRIGGER; >+ CHN_UNLOCK(wrch); > } >- CHN_UNLOCK(wrch); > } > break; > >@@ -1789,11 +1794,17 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, > > case SNDCTL_DSP_POST: > if (wrch) { >+ chn_prepare(wrch, 1); > CHN_LOCK(wrch); > wrch->flags &= ~CHN_F_NOTRIGGER; > chn_start(wrch, 1); > CHN_UNLOCK(wrch); > } >+#if 0 >+ if (rdch) { >+ chn_prepare(rdch, 1); >+ } >+#endif > break; > > case SNDCTL_DSP_SETDUPLEX: >diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c >index a2e25e352055..9b5ed8aaac2d 100644 >--- a/sys/dev/sound/pcm/vchan.c >+++ b/sys/dev/sound/pcm/vchan.c >@@ -184,6 +184,21 @@ vchan_trigger(kobj_t obj, void *data, int go) > return (ret); > } > >+static int >+vchan_prepare(kobj_t obj, void *data, int go) >+{ >+ struct vchan_info *info; >+ struct pcm_channel *c, *p; >+ >+ info = data; >+ c = info->channel; >+ p = c->parentchannel; >+ >+ if (p) >+ chn_prepare(p, go); >+ return 1; >+} >+ > static struct pcmchan_caps * > vchan_getcaps(kobj_t obj, void *data) > { >@@ -244,6 +259,7 @@ static kobj_method_t vchan_methods[] = { > KOBJMETHOD(channel_setformat, vchan_setformat), > KOBJMETHOD(channel_setspeed, vchan_setspeed), > KOBJMETHOD(channel_trigger, vchan_trigger), >+ KOBJMETHOD(channel_prepare, vchan_prepare), > KOBJMETHOD(channel_getcaps, vchan_getcaps), > KOBJMETHOD(channel_getmatrix, vchan_getmatrix), > KOBJMETHOD_END >diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c >index cfad299dc313..55c86bf68fe3 100644 >--- a/sys/dev/sound/usb/uaudio.c >+++ b/sys/dev/sound/usb/uaudio.c >@@ -267,6 +267,7 @@ struct uaudio_chan { > #define CHAN_OP_DRAIN 3 > > uint8_t iface_index; >+ uint8_t cur_alt_index; > }; > > #define UMIDI_EMB_JACK_MAX 16 /* units */ >@@ -1342,6 +1343,8 @@ uaudio_configure_msg_sub(struct uaudio_softc *sc, > goto error; > } > >+ chan->cur_alt_index = (operation == CHAN_OP_START) ? >+ chan_alt->iface_alt_index : 0; > /* > * Only set the sample rate if the channel reports that it > * supports the frequency control. >@@ -2775,6 +2778,22 @@ uaudio_chan_need_none(struct uaudio_chan *pchan, struct uaudio_chan *rchan) > rchan->running == 0); > } > >+void >+uaudio_chan_prepare(struct uaudio_chan *ch, int enable) >+{ >+ struct uaudio_softc *sc = ch->priv_sc; >+ >+ if (ch->cur_alt_index == ch->usb_alt[ch->cur_alt].iface_alt_index) { >+ return; >+ } >+ usbd_req_set_alt_interface_no(sc->sc_udev, >+ NULL, >+ ch->iface_index, >+ ch->usb_alt[ch->cur_alt].iface_alt_index); >+ >+ ch->cur_alt_index = ch->usb_alt[ch->cur_alt].iface_alt_index; >+} >+ > void > uaudio_chan_start(struct uaudio_chan *ch) > { >@@ -2836,8 +2855,20 @@ uaudio_chan_stop_sub(struct uaudio_chan *ch) > } > } > if (do_stop) { >- usbd_transfer_stop(ch->xfer[0]); >- usbd_transfer_stop(ch->xfer[1]); >+ usb_proc_explore_unlock(sc->sc_udev); >+ CHN_UNLOCK(ch->pcm_ch); >+ >+ usbd_transfer_drain(ch->xfer[0]); >+ usbd_transfer_drain(ch->xfer[1]); >+ >+ usbd_req_set_alt_interface_no(sc->sc_udev, >+ NULL, >+ ch->iface_index, >+ 0); >+ ch->cur_alt_index = 0; >+ CHN_LOCK(ch->pcm_ch); >+ usb_proc_explore_lock(sc->sc_udev); >+ > } > } > >diff --git a/sys/dev/sound/usb/uaudio.h b/sys/dev/sound/usb/uaudio.h >index ece0a5b41849..26ea4659d93d 100644 >--- a/sys/dev/sound/usb/uaudio.h >+++ b/sys/dev/sound/usb/uaudio.h >@@ -56,6 +56,7 @@ extern struct pcmchan_matrix *uaudio_chan_getmatrix(struct uaudio_chan *ch, > uint32_t format); > extern int uaudio_chan_set_param_format(struct uaudio_chan *ch, > uint32_t format); >+extern void uaudio_chan_prepare(struct uaudio_chan *ch, int enable); > extern void uaudio_chan_start(struct uaudio_chan *ch); > extern void uaudio_chan_stop(struct uaudio_chan *ch); > extern int uaudio_mixer_init_sub(struct uaudio_softc *, struct snd_mixer *); >diff --git a/sys/dev/sound/usb/uaudio_pcm.c b/sys/dev/sound/usb/uaudio_pcm.c >index 9c4666c41bba..4fa2fe907702 100644 >--- a/sys/dev/sound/usb/uaudio_pcm.c >+++ b/sys/dev/sound/usb/uaudio_pcm.c >@@ -79,6 +79,13 @@ ua_chan_setfragments(kobj_t obj, void *data, uint32_t blocksize, uint32_t blockc > return (uaudio_chan_set_param_fragments(data, blocksize, blockcount)); > } > >+static int >+ua_chan_prepare(kobj_t obj, void *data, int go) >+{ >+ uaudio_chan_prepare(data, go); >+ return 0; >+} >+ > static int > ua_chan_trigger(kobj_t obj, void *data, int go) > { >@@ -118,6 +125,7 @@ static kobj_method_t ua_chan_methods[] = { > KOBJMETHOD(channel_setblocksize, ua_chan_setblocksize), > KOBJMETHOD(channel_setfragments, ua_chan_setfragments), > KOBJMETHOD(channel_trigger, ua_chan_trigger), >+ KOBJMETHOD(channel_prepare, ua_chan_prepare), > KOBJMETHOD(channel_getptr, ua_chan_getptr), > KOBJMETHOD(channel_getcaps, ua_chan_getcaps), > KOBJMETHOD(channel_getmatrix, ua_chan_getmatrix),
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 252434
: 221286