aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStig M. Baugstø <1129097-stigma@users.noreply.gitlab.freedesktop.org>2024-10-23 17:11:07 +0200
committerStig M. Baugstø <1129097-stigma@users.noreply.gitlab.freedesktop.org>2024-10-24 15:21:57 +0200
commit0c167a51248cf9ff73f6f832e3d14e475a860e55 (patch)
treef1e6781ce3673448b16bc9e07ba60c376c22ed17 /src
parent78508b7dcea158c3e54386f8bfdaf0fd855ea169 (diff)
cellient: new generic plugin for Cellient modems with optional QMI
Simple plugin handling Cellient (vid 0x2692) modems. Optional QMI through the WITH_QMI compile flag. Disables QMI WDS PCO for the Qualcomm-branded MPL200 by setting the ID_MM_QMI_PCO_DISABLED udev tag, effectively preventing a modem crash. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/842 Signed-off-by: Stig M. Baugstø <1129097-stigma@users.noreply.gitlab.freedesktop.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cellient/77-mm-cellient.rules18
-rw-r--r--src/plugins/cellient/mm-plugin-cellient.c92
-rw-r--r--src/plugins/meson.build17
-rw-r--r--src/plugins/mm-builtin-plugins.c6
-rw-r--r--src/plugins/tests/test-udev-rules.c11
5 files changed, 144 insertions, 0 deletions
diff --git a/src/plugins/cellient/77-mm-cellient.rules b/src/plugins/cellient/77-mm-cellient.rules
new file mode 100644
index 00000000..361bd663
--- /dev/null
+++ b/src/plugins/cellient/77-mm-cellient.rules
@@ -0,0 +1,18 @@
+# do not edit this file, it will be overwritten on update
+ACTION!="add|change|move|bind", GOTO="mm_cellient_end"
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="2692", GOTO="mm_cellient_generic"
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", GOTO="mm_cellient_qualcomm"
+GOTO="mm_cellient_end"
+
+LABEL="mm_cellient_generic"
+# Cellient MPL200: Disable QMI WDS PCO
+ATTRS{idVendor}=="2692", ATTRS{idProduct}=="9025", ENV{ID_MM_QMI_PCO_DISABLED}="1"
+GOTO="mm_cellient_end"
+
+# Cellient products rebranded as Qualcomm
+LABEL="mm_cellient_qualcomm"
+
+# Cellient MPL200 (rebranded Qualcomm 05c6:9025): Disable QMI WDS PCO
+ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9025", ENV{ID_MM_QMI_PCO_DISABLED}="1"
+
+LABEL="mm_cellient_end"
diff --git a/src/plugins/cellient/mm-plugin-cellient.c b/src/plugins/cellient/mm-plugin-cellient.c
new file mode 100644
index 00000000..ec0936e3
--- /dev/null
+++ b/src/plugins/cellient/mm-plugin-cellient.c
@@ -0,0 +1,92 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2024 Stig Magnus Baugstø <stig@peerconsulting.no>
+ */
+
+#define _LIBMM_INSIDE_MM
+#include "mm-plugin-common.h"
+#include "mm-log-object.h"
+
+#if defined WITH_QMI
+# include "mm-broadband-modem-qmi.h"
+#else
+# include "mm-broadband-modem.h"
+#endif
+
+#define MM_TYPE_PLUGIN_CELLIENT mm_plugin_cellient_get_type ()
+MM_DEFINE_PLUGIN (CELLIENT, cellient, Cellient)
+
+/*****************************************************************************/
+
+static MMBaseModem *
+create_modem (MMPlugin *self,
+ const gchar *uid,
+ const gchar *physdev,
+ const gchar **drivers,
+ guint16 vendor,
+ guint16 product,
+ guint16 subsystem_vendor,
+ GList *probes,
+ GError **error)
+{
+#if defined WITH_QMI
+ if (mm_port_probe_list_has_qmi_port (probes)) {
+ mm_obj_dbg (self, "QMI-powered Cellient modem found...");
+ return MM_BASE_MODEM (mm_broadband_modem_qmi_new (uid,
+ physdev,
+ drivers,
+ mm_plugin_get_name (self),
+ vendor,
+ product));
+ }
+#endif
+
+ mm_obj_dbg (self, "Generic Cellient modem found...");
+ return MM_BASE_MODEM (mm_broadband_modem_new (uid,
+ physdev,
+ drivers,
+ mm_plugin_get_name (self),
+ vendor,
+ product));
+}
+
+/*****************************************************************************/
+
+MM_PLUGIN_NAMED_CREATOR_SCOPE MMPlugin *
+mm_plugin_create_cellient (void)
+{
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", "wwan", NULL };
+ static const guint16 vendor_ids[] = { 0x2692, 0 };
+
+ return MM_PLUGIN (
+ g_object_new (MM_TYPE_PLUGIN_CELLIENT,
+ MM_PLUGIN_NAME, MM_MODULE_NAME,
+ MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
+ MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
+ MM_PLUGIN_ALLOWED_AT, TRUE,
+ MM_PLUGIN_ALLOWED_QMI, TRUE,
+ NULL));
+}
+
+static void
+mm_plugin_cellient_init (MMPluginCellient *self)
+{
+}
+
+static void
+mm_plugin_cellient_class_init (MMPluginCellientClass *klass)
+{
+ MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
+
+ plugin_class->create_modem = create_modem;
+}
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 3742ced5..b21b5e36 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -357,6 +357,23 @@ if plugins_options['broadmobi']
plugins_udev_rules += files('broadmobi/77-mm-broadmobi-port-types.rules')
endif
+# plugin: cellient
+if plugins_options['cellient']
+ test_udev_rules_dir_c_args = ['-DTESTUDEVRULESDIR_CELLIENT="@0@"'.format(plugins_dir / 'cellient')]
+ plugins_test_udev_rules_dir_c_args += test_udev_rules_dir_c_args
+
+ sources = files(
+ 'cellient/mm-plugin-cellient.c',
+ )
+
+ plugins += {'plugin-cellient': {
+ 'plugin': true,
+ 'module': {'sources': sources, 'include_directories': plugins_incs, 'c_args': test_udev_rules_dir_c_args + ['-DMM_MODULE_NAME="cellient"']},
+ }}
+
+ plugins_udev_rules += files('cellient/77-mm-cellient.rules')
+endif
+
# plugin: cinterion (previously siemens)
if plugins_options['cinterion']
test_udev_rules_dir_c_args = ['-DTESTUDEVRULESDIR_CINTERION="@0@"'.format(plugins_dir / 'cinterion')]
diff --git a/src/plugins/mm-builtin-plugins.c b/src/plugins/mm-builtin-plugins.c
index 0fd96700..c7f91633 100644
--- a/src/plugins/mm-builtin-plugins.c
+++ b/src/plugins/mm-builtin-plugins.c
@@ -28,6 +28,9 @@ MMPlugin *mm_plugin_create_anydata (void);
#if defined ENABLE_PLUGIN_BROADMOBI
MMPlugin *mm_plugin_create_broadmobi (void);
#endif
+#if defined ENABLE_PLUGIN_CELLIENT
+MMPlugin *mm_plugin_create_cellient (void);
+#endif
#if defined ENABLE_PLUGIN_CINTERION
MMPlugin *mm_plugin_create_cinterion (void);
#endif
@@ -163,6 +166,9 @@ mm_builtin_plugins_load (void)
#if defined ENABLE_PLUGIN_BROADMOBI
PREPEND_PLUGIN (broadmobi);
#endif
+#if defined ENABLE_PLUGIN_CELLIENT
+ PREPEND_PLUGIN (cellient);
+#endif
#if defined ENABLE_PLUGIN_CINTERION
PREPEND_PLUGIN (cinterion);
#endif
diff --git a/src/plugins/tests/test-udev-rules.c b/src/plugins/tests/test-udev-rules.c
index 91698f0b..8f5ffd64 100644
--- a/src/plugins/tests/test-udev-rules.c
+++ b/src/plugins/tests/test-udev-rules.c
@@ -112,6 +112,14 @@ test_x22x (void)
}
#endif
+#if defined ENABLE_PLUGIN_CELLIENT
+static void
+test_cellient (void)
+{
+ common_test (TESTUDEVRULESDIR_CELLIENT);
+}
+#endif
+
#if defined ENABLE_PLUGIN_CINTERION
static void
test_cinterion (void)
@@ -238,6 +246,9 @@ int main (int argc, char **argv)
#if defined ENABLE_PLUGIN_X22X
g_test_add_func ("/MM/test-udev-rules/x22x", test_x22x);
#endif
+#if defined ENABLE_PLUGIN_CELLIENT
+ g_test_add_func ("/MM/test-udev-rules/cellient", test_cellient);
+#endif
#if defined ENABLE_PLUGIN_CINTERION
g_test_add_func ("/MM/test-udev-rules/cinterion", test_cinterion);
#endif