diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2022-10-12 22:18:02 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2022-10-12 22:18:02 +0200 |
commit | 56a79f60e10266ba094d1ca92e0ae887edade777 (patch) | |
tree | 3853f1250f8d4123fcd83a8276a85dfe78200c45 /src | |
parent | 6005fb3ea81340ca975c5091722394c9e811fb13 (diff) |
usb: Claim and set interface alt-setting only for used lines
If a line is not auto-created, there is no point on claiming the
matching interface and even less point setting the alt setting that
will try to use USB isoc bandwith.
With this you can no use only line 1 and not line 0 of a ice1usb
for instance. While previously it would still "enable" line 0 and
then line 1 would fail because on BW issues most of the case.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Iea5d72272f11875e7a32c78b60c188590deda831
Diffstat (limited to 'src')
-rw-r--r-- | src/usb.c | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -904,21 +904,6 @@ _e1_usb_open_device(struct e1_daemon *e1d, struct libusb_device *dev) } } - /* Get interface and set it up */ - ret = libusb_claim_interface(devh, id->bInterfaceNumber); - if (ret) { - LOGP(DE1D, LOGL_ERROR, "Failed to claim interface %d:%s\n", id->bInterfaceNumber, - libusb_strerror(ret)); - goto next_interface; - } - - ret = libusb_set_interface_alt_setting(devh, id->bInterfaceNumber, 1); - if (ret) { - LOGP(DE1D, LOGL_ERROR, "Failed to set interface %d altsetting:%s\n", id->bInterfaceNumber, - libusb_strerror(ret)); - goto next_interface; - } - /* Setup driver data and find endpoints */ line_data = talloc_zero(e1d->ctx, struct e1_usb_line_data); @@ -965,6 +950,22 @@ _e1_usb_open_device(struct e1_daemon *e1d, struct libusb_device *dev) line->drv_data = line_data; } + /* Get interface and set it up */ + ret = libusb_claim_interface(devh, id->bInterfaceNumber); + if (ret) { + LOGP(DE1D, LOGL_ERROR, "Failed to claim interface %d:%s\n", id->bInterfaceNumber, + libusb_strerror(ret)); + goto next_interface; + } + + ret = libusb_set_interface_alt_setting(devh, id->bInterfaceNumber, 1); + if (ret) { + LOGP(DE1D, LOGL_ERROR, "Failed to set interface %d altsetting:%s\n", id->bInterfaceNumber, + libusb_strerror(ret)); + goto next_interface; + } + + /* Create data flows and start the line */ line_data->flow_in = e1uf_create(line, e1_usb_xfer_in, line_data->ep_in, 4, line_data->pkt_size, 4); line_data->flow_out = e1uf_create(line, e1_usb_xfer_out, line_data->ep_out, 4, line_data->pkt_size, 4); line_data->flow_fb = e1uf_create(line, e1_usb_xfer_fb, line_data->ep_fb, 2, 3, 1); |