[LEDE-DEV] [PATCH 3/3] support PantechMode
Bjørn Mork
bjorn at mork.no
Mon Dec 18 06:00:56 PST 2017
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 at mork.no>
---
convert-modeswitch.pl | 9 +++++++++
switch.c | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/convert-modeswitch.pl b/convert-modeswitch.pl
index 48d0fd43bfce..b1530bd7b529 100755
--- a/convert-modeswitch.pl
+++ b/convert-modeswitch.pl
@@ -46,9 +46,15 @@ sub add_mode {
return $_[1];
}
+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 $value_mode_option = [ "Mode", \&add_mode, \&add_modeval ];
my %options = (
TargetVendor => $hex_option,
TargetProductList => [ "TargetProduct", sub { return [ map(hex,split(/,/, $_[0])) ]; } ],
@@ -64,6 +70,7 @@ my %options = (
HuaweiNewMode => $mode_option,
QuantaMode => $mode_option,
BlackberryMode => $mode_option,
+ PantechMode => $value_mode_option,
OptionMode => $mode_option,
SierraMode => $mode_option,
SonyMode => $mode_option,
@@ -116,6 +123,7 @@ sub parse_file($) {
next;
};
+ $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;
@@ -210,6 +218,7 @@ foreach my $devid (sort keys %devices) {
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 = [
diff --git a/switch.c b/switch.c
index fe25e800dc33..cc0423702398 100644
--- a/switch.c
+++ b/switch.c
@@ -3,6 +3,7 @@
enum {
DATA_MODE,
+ DATA_MODEVAL,
DATA_MSG,
DATA_INTERFACE,
DATA_MSG_EP,
@@ -392,6 +393,18 @@ static void handle_blackberry(struct usbdev_data *data, struct blob_attr **tb)
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))
@@ -418,6 +431,7 @@ enum {
MODE_OPTION,
MODE_QUANTA,
MODE_BLACKBERRY,
+ MODE_PANTECH,
__MODE_MAX
};
@@ -441,12 +455,14 @@ static const struct {
[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 },
+ [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 },
--
2.11.0
More information about the Lede-dev
mailing list