plugins: allow plugins to more easily suggest port types

ZTE modems need to use udev rules to assign port type hints,
so generalize that and port all the plugins over to suggested
port types in the MMModem interface's grab_port() function.
This commit is contained in:
Dan Williams
2009-07-02 13:48:30 -04:00
parent 4e7548e496
commit 52da9990ee
24 changed files with 191 additions and 79 deletions

View File

@@ -0,0 +1,75 @@
# do not edit this file, it will be overwritten on update
ACTION!="add|change", GOTO="mm_zte_port_types_end"
SUBSYSTEM!="tty", GOTO="mm_zte_port_types_end"
SUBSYSTEMS!="usb", GOTO="mm_zte_port_types_end"
ATTRS{idVendor}!="19d2", GOTO="mm_zte_port_types_end"
ATTRS{idProduct}=="0001", ATTRS{bInterfaceNumber}=="00", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0001", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0002", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0002", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0012", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0012", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0015", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0015", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0016", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0016", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0017", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0017", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0021", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0021", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0025", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0025", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0030", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0030", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0031", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0031", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0033", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0033", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0042", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0042", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0043", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0043", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0048", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0048", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0049", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0049", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0052", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0052", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0055", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0055", ATTRS{bInterfaceNumber}=="04", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0061", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0061", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0063", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0063", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0064", ATTRS{bInterfaceNumber}=="02", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0064", ATTRS{bInterfaceNumber}=="00", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="0066", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="0066", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
ATTRS{idProduct}=="2002", ATTRS{bInterfaceNumber}=="03", ENV{ID_MM_ZTE_PORT_TYPE_MODEM}="1"
ATTRS{idProduct}=="2002", ATTRS{bInterfaceNumber}=="01", ENV{ID_MM_ZTE_PORT_TYPE_AUX}="1"
LABEL="mm_zte_port_types_end"

View File

@@ -213,7 +213,9 @@ libmm_plugin_zte_la_LDFLAGS = \
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
udevrules_DATA = 77-mm-ericsson-mbm.rules
udevrules_DATA = \
77-mm-ericsson-mbm.rules \
77-mm-zte-port-types.rules
BUILT_SOURCES = \
mm-modem-gsm-hso-glue.h

View File

@@ -564,6 +564,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -601,7 +602,7 @@ grab_port (MMModem *modem,
if (g_file_get_contents (hsotype_path, &contents, NULL, NULL)) {
if (g_str_has_prefix (contents, "Control"))
ptype = MM_PORT_TYPE_PRIMARY;
else
else if (g_str_has_prefix (contents, "Application") || g_str_has_prefix (contents, "Application2"))
ptype = MM_PORT_TYPE_SECONDARY;
g_free (contents);
}

View File

@@ -496,11 +496,11 @@ handle_status_change (MMSerialPort *port,
/*****************************************************************************/
/* user_data != NULL means the port is a secondary port */
static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -533,16 +533,14 @@ grab_port (MMModem *modem,
if (usbif == 0) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
} else if (user_data) {
} else if (suggested_type == MM_PORT_TYPE_SECONDARY) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
}
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
if (!port)
goto out;
if (MM_IS_SERIAL_PORT (port)) {
if (port && MM_IS_SERIAL_PORT (port)) {
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
if (ptype == MM_PORT_TYPE_SECONDARY) {
GRegex *regex;

View File

@@ -668,6 +668,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -676,17 +677,17 @@ grab_port (MMModem *modem,
MMPort *port = NULL;
if (!strcmp (subsys, "tty")) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
} else
ptype = suggested_type;
}
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
if (!port)
return FALSE;
if (MM_IS_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
if (port && MM_IS_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
GRegex *regex;
mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (modem), TRUE);

View File

@@ -43,6 +43,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -50,10 +51,13 @@ grab_port (MMModem *modem,
MMPortType ptype = MM_PORT_TYPE_IGNORED;
MMPort *port = NULL;
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
} else
ptype = suggested_type;
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
if (port && MM_IS_SERIAL_PORT (port)) {

View File

@@ -159,6 +159,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -166,16 +167,16 @@ grab_port (MMModem *modem,
MMPortType ptype = MM_PORT_TYPE_IGNORED;
MMPort *port = NULL;
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
} else
ptype = suggested_type;
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
if (!port)
return FALSE;
if (MM_IS_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
if (port && MM_IS_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
/* Flip secondary ports to AT mode */
if (mm_serial_port_open (MM_SERIAL_PORT (port), NULL))
mm_serial_port_queue_command (MM_SERIAL_PORT (port), "$NWDMAT=1", 2, dmat_callback, NULL);

View File

@@ -128,11 +128,11 @@ enable (MMModem *modem,
}
}
/* user_data != NULL means the port is a secondary port */
static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -140,13 +140,13 @@ grab_port (MMModem *modem,
MMPortType ptype = MM_PORT_TYPE_IGNORED;
MMPort *port;
if (user_data) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
} else {
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
}
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
} else
ptype = suggested_type;
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);

View File

@@ -151,6 +151,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -158,10 +159,13 @@ grab_port (MMModem *modem,
MMPortType ptype = MM_PORT_TYPE_IGNORED;
MMPort *port = NULL;
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
if (suggested_type == MM_PORT_TYPE_UNKNOWN) {
if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_PRIMARY))
ptype = MM_PORT_TYPE_PRIMARY;
else if (!mm_generic_gsm_get_port (gsm, MM_PORT_TYPE_SECONDARY))
ptype = MM_PORT_TYPE_SECONDARY;
} else
ptype = suggested_type;
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
if (port && MM_IS_SERIAL_PORT (port)) {

View File

@@ -144,7 +144,7 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
@@ -152,7 +152,7 @@ grab_port (MMPluginBase *base,
} else {
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}
}

View File

@@ -134,7 +134,7 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
@@ -142,7 +142,7 @@ grab_port (MMPluginBase *base,
} else {
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}
}

View File

@@ -148,14 +148,14 @@ grab_port (MMPluginBase *base,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
}
} else {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}

View File

@@ -298,21 +298,21 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
}
} else {
HuaweiSupportsInfo *info;
gboolean huawei_is_secondary = FALSE;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
info = g_object_get_data (G_OBJECT (task), TAG_SUPPORTS_INFO);
if (info && (product != 0x1001))
huawei_is_secondary = info->secondary;
if (info && info->secondary && (product != 0x1001))
ptype = MM_PORT_TYPE_SECONDARY;
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, GUINT_TO_POINTER (huawei_is_secondary), error))
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
return NULL;
}

View File

@@ -143,14 +143,14 @@ grab_port (MMPluginBase *base,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
}
} else {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}

View File

@@ -128,14 +128,14 @@ grab_port (MMPluginBase *base,
mm_plugin_get_name (MM_PLUGIN (base)));
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
}
} else {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}

View File

@@ -143,7 +143,7 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
@@ -151,7 +151,7 @@ grab_port (MMPluginBase *base,
} else {
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}
}

View File

@@ -147,7 +147,7 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
@@ -155,7 +155,7 @@ grab_port (MMPluginBase *base,
} else {
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}
}

View File

@@ -135,7 +135,7 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);
return NULL;
}
@@ -143,7 +143,7 @@ grab_port (MMPluginBase *base,
} else {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
return NULL;
}
}

View File

@@ -127,7 +127,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
gpointer gsm_data = NULL;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -151,11 +151,11 @@ grab_port (MMPluginBase *base,
/* Is it a GSM secondary port? */
if (g_object_get_data (G_OBJECT (task), TAG_SIERRA_SECONDARY_PORT))
gsm_data = GUINT_TO_POINTER (TRUE);
ptype = MM_PORT_TYPE_SECONDARY;
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
if (!existing) {
if ((caps & MM_PLUGIN_BASE_PORT_CAP_GSM) || gsm_data) {
if ((caps & MM_PLUGIN_BASE_PORT_CAP_GSM) || (ptype != MM_PORT_TYPE_UNKNOWN)) {
modem = mm_modem_sierra_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
@@ -166,15 +166,16 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, gsm_data, error)) {
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error)) {
g_object_unref (modem);
return NULL;
}
}
} else {
if ((caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) || gsm_data) {
if ( (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA))
|| (ptype != MM_PORT_TYPE_UNKNOWN)) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, gsm_data, error))
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
return NULL;
}
}

View File

@@ -109,10 +109,17 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *sysfs_path;
guint32 caps;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
/* Look for port type hints */
if (g_udev_device_get_property_as_boolean (port, "ID_MM_ZTE_PORT_TYPE_MODEM"))
ptype = MM_PORT_TYPE_PRIMARY;
else if (g_udev_device_get_property_as_boolean (port, "ID_MM_ZTE_PORT_TYPE_AUX"))
ptype = MM_PORT_TYPE_SECONDARY;
physdev = mm_plugin_base_supports_task_get_physdev (task);
g_assert (physdev);
sysfs_path = g_udev_device_get_sysfs_path (physdev);
@@ -137,7 +144,7 @@ grab_port (MMPluginBase *base,
}
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, NULL, error)) {
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error)) {
g_object_unref (modem);
return NULL;
}
@@ -145,7 +152,7 @@ grab_port (MMPluginBase *base,
} else {
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
modem = existing;
if (!mm_modem_grab_port (modem, subsys, name, NULL, error))
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
return NULL;
}
}

View File

@@ -85,6 +85,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -94,24 +95,28 @@ grab_port (MMModem *modem,
MMPort *port;
g_return_val_if_fail (!strcmp (subsys, "net") || !strcmp (subsys, "tty"), FALSE);
if (priv->primary)
g_return_val_if_fail (suggested_type != MM_PORT_TYPE_PRIMARY, FALSE);
if (!strcmp (subsys, "tty")) {
if (!priv->primary)
ptype = MM_PORT_TYPE_PRIMARY;
else if (!priv->secondary)
ptype = MM_PORT_TYPE_SECONDARY;
if (suggested_type != MM_PORT_TYPE_UNKNOWN)
ptype = suggested_type;
else {
if (!priv->primary)
ptype = MM_PORT_TYPE_PRIMARY;
else if (!priv->secondary)
ptype = MM_PORT_TYPE_SECONDARY;
}
}
port = mm_modem_base_add_port (MM_MODEM_BASE (self), subsys, name, ptype);
if (MM_IS_SERIAL_PORT (port)) {
if (port && MM_IS_SERIAL_PORT (port)) {
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
mm_serial_port_set_response_parser (MM_SERIAL_PORT (port),
mm_serial_parser_v1_parse,
mm_serial_parser_v1_new (),
mm_serial_parser_v1_destroy);
}
if (MM_IS_SERIAL_PORT (port)) {
if (ptype == MM_PORT_TYPE_PRIMARY) {
priv->primary = MM_SERIAL_PORT (port);
if (!priv->data) {

View File

@@ -217,7 +217,7 @@ mm_generic_gsm_grab_port (MMGenericGsm *self,
g_return_val_if_fail (!strcmp (subsys, "net") || !strcmp (subsys, "tty"), FALSE);
port = mm_modem_base_add_port (MM_MODEM_BASE (self), subsys, name, ptype);
if (MM_IS_SERIAL_PORT (port)) {
if (port && MM_IS_SERIAL_PORT (port)) {
mm_serial_port_set_response_parser (MM_SERIAL_PORT (port),
mm_serial_parser_v1_parse,
mm_serial_parser_v1_new (),
@@ -252,6 +252,7 @@ static gboolean
grab_port (MMModem *modem,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -259,11 +260,18 @@ grab_port (MMModem *modem,
MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self);
MMPortType ptype = MM_PORT_TYPE_IGNORED;
if (priv->primary)
g_return_val_if_fail (suggested_type != MM_PORT_TYPE_PRIMARY, FALSE);
if (!strcmp (subsys, "tty")) {
if (!priv->primary)
ptype = MM_PORT_TYPE_PRIMARY;
else if (!priv->secondary)
ptype = MM_PORT_TYPE_SECONDARY;
if (suggested_type != MM_PORT_TYPE_UNKNOWN)
ptype = suggested_type;
else {
if (!priv->primary)
ptype = MM_PORT_TYPE_PRIMARY;
else if (!priv->secondary)
ptype = MM_PORT_TYPE_SECONDARY;
}
}
return !!mm_generic_gsm_grab_port (self, subsys, name, ptype, error);

View File

@@ -300,6 +300,7 @@ gboolean
mm_modem_grab_port (MMModem *self,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error)
{
@@ -309,7 +310,7 @@ mm_modem_grab_port (MMModem *self,
g_return_val_if_fail (name, FALSE);
g_assert (MM_MODEM_GET_INTERFACE (self)->grab_port);
return MM_MODEM_GET_INTERFACE (self)->grab_port (self, subsys, name, user_data, error);
return MM_MODEM_GET_INTERFACE (self)->grab_port (self, subsys, name, suggested_type, user_data, error);
}
void

View File

@@ -5,6 +5,8 @@
#include <glib-object.h>
#include "mm-port.h"
#define MM_TYPE_MODEM (mm_modem_get_type ())
#define MM_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM, MMModem))
#define MM_IS_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM))
@@ -78,6 +80,7 @@ struct _MMModem {
gboolean (*grab_port) (MMModem *self,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error);
@@ -117,6 +120,7 @@ gboolean mm_modem_owns_port (MMModem *self,
gboolean mm_modem_grab_port (MMModem *self,
const char *subsys,
const char *name,
MMPortType suggested_type,
gpointer user_data,
GError **error);