aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers-qmi.c
diff options
context:
space:
mode:
authorPrakash Pabba <quic_ppabba@quicinc.com>2021-08-31 18:05:59 +0530
committerPrakash Pabba <quic_ppabba@quicinc.com>2021-11-14 20:19:37 +0530
commit103eb9cf29d0dc550b42cecb1e2fe8d6f5d80377 (patch)
tree26b603369a1a867b273ebfdfa182746ed2880ad7 /src/mm-modem-helpers-qmi.c
parent6e1cb371ca26efda0454328e6e2af864ddd2b992 (diff)
shared-qmi,modem-helpers-qmi: Add support for NR5G band preference
Implement support for the NR5G band list to get current NR5G bands. This will also allow us to configure supported NR5G bands via mmcli.
Diffstat (limited to 'src/mm-modem-helpers-qmi.c')
-rw-r--r--src/mm-modem-helpers-qmi.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index 8228438d..d5316363 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -599,11 +599,50 @@ nas_add_extended_qmi_lte_bands (GArray *mm_bands,
}
}
+static void
+nas_add_qmi_nr5g_bands (GArray *mm_bands,
+ const guint64 *qmi_nr5g_bands,
+ guint qmi_nr5g_bands_size,
+ gpointer log_object)
+{
+ guint i;
+
+ g_assert (mm_bands != NULL);
+
+ for (i = 0; i < qmi_nr5g_bands_size; i++) {
+ guint j;
+
+ for (j = 0; j < 64; j++) {
+ guint val;
+
+ if (!(qmi_nr5g_bands[i] & (((guint64) 1) << j)))
+ continue;
+
+ val = 1 + j + (i * 64);
+
+ /* MM_MODEM_BAND_NGRAN_1 = 301,
+ * ...
+ * MM_MODEM_BAND_NGRAN_261 = 561
+ */
+ if (val < 1 || val > 261)
+ mm_obj_dbg (log_object, "unexpected NR5G band supported by module: NGRAN %u", val);
+ else {
+ MMModemBand band;
+
+ band = (val + MM_MODEM_BAND_NGRAN_1 - 1);
+ g_array_append_val (mm_bands, band);
+ }
+ }
+ }
+}
+
GArray *
mm_modem_bands_from_qmi_band_preference (QmiNasBandPreference qmi_bands,
QmiNasLteBandPreference qmi_lte_bands,
const guint64 *extended_qmi_lte_bands,
guint extended_qmi_lte_bands_size,
+ const guint64 *qmi_nr5g_bands,
+ guint qmi_nr5g_bands_size,
gpointer log_object)
{
GArray *mm_bands;
@@ -616,6 +655,9 @@ mm_modem_bands_from_qmi_band_preference (QmiNasBandPreference qmi_bands,
else
nas_add_qmi_lte_bands (mm_bands, qmi_lte_bands);
+ if (qmi_nr5g_bands && qmi_nr5g_bands_size)
+ nas_add_qmi_nr5g_bands (mm_bands, qmi_nr5g_bands, qmi_nr5g_bands_size, log_object);
+
return mm_bands;
}
@@ -625,6 +667,8 @@ mm_modem_bands_to_qmi_band_preference (GArray *mm_bands,
QmiNasLteBandPreference *qmi_lte_bands,
guint64 *extended_qmi_lte_bands,
guint extended_qmi_lte_bands_size,
+ guint64 *qmi_nr5g_bands,
+ guint qmi_nr5g_bands_size,
gpointer log_object)
{
guint i;
@@ -633,6 +677,8 @@ mm_modem_bands_to_qmi_band_preference (GArray *mm_bands,
*qmi_lte_bands = 0;
if (extended_qmi_lte_bands)
memset (extended_qmi_lte_bands, 0, extended_qmi_lte_bands_size * sizeof (guint64));
+ if (qmi_nr5g_bands)
+ memset (qmi_nr5g_bands, 0, qmi_nr5g_bands_size * sizeof (guint64));
for (i = 0; i < mm_bands->len; i++) {
MMModemBand band;
@@ -669,6 +715,22 @@ mm_modem_bands_to_qmi_band_preference (GArray *mm_bands,
mm_obj_dbg (log_object, "cannot add the following LTE band: '%s'",
mm_modem_band_get_string (band));
}
+ } else if (band >= MM_MODEM_BAND_NGRAN_1 && band <= MM_MODEM_BAND_NGRAN_261) {
+ if (qmi_nr5g_bands && qmi_nr5g_bands_size) {
+ /* Add NR5G band preference */
+ guint val;
+ guint j;
+ guint k;
+
+ /* it's really (band - MM_MODEM_BAND_NGRAN_1 +1 -1), because
+ * we want NGRAN1 in index 0 */
+ val = band - MM_MODEM_BAND_NGRAN_1;
+ j = val / 64;
+ g_assert (j < qmi_nr5g_bands_size);
+ k = val % 64;
+
+ qmi_nr5g_bands[j] |= ((guint64)1 << k);
+ }
} else {
/* Add non-LTE band preference */
guint j;