aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-01-23 21:49:13 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-02-08 18:49:21 +0100
commitae4bf3a0335baa2027abb8c56d1adc1824c8a701 (patch)
tree178a657308f5cc80b3063553f77f90394acd2224
parent3b56f04e3befadd40f62568e028b1cd09a735296 (diff)
downloadexternal_libqmi-ae4bf3a0335baa2027abb8c56d1adc1824c8a701.zip
external_libqmi-ae4bf3a0335baa2027abb8c56d1adc1824c8a701.tar.gz
external_libqmi-ae4bf3a0335baa2027abb8c56d1adc1824c8a701.tar.bz2
qmi-firmware-update: support automatic mode (QMI/MBIM) detection by default
The default, if nothing specified, is the 'auto mode', which can also be explicitly selected with --device-open-auto. The user may also select an explicit mode with --device-open-mbim or --device-open-qmi.
-rw-r--r--src/qmi-firmware-update/qfu-main.c34
-rw-r--r--src/qmi-firmware-update/qfu-operation-reset.c5
-rw-r--r--src/qmi-firmware-update/qfu-operation-update.c6
-rw-r--r--src/qmi-firmware-update/qfu-operation.h7
-rw-r--r--src/qmi-firmware-update/qfu-reseter.c12
-rw-r--r--src/qmi-firmware-update/qfu-reseter.h3
-rw-r--r--src/qmi-firmware-update/qfu-updater.c17
-rw-r--r--src/qmi-firmware-update/qfu-updater.h3
-rw-r--r--src/qmi-firmware-update/qfu-utils.c28
-rw-r--r--src/qmi-firmware-update/qfu-utils.h3
10 files changed, 58 insertions, 60 deletions
diff --git a/src/qmi-firmware-update/qfu-main.c b/src/qmi-firmware-update/qfu-main.c
index f8cb144..876e1cf 100644
--- a/src/qmi-firmware-update/qfu-main.c
+++ b/src/qmi-firmware-update/qfu-main.c
@@ -54,7 +54,9 @@ static gchar *firmware_version_str;
static gchar *config_version_str;
static gchar *carrier_str;
static gboolean device_open_proxy_flag;
+static gboolean device_open_qmi_flag;
static gboolean device_open_mbim_flag;
+static gboolean device_open_auto_flag;
static gboolean ignore_version_errors_flag;
static gboolean override_download_flag;
static gint modem_storage_index_int;
@@ -261,8 +263,16 @@ static GOptionEntry context_main_entries[] = {
"Request to use the 'qmi-proxy' proxy.",
NULL
},
+ { "device-open-qmi", 0, 0, G_OPTION_ARG_NONE, &device_open_qmi_flag,
+ "Open a cdc-wdm device explicitly in QMI mode",
+ NULL
+ },
{ "device-open-mbim", 0, 0, G_OPTION_ARG_NONE, &device_open_mbim_flag,
- "Open an MBIM device with EXT_QMUX support.",
+ "Open a cdc-wdm device explicitly in MBIM mode",
+ NULL
+ },
+ { "device-open-auto", 0, 0, G_OPTION_ARG_NONE, &device_open_auto_flag,
+ "Open a cdc-wdm device in either QMI or MBIM mode (default)",
NULL
},
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &stdout_verbose_flag,
@@ -466,6 +476,7 @@ int main (int argc, char **argv)
guint n_actions;
gboolean result = FALSE;
QfuDeviceSelection *device_selection = NULL;
+ QmiDeviceOpenFlags device_open_flags = QMI_DEVICE_OPEN_FLAGS_NONE;
setlocale (LC_ALL, "");
@@ -553,6 +564,20 @@ int main (int argc, char **argv)
}
}
+ /* Validate device open flags */
+ if (action_update_flag || action_reset_flag) {
+ if (device_open_mbim_flag + device_open_qmi_flag + device_open_auto_flag > 1) {
+ g_printerr ("error: cannot specify multiple mode flags to open device\n");
+ goto out;
+ }
+ if (device_open_proxy_flag)
+ device_open_flags |= QMI_DEVICE_OPEN_FLAGS_PROXY;
+ if (device_open_mbim_flag)
+ device_open_flags |= QMI_DEVICE_OPEN_FLAGS_MBIM;
+ if (device_open_auto_flag || (!device_open_qmi_flag && !device_open_mbim_flag))
+ device_open_flags |= QMI_DEVICE_OPEN_FLAGS_AUTO;
+ }
+
/* Run */
if (action_update_flag) {
@@ -570,8 +595,7 @@ int main (int argc, char **argv)
firmware_version_str,
config_version_str,
carrier_str,
- device_open_proxy_flag,
- device_open_mbim_flag,
+ device_open_flags,
ignore_version_errors_flag,
override_download_flag,
(guint8) modem_storage_index_int,
@@ -588,9 +612,7 @@ int main (int argc, char **argv)
if (action_reset_flag) {
g_assert (QFU_IS_DEVICE_SELECTION (device_selection));
- result = qfu_operation_reset_run (device_selection,
- device_open_proxy_flag,
- device_open_mbim_flag);
+ result = qfu_operation_reset_run (device_selection, device_open_flags);
goto out;
}
diff --git a/src/qmi-firmware-update/qfu-operation-reset.c b/src/qmi-firmware-update/qfu-operation-reset.c
index 65b5e21..41af3c1 100644
--- a/src/qmi-firmware-update/qfu-operation-reset.c
+++ b/src/qmi-firmware-update/qfu-operation-reset.c
@@ -106,13 +106,12 @@ operation_reseter_run (QfuReseter *reseter)
gboolean
qfu_operation_reset_run (QfuDeviceSelection *device_selection,
- gboolean device_open_proxy,
- gboolean device_open_mbim)
+ QmiDeviceOpenFlags device_open_flags)
{
QfuReseter *reseter = NULL;
gboolean result;
- reseter = qfu_reseter_new (device_selection, NULL, device_open_proxy, device_open_mbim);
+ reseter = qfu_reseter_new (device_selection, NULL, device_open_flags);
result = operation_reseter_run (reseter);
g_object_unref (reseter);
return result;
diff --git a/src/qmi-firmware-update/qfu-operation-update.c b/src/qmi-firmware-update/qfu-operation-update.c
index 8a58984..f7aa6fd 100644
--- a/src/qmi-firmware-update/qfu-operation-update.c
+++ b/src/qmi-firmware-update/qfu-operation-update.c
@@ -121,8 +121,7 @@ qfu_operation_update_run (const gchar **images,
const gchar *firmware_version,
const gchar *config_version,
const gchar *carrier,
- gboolean device_open_proxy,
- gboolean device_open_mbim,
+ QmiDeviceOpenFlags device_open_flags,
gboolean ignore_version_errors,
gboolean override_download,
guint8 modem_storage_index,
@@ -137,8 +136,7 @@ qfu_operation_update_run (const gchar **images,
firmware_version,
config_version,
carrier,
- device_open_proxy,
- device_open_mbim,
+ device_open_flags,
ignore_version_errors,
override_download,
modem_storage_index,
diff --git a/src/qmi-firmware-update/qfu-operation.h b/src/qmi-firmware-update/qfu-operation.h
index 95c2b5e..c72c929 100644
--- a/src/qmi-firmware-update/qfu-operation.h
+++ b/src/qmi-firmware-update/qfu-operation.h
@@ -23,6 +23,7 @@
#define QFU_OPERATION_H
#include <glib.h>
+#include <libqmi-glib.h>
#include "qfu-device-selection.h"
G_BEGIN_DECLS
@@ -32,8 +33,7 @@ gboolean qfu_operation_update_run (const gchar **images,
const gchar *firmware_version,
const gchar *config_version,
const gchar *carrier,
- gboolean device_open_proxy,
- gboolean device_open_mbim,
+ QmiDeviceOpenFlags device_open_flags,
gboolean ignore_version_errors,
gboolean override_download,
guint8 modem_storage_index,
@@ -42,8 +42,7 @@ gboolean qfu_operation_update_qdl_run (const gchar **images,
QfuDeviceSelection *device_selection);
gboolean qfu_operation_verify_run (const gchar **images);
gboolean qfu_operation_reset_run (QfuDeviceSelection *device_selection,
- gboolean device_open_proxy,
- gboolean device_open_mbim);
+ QmiDeviceOpenFlags device_open_flags);
G_END_DECLS
diff --git a/src/qmi-firmware-update/qfu-reseter.c b/src/qmi-firmware-update/qfu-reseter.c
index aad09a5..7fc0c68 100644
--- a/src/qmi-firmware-update/qfu-reseter.c
+++ b/src/qmi-firmware-update/qfu-reseter.c
@@ -36,8 +36,7 @@ G_DEFINE_TYPE (QfuReseter, qfu_reseter, G_TYPE_OBJECT)
struct _QfuReseterPrivate {
QfuDeviceSelection *device_selection;
QmiClientDms *qmi_client;
- gboolean device_open_proxy;
- gboolean device_open_mbim;
+ QmiDeviceOpenFlags device_open_flags;
};
/******************************************************************************/
@@ -387,8 +386,7 @@ qfu_reseter_run (QfuReseter *self,
g_assert (ctx->cdc_wdm);
qfu_utils_new_client_dms (ctx->cdc_wdm,
3,
- self->priv->device_open_proxy,
- self->priv->device_open_mbim,
+ self->priv->device_open_flags,
FALSE,
cancellable,
(GAsyncReadyCallback) new_client_dms_ready,
@@ -400,16 +398,14 @@ qfu_reseter_run (QfuReseter *self,
QfuReseter *
qfu_reseter_new (QfuDeviceSelection *device_selection,
QmiClientDms *qmi_client,
- gboolean device_open_proxy,
- gboolean device_open_mbim)
+ QmiDeviceOpenFlags device_open_flags)
{
QfuReseter *self;
self = g_object_new (QFU_TYPE_RESETER, NULL);
self->priv->device_selection = g_object_ref (device_selection);
self->priv->qmi_client = qmi_client ? g_object_ref (qmi_client) : NULL;
- self->priv->device_open_proxy = device_open_proxy;
- self->priv->device_open_mbim = device_open_mbim;
+ self->priv->device_open_flags = device_open_flags;
return self;
}
diff --git a/src/qmi-firmware-update/qfu-reseter.h b/src/qmi-firmware-update/qfu-reseter.h
index e80f77a..56aaf9d 100644
--- a/src/qmi-firmware-update/qfu-reseter.h
+++ b/src/qmi-firmware-update/qfu-reseter.h
@@ -53,8 +53,7 @@ struct _QfuReseterClass {
GType qfu_reseter_get_type (void);
QfuReseter *qfu_reseter_new (QfuDeviceSelection *device_selection,
QmiClientDms *qmi_client,
- gboolean device_open_proxy,
- gboolean device_open_mbim);
+ QmiDeviceOpenFlags device_open_flags);
void qfu_reseter_run (QfuReseter *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
diff --git a/src/qmi-firmware-update/qfu-updater.c b/src/qmi-firmware-update/qfu-updater.c
index 10eb27c..ca22281 100644
--- a/src/qmi-firmware-update/qfu-updater.c
+++ b/src/qmi-firmware-update/qfu-updater.c
@@ -52,8 +52,7 @@ struct _QfuUpdaterPrivate {
gchar *firmware_version;
gchar *config_version;
gchar *carrier;
- gboolean device_open_proxy;
- gboolean device_open_mbim;
+ QmiDeviceOpenFlags device_open_flags;
gboolean ignore_version_errors;
gboolean override_download;
guint8 modem_storage_index;
@@ -410,8 +409,7 @@ run_context_step_qmi_client_after (GTask *task)
g_assert (ctx->cdc_wdm_file);
qfu_utils_new_client_dms (ctx->cdc_wdm_file,
1, /* single try to allocate DMS client */
- self->priv->device_open_proxy,
- self->priv->device_open_mbim,
+ self->priv->device_open_flags,
TRUE,
g_task_get_cancellable (task),
(GAsyncReadyCallback) new_client_dms_after_ready,
@@ -852,7 +850,7 @@ run_context_step_power_cycle (GTask *task)
g_assert (ctx->pending_images != NULL);
/* Boothold reset */
- reseter = qfu_reseter_new (self->priv->device_selection, ctx->qmi_client, FALSE, FALSE);
+ reseter = qfu_reseter_new (self->priv->device_selection, ctx->qmi_client, self->priv->device_open_flags);
qfu_reseter_run (reseter,
g_task_get_cancellable (task),
(GAsyncReadyCallback) reseter_run_ready,
@@ -1245,8 +1243,7 @@ run_context_step_qmi_client (GTask *task)
g_assert (ctx->cdc_wdm_file);
qfu_utils_new_client_dms (ctx->cdc_wdm_file,
3, /* initially, up to 3 tries to allocate DMS client */
- self->priv->device_open_proxy,
- self->priv->device_open_mbim,
+ self->priv->device_open_flags,
TRUE,
g_task_get_cancellable (task),
(GAsyncReadyCallback) new_client_dms_ready,
@@ -1386,8 +1383,7 @@ qfu_updater_new (QfuDeviceSelection *device_selection,
const gchar *firmware_version,
const gchar *config_version,
const gchar *carrier,
- gboolean device_open_proxy,
- gboolean device_open_mbim,
+ QmiDeviceOpenFlags device_open_flags,
gboolean ignore_version_errors,
gboolean override_download,
guint8 modem_storage_index,
@@ -1400,8 +1396,7 @@ qfu_updater_new (QfuDeviceSelection *device_selection,
self = g_object_new (QFU_TYPE_UPDATER, NULL);
self->priv->type = UPDATER_TYPE_GENERIC;
self->priv->device_selection = g_object_ref (device_selection);
- self->priv->device_open_proxy = device_open_proxy;
- self->priv->device_open_mbim = device_open_mbim;
+ self->priv->device_open_flags = device_open_flags;
self->priv->firmware_version = (firmware_version ? g_strdup (firmware_version) : NULL);
self->priv->config_version = (config_version ? g_strdup (config_version) : NULL);
self->priv->carrier = (carrier ? g_strdup (carrier) : NULL);
diff --git a/src/qmi-firmware-update/qfu-updater.h b/src/qmi-firmware-update/qfu-updater.h
index c3e4a8f..bc74a9e 100644
--- a/src/qmi-firmware-update/qfu-updater.h
+++ b/src/qmi-firmware-update/qfu-updater.h
@@ -54,8 +54,7 @@ QfuUpdater *qfu_updater_new (QfuDeviceSelection *device_selection,
const gchar *firmware_version,
const gchar *config_version,
const gchar *carrier,
- gboolean device_open_proxy,
- gboolean device_open_mbim,
+ QmiDeviceOpenFlags device_open_flags,
gboolean ignore_version_errors,
gboolean override_download,
guint8 modem_storage_index,
diff --git a/src/qmi-firmware-update/qfu-utils.c b/src/qmi-firmware-update/qfu-utils.c
index 9977f1f..32437e3 100644
--- a/src/qmi-firmware-update/qfu-utils.c
+++ b/src/qmi-firmware-update/qfu-utils.c
@@ -217,11 +217,10 @@ out:
/******************************************************************************/
typedef struct {
- QmiDevice *qmi_device;
- gboolean device_open_proxy;
- gboolean device_open_mbim;
- gint qmi_client_retries;
- QmiClientDms *qmi_client;
+ QmiDevice *qmi_device;
+ QmiDeviceOpenFlags device_open_flags;
+ gint qmi_client_retries;
+ QmiClientDms *qmi_client;
gboolean load_capabilities;
gchar *revision;
@@ -544,7 +543,6 @@ qmi_device_ready (GObject *source,
{
NewClientDmsContext *ctx;
GError *error = NULL;
- QmiDeviceOpenFlags flags = QMI_DEVICE_OPEN_FLAGS_SYNC;
ctx = (NewClientDmsContext *) g_task_get_task_data (task);
@@ -558,16 +556,12 @@ qmi_device_ready (GObject *source,
g_debug ("[qfu,utils] QMI device created");
- if (ctx->device_open_proxy)
- flags |= QMI_DEVICE_OPEN_FLAGS_PROXY;
- if (ctx->device_open_mbim)
- flags |= QMI_DEVICE_OPEN_FLAGS_MBIM;
-
g_debug ("[qfu,utils] opening QMI device (%s proxy, %s mode)...",
- ctx->device_open_proxy ? "with" : "without",
- ctx->device_open_mbim ? "mbim" : "qmi");
+ (ctx->device_open_flags & QMI_DEVICE_OPEN_FLAGS_PROXY) ? "with" : "without",
+ (ctx->device_open_flags & QMI_DEVICE_OPEN_FLAGS_MBIM) ? "mbim" : "qmi");
+
qmi_device_open (ctx->qmi_device,
- flags,
+ ctx->device_open_flags | QMI_DEVICE_OPEN_FLAGS_SYNC,
20,
g_task_get_cancellable (task),
(GAsyncReadyCallback) qmi_device_open_ready,
@@ -577,8 +571,7 @@ qmi_device_ready (GObject *source,
void
qfu_utils_new_client_dms (GFile *cdc_wdm_file,
guint retries,
- gboolean device_open_proxy,
- gboolean device_open_mbim,
+ QmiDeviceOpenFlags device_open_flags,
gboolean load_capabilities,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -589,8 +582,7 @@ qfu_utils_new_client_dms (GFile *cdc_wdm_file,
ctx = g_slice_new0 (NewClientDmsContext);
ctx->qmi_client_retries = retries;
- ctx->device_open_proxy = device_open_proxy;
- ctx->device_open_mbim = device_open_mbim;
+ ctx->device_open_flags = device_open_flags;
ctx->load_capabilities = load_capabilities;
task = g_task_new (NULL, cancellable, callback, user_data);
diff --git a/src/qmi-firmware-update/qfu-utils.h b/src/qmi-firmware-update/qfu-utils.h
index f661a3a..0111aac 100644
--- a/src/qmi-firmware-update/qfu-utils.h
+++ b/src/qmi-firmware-update/qfu-utils.h
@@ -46,8 +46,7 @@ gboolean qfu_utils_parse_cwe_version_string (const gchar *version,
void qfu_utils_new_client_dms (GFile *cdc_wdm_file,
guint retries,
- gboolean device_open_proxy,
- gboolean device_open_mbim,
+ QmiDeviceOpenFlags device_open_flags,
gboolean load_capabilities,
GCancellable *cancellable,
GAsyncReadyCallback callback,