Skip to content

Commit 87cb9af

Browse files
committed
ALSA: usb-audio: Fix UAC1 rate setup for secondary endpoints
The current sample rate setup function for UAC1 assumes only the first endpoint retrieved from the interface:altset pair, but the rate set up may be needed also for the secondary endpoint. Also, retrieving the endpoint number from the interface descriptor is redundant; we have already the target endpoint in the given audioformat object. This patch simplifies the code and corrects the target endpoint as described in the above. It simply refers to fmt->endpoint directly. Also, this patch drops the pioneer_djm_set_format_quirk() that is caleld from snd_usb_set_format_quirk(); this function does the sample rate setup but for the capture endpoint (0x82), and that's exactly what the change above fixes. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent f84d3a1 commit 87cb9af

File tree

2 files changed

+6
-43
lines changed

2 files changed

+6
-43
lines changed

sound/usb/clock.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,9 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip,
485485
const struct audioformat *fmt, int rate)
486486
{
487487
struct usb_device *dev = chip->dev;
488-
struct usb_host_interface *alts;
489-
unsigned int ep;
490488
unsigned char data[3];
491489
int err, crate;
492490

493-
alts = snd_usb_get_host_interface(chip, fmt->iface, fmt->altsetting);
494-
if (!alts)
495-
return -EINVAL;
496-
if (get_iface_desc(alts)->bNumEndpoints < 1)
497-
return -EINVAL;
498-
ep = get_endpoint(alts, 0)->bEndpointAddress;
499-
500491
/* if endpoint doesn't have sampling rate control, bail out */
501492
if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE))
502493
return 0;
@@ -506,11 +497,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip,
506497
data[2] = rate >> 16;
507498
err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
508499
USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
509-
UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
510-
data, sizeof(data));
500+
UAC_EP_CS_ATTR_SAMPLE_RATE << 8,
501+
fmt->endpoint, data, sizeof(data));
511502
if (err < 0) {
512503
dev_err(&dev->dev, "%d:%d: cannot set freq %d to ep %#x\n",
513-
fmt->iface, fmt->altsetting, rate, ep);
504+
fmt->iface, fmt->altsetting, rate, fmt->endpoint);
514505
return err;
515506
}
516507

@@ -524,11 +515,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip,
524515

525516
err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
526517
USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
527-
UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
528-
data, sizeof(data));
518+
UAC_EP_CS_ATTR_SAMPLE_RATE << 8,
519+
fmt->endpoint, data, sizeof(data));
529520
if (err < 0) {
530521
dev_err(&dev->dev, "%d:%d: cannot get freq at ep %#x\n",
531-
fmt->iface, fmt->altsetting, ep);
522+
fmt->iface, fmt->altsetting, fmt->endpoint);
532523
chip->sample_rate_read_error++;
533524
return 0; /* some devices don't support reading */
534525
}

sound/usb/quirks.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,30 +1470,6 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs,
14701470
subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
14711471
}
14721472

1473-
1474-
/*
1475-
* Pioneer DJ DJM-900NXS2
1476-
* Device needs to know the sample rate each time substream is started
1477-
*/
1478-
static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs)
1479-
{
1480-
unsigned int cur_rate = subs->data_endpoint->cur_rate;
1481-
/* Convert sample rate value to little endian */
1482-
u8 sr[3];
1483-
1484-
sr[0] = cur_rate & 0xff;
1485-
sr[1] = (cur_rate >> 8) & 0xff;
1486-
sr[2] = (cur_rate >> 16) & 0xff;
1487-
1488-
/* Configure device */
1489-
usb_set_interface(subs->dev, 0, 1);
1490-
snd_usb_ctl_msg(subs->stream->chip->dev,
1491-
usb_rcvctrlpipe(subs->stream->chip->dev, 0),
1492-
0x01, 0x22, 0x0100, 0x0082, &sr, 0x0003);
1493-
1494-
return 0;
1495-
}
1496-
14971473
void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
14981474
const struct audioformat *fmt)
14991475
{
@@ -1504,10 +1480,6 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
15041480
case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
15051481
set_format_emu_quirk(subs, fmt);
15061482
break;
1507-
case USB_ID(0x2b73, 0x000a): /* Pioneer DJ DJM-900NXS2 */
1508-
case USB_ID(0x2b73, 0x0017): /* Pioneer DJ DJM-250MK2 */
1509-
pioneer_djm_set_format_quirk(subs);
1510-
break;
15111483
case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */
15121484
subs->stream_offset_adj = 2;
15131485
break;

0 commit comments

Comments
 (0)