Commit 8a463225 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: usb-audio: Add keep_iface flag

Introduce a new flag to struct snd_usb_audio for allowing the device
to skip usb_set_interface() calls at changing or closing the stream.
As of this patch, the flag is nowhere set, so it's just a place
holder.  The dynamic switching will be added in the following patch.

A background information for this change:

Dell WD15 dock with Realtek chip gives a very long pause at each time
the driver changes the altset, which eventually happens at every PCM
stream open/close and parameter change.  As the long pause happens in
each usb_set_interface() call, there is nothing we can do as long as
it's called.  The workaround is to reduce calling it as much as
possible, and this flag indicates that behavior.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b099b969
...@@ -509,6 +509,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) ...@@ -509,6 +509,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
/* close the old interface */ /* close the old interface */
if (subs->interface >= 0 && subs->interface != fmt->iface) { if (subs->interface >= 0 && subs->interface != fmt->iface) {
if (!subs->stream->chip->keep_iface) {
err = usb_set_interface(subs->dev, subs->interface, 0); err = usb_set_interface(subs->dev, subs->interface, 0);
if (err < 0) { if (err < 0) {
dev_err(&dev->dev, dev_err(&dev->dev,
...@@ -516,6 +517,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) ...@@ -516,6 +517,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
fmt->iface, fmt->altsetting, err); fmt->iface, fmt->altsetting, err);
return -EIO; return -EIO;
} }
}
subs->interface = -1; subs->interface = -1;
subs->altset_idx = 0; subs->altset_idx = 0;
} }
...@@ -1253,7 +1255,8 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) ...@@ -1253,7 +1255,8 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
stop_endpoints(subs, true); stop_endpoints(subs, true);
if (subs->interface >= 0 && if (!as->chip->keep_iface &&
subs->interface >= 0 &&
!snd_usb_lock_shutdown(subs->stream->chip)) { !snd_usb_lock_shutdown(subs->stream->chip)) {
usb_set_interface(subs->dev, subs->interface, 0); usb_set_interface(subs->dev, subs->interface, 0);
subs->interface = -1; subs->interface = -1;
......
...@@ -59,6 +59,9 @@ struct snd_usb_audio { ...@@ -59,6 +59,9 @@ struct snd_usb_audio {
int setup; /* from the 'device_setup' module param */ int setup; /* from the 'device_setup' module param */
bool autoclock; /* from the 'autoclock' module param */ bool autoclock; /* from the 'autoclock' module param */
bool keep_iface; /* keep interface/altset after closing
* or parameter change
*/
struct usb_host_interface *ctrl_intf; /* the audio control interface */ struct usb_host_interface *ctrl_intf; /* the audio control interface */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment