Skip to content

Commit f7b82b1

Browse files
committed
Merge branch 'for-linus' into for-next
2 parents ea41a49 + 4801bee commit f7b82b1

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

sound/core/pcm_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
17461746
channels = params_channels(params);
17471747
frame_size = snd_pcm_format_size(format, channels);
17481748
if (frame_size > 0)
1749-
params->fifo_size /= (unsigned)frame_size;
1749+
params->fifo_size /= frame_size;
17501750
}
17511751
return 0;
17521752
}

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];
@@ -93,6 +94,8 @@ MODULE_PARM_DESC(ignore_ctl_error,
9394
"Ignore errors from USB controller for mixer interfaces.");
9495
module_param(autoclock, bool, 0444);
9596
MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes).");
97+
module_param(lowlatency, bool, 0444);
98+
MODULE_PARM_DESC(lowlatency, "Enable low latency playback (default: yes).");
9699
module_param_array(quirk_alias, charp, NULL, 0444);
97100
MODULE_PARM_DESC(quirk_alias, "Quirk aliases, e.g. 0123abcd:5678beef.");
98101
module_param_array(delayed_register, charp, NULL, 0444);
@@ -623,6 +626,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
623626
chip->setup = device_setup[idx];
624627
chip->generic_implicit_fb = implicit_fb[idx];
625628
chip->autoclock = autoclock;
629+
chip->lowlatency = lowlatency;
626630
atomic_set(&chip->active, 1); /* avoid autopm during probing */
627631
atomic_set(&chip->usage_count, 0);
628632
atomic_set(&chip->shutdown, 0);

sound/usb/card.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct snd_usb_endpoint {
9494
struct list_head ready_playback_urbs; /* playback URB FIFO for implicit fb */
9595

9696
unsigned int nurbs; /* # urbs */
97+
unsigned int nominal_queue_size; /* total buffer sizes in URBs */
9798
unsigned long active_mask; /* bitmask of active urbs */
9899
unsigned long unlink_mask; /* bitmask of unlinked urbs */
99100
char *syncbuf; /* sync buffer for all sync URBs */
@@ -187,6 +188,7 @@ struct snd_usb_substream {
187188
} dsd_dop;
188189

189190
bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */
191+
bool early_playback_start; /* early start needed for playback? */
190192
struct media_ctl *media_ctl;
191193
};
192194

sound/usb/endpoint.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,10 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep)
11321132
INIT_LIST_HEAD(&u->ready_list);
11331133
}
11341134

1135+
/* total buffer bytes of all URBs plus the next queue;
1136+
* referred in pcm.c
1137+
*/
1138+
ep->nominal_queue_size = maxsize * urb_packs * (ep->nurbs + 1);
11351139
return 0;
11361140

11371141
out_of_memory:

sound/usb/pcm.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,15 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
614614
subs->period_elapsed_pending = 0;
615615
runtime->delay = 0;
616616

617+
/* check whether early start is needed for playback stream */
618+
subs->early_playback_start =
619+
subs->direction == SNDRV_PCM_STREAM_PLAYBACK &&
620+
(!chip->lowlatency ||
621+
(subs->data_endpoint->nominal_queue_size >= subs->buffer_bytes));
622+
623+
if (subs->early_playback_start)
624+
ret = start_endpoints(subs);
625+
617626
unlock:
618627
snd_usb_unlock_shutdown(chip);
619628
return ret;
@@ -1394,7 +1403,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
13941403
subs->trigger_tstamp_pending_update = false;
13951404
}
13961405

1397-
if (period_elapsed && !subs->running) {
1406+
if (period_elapsed && !subs->running && !subs->early_playback_start) {
13981407
subs->period_elapsed_pending = 1;
13991408
period_elapsed = 0;
14001409
}
@@ -1448,7 +1457,8 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
14481457
prepare_playback_urb,
14491458
retire_playback_urb,
14501459
subs);
1451-
if (cmd == SNDRV_PCM_TRIGGER_START) {
1460+
if (!subs->early_playback_start &&
1461+
cmd == SNDRV_PCM_TRIGGER_START) {
14521462
err = start_endpoints(subs);
14531463
if (err < 0) {
14541464
snd_usb_endpoint_set_callback(subs->data_endpoint,

sound/usb/usbaudio.h

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

58+
bool lowlatency; /* from the 'lowlatency' module param */
5859
struct usb_host_interface *ctrl_intf; /* the audio control interface */
5960
struct media_device *media_dev;
6061
struct media_intf_devnode *ctl_intf_media_devnode;

0 commit comments

Comments
 (0)