core: grab probed QCDM ports for plugins where they are useful
This commit is contained in:
@@ -42,9 +42,11 @@ mm_plugin_create (void)
|
||||
static guint32
|
||||
get_level_for_capabilities (guint32 capabilities)
|
||||
{
|
||||
/* Only CDMA for now */
|
||||
/* Only CDMA and QCDM for now */
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 10;
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
return 10;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -150,12 +152,15 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & CAP_CDMA) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
|
||||
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -59,6 +59,8 @@ get_level_for_capabilities (guint32 capabilities)
|
||||
return 5;
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 5;
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
return 5;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -159,12 +161,15 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
|
||||
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -141,12 +141,10 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -55,6 +55,8 @@ get_level_for_capabilities (guint32 capabilities)
|
||||
return 10;
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 10;
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -308,6 +310,8 @@ grab_port (MMPluginBase *base,
|
||||
info = g_object_get_data (G_OBJECT (task), TAG_SUPPORTS_INFO);
|
||||
if (info && info->secondary)
|
||||
ptype = MM_PORT_TYPE_SECONDARY;
|
||||
else if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
|
||||
@@ -47,6 +47,8 @@ get_level_for_capabilities (guint32 capabilities)
|
||||
return 10;
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 10;
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,12 +164,13 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -37,18 +37,21 @@ mm_plugin_create (void)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static guint32
|
||||
get_level_for_capabilities (guint32 capabilities)
|
||||
{
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_GSM)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
probe_result (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task,
|
||||
guint32 capabilities,
|
||||
gpointer user_data)
|
||||
{
|
||||
guint32 level = 0;
|
||||
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_GSM)
|
||||
level = 10;
|
||||
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
|
||||
}
|
||||
|
||||
static MMPluginSupportsResult
|
||||
@@ -58,7 +61,7 @@ supports_port (MMPluginBase *base,
|
||||
{
|
||||
GUdevDevice *port;
|
||||
const char *tmp;
|
||||
guint32 cached = 0;
|
||||
guint32 cached = 0, level;
|
||||
|
||||
/* Can't do anything with non-serial ports */
|
||||
port = mm_plugin_base_supports_task_get_port (task);
|
||||
@@ -78,7 +81,8 @@ supports_port (MMPluginBase *base,
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
if (mm_plugin_base_get_cached_port_capabilities (base, port, &cached)) {
|
||||
if (cached & MM_PLUGIN_BASE_PORT_CAP_GSM) {
|
||||
level = get_level_for_capabilities (cached);
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, 10);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
|
||||
@@ -150,12 +150,10 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -47,6 +47,8 @@ get_level_for_capabilities (guint32 capabilities)
|
||||
return 10;
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 10;
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -154,12 +156,15 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
|
||||
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -151,12 +151,13 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
@@ -173,13 +173,10 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps) || (ptype != MM_PORT_TYPE_UNKNOWN)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
+10
-7
@@ -47,6 +47,8 @@ get_level_for_capabilities (guint32 capabilities)
|
||||
return 10;
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 10;
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,7 +102,7 @@ supports_port (MMPluginBase *base,
|
||||
* 1235f71b20c92cded4abd976ccc5010649aae1a0 and
|
||||
* f38ad328acfdc6ce29dd1380602c546b064161ae for more details.
|
||||
*/
|
||||
mm_plugin_base_supports_task_set_custom_init_command (task, "ATE0+CPMS?", 3, 4, TRUE);
|
||||
mm_plugin_base_supports_task_set_custom_init_command (task, "ATE0+CPMS?", 3, 4, FALSE);
|
||||
|
||||
if (mm_plugin_base_probe_port (base, task, NULL))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
@@ -160,12 +162,13 @@ grab_port (MMPluginBase *base,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (caps & (MM_PLUGIN_BASE_PORT_CAP_GSM | CAP_CDMA)) {
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
} else if (get_level_for_capabilities (caps)) {
|
||||
if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
|
||||
ptype = MM_PORT_TYPE_QCDM;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
|
||||
+23
-3
@@ -24,6 +24,7 @@
|
||||
#include "mm-modem-cdma.h"
|
||||
#include "mm-modem-simple.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-qcdm-serial-port.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
@@ -74,6 +75,7 @@ typedef struct {
|
||||
|
||||
MMAtSerialPort *primary;
|
||||
MMAtSerialPort *secondary;
|
||||
MMQcdmSerialPort *qcdm;
|
||||
MMPort *data;
|
||||
} MMGenericCdmaPrivate;
|
||||
|
||||
@@ -169,9 +171,11 @@ mm_generic_cdma_grab_port (MMGenericCdma *self,
|
||||
check_valid (self);
|
||||
} else if (ptype == MM_PORT_TYPE_SECONDARY)
|
||||
priv->secondary = MM_AT_SERIAL_PORT (port);
|
||||
} else if (MM_IS_QCDM_SERIAL_PORT (port) && !priv->qcdm) {
|
||||
priv->qcdm = MM_QCDM_SERIAL_PORT (port);
|
||||
} else {
|
||||
/* Net device (if any) is the preferred data port */
|
||||
if (!priv->data || MM_IS_SERIAL_PORT (priv->data)) {
|
||||
if (!priv->data || MM_IS_AT_SERIAL_PORT (priv->data)) {
|
||||
priv->data = port;
|
||||
g_object_notify (G_OBJECT (self), MM_MODEM_DATA_DEVICE);
|
||||
check_valid (self);
|
||||
@@ -202,7 +206,7 @@ release_port (MMModem *modem, const char *subsys, const char *name)
|
||||
if (!port)
|
||||
return;
|
||||
|
||||
if (port == MM_PORT (priv->primary)) {
|
||||
if (port == (MMPort *) priv->primary) {
|
||||
mm_modem_base_remove_port (MM_MODEM_BASE (modem), port);
|
||||
priv->primary = NULL;
|
||||
}
|
||||
@@ -212,11 +216,16 @@ release_port (MMModem *modem, const char *subsys, const char *name)
|
||||
g_object_notify (G_OBJECT (modem), MM_MODEM_DATA_DEVICE);
|
||||
}
|
||||
|
||||
if (port == MM_PORT (priv->secondary)) {
|
||||
if (port == (MMPort *) priv->secondary) {
|
||||
mm_modem_base_remove_port (MM_MODEM_BASE (modem), port);
|
||||
priv->secondary = NULL;
|
||||
}
|
||||
|
||||
if (port == (MMPort *) priv->qcdm) {
|
||||
mm_modem_base_remove_port (MM_MODEM_BASE (modem), port);
|
||||
priv->qcdm = NULL;
|
||||
}
|
||||
|
||||
check_valid (MM_GENERIC_CDMA (modem));
|
||||
}
|
||||
|
||||
@@ -432,6 +441,14 @@ enable_all_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
}
|
||||
}
|
||||
|
||||
/* Open up the second port, if one exists */
|
||||
if (priv->qcdm) {
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (priv->qcdm), &info->error)) {
|
||||
g_assert (info->error);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
update_enabled_state (self, FALSE, MM_MODEM_STATE_REASON_NONE);
|
||||
|
||||
/* Grab device info right away */
|
||||
@@ -618,8 +635,11 @@ disable (MMModem *modem,
|
||||
GUINT_TO_POINTER (state),
|
||||
NULL);
|
||||
|
||||
/* Close auxiliary serial ports */
|
||||
if (priv->secondary)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (priv->secondary));
|
||||
if (priv->qcdm)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (priv->qcdm));
|
||||
|
||||
mm_modem_set_state (MM_MODEM (info->modem),
|
||||
MM_MODEM_STATE_DISABLING,
|
||||
|
||||
+11
-2
@@ -28,6 +28,7 @@
|
||||
#include "mm-errors.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-qcdm-serial-port.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
#include "mm-options.h"
|
||||
@@ -92,6 +93,7 @@ typedef struct {
|
||||
|
||||
MMAtSerialPort *primary;
|
||||
MMAtSerialPort *secondary;
|
||||
MMQcdmSerialPort *qcdm;
|
||||
MMPort *data;
|
||||
} MMGenericGsmPrivate;
|
||||
|
||||
@@ -430,6 +432,8 @@ mm_generic_gsm_grab_port (MMGenericGsm *self,
|
||||
|
||||
} else if (ptype == MM_PORT_TYPE_SECONDARY)
|
||||
priv->secondary = MM_AT_SERIAL_PORT (port);
|
||||
} else if (MM_IS_QCDM_SERIAL_PORT (port) && !priv->qcdm) {
|
||||
priv->qcdm = MM_QCDM_SERIAL_PORT (port);
|
||||
} else {
|
||||
/* Net device (if any) is the preferred data port */
|
||||
if (!priv->data || MM_IS_SERIAL_PORT (priv->data)) {
|
||||
@@ -484,7 +488,7 @@ release_port (MMModem *modem, const char *subsys, const char *name)
|
||||
if (!port)
|
||||
return;
|
||||
|
||||
if (port == MM_PORT (priv->primary)) {
|
||||
if (port == (MMPort *) priv->primary) {
|
||||
mm_modem_base_remove_port (MM_MODEM_BASE (modem), port);
|
||||
priv->primary = NULL;
|
||||
}
|
||||
@@ -494,11 +498,16 @@ release_port (MMModem *modem, const char *subsys, const char *name)
|
||||
g_object_notify (G_OBJECT (modem), MM_MODEM_DATA_DEVICE);
|
||||
}
|
||||
|
||||
if (port == MM_PORT (priv->secondary)) {
|
||||
if (port == (MMPort *) priv->secondary) {
|
||||
mm_modem_base_remove_port (MM_MODEM_BASE (modem), port);
|
||||
priv->secondary = NULL;
|
||||
}
|
||||
|
||||
if (port == (MMPort *) priv->qcdm) {
|
||||
mm_modem_base_remove_port (MM_MODEM_BASE (modem), port);
|
||||
priv->qcdm = NULL;
|
||||
}
|
||||
|
||||
check_valid (MM_GENERIC_GSM (modem));
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -22,6 +22,7 @@
|
||||
#include "mm-modem-base.h"
|
||||
#include "mm-modem.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-qcdm-serial-port.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-options.h"
|
||||
#include "mm-properties-changed-signal.h"
|
||||
@@ -120,9 +121,12 @@ mm_modem_base_add_port (MMModemBase *self,
|
||||
g_return_val_if_fail (port == NULL, FALSE);
|
||||
}
|
||||
|
||||
if (!strcmp (subsys, "tty"))
|
||||
port = MM_PORT (mm_at_serial_port_new (name, ptype));
|
||||
else if (!strcmp (subsys, "net")) {
|
||||
if (!strcmp (subsys, "tty")) {
|
||||
if (ptype == MM_PORT_TYPE_QCDM)
|
||||
port = MM_PORT (mm_qcdm_serial_port_new (name, ptype));
|
||||
else
|
||||
port = MM_PORT (mm_at_serial_port_new (name, ptype));
|
||||
} else if (!strcmp (subsys, "net")) {
|
||||
port = MM_PORT (g_object_new (MM_TYPE_PORT,
|
||||
MM_PORT_DEVICE, name,
|
||||
MM_PORT_SUBSYS, MM_PORT_SUBSYS_NET,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE /* for strcasestr */
|
||||
@@ -575,7 +575,7 @@ real_handle_probe_response (MMPluginBase *self,
|
||||
ignore_error = TRUE;
|
||||
|
||||
if (error && !ignore_error) {
|
||||
if (error->code == MM_SERIAL_RESPONSE_TIMEOUT) {
|
||||
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_RESPONSE_TIMEOUT)) {
|
||||
/* Try GCAP again */
|
||||
if (task_priv->probe_state < PROBE_STATE_GCAP_TRY3) {
|
||||
task_priv->probe_state++;
|
||||
|
||||
+2
-1
@@ -33,8 +33,9 @@ typedef enum {
|
||||
MM_PORT_TYPE_PRIMARY,
|
||||
MM_PORT_TYPE_SECONDARY,
|
||||
MM_PORT_TYPE_IGNORED,
|
||||
MM_PORT_TYPE_QCDM,
|
||||
|
||||
MM_PORT_TYPE_LAST = MM_PORT_TYPE_IGNORED
|
||||
MM_PORT_TYPE_LAST = MM_PORT_TYPE_QCDM
|
||||
} MMPortType;
|
||||
|
||||
#define MM_TYPE_PORT (mm_port_get_type ())
|
||||
|
||||
Reference in New Issue
Block a user