This has two parts: * intervals_per_second setup (high speed needs 8000, instead of 1000) * iso_buffers setup (count of iso buffers depends on USB speed, 2 is not enough for high speed)
Unified · Split
| @@ -181,7 +181,15 @@ static void audio_in_callback(struct urb *urb) · 180 unmodified lines | ||
| 181 | 181 | |
| 182 | 182 | length += fsize; |
| 183 | 183 | |
| 184 | − /* the following assumes LINE6_ISO_PACKETS == 1: */ | |
| 184 | + BUILD_BUG_ON_MSG(LINE6_ISO_PACKETS != 1, | |
| 185 | + "The following code assumes LINE6_ISO_PACKETS == 1"); | |
| 186 | + /* TODO: | |
| 187 | + * Also, if iso_buffers != 2, the prev frame is almost random at | |
| 188 | + * playback side. | |
| 189 | + * This needs to be redesigned. It should be "stable", but we may | |
| 190 | + * experience sync problems on such high-speed configs. | |
| 191 | + */ | |
| 192 | + | |
| 185 | 193 | line6pcm->prev_fbuf = fbuf; |
| 186 | 194 | line6pcm->prev_fsize = fsize; |
| 187 | 195 | |
| @@ -462,14 +462,18 @@ static void line6_destruct(struct snd_card *card) · 461 unmodified lines | ||
| 462 | 462 | static void line6_get_interval(struct usb_line6 *line6) |
| 463 | 463 | { |
| 464 | 464 | struct usb_device *usbdev = line6->usbdev; |
| 465 | − struct usb_host_endpoint *ep; | |
| 466 | − unsigned pipe = usb_rcvintpipe(usbdev, line6->properties->ep_ctrl_r); | |
| 467 | − unsigned epnum = usb_pipeendpoint(pipe); | |
| 465 | + struct usb_host_endpoint *ep = usbdev->ep_in[line6->properties->ep_ctrl_r]; | |
| 468 | 466 | |
| 469 | − ep = usbdev->ep_in[epnum]; | |
| 470 | − line6->iso_buffers = LINE6_ISO_BUFFERS; | |
| 471 | 467 | if (ep) { |
| 472 | 468 | line6->interval = ep->desc.bInterval; |
| 469 | + if (usbdev->speed == USB_SPEED_LOW) { | |
| 470 | + line6->intervals_per_second = USB_LOW_INTERVALS_PER_SECOND; | |
| 471 | + line6->iso_buffers = USB_LOW_ISO_BUFFERS; | |
| 472 | + } else { | |
| 473 | + line6->intervals_per_second = USB_HIGH_INTERVALS_PER_SECOND; | |
| 474 | + line6->iso_buffers = USB_HIGH_ISO_BUFFERS; | |
| 475 | + } | |
| 476 | + | |
| 473 | 477 | line6->max_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); |
| 474 | 478 | } else { |
| 475 | 479 | dev_err(line6->ifcdev, |
| @@ -559,6 +563,7 @@ int line6_probe(struct usb_interface *interface, · 83 unmodified lines | ||
| 559 | 563 | /* query interface number */ |
| 560 | 564 | interface_number = interface->cur_altsetting->desc.bInterfaceNumber; |
| 561 | 565 | |
| 566 | + /* TODO reserves the bus bandwidth even without actual transfer */ | |
| 562 | 567 | ret = usb_set_interface(usbdev, interface_number, |
| 563 | 568 | properties->altsetting); |
| 564 | 569 | if (ret < 0) { |
| @@ -18,7 +18,13 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | #include "midi.h" |
| 20 | 20 | |
| 21 | −#define USB_INTERVALS_PER_SECOND 1000 | |
| 21 | +/* USB 1.1 speed configuration */ | |
| 22 | +#define USB_LOW_INTERVALS_PER_SECOND 1000 | |
| 23 | +#define USB_LOW_ISO_BUFFERS 2 | |
| 24 | + | |
| 25 | +/* USB 2.0+ speed configuration */ | |
| 26 | +#define USB_HIGH_INTERVALS_PER_SECOND 8000 | |
| 27 | +#define USB_HIGH_ISO_BUFFERS 16 | |
| 22 | 28 | |
| 23 | 29 | /* Fallback USB interval and max packet size values */ |
| 24 | 30 | #define LINE6_FALLBACK_INTERVAL 10 |
| @@ -109,12 +115,15 @@ struct usb_line6 { · 84 unmodified lines | ||
| 109 | 115 | /* Properties */ |
| 110 | 116 | const struct line6_properties *properties; |
| 111 | 117 | |
| 112 | − /* Interval (ms) */ | |
| 118 | + /* Interval for data USB packets */ | |
| 113 | 119 | int interval; |
| 120 | + /* ...for isochronous transfers framing */ | |
| 121 | + int intervals_per_second; | |
| 122 | + | |
| 114 | 123 | /* Number of isochronous URBs used for frame transfers */ |
| 115 | 124 | int iso_buffers; |
| 116 | 125 | |
| 117 | − /* Maximum size of USB packet */ | |
| 126 | + /* Maximum size of data USB packet */ | |
| 118 | 127 | int max_packet_size; |
| 119 | 128 | |
| 120 | 129 | /* Device representing the USB interface */ |
| @@ -20,9 +20,6 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | #include "driver.h" |
| 22 | 22 | |
| 23 | −/* number of URBs */ | |
| 24 | −#define LINE6_ISO_BUFFERS 2 | |
| 25 | − | |
| 26 | 23 | /* |
| 27 | 24 | number of USB frames per URB |
| 28 | 25 | The Line 6 Windows driver always transmits two frames per packet, but |
| @@ -31,7 +28,9 @@ · 2 unmodified lines | ||
| 31 | 28 | */ |
| 32 | 29 | #define LINE6_ISO_PACKETS 1 |
| 33 | 30 | |
| 34 | −/* in a "full speed" device (such as the PODxt Pro) this means 1ms */ | |
| 31 | +/* in a "full speed" device (such as the PODxt Pro) this means 1ms, | |
| 32 | + * for "high speed" it's 1/8ms | |
| 33 | + */ | |
| 35 | 34 | #define LINE6_ISO_INTERVAL 1 |
| 36 | 35 | |
| 37 | 36 | #define LINE6_IMPULSE_DEFAULT_PERIOD 100 |
| @@ -151,7 +151,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) · 150 unmodified lines | ||
| 151 | 151 | line6pcm->properties->rates.rats[0].num_min; |
| 152 | 152 | const int frame_factor = |
| 153 | 153 | line6pcm->properties->rates.rats[0].den * |
| 154 | − (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); | |
| 154 | + (line6pcm->line6->intervals_per_second / LINE6_ISO_INTERVAL); | |
| 155 | 155 | struct urb *urb_out; |
| 156 | 156 | |
| 157 | 157 | index = find_first_zero_bit(&line6pcm->out.active_urbs, |