aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-05-19 15:37:47 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-05-23 00:23:17 +0200
commit9fdbbc6929cb61d4168e1696a94e5b2f07bc578e (patch)
tree533bf48bb9f4dcba25e9a40c63d6d97a2c6d5a3f
parent76f24256174039a75926cdc0ce3a6b1f03ea10ee (diff)
foxconn: setup FCC unlock step
Use the new "DMS Foxconn Set FCC authentication" command to request the modem unlock during a power up operation. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/373
-rw-r--r--configure.ac2
-rw-r--r--plugins/foxconn/mm-broadband-modem-mbim-foxconn.c67
2 files changed, 66 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index d0f42de2..66454b60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -399,7 +399,7 @@ dnl-----------------------------------------------------------------------------
dnl QMI support (enabled by default)
dnl
-LIBQMI_VERSION=1.29.6
+LIBQMI_VERSION=1.29.7
AC_ARG_WITH(qmi, AS_HELP_STRING([--without-qmi], [Build without QMI support]), [], [with_qmi=yes])
AM_CONDITIONAL(WITH_QMI, test "x$with_qmi" = "xyes")
diff --git a/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c b/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c
index 4e519bb2..bc8425e4 100644
--- a/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c
+++ b/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c
@@ -41,6 +41,7 @@
static void iface_modem_location_init (MMIfaceModemLocation *iface);
#if defined WITH_QMI
+static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
#endif
@@ -48,6 +49,7 @@ static MMIfaceModemLocation *iface_modem_location_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimFoxconn, mm_broadband_modem_mbim_foxconn, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
#if defined WITH_QMI
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
#endif
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init))
@@ -62,6 +64,62 @@ struct _MMBroadbandModemMbimFoxconnPrivate {
FeatureSupport unmanaged_gps_support;
};
+
+#if defined WITH_QMI
+
+/*****************************************************************************/
+/* FCC unlock (Modem interface) */
+
+static gboolean
+fcc_unlock_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (res), error);
+}
+
+static void
+dms_foxconn_set_fcc_authentication_ready (QmiClientDms *client,
+ GAsyncResult *res,
+ GTask *task)
+{
+ GError *error = NULL;
+ g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationOutput) output = NULL;
+
+ output = qmi_client_dms_foxconn_set_fcc_authentication_finish (client, res, &error);
+ if (!output || !qmi_message_dms_foxconn_set_fcc_authentication_output_get_result (output, &error))
+ g_task_return_error (task, error);
+ else
+ g_task_return_boolean (task, TRUE);
+ g_object_unref (task);
+}
+
+static void
+fcc_unlock (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GTask *task;
+ QmiClient *client = NULL;
+ g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationInput) input = NULL;
+
+ if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
+ QMI_SERVICE_DMS, &client,
+ callback, user_data))
+ return;
+
+ task = g_task_new (self, NULL, callback, user_data);
+
+ input = qmi_message_dms_foxconn_set_fcc_authentication_input_new ();
+ qmi_message_dms_foxconn_set_fcc_authentication_input_set_value (input, 0x00, NULL);
+ qmi_client_dms_foxconn_set_fcc_authentication (QMI_CLIENT_DMS (client),
+ input,
+ 5,
+ NULL,
+ (GAsyncReadyCallback)dms_foxconn_set_fcc_authentication_ready,
+ task);
+}
+
/*****************************************************************************/
/* Firmware update settings
*
@@ -70,8 +128,6 @@ struct _MMBroadbandModemMbimFoxconnPrivate {
* report.
*/
-#if defined WITH_QMI
-
static MMFirmwareUpdateSettings *
firmware_load_update_settings_finish (MMIfaceModemFirmware *self,
GAsyncResult *res,
@@ -483,6 +539,13 @@ iface_modem_location_init (MMIfaceModemLocation *iface)
#if defined WITH_QMI
static void
+iface_modem_init (MMIfaceModem *iface)
+{
+ iface->fcc_unlock = fcc_unlock;
+ iface->fcc_unlock_finish = fcc_unlock_finish;
+}
+
+static void
iface_modem_firmware_init (MMIfaceModemFirmware *iface)
{
iface->load_update_settings = firmware_load_update_settings;