summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-06-26 16:34:01 +0200
committerAleksander Morgado <aleksander@aleksander.es>2018-06-26 16:34:01 +0200
commitdd34e04c41c1524984c19b311f94e1cdb4f822de (patch)
tree6a97ae8dd4d89751d02cec94d5d031b5b06457aa
parent323cabb3505248348afd28960684bd5ade918070 (diff)
downloadModemManager-aleksander/dw5821e.tar.gz
shared-qmi wipaleksander/dw5821e
-rw-r--r--src/Makefile.am2
-rw-r--r--src/mm-broadband-modem-qmi.c139
-rw-r--r--src/mm-shared-qmi.c131
-rw-r--r--src/mm-shared-qmi.h63
4 files changed, 231 insertions, 104 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index be2cb02dd..7d7bc2e89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -366,6 +366,8 @@ endif
# Additional QMI support in ModemManager
if WITH_QMI
ModemManager_SOURCES += \
+ mm-shared-qmi.h \
+ mm-shared-qmi.c \
mm-sms-qmi.h \
mm-sms-qmi.c \
mm-sim-qmi.h \
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 40d6ce190..b7a65165f 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -39,6 +39,7 @@
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-signal.h"
#include "mm-iface-modem-oma.h"
+#include "mm-shared-qmi.h"
#include "mm-sim-qmi.h"
#include "mm-bearer-qmi.h"
#include "mm-sms-qmi.h"
@@ -54,6 +55,7 @@ static void iface_modem_location_init (MMIfaceModemLocation *iface);
static void iface_modem_oma_init (MMIfaceModemOma *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
static void iface_modem_signal_init (MMIfaceModemSignal *iface);
+static void shared_qmi_init (MMSharedQmi *iface);
static MMIfaceModemMessaging *iface_modem_messaging_parent;
static MMIfaceModemLocation *iface_modem_location_parent;
@@ -67,7 +69,8 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmi, mm_broadband_modem_qmi, MM_TYPE_BRO
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_SIGNAL, iface_modem_signal_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_OMA, iface_modem_oma_init)
- G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init))
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
+ G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_QMI, shared_qmi_init))
struct _MMBroadbandModemQmiPrivate {
/* Cached device IDs, retrieved by the modem interface when loading device
@@ -134,9 +137,10 @@ struct _MMBroadbandModemQmiPrivate {
/*****************************************************************************/
static QmiClient *
-peek_qmi_client (MMBroadbandModemQmi *self,
- QmiService service,
- GError **error)
+shared_qmi_peek_client (MMSharedQmi *self,
+ QmiService service,
+ MMPortQmiFlag flag,
+ GError **error)
{
MMPortQmi *port;
QmiClient *client;
@@ -150,9 +154,7 @@ peek_qmi_client (MMBroadbandModemQmi *self,
return NULL;
}
- client = mm_port_qmi_peek_client (port,
- service,
- MM_PORT_QMI_FLAG_DEFAULT);
+ client = mm_port_qmi_peek_client (port, service, flag);
if (!client)
g_set_error (error,
MM_CORE_ERROR,
@@ -173,7 +175,7 @@ ensure_qmi_client (MMBroadbandModemQmi *self,
GError *error = NULL;
QmiClient *client;
- client = peek_qmi_client (self, service, &error);
+ client = shared_qmi_peek_client (MM_SHARED_QMI (self), service, MM_PORT_QMI_FLAG_DEFAULT, &error);
if (!client) {
g_task_report_error (self, callback, user_data, ensure_qmi_client, error);
return FALSE;
@@ -1766,7 +1768,7 @@ load_unlock_required_context_step (GTask *task)
case LOAD_UNLOCK_REQUIRED_STEP_DMS:
if (!self->priv->dms_uim_deprecated) {
/* Failure to get DMS client is hard really */
- client = peek_qmi_client (self, QMI_SERVICE_DMS, &error);
+ client = shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_DMS, MM_PORT_QMI_FLAG_DEFAULT, &error);
if (!client) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -1787,7 +1789,7 @@ load_unlock_required_context_step (GTask *task)
case LOAD_UNLOCK_REQUIRED_STEP_UIM:
/* Failure to get UIM client at this point is hard as well */
- client = peek_qmi_client (self, QMI_SERVICE_UIM, &error);
+ client = shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_UIM, MM_PORT_QMI_FLAG_DEFAULT, &error);
if (!client) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -1883,7 +1885,7 @@ uim_load_unlock_retries (MMBroadbandModemQmi *self,
QmiClient *client;
GError *error = NULL;
- client = peek_qmi_client (self, QMI_SERVICE_UIM, &error);
+ client = shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_UIM, MM_PORT_QMI_FLAG_DEFAULT, &error);
if (!client) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -1972,7 +1974,7 @@ dms_uim_load_unlock_retries (MMBroadbandModemQmi *self,
{
QmiClient *client;
- client = peek_qmi_client (self, QMI_SERVICE_DMS, NULL);
+ client = shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_DMS, MM_PORT_QMI_FLAG_DEFAULT, NULL);
if (!client) {
/* Very unlikely that this will ever happen, but anyway, try with
* UIM service instead */
@@ -2016,7 +2018,7 @@ modem_load_supported_bands_finish (MMIfaceModem *_self,
{
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
GArray *supported_bands;
-
+
supported_bands = g_task_propagate_pointer (G_TASK (res), error);
if (supported_bands) {
if (self->priv->supported_bands)
@@ -7029,13 +7031,11 @@ messaging_check_support (MMIfaceModemMessaging *self,
gpointer user_data)
{
GTask *task;
- MMPortQmi *port;
task = g_task_new (self, NULL, callback, user_data);
- port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
/* If we have support for the WMS client, messaging is supported */
- if (!port || !mm_port_qmi_peek_client (port, QMI_SERVICE_WMS, MM_PORT_QMI_FLAG_DEFAULT)) {
+ if (!shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_WMS, MM_PORT_QMI_FLAG_DEFAULT, NULL)) {
/* Try to fallback to AT support */
iface_modem_messaging_parent->check_support (
self,
@@ -8059,78 +8059,6 @@ messaging_create_sms (MMIfaceModemMessaging *_self)
}
/*****************************************************************************/
-/* Location capabilities loading (Location interface) */
-
-static MMModemLocationSource
-location_load_capabilities_finish (MMIfaceModemLocation *self,
- GAsyncResult *res,
- GError **error)
-{
- GError *inner_error = NULL;
- gssize value;
-
- value = g_task_propagate_int (G_TASK (res), &inner_error);
- if (inner_error) {
- g_propagate_error (error, inner_error);
- return MM_MODEM_LOCATION_SOURCE_NONE;
- }
- return (MMModemLocationSource)value;
-}
-
-static void
-parent_load_capabilities_ready (MMIfaceModemLocation *self,
- GAsyncResult *res,
- GTask *task)
-{
- MMModemLocationSource sources;
- GError *error = NULL;
- MMPortQmi *port;
-
- sources = iface_modem_location_parent->load_capabilities_finish (self, res, &error);
- if (error) {
- g_task_return_error (task, error);
- g_object_unref (task);
- return;
- }
-
- port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
-
- /* Now our own checks */
-
- /* If we have support for the PDS client, GPS and A-GPS location is supported */
- if (port && mm_port_qmi_peek_client (port,
- QMI_SERVICE_PDS,
- MM_PORT_QMI_FLAG_DEFAULT))
- sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
- MM_MODEM_LOCATION_SOURCE_GPS_RAW |
- MM_MODEM_LOCATION_SOURCE_AGPS);
-
- /* If the modem is CDMA, we have support for CDMA BS location */
- if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (self)))
- sources |= MM_MODEM_LOCATION_SOURCE_CDMA_BS;
-
- /* So we're done, complete */
- g_task_return_int (task, sources);
- g_object_unref (task);
-}
-
-static void
-location_load_capabilities (MMIfaceModemLocation *self,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GTask *task;
-
- task = g_task_new (self, NULL, callback, user_data);
-
- /* Chain up parent's setup */
- iface_modem_location_parent->load_capabilities (
- self,
- (GAsyncReadyCallback)parent_load_capabilities_ready,
- task);
-}
-
-/*****************************************************************************/
/* Load SUPL server */
static gchar *
@@ -8981,7 +8909,7 @@ parent_enable_location_gathering_ready (MMIfaceModemLocation *_self,
}
/* Setup context and client */
- client = peek_qmi_client (self, QMI_SERVICE_PDS, &error);
+ client = shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_PDS, MM_PORT_QMI_FLAG_DEFAULT, &error);
if (!client) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -9075,13 +9003,11 @@ oma_check_support (MMIfaceModemOma *self,
gpointer user_data)
{
GTask *task;
- MMPortQmi *port;
task = g_task_new (self, NULL, callback, user_data);
- port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
/* If we have support for the OMA client, OMA is supported */
- if (!port || !mm_port_qmi_peek_client (port, QMI_SERVICE_OMA, MM_PORT_QMI_FLAG_DEFAULT)) {
+ if (!shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_OMA, MM_PORT_QMI_FLAG_DEFAULT, NULL)) {
mm_dbg ("OMA capabilities not supported");
g_task_return_boolean (task, FALSE);
} else {
@@ -10346,20 +10272,19 @@ signal_check_support (MMIfaceModemSignal *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- MMPortQmi *port;
- gboolean supported = FALSE;
GTask *task;
- port = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
+ task = g_task_new (self, NULL, callback, user_data);
/* If NAS service is available, assume either signal info or signal strength are supported */
- if (port)
- supported = !!mm_port_qmi_peek_client (port, QMI_SERVICE_NAS, MM_PORT_QMI_FLAG_DEFAULT);
-
- mm_dbg ("Extended signal capabilities %ssupported", supported ? "" : "not ");
-
- task = g_task_new (self, NULL, callback, user_data);
- g_task_return_boolean (task, supported);
+ /* If we have support for the OMA client, OMA is supported */
+ if (!shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_NAS, MM_PORT_QMI_FLAG_DEFAULT, NULL)) {
+ mm_dbg ("Extended signal capabilities not supported");
+ g_task_return_boolean (task, FALSE);
+ } else {
+ mm_dbg ("Extended signal capabilities supported");
+ g_task_return_boolean (task, TRUE);
+ }
g_object_unref (task);
}
@@ -11359,8 +11284,8 @@ iface_modem_location_init (MMIfaceModemLocation *iface)
{
iface_modem_location_parent = g_type_interface_peek_parent (iface);
- iface->load_capabilities = location_load_capabilities;
- iface->load_capabilities_finish = location_load_capabilities_finish;
+ iface->load_capabilities = mm_shared_qmi_location_load_capabilities;
+ iface->load_capabilities_finish = mm_shared_qmi_location_load_capabilities_finish;
iface->load_supl_server = location_load_supl_server;
iface->load_supl_server_finish = location_load_supl_server_finish;
iface->set_supl_server = location_set_supl_server;
@@ -11419,6 +11344,12 @@ iface_modem_firmware_init (MMIfaceModemFirmware *iface)
}
static void
+shared_qmi_init (MMSharedQmi *iface)
+{
+ iface->peek_client = shared_qmi_peek_client;
+}
+
+static void
mm_broadband_modem_qmi_class_init (MMBroadbandModemQmiClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c
new file mode 100644
index 000000000..d602b464e
--- /dev/null
+++ b/src/mm-shared-qmi.c
@@ -0,0 +1,131 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include <libqmi-glib.h>
+
+#include "mm-iface-modem.h"
+#include "mm-iface-modem-location.h"
+#include "mm-shared-qmi.h"
+
+/*****************************************************************************/
+
+MMModemLocationSource
+mm_shared_qmi_location_load_capabilities_finish (MMIfaceModemLocation *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ GError *inner_error = NULL;
+ gssize value;
+
+ value = g_task_propagate_int (G_TASK (res), &inner_error);
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
+ return MM_MODEM_LOCATION_SOURCE_NONE;
+ }
+ return (MMModemLocationSource)value;
+}
+
+static void
+parent_load_capabilities_ready (MMIfaceModemLocation *self,
+ GAsyncResult *res,
+ GTask *task)
+{
+ MMIfaceModemLocation *parent_iface;
+ MMModemLocationSource sources;
+ GError *error = NULL;
+
+ parent_iface = g_type_interface_peek_parent (MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self));
+ sources = parent_iface->load_capabilities_finish (self, res, &error);
+ if (error) {
+ g_task_return_error (task, error);
+ g_object_unref (task);
+ return;
+ }
+
+ /* Now our own checks */
+
+ /* If we have support for the PDS client, GPS and A-GPS location is supported */
+ if (mm_shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_PDS, MM_PORT_QMI_FLAG_DEFAULT, NULL))
+ sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
+ MM_MODEM_LOCATION_SOURCE_GPS_RAW |
+ MM_MODEM_LOCATION_SOURCE_AGPS);
+
+ /* If the modem is CDMA, we have support for CDMA BS location */
+ if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (self)))
+ sources |= MM_MODEM_LOCATION_SOURCE_CDMA_BS;
+
+ /* So we're done, complete */
+ g_task_return_int (task, sources);
+ g_object_unref (task);
+}
+
+void
+mm_shared_qmi_location_load_capabilities (MMIfaceModemLocation *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ MMIfaceModemLocation *parent_iface;
+ GTask *task;
+
+ task = g_task_new (self, NULL, callback, user_data);
+
+ parent_iface = g_type_interface_peek_parent (MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self));
+ parent_iface->load_capabilities (self,
+ (GAsyncReadyCallback)parent_load_capabilities_ready,
+ task);
+}
+
+/*****************************************************************************/
+
+QmiClient *
+mm_shared_qmi_peek_client (MMSharedQmi *self,
+ QmiService service,
+ MMPortQmiFlag flag,
+ GError **error)
+{
+ g_assert (MM_SHARED_QMI_GET_INTERFACE (self)->peek_client);
+ return MM_SHARED_QMI_GET_INTERFACE (self)->peek_client (self, service, flag, error);
+}
+
+static void
+shared_qmi_init (gpointer g_iface)
+{
+}
+
+GType
+mm_shared_qmi_get_type (void)
+{
+ static GType shared_qmi_type = 0;
+
+ if (!G_UNLIKELY (shared_qmi_type)) {
+ static const GTypeInfo info = {
+ sizeof (MMSharedQmi), /* class_size */
+ shared_qmi_init, /* base_init */
+ NULL, /* base_finalize */
+ };
+
+ shared_qmi_type = g_type_register_static (G_TYPE_INTERFACE, "MMSharedQmi", &info, 0);
+ g_type_interface_add_prerequisite (shared_qmi_type, MM_TYPE_IFACE_MODEM);
+ g_type_interface_add_prerequisite (shared_qmi_type, MM_TYPE_IFACE_MODEM_LOCATION);
+ }
+
+ return shared_qmi_type;
+}
diff --git a/src/mm-shared-qmi.h b/src/mm-shared-qmi.h
new file mode 100644
index 000000000..40cfdaf6a
--- /dev/null
+++ b/src/mm-shared-qmi.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#ifndef MM_SHARED_QMI_H
+#define MM_SHARED_QMI_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include <libqmi-glib.h>
+
+#include "mm-iface-modem-location.h"
+#include "mm-port-qmi.h"
+
+#define MM_TYPE_SHARED_QMI (mm_shared_qmi_get_type ())
+#define MM_SHARED_QMI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_QMI, MMSharedQmi))
+#define MM_IS_SHARED_QMI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_QMI))
+#define MM_SHARED_QMI_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_QMI, MMSharedQmi))
+
+typedef struct _MMSharedQmi MMSharedQmi;
+
+struct _MMSharedQmi {
+ GTypeInterface g_iface;
+
+ QmiClient * (* peek_client) (MMSharedQmi *self,
+ QmiService service,
+ MMPortQmiFlag flag,
+ GError **error);
+};
+
+GType mm_shared_qmi_get_type (void);
+
+QmiClient *mm_shared_qmi_peek_client (MMSharedQmi *self,
+ QmiService service,
+ MMPortQmiFlag flag,
+ GError **error);
+QmiClient *mm_shared_qmi_peek_client_default (MMSharedQmi *self,
+ QmiService service,
+ GError **error);
+
+void mm_shared_qmi_location_load_capabilities (MMIfaceModemLocation *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMModemLocationSource mm_shared_qmi_location_load_capabilities_finish (MMIfaceModemLocation *self,
+ GAsyncResult *res,
+ GError **error);
+
+#endif /* MM_SHARED_QMI_H */