Skip to content

Commit

Permalink
usb: gadget: u_audio: improve uac compatibility
Browse files Browse the repository at this point in the history
Some PC USB Hosts (e.g Dell laptop) fail to send
SetInterface(AltSet=0) to stop capture/playback
when PC enter suspend or play YouTube Video.

To be compatible with these PC, add this patch to
stop capture/playback prior to start again if the
stream_state is true.

Change-Id: Iced57de39b6b88a7c987897dcb123cf8d7cf6473
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
  • Loading branch information
wuliangfeng authored and rkhuangtao committed Apr 1, 2022
1 parent 1abe698 commit 01ccdd1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/usb/gadget/function/u_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,15 @@ int u_audio_start_capture(struct g_audio *audio_dev)
struct uac_params *params = &audio_dev->params;
int req_len, i;

/*
* For better compatibility on some PC Hosts which
* failed to send SetInterface(AltSet=0) to stop
* capture last time. It needs to stop capture
* prior to start capture next time.
*/
if (audio_dev->stream_state[STATE_OUT])
u_audio_stop_capture(audio_dev);

audio_dev->usb_state[SET_INTERFACE_OUT] = true;
audio_dev->stream_state[STATE_OUT] = true;
schedule_work(&audio_dev->work);
Expand Down Expand Up @@ -705,6 +714,15 @@ int u_audio_start_playback(struct g_audio *audio_dev)
int req_len, i;
unsigned int p_pktsize;

/*
* For better compatibility on some PC Hosts which
* failed to send SetInterface(AltSet=0) to stop
* playback last time. It needs to stop playback
* prior to start playback next time.
*/
if (audio_dev->stream_state[STATE_IN])
u_audio_stop_playback(audio_dev);

audio_dev->usb_state[SET_INTERFACE_IN] = true;
audio_dev->stream_state[STATE_IN] = true;
schedule_work(&audio_dev->work);
Expand Down

0 comments on commit 01ccdd1

Please sign in to comment.