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/20210118075816.25068-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@@ -485,18 +485,9 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip,
|
||||
const struct audioformat *fmt, int rate)
|
||||
{
|
||||
struct usb_device *dev = chip->dev;
|
||||
struct usb_host_interface *alts;
|
||||
unsigned int ep;
|
||||
unsigned char data[3];
|
||||
int err, crate;
|
||||
|
||||
alts = snd_usb_get_host_interface(chip, fmt->iface, fmt->altsetting);
|
||||
if (!alts)
|
||||
return -EINVAL;
|
||||
if (get_iface_desc(alts)->bNumEndpoints < 1)
|
||||
return -EINVAL;
|
||||
ep = get_endpoint(alts, 0)->bEndpointAddress;
|
||||
|
||||
/* if endpoint doesn't have sampling rate control, bail out */
|
||||
if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE))
|
||||
return 0;
|
||||
@@ -506,11 +497,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip,
|
||||
data[2] = rate >> 16;
|
||||
err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
|
||||
USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
|
||||
UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
|
||||
data, sizeof(data));
|
||||
UAC_EP_CS_ATTR_SAMPLE_RATE << 8,
|
||||
fmt->endpoint, data, sizeof(data));
|
||||
if (err < 0) {
|
||||
dev_err(&dev->dev, "%d:%d: cannot set freq %d to ep %#x\n",
|
||||
fmt->iface, fmt->altsetting, rate, ep);
|
||||
fmt->iface, fmt->altsetting, rate, fmt->endpoint);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -524,11 +515,11 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip,
|
||||
|
||||
err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
|
||||
USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
|
||||
UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep,
|
||||
data, sizeof(data));
|
||||
UAC_EP_CS_ATTR_SAMPLE_RATE << 8,
|
||||
fmt->endpoint, data, sizeof(data));
|
||||
if (err < 0) {
|
||||
dev_err(&dev->dev, "%d:%d: cannot get freq at ep %#x\n",
|
||||
fmt->iface, fmt->altsetting, ep);
|
||||
fmt->iface, fmt->altsetting, fmt->endpoint);
|
||||
chip->sample_rate_read_error++;
|
||||
return 0; /* some devices don't support reading */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user