support Quanta and Blackberry modes
[project/usbmode.git] / switch.c
index 587a2af..fe25e80 100644 (file)
--- a/switch.c
+++ b/switch.c
@@ -152,6 +152,20 @@ static void handle_huaweinew(struct usbdev_data *data, struct blob_attr **tb)
        send_messages(data, msgs, ARRAY_SIZE(msgs));
 }
 
+static void handle_option(struct usbdev_data *data, struct blob_attr **tb)
+{
+       static struct msg_entry msgs[] = {
+               {
+                       "\x55\x53\x42\x43\x12\x34\x56\x78\x00\x00\x00\x00\x00\x00\x06\x01"
+                       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 31
+               }
+       };
+
+       detach_driver(data);
+       data->need_response = false;
+       send_messages(data, msgs, ARRAY_SIZE(msgs));
+}
+
 static void handle_standardeject(struct usbdev_data *data, struct blob_attr **tb)
 {
        static struct msg_entry msgs[] = {
@@ -361,6 +375,23 @@ static void handle_mbim(struct usbdev_data *data, struct blob_attr **tb)
        }
 }
 
+static void handle_quanta(struct usbdev_data *data, struct blob_attr **tb)
+{
+       int type = LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN;
+
+       detach_driver(data);
+       send_control_packet(data, type, 0xff, 0, 0, 8);
+}
+
+static void handle_blackberry(struct usbdev_data *data, struct blob_attr **tb)
+{
+       int type = LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN;
+
+       detach_driver(data);
+       send_control_packet(data, type, 0xb1, 0x0000, 0, 8);
+       send_control_packet(data, type, 0xa9, 0x000e, 0, 8);
+}
+
 static void set_alt_setting(struct usbdev_data *data, int setting)
 {
        if (libusb_claim_interface(data->devh, data->interface))
@@ -384,6 +415,9 @@ enum {
        MODE_MOBILE_ACTION,
        MODE_CISCO,
        MODE_MBIM,
+       MODE_OPTION,
+       MODE_QUANTA,
+       MODE_BLACKBERRY,
        __MODE_MAX
 };
 
@@ -404,6 +438,9 @@ static const struct {
        [MODE_MOBILE_ACTION] = { "MobileAction", handle_mobile_action },
        [MODE_CISCO] = { "Cisco", handle_cisco },
        [MODE_MBIM] = { "MBIM", handle_mbim },
+       [MODE_OPTION] = { "Option", handle_option },
+       [MODE_QUANTA] = { "Quanta", handle_quanta },
+       [MODE_BLACKBERRY] = { "Blackberry", handle_blackberry },
 };
 
 void handle_switch(struct usbdev_data *data)