diff options
Diffstat (limited to 'src/mm-broadband-modem-qmi.c')
-rw-r--r-- | src/mm-broadband-modem-qmi.c | 347 |
1 files changed, 6 insertions, 341 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index c63618f1..9f1927c3 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -1306,341 +1306,6 @@ modem_load_unlock_retries (MMIfaceModem *_self, } /*****************************************************************************/ -/* Load supported bands (Modem interface) */ - -static GArray * -modem_load_supported_bands_finish (MMIfaceModem *_self, - GAsyncResult *res, - GError **error) -{ - 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) - g_array_unref (self->priv->supported_bands); - - /* Cache the supported bands value */ - self->priv->supported_bands = g_array_ref (supported_bands); - } - return supported_bands; -} - -static void -dms_get_band_capabilities_ready (QmiClientDms *client, - GAsyncResult *res, - GTask *task) -{ - QmiMessageDmsGetBandCapabilitiesOutput *output; - GError *error = NULL; - - output = qmi_client_dms_get_band_capabilities_finish (client, res, &error); - if (!output) { - g_prefix_error (&error, "QMI operation failed: "); - g_task_return_error (task, error); - } else if (!qmi_message_dms_get_band_capabilities_output_get_result (output, &error)) { - g_prefix_error (&error, "Couldn't get band capabilities: "); - g_task_return_error (task, error); - } else { - GArray *mm_bands; - QmiDmsBandCapability qmi_bands = 0; - QmiDmsLteBandCapability qmi_lte_bands = 0; - - qmi_message_dms_get_band_capabilities_output_get_band_capability ( - output, - &qmi_bands, - NULL); - qmi_message_dms_get_band_capabilities_output_get_lte_band_capability ( - output, - &qmi_lte_bands, - NULL); - - mm_bands = mm_modem_bands_from_qmi_band_capabilities (qmi_bands, qmi_lte_bands); - - if (mm_bands->len == 0) { - g_array_unref (mm_bands); - g_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse the list of supported bands"); - } else { - g_task_return_pointer (task, mm_bands, (GDestroyNotify)g_array_unref); - } - } - - if (output) - qmi_message_dms_get_band_capabilities_output_unref (output); - - g_object_unref (task); -} - -static void -modem_load_supported_bands (MMIfaceModem *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - QmiClient *client = NULL; - - if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self), - QMI_SERVICE_DMS, &client, - callback, user_data)) - return; - - mm_dbg ("loading band capabilities..."); - qmi_client_dms_get_band_capabilities (QMI_CLIENT_DMS (client), - NULL, - 5, - NULL, - (GAsyncReadyCallback)dms_get_band_capabilities_ready, - g_task_new (self, NULL, callback, user_data)); -} - -/*****************************************************************************/ -/* Load current bands (Modem interface) */ - -static GArray * -modem_load_current_bands_finish (MMIfaceModem *self, - GAsyncResult *res, - GError **error) -{ - return g_task_propagate_pointer (G_TASK (res), error); -} - -#if defined WITH_NEWEST_QMI_COMMANDS - -static void -nas_get_rf_band_information_ready (QmiClientNas *client, - GAsyncResult *res, - GTask *task) -{ - QmiMessageNasGetRfBandInformationOutput *output; - GError *error = NULL; - - output = qmi_client_nas_get_rf_band_information_finish (client, res, &error); - if (!output) { - g_prefix_error (&error, "QMI operation failed: "); - g_task_return_error (task, error); - } else if (!qmi_message_nas_get_rf_band_information_output_get_result (output, &error)) { - g_prefix_error (&error, "Couldn't get current band information: "); - g_task_return_error (task, error); - } else { - GArray *mm_bands; - GArray *info_array = NULL; - - qmi_message_nas_get_rf_band_information_output_get_list (output, &info_array, NULL); - - mm_bands = mm_modem_bands_from_qmi_rf_band_information_array (info_array); - - if (mm_bands->len == 0) { - g_array_unref (mm_bands); - g_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse the list of current bands"); - } else { - g_task_return_pointer (task, mm_bands, (GDestroyNotify)g_array_unref); - } - } - - if (output) - qmi_message_nas_get_rf_band_information_output_unref (output); - - g_object_unref (task); -} - -#endif /* WITH_NEWEST_QMI_COMMANDS */ - -static void -load_bands_get_system_selection_preference_ready (QmiClientNas *client, - GAsyncResult *res, - GTask *task) -{ - QmiMessageNasGetSystemSelectionPreferenceOutput *output = NULL; - GError *error = NULL; - - output = qmi_client_nas_get_system_selection_preference_finish (client, res, &error); - if (!output) { - g_prefix_error (&error, "QMI operation failed: "); - g_task_return_error (task, error); - } else if (!qmi_message_nas_get_system_selection_preference_output_get_result (output, &error)) { - g_prefix_error (&error, "Couldn't get system selection preference: "); - g_task_return_error (task, error); - } else { - GArray *mm_bands; - QmiNasBandPreference band_preference_mask = 0; - QmiNasLteBandPreference lte_band_preference_mask = 0; - - qmi_message_nas_get_system_selection_preference_output_get_band_preference ( - output, - &band_preference_mask, - NULL); - - qmi_message_nas_get_system_selection_preference_output_get_lte_band_preference ( - output, - <e_band_preference_mask, - NULL); - - mm_bands = mm_modem_bands_from_qmi_band_preference (band_preference_mask, - lte_band_preference_mask); - - if (mm_bands->len == 0) { - g_array_unref (mm_bands); - g_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse the list of current bands"); - } else { - gchar *str; - - str = qmi_nas_band_preference_build_string_from_mask (band_preference_mask); - mm_dbg ("Bands reported in system selection preference: '%s'", str); - g_free (str); - - g_task_return_pointer (task, mm_bands, (GDestroyNotify)g_array_unref); - } - } - - if (output) - qmi_message_nas_get_system_selection_preference_output_unref (output); - - g_object_unref (task); -} - -static void -modem_load_current_bands (MMIfaceModem *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GTask *task; - QmiClient *client = NULL; - - if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self), - QMI_SERVICE_NAS, &client, - callback, user_data)) - return; - - task = g_task_new (self, NULL, callback, user_data); - - mm_dbg ("loading current bands..."); - -#if defined WITH_NEWEST_QMI_COMMANDS - /* Introduced in NAS 1.19 */ - if (qmi_client_check_version (client, 1, 19)) { - qmi_client_nas_get_rf_band_information (QMI_CLIENT_NAS (client), - NULL, - 5, - NULL, - (GAsyncReadyCallback)nas_get_rf_band_information_ready, - task); - return; - } -#endif - - qmi_client_nas_get_system_selection_preference ( - QMI_CLIENT_NAS (client), - NULL, /* no input */ - 5, - NULL, /* cancellable */ - (GAsyncReadyCallback)load_bands_get_system_selection_preference_ready, - task); -} - -/*****************************************************************************/ -/* Set current bands (Modem interface) */ - -static gboolean -set_current_bands_finish (MMIfaceModem *self, - GAsyncResult *res, - GError **error) -{ - return g_task_propagate_boolean (G_TASK (res), error); -} - -static void -bands_set_system_selection_preference_ready (QmiClientNas *client, - GAsyncResult *res, - GTask *task) -{ - QmiMessageNasSetSystemSelectionPreferenceOutput *output = NULL; - GError *error = NULL; - - output = qmi_client_nas_set_system_selection_preference_finish (client, res, &error); - if (!output) { - g_prefix_error (&error, "QMI operation failed: "); - g_task_return_error (task, error); - } else if (!qmi_message_nas_set_system_selection_preference_output_get_result (output, &error)) { - g_prefix_error (&error, "Couldn't set system selection preference: "); - g_task_return_error (task, error); - - } else - /* Good! TODO: do we really need to wait for the indication? */ - g_task_return_boolean (task, TRUE); - - if (output) - qmi_message_nas_set_system_selection_preference_output_unref (output); - - g_object_unref (task); -} - -static void -set_current_bands (MMIfaceModem *_self, - GArray *bands_array, - GAsyncReadyCallback callback, - gpointer user_data) -{ - MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self); - QmiMessageNasSetSystemSelectionPreferenceInput *input; - GTask *task; - QmiClient *client = NULL; - QmiNasBandPreference qmi_bands = 0; - QmiNasLteBandPreference qmi_lte_bands = 0; - - if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self), - QMI_SERVICE_NAS, &client, - callback, user_data)) - return; - - task = g_task_new (self, NULL, callback, user_data); - - /* Handle ANY separately */ - if (bands_array->len == 1 && - g_array_index (bands_array, MMModemBand, 0) == MM_MODEM_BAND_ANY) { - if (!self->priv->supported_bands) { - g_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Cannot handle 'ANY' if supported bands are unknown"); - g_object_unref (task); - return; - } - - mm_modem_bands_to_qmi_band_preference (self->priv->supported_bands, - &qmi_bands, - &qmi_lte_bands); - } else - mm_modem_bands_to_qmi_band_preference (bands_array, - &qmi_bands, - &qmi_lte_bands); - - input = qmi_message_nas_set_system_selection_preference_input_new (); - qmi_message_nas_set_system_selection_preference_input_set_band_preference (input, qmi_bands, NULL); - if (mm_iface_modem_is_3gpp_lte (_self)) - qmi_message_nas_set_system_selection_preference_input_set_lte_band_preference (input, qmi_lte_bands, NULL); - - qmi_message_nas_set_system_selection_preference_input_set_change_duration (input, QMI_NAS_CHANGE_DURATION_PERMANENT, NULL); - - qmi_client_nas_set_system_selection_preference ( - QMI_CLIENT_NAS (client), - input, - 5, - NULL, /* cancellable */ - (GAsyncReadyCallback)bands_set_system_selection_preference_ready, - task); - qmi_message_nas_set_system_selection_preference_input_unref (input); -} - -/*****************************************************************************/ /* Load supported IP families (Modem interface) */ static MMBearerIpFamily @@ -8881,8 +8546,8 @@ iface_modem_init (MMIfaceModem *iface) iface->load_unlock_required_finish = modem_load_unlock_required_finish; iface->load_unlock_retries = modem_load_unlock_retries; iface->load_unlock_retries_finish = modem_load_unlock_retries_finish; - iface->load_supported_bands = modem_load_supported_bands; - iface->load_supported_bands_finish = modem_load_supported_bands_finish; + iface->load_supported_bands = mm_shared_qmi_load_supported_bands; + iface->load_supported_bands_finish = mm_shared_qmi_load_supported_bands_finish; iface->load_supported_modes = mm_shared_qmi_load_supported_modes; iface->load_supported_modes_finish = mm_shared_qmi_load_supported_modes_finish; iface->load_power_state = load_power_state; @@ -8911,10 +8576,10 @@ iface_modem_init (MMIfaceModem *iface) iface->set_current_modes_finish = mm_shared_qmi_set_current_modes_finish; iface->load_signal_quality = load_signal_quality; iface->load_signal_quality_finish = load_signal_quality_finish; - iface->load_current_bands = modem_load_current_bands; - iface->load_current_bands_finish = modem_load_current_bands_finish; - iface->set_current_bands = set_current_bands; - iface->set_current_bands_finish = set_current_bands_finish; + iface->load_current_bands = mm_shared_qmi_load_current_bands; + iface->load_current_bands_finish = mm_shared_qmi_load_current_bands_finish; + iface->set_current_bands = mm_shared_qmi_set_current_bands; + iface->set_current_bands_finish = mm_shared_qmi_set_current_bands_finish; /* Don't try to load access technologies, as we would be using parent's * generic method (QCDM based). Access technologies are already reported via |