Skip to content

Commit eae4d05

Browse files
committed
ALSA: usb-audio: Annotate the endpoint index in audioformat
There are devices that have multiple endpoints sharing the same iface/altset not only for sync but also for the actual streams, and the audioformat for such an endpoint needs to be handled with the proper endpoint index; otherwise it confuses the endpoint management. This patch extends the audioformat to annotate the endpoint index, and put the proper ep_idx=1 to Pioneer device quirk entries accordingly. Fixes: bf6313a ("ALSA: usb-audio: Refactor endpoint management") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 00272c6 commit eae4d05

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

sound/usb/card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct audioformat {
1818
unsigned int frame_size; /* samples per frame for non-audio */
1919
unsigned char iface; /* interface number */
2020
unsigned char altsetting; /* corresponding alternate setting */
21+
unsigned char ep_idx; /* endpoint array index */
2122
unsigned char altset_idx; /* array index of altenate setting */
2223
unsigned char attributes; /* corresponding attributes of cs endpoint */
2324
unsigned char endpoint; /* endpoint */

sound/usb/endpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip,
683683
} else {
684684
ep->iface = fp->iface;
685685
ep->altsetting = fp->altsetting;
686-
ep->ep_idx = 0;
686+
ep->ep_idx = fp->ep_idx;
687687
}
688688
usb_audio_dbg(chip, "Open EP 0x%x, iface=%d:%d, idx=%d\n",
689689
ep_num, ep->iface, ep->altsetting, ep->ep_idx);

sound/usb/quirks-table.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,6 +3362,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
33623362
.altsetting = 1,
33633363
.altset_idx = 1,
33643364
.endpoint = 0x86,
3365+
.ep_idx = 1,
33653366
.ep_attr = USB_ENDPOINT_XFER_ISOC|
33663367
USB_ENDPOINT_SYNC_ASYNC|
33673368
USB_ENDPOINT_USAGE_IMPLICIT_FB,
@@ -3450,6 +3451,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
34503451
.altsetting = 1,
34513452
.altset_idx = 1,
34523453
.endpoint = 0x82,
3454+
.ep_idx = 1,
34533455
.ep_attr = USB_ENDPOINT_XFER_ISOC|
34543456
USB_ENDPOINT_SYNC_ASYNC|
34553457
USB_ENDPOINT_USAGE_IMPLICIT_FB,
@@ -3506,6 +3508,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
35063508
.altsetting = 1,
35073509
.altset_idx = 1,
35083510
.endpoint = 0x82,
3511+
.ep_idx = 1,
35093512
.ep_attr = USB_ENDPOINT_XFER_ISOC|
35103513
USB_ENDPOINT_SYNC_ASYNC|
35113514
USB_ENDPOINT_USAGE_IMPLICIT_FB,
@@ -3562,6 +3565,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
35623565
.altsetting = 1,
35633566
.altset_idx = 1,
35643567
.endpoint = 0x82,
3568+
.ep_idx = 1,
35653569
.ep_attr = USB_ENDPOINT_XFER_ISOC|
35663570
USB_ENDPOINT_SYNC_ASYNC|
35673571
USB_ENDPOINT_USAGE_IMPLICIT_FB,
@@ -3619,6 +3623,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
36193623
.altsetting = 1,
36203624
.altset_idx = 1,
36213625
.endpoint = 0x82,
3626+
.ep_idx = 1,
36223627
.ep_attr = USB_ENDPOINT_XFER_ISOC|
36233628
USB_ENDPOINT_SYNC_ASYNC|
36243629
USB_ENDPOINT_USAGE_IMPLICIT_FB,
@@ -3679,6 +3684,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
36793684
.altsetting = 1,
36803685
.altset_idx = 1,
36813686
.endpoint = 0x82,
3687+
.ep_idx = 1,
36823688
.ep_attr = USB_ENDPOINT_XFER_ISOC|
36833689
USB_ENDPOINT_SYNC_ASYNC|
36843690
USB_ENDPOINT_USAGE_IMPLICIT_FB,

sound/usb/quirks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
194194
}
195195
alts = &iface->altsetting[fp->altset_idx];
196196
altsd = get_iface_desc(alts);
197-
if (altsd->bNumEndpoints < 1) {
197+
if (altsd->bNumEndpoints <= fp->ep_idx) {
198198
err = -EINVAL;
199199
goto error;
200200
}
@@ -204,7 +204,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
204204
if (fp->datainterval == 0)
205205
fp->datainterval = snd_usb_parse_datainterval(chip, alts);
206206
if (fp->maxpacksize == 0)
207-
fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
207+
fp->maxpacksize = le16_to_cpu(get_endpoint(alts, fp->ep_idx)->wMaxPacketSize);
208208
if (!fp->fmt_type)
209209
fp->fmt_type = UAC_FORMAT_TYPE_I;
210210

0 commit comments

Comments
 (0)