Skip to content

Commit 4801bee

Browse files
committed
ALSA: usb-audio: Add lowlatency module option
For making user to switch back to the old playback mode, this patch adds a new module option 'lowlatency' to snd-usb-audio driver. When user face a regression due to the recent low-latency playback support, they can test easily by passing lowlatency=0 option without rebuilding the kernel. Fixes: 307cc9b ("ALSA: usb-audio: Reduce latency at playback start, take#2") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 4267c5a commit 4801bee

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

sound/usb/card.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
6868
static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
6969
static bool ignore_ctl_error;
7070
static bool autoclock = true;
71+
static bool lowlatency = true;
7172
static char *quirk_alias[SNDRV_CARDS];
7273
static char *delayed_register[SNDRV_CARDS];
7374
static bool implicit_fb[SNDRV_CARDS];
@@ -92,6 +93,8 @@ MODULE_PARM_DESC(ignore_ctl_error,
9293
"Ignore errors from USB controller for mixer interfaces.");
9394
module_param(autoclock, bool, 0444);
9495
MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes).");
96+
module_param(lowlatency, bool, 0444);
97+
MODULE_PARM_DESC(lowlatency, "Enable low latency playback (default: yes).");
9598
module_param_array(quirk_alias, charp, NULL, 0444);
9699
MODULE_PARM_DESC(quirk_alias, "Quirk aliases, e.g. 0123abcd:5678beef.");
97100
module_param_array(delayed_register, charp, NULL, 0444);
@@ -599,6 +602,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
599602
chip->setup = device_setup[idx];
600603
chip->generic_implicit_fb = implicit_fb[idx];
601604
chip->autoclock = autoclock;
605+
chip->lowlatency = lowlatency;
602606
atomic_set(&chip->active, 1); /* avoid autopm during probing */
603607
atomic_set(&chip->usage_count, 0);
604608
atomic_set(&chip->shutdown, 0);

sound/usb/pcm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
617617
/* check whether early start is needed for playback stream */
618618
subs->early_playback_start =
619619
subs->direction == SNDRV_PCM_STREAM_PLAYBACK &&
620-
subs->data_endpoint->nominal_queue_size >= subs->buffer_bytes;
620+
(!chip->lowlatency ||
621+
(subs->data_endpoint->nominal_queue_size >= subs->buffer_bytes));
621622

622623
if (subs->early_playback_start)
623624
ret = start_endpoints(subs);

sound/usb/usbaudio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct snd_usb_audio {
5757
bool generic_implicit_fb; /* from the 'implicit_fb' module param */
5858
bool autoclock; /* from the 'autoclock' module param */
5959

60+
bool lowlatency; /* from the 'lowlatency' module param */
6061
struct usb_host_interface *ctrl_intf; /* the audio control interface */
6162
struct media_device *media_dev;
6263
struct media_intf_devnode *ctl_intf_media_devnode;

0 commit comments

Comments
 (0)