aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers-qmi.c
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/mm-modem-helpers-qmi.c
parentf370c096ec53c35e9b28a4ba966eade42c07f375 (diff)
modem-helpers-qmi: new helper to build array of supported capabilities
Diffstat (limited to 'src/mm-modem-helpers-qmi.c')
-rw-r--r--src/mm-modem-helpers-qmi.c45
1 files changed, 44 insertions, 1 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)