projects
/
project
/
usbmode.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
525e150
)
add config/altsetting switching
author
Felix Fietkau
<nbd@openwrt.org>
Fri, 31 May 2013 12:18:58 +0000
(14:18 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Fri, 31 May 2013 12:18:58 +0000
(14:18 +0200)
switch.c
patch
|
blob
|
history
diff --git
a/switch.c
b/switch.c
index ec5baa0ad6d3f24a53638b2b66cf1671401e0967..1c8a7a7ff1289b864ea8e6c31b1cf90e8d006a55 100644
(file)
--- a/
switch.c
+++ b/
switch.c
@@
-9,6
+9,8
@@
enum {
DATA_RES_EP,
DATA_RESPONSE,
DATA_RELEASE_DELAY,
DATA_RES_EP,
DATA_RESPONSE,
DATA_RELEASE_DELAY,
+ DATA_CONFIG,
+ DATA_ALT,
__DATA_MAX
};
__DATA_MAX
};
@@
-146,6
+148,15
@@
static void handle_cisco(struct usbdev_data *data, struct blob_attr **tb)
/* TODO */
}
/* TODO */
}
+static void set_alt_setting(struct usbdev_data *data, int setting)
+{
+ if (libusb_claim_interface(data->devh, data->interface))
+ return;
+
+ libusb_set_interface_alt_setting(data->devh, data->interface, setting);
+ libusb_release_interface(data->devh, data->interface);
+}
+
enum {
MODE_GENERIC,
MODE_HUAWEI,
enum {
MODE_GENERIC,
MODE_HUAWEI,
@@
-185,6
+196,8
@@
void handle_switch(struct usbdev_data *data)
[DATA_MSG_EP] = { .name = "msg_endpoint", .type = BLOBMSG_TYPE_INT32 },
[DATA_RES_EP] = { .name = "response_endpoint", .type = BLOBMSG_TYPE_INT32 },
[DATA_RESPONSE] = { .name = "response", .type = BLOBMSG_TYPE_INT32 },
[DATA_MSG_EP] = { .name = "msg_endpoint", .type = BLOBMSG_TYPE_INT32 },
[DATA_RES_EP] = { .name = "response_endpoint", .type = BLOBMSG_TYPE_INT32 },
[DATA_RESPONSE] = { .name = "response", .type = BLOBMSG_TYPE_INT32 },
+ [DATA_CONFIG] = { .name = "config", .type = BLOBMSG_TYPE_INT32 },
+ [DATA_ALT] = { .name = "alt", .type = BLOBMSG_TYPE_INT32 },
};
struct blob_attr *tb[__DATA_MAX];
int mode = MODE_GENERIC;
};
struct blob_attr *tb[__DATA_MAX];
int mode = MODE_GENERIC;
@@
-221,4
+234,18
@@
void handle_switch(struct usbdev_data *data)
}
modeswitch_cb[mode].cb(data, tb);
}
modeswitch_cb[mode].cb(data, tb);
+
+ if (tb[DATA_CONFIG]) {
+ int config, config_new;
+
+ config_new = blobmsg_get_u32(tb[DATA_CONFIG]);
+ if (libusb_get_configuration(data->devh, &config) ||
+ config != config_new)
+ libusb_set_configuration(data->devh, config_new);
+ }
+
+ if (tb[DATA_ALT]) {
+ int new = blobmsg_get_u32(tb[DATA_ALT]);
+ set_alt_setting(data, new);
+ }
}
}