modem-helpers-qmi: new helper to build array of supported capabilities

This commit is contained in:
Aleksander Morgado
2022-01-31 22:48:57 +01:00
parent f370c096ec
commit d0c87c5877
3 changed files with 70 additions and 39 deletions
+44 -1
View File
@@ -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 {
@@ -1885,6 +1886,48 @@ mm_current_capability_from_qmi_current_capabilities_context (MMQmiCurrentCapabil
return tmp;
}
/*****************************************************************************/
/* 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
+15
View File
@@ -171,6 +171,21 @@ typedef struct {
MMModemCapability mm_current_capability_from_qmi_current_capabilities_context (MMQmiCurrentCapabilitiesContext *ctx,
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 */
+11 -38
View File
@@ -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);
ctx.dms_capabilities |= 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);
}
}
/* 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);
}