aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2022-01-30 17:11:31 +0100
committerAleksander Morgado <aleksander@aleksander.es>2022-01-31 22:48:57 +0100
commitd0c87c5877b247ee34fb133604904404581e7814 (patch)
tree58b6338ac780439347738dd859bbaa95cc4e4754 /src
parentf370c096ec53c35e9b28a4ba966eade42c07f375 (diff)
modem-helpers-qmi: new helper to build array of supported capabilities
Diffstat (limited to 'src')
-rw-r--r--src/mm-modem-helpers-qmi.c45
-rw-r--r--src/mm-modem-helpers-qmi.h15
-rw-r--r--src/mm-shared-qmi.c49
3 files changed, 70 insertions, 39 deletions
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index f61f07a3..e33a8232 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -26,6 +26,8 @@
#include "mm-enums-types.h"
#include "mm-log-object.h"
+#define MULTIMODE (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_CDMA_EVDO)
+
/*****************************************************************************/
MMModemCapability
@@ -1842,7 +1844,6 @@ mm_current_capability_from_qmi_current_capabilities_context (MMQmiCurrentCapabil
g_autofree gchar *tmp_str = NULL;
/* If not a multimode device, we're done */
-#define MULTIMODE (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_CDMA_EVDO)
if ((ctx->dms_capabilities & MULTIMODE) != MULTIMODE)
tmp = ctx->dms_capabilities;
else {
@@ -1886,6 +1887,48 @@ mm_current_capability_from_qmi_current_capabilities_context (MMQmiCurrentCapabil
}
/*****************************************************************************/
+/* Utility to build list of supported capabilities */
+
+GArray *
+mm_supported_capabilities_from_qmi_supported_capabilities_context (MMQmiSupportedCapabilitiesContext *ctx,
+ gpointer log_object)
+{
+ GArray *supported_combinations;
+
+ supported_combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemCapability), 4);
+
+ /* Add all possible supported capability combinations.
+ * In order to avoid unnecessary modem reboots, we will only implement capabilities
+ * switching only when switching GSM/UMTS+CDMA/EVDO multimode devices, and only if
+ * we have support for the commands doing it.
+ */
+ if ((ctx->nas_tp_supported || ctx->nas_ssp_supported) &&
+ ((ctx->dms_capabilities & MULTIMODE) == MULTIMODE)) {
+ MMModemCapability single;
+
+ /* Multimode GSM/UMTS+CDMA/EVDO+(LTE/5GNR) device switched to GSM/UMTS+(LTE/5GNR) device */
+ single = MM_MODEM_CAPABILITY_GSM_UMTS | (MULTIMODE ^ ctx->dms_capabilities);
+ g_array_append_val (supported_combinations, single);
+ /* Multimode GSM/UMTS+CDMA/EVDO+(LTE/5GNR) device switched to CDMA/EVDO+(LTE/5GNR) device */
+ single = MM_MODEM_CAPABILITY_CDMA_EVDO | (MULTIMODE ^ ctx->dms_capabilities);
+ g_array_append_val (supported_combinations, single);
+ /*
+ * Multimode GSM/UMTS+CDMA/EVDO+(LTE/5GNR) device switched to (LTE/5GNR) device
+ *
+ * This case is required because we use the same methods and operations to
+ * switch capabilities and modes.
+ */
+ if ((single = (MULTIMODE ^ ctx->dms_capabilities)))
+ g_array_append_val (supported_combinations, single);
+ }
+
+ /* Add the full mask itself */
+ g_array_append_val (supported_combinations, ctx->dms_capabilities);
+
+ return supported_combinations;
+}
+
+/*****************************************************************************/
MMOmaSessionType
mm_oma_session_type_from_qmi_oma_session_type (QmiOmaSessionType qmi_session_type)
diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h
index f9671bc0..4d974d2a 100644
--- a/src/mm-modem-helpers-qmi.h
+++ b/src/mm-modem-helpers-qmi.h
@@ -172,6 +172,21 @@ MMModemCapability mm_current_capability_from_qmi_current_capabilities_context (M
gpointer log_object);
/*****************************************************************************/
+/* Utility to build list of supported capabilities from various sources */
+
+typedef struct {
+ /* NAS System Selection Preference */
+ gboolean nas_ssp_supported;
+ /* NAS Technology Preference */
+ gboolean nas_tp_supported;
+ /* DMS Capabilities */
+ MMModemCapability dms_capabilities;
+} MMQmiSupportedCapabilitiesContext;
+
+GArray *mm_supported_capabilities_from_qmi_supported_capabilities_context (MMQmiSupportedCapabilitiesContext *ctx,
+ gpointer log_object);
+
+/*****************************************************************************/
/* QMI unique id manipulation */
gchar *mm_qmi_unique_id_to_firmware_unique_id (GArray *qmi_unique_id,
diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c
index 62a72edc..828137d4 100644
--- a/src/mm-shared-qmi.c
+++ b/src/mm-shared-qmi.c
@@ -1102,12 +1102,11 @@ mm_shared_qmi_load_supported_capabilities (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GTask *task;
- Private *priv;
- MMModemCapability mask;
- MMModemCapability single;
- GArray *supported_combinations;
- guint i;
+ GTask *task;
+ Private *priv;
+ GArray *supported_combinations;
+ guint i;
+ MMQmiSupportedCapabilitiesContext ctx = { 0 };
task = g_task_new (self, NULL, callback, user_data);
@@ -1121,41 +1120,15 @@ mm_shared_qmi_load_supported_capabilities (MMIfaceModem *self,
}
/* Build mask with all supported capabilities */
- mask = MM_MODEM_CAPABILITY_NONE;
+ ctx.dms_capabilities = MM_MODEM_CAPABILITY_NONE;
for (i = 0; i < priv->supported_radio_interfaces->len; i++)
- mask |= mm_modem_capability_from_qmi_radio_interface (g_array_index (priv->supported_radio_interfaces, QmiDmsRadioInterface, i), self);
-
- supported_combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemCapability), 3);
-
- /* Add all possible supported capability combinations.
- * In order to avoid unnecessary modem reboots, we will only implement capabilities
- * switching only when switching GSM/UMTS+CDMA/EVDO multimode devices, and only if
- * we have support for the commands doing it.
- */
-#define MULTIMODE (MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_CDMA_EVDO)
- if (priv->feature_nas_tp == FEATURE_SUPPORTED || priv->feature_nas_ssp == FEATURE_SUPPORTED) {
- if ((mask & MULTIMODE) == MULTIMODE) {
- /* Multimode GSM/UMTS+CDMA/EVDO+(LTE/5GNR) device switched to GSM/UMTS+(LTE/5GNR) device */
- single = MM_MODEM_CAPABILITY_GSM_UMTS | (MULTIMODE ^ mask);
- g_array_append_val (supported_combinations, single);
- /* Multimode GSM/UMTS+CDMA/EVDO+(LTE/5GNR) device switched to CDMA/EVDO+(LTE/5GNR) device */
- single = MM_MODEM_CAPABILITY_CDMA_EVDO | (MULTIMODE ^ mask);
- g_array_append_val (supported_combinations, single);
- /*
- * Multimode GSM/UMTS+CDMA/EVDO+(LTE/5GNR) device switched to (LTE/5GNR) device
- *
- * This case is required because we use the same methods and operations to
- * switch capabilities and modes.
- */
- if ((single = (MULTIMODE ^ mask)))
- g_array_append_val (supported_combinations, single);
- }
- }
+ ctx.dms_capabilities |= mm_modem_capability_from_qmi_radio_interface (g_array_index (priv->supported_radio_interfaces, QmiDmsRadioInterface, i), self);
- /* Add the full mask itself */
- single = mask;
- g_array_append_val (supported_combinations, single);
+ ctx.nas_tp_supported = (priv->feature_nas_tp == FEATURE_SUPPORTED);
+ ctx.nas_ssp_supported = (priv->feature_nas_ssp == FEATURE_SUPPORTED);
+ /* Build list of supported combinations */
+ supported_combinations = mm_supported_capabilities_from_qmi_supported_capabilities_context (&ctx, self);
g_task_return_pointer (task, supported_combinations, (GDestroyNotify) g_array_unref);
g_object_unref (task);
}