foxconn: consolidate checks for T99W175 and T99W265

These two devices require QDU and MCFG+APPS version string
comparison. We now have a single place where we check for this
requirements.
This commit is contained in:
Aleksander Morgado
2022-03-25 14:58:40 +01:00
parent cd2dd20b08
commit ea247f7e69

View File

@@ -81,22 +81,29 @@ firmware_load_update_settings_finish (MMIfaceModemFirmware *self,
return g_task_propagate_pointer (G_TASK (res), error); return g_task_propagate_pointer (G_TASK (res), error);
} }
static gboolean
needs_qdu_and_mcfg_apps_version (MMIfaceModemFirmware *self)
{
guint vendor_id;
guint product_id;
/* 0x105b is the T99W175 module, T99W175 supports QDU and requires MCFG+APPS version.
* T99W265(0x0489:0xe0da ; 0x0489:0xe0db): supports QDU and requires MCFG+APPS version.
* else support FASTBOOT and QMI PDC, and require only MCFG version.
*/
vendor_id = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self));
product_id = mm_base_modem_get_product_id (MM_BASE_MODEM (self));
return (vendor_id == 0x105b || (vendor_id == 0x0489 && (product_id == 0xe0da || product_id == 0xe0db)));
}
static MMFirmwareUpdateSettings * static MMFirmwareUpdateSettings *
create_update_settings (MMBroadbandModemMbimFoxconn *self, create_update_settings (MMIfaceModemFirmware *self,
const gchar *version_str) const gchar *version_str)
{ {
MMModemFirmwareUpdateMethod methods = MM_MODEM_FIRMWARE_UPDATE_METHOD_NONE; MMModemFirmwareUpdateMethod methods = MM_MODEM_FIRMWARE_UPDATE_METHOD_NONE;
MMFirmwareUpdateSettings *update_settings = NULL; MMFirmwareUpdateSettings *update_settings = NULL;
guint vendor_id;
guint product_id;
/* 0x105b is the T99W175 module, T99W175 supports QDU, if (needs_qdu_and_mcfg_apps_version (self))
* T99W265(0x0489:0xe0da ; 0x0489:0xe0db): supports QDU
* else support FASTBOOT and QMI PDC.
*/
vendor_id = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self));
product_id = mm_base_modem_get_product_id (MM_BASE_MODEM (self));
if (vendor_id == 0x105b || (vendor_id == 0x0489 && (product_id == 0xe0da || product_id == 0xe0db)))
methods = MM_MODEM_FIRMWARE_UPDATE_METHOD_MBIM_QDU; methods = MM_MODEM_FIRMWARE_UPDATE_METHOD_MBIM_QDU;
else else
methods = MM_MODEM_FIRMWARE_UPDATE_METHOD_FASTBOOT | MM_MODEM_FIRMWARE_UPDATE_METHOD_QMI_PDC; methods = MM_MODEM_FIRMWARE_UPDATE_METHOD_FASTBOOT | MM_MODEM_FIRMWARE_UPDATE_METHOD_QMI_PDC;
@@ -162,26 +169,11 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
gpointer user_data) gpointer user_data)
{ {
GTask *task; GTask *task;
QmiFoxFirmwareVersionType fox_version_type;
QmiClient *fox_client = NULL; QmiClient *fox_client = NULL;
QmiDmsFoxconnFirmwareVersionType dms_version_type;
QmiClient *dms_client = NULL; QmiClient *dms_client = NULL;
guint vendor_id;
guint product_id;
task = g_task_new (self, NULL, callback, user_data); task = g_task_new (self, NULL, callback, user_data);
/* 0x105b is the T99W175 module, T99W175/T99W265 need to compare the apps version. */
vendor_id = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self));
product_id = mm_base_modem_get_product_id (MM_BASE_MODEM (self));
if (vendor_id == 0x105b || (vendor_id == 0x0489 && (product_id == 0xe0da || product_id == 0xe0db))) {
fox_version_type = QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS;
dms_version_type = QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS;
} else {
fox_version_type = QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG;
dms_version_type = QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG;
}
/* Try to get firmware version over fox service, if it failed to peek client, try dms service. */ /* Try to get firmware version over fox service, if it failed to peek client, try dms service. */
fox_client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_FOX, MM_PORT_QMI_FLAG_DEFAULT, NULL); fox_client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_FOX, MM_PORT_QMI_FLAG_DEFAULT, NULL);
if (!fox_client) { if (!fox_client) {
@@ -198,7 +190,11 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL; g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL;
input = qmi_message_fox_get_firmware_version_input_new (); input = qmi_message_fox_get_firmware_version_input_new ();
qmi_message_fox_get_firmware_version_input_set_version_type (input, fox_version_type, NULL); qmi_message_fox_get_firmware_version_input_set_version_type (input,
(needs_qdu_and_mcfg_apps_version (self) ?
QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS :
QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG),
NULL);
qmi_client_fox_get_firmware_version (QMI_CLIENT_FOX (fox_client), qmi_client_fox_get_firmware_version (QMI_CLIENT_FOX (fox_client),
input, input,
10, 10,
@@ -212,7 +208,11 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionInput) input = NULL; g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionInput) input = NULL;
input = qmi_message_dms_foxconn_get_firmware_version_input_new (); input = qmi_message_dms_foxconn_get_firmware_version_input_new ();
qmi_message_dms_foxconn_get_firmware_version_input_set_version_type (input, dms_version_type, NULL); qmi_message_dms_foxconn_get_firmware_version_input_set_version_type (input,
(needs_qdu_and_mcfg_apps_version (self) ?
QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS:
QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG),
NULL);
qmi_client_dms_foxconn_get_firmware_version (QMI_CLIENT_DMS (dms_client), qmi_client_dms_foxconn_get_firmware_version (QMI_CLIENT_DMS (dms_client),
input, input,
10, 10,