The behaviour of the usb_modeswitch "Pantech" mode depends on the
option value, so we need to propagate this via the json config to
the usbmode tool.
Signed-off-by: Bjørn Mork <bjorn@mork.no>
+sub add_modeval {
+ return unless ($_[1] && $_[1] =~ /^\d+$/);
+ $_[0]->{"ModeValue"} = $_[1];
+}
+
my $hex_option = [ undef, \&add_hex ];
my $msg_option = [ undef, \&add_message ];
my $mode_option = [ "Mode", \&add_mode ];
my $hex_option = [ undef, \&add_hex ];
my $msg_option = [ undef, \&add_message ];
my $mode_option = [ "Mode", \&add_mode ];
+my $value_mode_option = [ "Mode", \&add_mode, \&add_modeval ];
my %options = (
TargetVendor => $hex_option,
TargetProductList => [ "TargetProduct", sub { return [ map(hex,split(/,/, $_[0])) ]; } ],
my %options = (
TargetVendor => $hex_option,
TargetProductList => [ "TargetProduct", sub { return [ map(hex,split(/,/, $_[0])) ]; } ],
HuaweiNewMode => $mode_option,
QuantaMode => $mode_option,
BlackberryMode => $mode_option,
HuaweiNewMode => $mode_option,
QuantaMode => $mode_option,
BlackberryMode => $mode_option,
+ PantechMode => $value_mode_option,
OptionMode => $mode_option,
SierraMode => $mode_option,
SonyMode => $mode_option,
OptionMode => $mode_option,
SierraMode => $mode_option,
SonyMode => $mode_option,
+ $opt->[2] and &{$opt->[2]}($dev, $val, $var);
$opt->[1] and $val = &{$opt->[1]}($val, $var);
$opt->[0] and $var = $opt->[0];
$dev->{$var} = $val;
$opt->[1] and $val = &{$opt->[1]}($val, $var);
$opt->[0] and $var = $opt->[0];
$dev->{$var} = $val;
dev_opt($cur->{TargetClass}, "t_class", "int", \$sep);
dev_opt($cur->{DetachStorageOnly}, "detach_storage", "bool", \$sep);
dev_opt($cur->{Mode}, "mode", "string", \$sep);
dev_opt($cur->{TargetClass}, "t_class", "int", \$sep);
dev_opt($cur->{DetachStorageOnly}, "detach_storage", "bool", \$sep);
dev_opt($cur->{Mode}, "mode", "string", \$sep);
+ dev_opt($cur->{ModeValue}, "modeval", "int", \$sep);
dev_opt($cur->{NoDriverLoading}, "no_driver", "bool", \$sep);
dev_opt($cur->{MessageEndpoint}, "msg_endpoint", "int", \$sep);
my $msg = [
dev_opt($cur->{NoDriverLoading}, "no_driver", "bool", \$sep);
dev_opt($cur->{MessageEndpoint}, "msg_endpoint", "int", \$sep);
my $msg = [
DATA_MSG,
DATA_INTERFACE,
DATA_MSG_EP,
DATA_MSG,
DATA_INTERFACE,
DATA_MSG_EP,
send_control_packet(data, type, 0xa9, 0x000e, 0, 8);
}
send_control_packet(data, type, 0xa9, 0x000e, 0, 8);
}
+static void handle_pantech(struct usbdev_data *data, struct blob_attr **tb)
+{
+ int type = LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT;
+ int val = 1;
+
+ if (tb[DATA_MODEVAL])
+ val = blobmsg_get_u32(tb[DATA_MODEVAL]);
+ detach_driver(data);
+ if (val > 1)
+ send_control_packet(data, type, 0x70, val, 0, 0);
+}
+
static void set_alt_setting(struct usbdev_data *data, int setting)
{
if (libusb_claim_interface(data->devh, data->interface))
static void set_alt_setting(struct usbdev_data *data, int setting)
{
if (libusb_claim_interface(data->devh, data->interface))
MODE_OPTION,
MODE_QUANTA,
MODE_BLACKBERRY,
MODE_OPTION,
MODE_QUANTA,
MODE_BLACKBERRY,
[MODE_OPTION] = { "Option", handle_option },
[MODE_QUANTA] = { "Quanta", handle_quanta },
[MODE_BLACKBERRY] = { "Blackberry", handle_blackberry },
[MODE_OPTION] = { "Option", handle_option },
[MODE_QUANTA] = { "Quanta", handle_quanta },
[MODE_BLACKBERRY] = { "Blackberry", handle_blackberry },
+ [MODE_PANTECH] = { "Pantech", handle_pantech },
};
void handle_switch(struct usbdev_data *data)
{
static const struct blobmsg_policy data_policy[__DATA_MAX] = {
[DATA_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
};
void handle_switch(struct usbdev_data *data)
{
static const struct blobmsg_policy data_policy[__DATA_MAX] = {
[DATA_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
+ [DATA_MODEVAL] = { .name = "modeval", .type = BLOBMSG_TYPE_INT32 },
[DATA_MSG] = { .name = "msg", .type = BLOBMSG_TYPE_ARRAY },
[DATA_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_INT32 },
[DATA_MSG_EP] = { .name = "msg_endpoint", .type = BLOBMSG_TYPE_INT32 },
[DATA_MSG] = { .name = "msg", .type = BLOBMSG_TYPE_ARRAY },
[DATA_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_INT32 },
[DATA_MSG_EP] = { .name = "msg_endpoint", .type = BLOBMSG_TYPE_INT32 },