Skip to content

Commit 79764ec

Browse files
committed
Revert "ALSA: usb-audio: Split endpoint setups for hw_params and prepare"
This reverts commit ff878b4. Unfortunately the recent fix seems bringing another regressions with PulseAudio / pipewire, at least for Steinberg and MOTU devices. As a temporary solution, do a straight revert. The issue for Android will be revisited again later by another different fix (if any). Fixes: ff878b4 ("ALSA: usb-audio: Split endpoint setups for hw_params and prepare") Cc: <[email protected]> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=216500 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent c3afa2a commit 79764ec

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

sound/usb/endpoint.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,7 @@ bool snd_usb_endpoint_compatible(struct snd_usb_audio *chip,
758758
* The endpoint needs to be closed via snd_usb_endpoint_close() later.
759759
*
760760
* Note that this function doesn't configure the endpoint. The substream
761-
* needs to set it up later via snd_usb_endpoint_set_params() and
762-
* snd_usb_endpoint_prepare().
761+
* needs to set it up later via snd_usb_endpoint_configure().
763762
*/
764763
struct snd_usb_endpoint *
765764
snd_usb_endpoint_open(struct snd_usb_audio *chip,
@@ -1293,13 +1292,12 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep)
12931292
/*
12941293
* snd_usb_endpoint_set_params: configure an snd_usb_endpoint
12951294
*
1296-
* It's called either from hw_params callback.
12971295
* Determine the number of URBs to be used on this endpoint.
12981296
* An endpoint must be configured before it can be started.
12991297
* An endpoint that is already running can not be reconfigured.
13001298
*/
1301-
int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
1302-
struct snd_usb_endpoint *ep)
1299+
static int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
1300+
struct snd_usb_endpoint *ep)
13031301
{
13041302
const struct audioformat *fmt = ep->cur_audiofmt;
13051303
int err;
@@ -1382,18 +1380,18 @@ static int init_sample_rate(struct snd_usb_audio *chip,
13821380
}
13831381

13841382
/*
1385-
* snd_usb_endpoint_prepare: Prepare the endpoint
1383+
* snd_usb_endpoint_configure: Configure the endpoint
13861384
*
13871385
* This function sets up the EP to be fully usable state.
1388-
* It's called either from prepare callback.
1386+
* It's called either from hw_params or prepare callback.
13891387
* The function checks need_setup flag, and performs nothing unless needed,
13901388
* so it's safe to call this multiple times.
13911389
*
13921390
* This returns zero if unchanged, 1 if the configuration has changed,
13931391
* or a negative error code.
13941392
*/
1395-
int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
1396-
struct snd_usb_endpoint *ep)
1393+
int snd_usb_endpoint_configure(struct snd_usb_audio *chip,
1394+
struct snd_usb_endpoint *ep)
13971395
{
13981396
bool iface_first;
13991397
int err = 0;
@@ -1414,6 +1412,9 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
14141412
if (err < 0)
14151413
goto unlock;
14161414
}
1415+
err = snd_usb_endpoint_set_params(chip, ep);
1416+
if (err < 0)
1417+
goto unlock;
14171418
goto done;
14181419
}
14191420

@@ -1441,6 +1442,10 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
14411442
if (err < 0)
14421443
goto unlock;
14431444

1445+
err = snd_usb_endpoint_set_params(chip, ep);
1446+
if (err < 0)
1447+
goto unlock;
1448+
14441449
err = snd_usb_select_mode_quirk(chip, ep->cur_audiofmt);
14451450
if (err < 0)
14461451
goto unlock;

sound/usb/endpoint.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip,
1717
bool is_sync_ep);
1818
void snd_usb_endpoint_close(struct snd_usb_audio *chip,
1919
struct snd_usb_endpoint *ep);
20-
int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
21-
struct snd_usb_endpoint *ep);
22-
int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
23-
struct snd_usb_endpoint *ep);
20+
int snd_usb_endpoint_configure(struct snd_usb_audio *chip,
21+
struct snd_usb_endpoint *ep);
2422
int snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock);
2523

2624
bool snd_usb_endpoint_compatible(struct snd_usb_audio *chip,

sound/usb/pcm.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -443,17 +443,17 @@ static int configure_endpoints(struct snd_usb_audio *chip,
443443
if (stop_endpoints(subs, false))
444444
sync_pending_stops(subs);
445445
if (subs->sync_endpoint) {
446-
err = snd_usb_endpoint_prepare(chip, subs->sync_endpoint);
446+
err = snd_usb_endpoint_configure(chip, subs->sync_endpoint);
447447
if (err < 0)
448448
return err;
449449
}
450-
err = snd_usb_endpoint_prepare(chip, subs->data_endpoint);
450+
err = snd_usb_endpoint_configure(chip, subs->data_endpoint);
451451
if (err < 0)
452452
return err;
453453
snd_usb_set_format_quirk(subs, subs->cur_audiofmt);
454454
} else {
455455
if (subs->sync_endpoint) {
456-
err = snd_usb_endpoint_prepare(chip, subs->sync_endpoint);
456+
err = snd_usb_endpoint_configure(chip, subs->sync_endpoint);
457457
if (err < 0)
458458
return err;
459459
}
@@ -551,13 +551,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
551551
subs->cur_audiofmt = fmt;
552552
mutex_unlock(&chip->mutex);
553553

554-
if (subs->sync_endpoint) {
555-
ret = snd_usb_endpoint_set_params(chip, subs->sync_endpoint);
556-
if (ret < 0)
557-
goto unlock;
558-
}
559-
560-
ret = snd_usb_endpoint_set_params(chip, subs->data_endpoint);
554+
ret = configure_endpoints(chip, subs);
561555

562556
unlock:
563557
if (ret < 0)

0 commit comments

Comments
 (0)