diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-01-12 16:56:55 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-04-11 18:40:15 +0200 |
commit | 9accd222e4f060e6c0b2d551b259eff4f709b653 (patch) | |
tree | a886cf1372c92e20e13fcc570e8a7a883a844f31 | |
parent | 0c154b7d5fb7d64406f6612bf1dacdf1bbe2de76 (diff) |
dms: add Dell-specific extension to switch to Fastboot mode
E.g. supported in the DW5821e.
(cherry picked from commit c5b507e51b10c102305678769ef9d41ce8cdfe6b)
-rw-r--r-- | data/qmi-service-dms.json | 18 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/libqmi-glib-common.sections | 5 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/libqmi-glib-docs.xml | 1 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-enums-dms.h | 25 | ||||
-rw-r--r-- | src/qmicli/qmicli-dms.c | 86 | ||||
-rw-r--r-- | src/qmicli/qmicli-helpers.c | 21 | ||||
-rw-r--r-- | src/qmicli/qmicli-helpers.h | 2 |
7 files changed, 157 insertions, 1 deletions
diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json index 3ea0b78..130f453 100644 --- a/data/qmi-service-dms.json +++ b/data/qmi-service-dms.json @@ -1415,6 +1415,22 @@ "id" : "0x555F", "version" : "1.0", "since" : "1.14", - "output" : [ { "common-ref" : "Operation Result" } ] } + "output" : [ { "common-ref" : "Operation Result" } ] }, + + // ********************************************************************************* + { "name" : "Dell Change Device Mode", + "type" : "Message", + "service" : "DMS", + "id" : "0x5562", + "vendor" : "0x413c", + "version" : "1.0", + "since" : "1.24", + "input" : [ { "name" : "Mode", + "id" : "0x01", + "type" : "TLV", + "since" : "1.24", + "format" : "guint8", + "public-format" : "QmiDmsDellDeviceMode" } ], + "output" : [ { "common-ref" : "Operation Result" } ] } ] diff --git a/docs/reference/libqmi-glib/libqmi-glib-common.sections b/docs/reference/libqmi-glib/libqmi-glib-common.sections index 93ed0d0..68757fd 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-common.sections +++ b/docs/reference/libqmi-glib/libqmi-glib-common.sections @@ -166,6 +166,7 @@ QmiDmsFirmwareImageType QmiDmsBootImageDownloadMode QmiDmsHpDeviceMode QmiDmsSwiUsbComposition +QmiDmsDellDeviceMode <SUBSECTION Methods> qmi_dms_data_service_capability_get_string qmi_dms_sim_capability_get_string @@ -188,6 +189,7 @@ qmi_dms_boot_image_download_mode_get_string qmi_dms_hp_device_mode_get_string qmi_dms_swi_usb_composition_get_string qmi_dms_swi_usb_composition_get_description +qmi_dms_dell_device_mode_get_string <SUBSECTION Private> qmi_dms_data_service_capability_build_string_from_mask qmi_dms_sim_capability_build_string_from_mask @@ -207,6 +209,7 @@ qmi_dms_firmware_image_type_build_string_from_mask qmi_dms_boot_image_download_mode_build_string_from_mask qmi_dms_hp_device_mode_build_string_from_mask qmi_dms_swi_usb_composition_build_string_from_mask +qmi_dms_dell_device_mode_build_string_from_mask <SUBSECTION Standard> QMI_TYPE_DMS_ACTIVATION_STATE QMI_TYPE_DMS_BOOT_IMAGE_DOWNLOAD_MODE @@ -226,6 +229,7 @@ QMI_TYPE_DMS_UIM_PIN_STATUS QMI_TYPE_DMS_UIM_STATE QMI_TYPE_DMS_HP_DEVICE_MODE QMI_TYPE_DMS_SWI_USB_COMPOSITION +QMI_TYPE_DMS_DELL_DEVICE_MODE qmi_dms_activation_state_get_type qmi_dms_boot_image_download_mode_get_type qmi_dms_data_service_capability_get_type @@ -244,6 +248,7 @@ qmi_dms_uim_pin_status_get_type qmi_dms_uim_state_get_type qmi_dms_hp_device_mode_get_type qmi_dms_swi_usb_composition_get_type +qmi_dms_dell_device_mode_get_type </SECTION> <SECTION> diff --git a/docs/reference/libqmi-glib/libqmi-glib-docs.xml b/docs/reference/libqmi-glib/libqmi-glib-docs.xml index 4e812a5..ee25f2b 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml +++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml @@ -123,6 +123,7 @@ <xi:include href="xml/qmi-message-dms-swi-get-usb-composition.xml"/> <xi:include href="xml/qmi-message-dms-swi-set-usb-composition.xml"/> <xi:include href="xml/qmi-message-dms-set-fcc-authentication.xml"/> + <xi:include href="xml/qmi-message-dms-dell-change-device-mode.xml"/> <xi:include href="xml/qmi-message-dms-get-supported-messages.xml"/> </section> </chapter> diff --git a/src/libqmi-glib/qmi-enums-dms.h b/src/libqmi-glib/qmi-enums-dms.h index 523415e..7812925 100644 --- a/src/libqmi-glib/qmi-enums-dms.h +++ b/src/libqmi-glib/qmi-enums-dms.h @@ -582,4 +582,29 @@ const gchar *qmi_dms_swi_usb_composition_get_description (QmiDmsSwiUsbCompositio * Since: 1.20 */ +/*****************************************************************************/ +/* Helper enums for the 'QMI DMS Dell Change Device Mode' message */ + +/** + * QmiDmsDellDeviceMode: + * @QMI_DMS_DELL_DEVICE_MODE_UNKNOWN: Unknown mode. + * @QMI_DMS_DELL_DEVICE_MODE_FASTBOOT_ONLINE: Fastboot download mode for full partition files. + * @QMI_DMS_DELL_DEVICE_MODE_FASTBOOT_OTA: Fastboot download mode for OTA files. + * + * Dell specific device modes. + * + * Since: 1.24 + */ +typedef enum { + QMI_DMS_DELL_DEVICE_MODE_UNKNOWN = 0, + QMI_DMS_DELL_DEVICE_MODE_FASTBOOT_ONLINE = 0x05, + QMI_DMS_DELL_DEVICE_MODE_FASTBOOT_OTA = 0x0A, +} QmiDmsDellDeviceMode; + +/** + * qmi_dms_dell_device_mode_get_string: + * + * Since: 1.24 + */ + #endif /* _LIBQMI_GLIB_QMI_ENUMS_DMS_H_ */ diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c index 7143c55..3f9b1a3 100644 --- a/src/qmicli/qmicli-dms.c +++ b/src/qmicli/qmicli-dms.c @@ -96,6 +96,7 @@ static gchar *hp_change_device_mode_str; static gboolean swi_get_current_firmware_flag; static gboolean swi_get_usb_composition_flag; static gchar *swi_set_usb_composition_str; +static gchar *dell_change_device_mode_str; static gboolean reset_flag; static gboolean noop_flag; @@ -304,6 +305,10 @@ static GOptionEntry entries[] = { "Set USB composition (Sierra Wireless specific)", "[#]" }, + { "dms-dell-change-device-mode", 0, 0, G_OPTION_ARG_STRING, &dell_change_device_mode_str, + "Change device mode (DELL specific)", + "[fastboot-ota|fastboot-online]" + }, { "dms-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag, "Reset the service state", NULL @@ -390,6 +395,7 @@ qmicli_dms_options_enabled (void) swi_get_current_firmware_flag + swi_get_usb_composition_flag + !!swi_set_usb_composition_str + + !!dell_change_device_mode_str + reset_flag + noop_flag); @@ -3649,6 +3655,64 @@ swi_set_usb_composition_input_create (const gchar *str) return input; } +static QmiMessageDmsDellChangeDeviceModeInput * +dell_change_device_mode_input_create (const gchar *str) +{ + QmiMessageDmsDellChangeDeviceModeInput *input = NULL; + QmiDmsDellDeviceMode mode; + GError *error = NULL; + + if (!qmicli_read_dell_device_mode_from_string (str, &mode)) { + g_printerr ("error: couldn't parse input dell device mode : '%s'\n", str); + return NULL; + } + + input = qmi_message_dms_dell_change_device_mode_input_new (); + if (!qmi_message_dms_dell_change_device_mode_input_set_mode (input, mode, &error)) { + g_printerr ("error: couldn't create input data bundle: '%s'\n", + error->message); + g_error_free (error); + qmi_message_dms_dell_change_device_mode_input_unref (input); + return NULL; + } + + return input; +} + +static void +dell_change_device_mode_ready (QmiClientDms *client, + GAsyncResult *res) +{ + QmiMessageDmsDellChangeDeviceModeOutput *output; + GError *error = NULL; + + output = qmi_client_dms_dell_change_device_mode_finish (client, res, &error); + if (!output) { + g_printerr ("error: operation failed: %s\n", error->message); + g_error_free (error); + operation_shutdown (FALSE); + return; + } + + if (!qmi_message_dms_dell_change_device_mode_output_get_result (output, &error)) { + g_printerr ("error: couldn't change Dell device mode: %s\n", error->message); + g_error_free (error); + qmi_message_dms_dell_change_device_mode_output_unref (output); + operation_shutdown (FALSE); + return; + } + + g_print ("[%s] Successfully changed Dell device mode\n", + qmi_device_get_path_display (ctx->device)); + + qmi_message_dms_dell_change_device_mode_output_unref (output); + + /* Changing the mode will end up power cycling the device right away, so + * just ignore any error from now on and don't even try to release the + * client CID */ + operation_shutdown_skip_cid_release (TRUE); +} + static void reset_ready (QmiClientDms *client, GAsyncResult *res) @@ -4467,6 +4531,28 @@ qmicli_dms_run (QmiDevice *device, return; } + /* Request to change device download mode */ + if (dell_change_device_mode_str) { + QmiMessageDmsDellChangeDeviceModeInput *input; + + g_debug ("Asynchronously changing device mode (Dell specific)..."); + + input = dell_change_device_mode_input_create (dell_change_device_mode_str); + if (!input) { + operation_shutdown (FALSE); + return; + } + + qmi_client_dms_dell_change_device_mode (ctx->client, + input, + 10, + ctx->cancellable, + (GAsyncReadyCallback)dell_change_device_mode_ready, + NULL); + qmi_message_dms_dell_change_device_mode_input_unref (input); + return; + } + /* Request to reset DMS service? */ if (reset_flag) { g_debug ("Asynchronously resetting DMS service..."); diff --git a/src/qmicli/qmicli-helpers.c b/src/qmicli/qmicli-helpers.c index 3481b36..e380db5 100644 --- a/src/qmicli/qmicli-helpers.c +++ b/src/qmicli/qmicli-helpers.c @@ -757,6 +757,27 @@ qmicli_read_swi_usb_composition_from_string (const gchar *str, } gboolean +qmicli_read_dell_device_mode_from_string (const gchar *str, + QmiDmsDellDeviceMode *out) +{ + GType type; + GEnumClass *enum_class; + GEnumValue *enum_value; + + type = qmi_dms_dell_device_mode_get_type (); + enum_class = G_ENUM_CLASS (g_type_class_ref (type)); + enum_value = g_enum_get_value_by_nick (enum_class, str); + + if (enum_value) + *out = (QmiDmsDellDeviceMode)enum_value->value; + else + g_printerr ("error: invalid Dell device mode value given: '%s'\n", str); + + g_type_class_unref (enum_class); + return !!enum_value; +} + +gboolean qmicli_read_uint_from_string (const gchar *str, guint *out) { diff --git a/src/qmicli/qmicli-helpers.h b/src/qmicli/qmicli-helpers.h index ed8e61a..2307b6d 100644 --- a/src/qmicli/qmicli-helpers.h +++ b/src/qmicli/qmicli-helpers.h @@ -78,6 +78,8 @@ gboolean qmicli_read_hp_device_mode_from_string (const gchar *str, QmiDmsHpDeviceMode *out); gboolean qmicli_read_swi_usb_composition_from_string (const gchar *str, QmiDmsSwiUsbComposition *out); +gboolean qmicli_read_dell_device_mode_from_string (const gchar *str, + QmiDmsDellDeviceMode *out); gboolean qmicli_read_non_empty_string (const gchar *str, const gchar *description, |