core: allow flagging ports as 'audio'

Instead of flagging them as 'ignored' so that they aren't probed, we
can also flag them as 'audio' now, so that the logic knows which port
to report as used for audio in the Call object.
This commit is contained in:
Aleksander Morgado
2019-10-15 12:35:11 +02:00
parent d61cb4a21c
commit e3a1364ddc
6 changed files with 65 additions and 2 deletions

View File

@@ -514,6 +514,7 @@ typedef enum { /*< underscore_name=mm_modem_band >*/
* @MM_MODEM_PORT_TYPE_GPS: GPS port. * @MM_MODEM_PORT_TYPE_GPS: GPS port.
* @MM_MODEM_PORT_TYPE_QMI: QMI port. * @MM_MODEM_PORT_TYPE_QMI: QMI port.
* @MM_MODEM_PORT_TYPE_MBIM: MBIM port. * @MM_MODEM_PORT_TYPE_MBIM: MBIM port.
* @MM_MODEM_PORT_TYPE_AUDIO: Audio port.
* *
* Type of modem port. * Type of modem port.
*/ */
@@ -524,7 +525,8 @@ typedef enum { /*< underscore_name=mm_modem_port_type >*/
MM_MODEM_PORT_TYPE_QCDM = 4, MM_MODEM_PORT_TYPE_QCDM = 4,
MM_MODEM_PORT_TYPE_GPS = 5, MM_MODEM_PORT_TYPE_GPS = 5,
MM_MODEM_PORT_TYPE_QMI = 6, MM_MODEM_PORT_TYPE_QMI = 6,
MM_MODEM_PORT_TYPE_MBIM = 7 MM_MODEM_PORT_TYPE_MBIM = 7,
MM_MODEM_PORT_TYPE_AUDIO = 8,
} MMModemPortType; } MMModemPortType;
/** /**

View File

@@ -177,6 +177,16 @@
*/ */
#define ID_MM_PORT_TYPE_GPS "ID_MM_PORT_TYPE_GPS" #define ID_MM_PORT_TYPE_GPS "ID_MM_PORT_TYPE_GPS"
/**
* ID_MM_PORT_TYPE_AUDIO:
*
* This is a port-specific tag applied to TTYs that we know in advance
* are audio ports.
*
* This tag also prevents AT and QCDM probing in the port.
*/
#define ID_MM_PORT_TYPE_AUDIO "ID_MM_PORT_TYPE_AUDIO"
/** /**
* ID_MM_TTY_BAUDRATE: * ID_MM_TTY_BAUDRATE:
* *

View File

@@ -95,6 +95,9 @@ struct _MMBaseModemPrivate {
MMPortSerialAt *gps_control; MMPortSerialAt *gps_control;
MMPortSerialGps *gps; MMPortSerialGps *gps;
/* Some audio-capable devices will have a port for audio specifically */
MMPortSerial *audio;
/* Support for parallel enable/disable operations */ /* Support for parallel enable/disable operations */
GList *enable_tasks; GList *enable_tasks;
GList *disable_tasks; GList *disable_tasks;
@@ -232,6 +235,9 @@ mm_base_modem_grab_port (MMBaseModem *self,
} else if (ptype == MM_PORT_TYPE_GPS) { } else if (ptype == MM_PORT_TYPE_GPS) {
/* Raw GPS port */ /* Raw GPS port */
port = MM_PORT (mm_port_serial_gps_new (name)); port = MM_PORT (mm_port_serial_gps_new (name));
} else if (ptype == MM_PORT_TYPE_AUDIO) {
/* Generic audio port */
port = MM_PORT (mm_port_serial_new (name, ptype));
} else { } else {
g_set_error (error, g_set_error (error,
MM_CORE_ERROR, MM_CORE_ERROR,
@@ -646,6 +652,22 @@ mm_base_modem_peek_port_gps (MMBaseModem *self)
return self->priv->gps; return self->priv->gps;
} }
MMPortSerial *
mm_base_modem_get_port_audio (MMBaseModem *self)
{
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
return (self->priv->audio ? g_object_ref (self->priv->audio) : NULL);
}
MMPortSerial *
mm_base_modem_peek_port_audio (MMBaseModem *self)
{
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
return self->priv->audio;
}
#if defined WITH_QMI #if defined WITH_QMI
MMPortQmi * MMPortQmi *
@@ -929,6 +951,9 @@ mm_base_modem_get_port_infos (MMBaseModem *self,
case MM_PORT_TYPE_GPS: case MM_PORT_TYPE_GPS:
port_infos[i].type = MM_MODEM_PORT_TYPE_GPS; port_infos[i].type = MM_MODEM_PORT_TYPE_GPS;
break; break;
case MM_PORT_TYPE_AUDIO:
port_infos[i].type = MM_MODEM_PORT_TYPE_AUDIO;
break;
case MM_PORT_TYPE_QMI: case MM_PORT_TYPE_QMI:
port_infos[i].type = MM_MODEM_PORT_TYPE_QMI; port_infos[i].type = MM_MODEM_PORT_TYPE_QMI;
break; break;
@@ -1039,6 +1064,7 @@ mm_base_modem_organize_ports (MMBaseModem *self,
MMPortSerialQcdm *qcdm = NULL; MMPortSerialQcdm *qcdm = NULL;
MMPortSerialAt *gps_control = NULL; MMPortSerialAt *gps_control = NULL;
MMPortSerialGps *gps = NULL; MMPortSerialGps *gps = NULL;
MMPortSerial *audio = NULL;
MMPort *data_primary = NULL; MMPort *data_primary = NULL;
GList *data = NULL; GList *data = NULL;
#if defined WITH_QMI #if defined WITH_QMI
@@ -1129,6 +1155,12 @@ mm_base_modem_organize_ports (MMBaseModem *self,
gps = MM_PORT_SERIAL_GPS (candidate); gps = MM_PORT_SERIAL_GPS (candidate);
break; break;
case MM_PORT_TYPE_AUDIO:
g_assert (MM_IS_PORT_SERIAL (candidate));
if (!audio)
audio = MM_PORT_SERIAL (candidate);
break;
#if defined WITH_QMI #if defined WITH_QMI
case MM_PORT_TYPE_QMI: case MM_PORT_TYPE_QMI:
if (!qmi_primary) if (!qmi_primary)
@@ -1246,6 +1278,7 @@ mm_base_modem_organize_ports (MMBaseModem *self,
log_port (self, MM_PORT (qcdm), "qcdm"); log_port (self, MM_PORT (qcdm), "qcdm");
log_port (self, MM_PORT (gps_control), "gps (control)"); log_port (self, MM_PORT (gps_control), "gps (control)");
log_port (self, MM_PORT (gps), "gps (nmea)"); log_port (self, MM_PORT (gps), "gps (nmea)");
log_port (self, MM_PORT (audio), "audio");
#if defined WITH_QMI #if defined WITH_QMI
log_port (self, MM_PORT (qmi_primary), "qmi (primary)"); log_port (self, MM_PORT (qmi_primary), "qmi (primary)");
for (l = qmi; l; l = g_list_next (l)) for (l = qmi; l; l = g_list_next (l))
@@ -1576,6 +1609,7 @@ dispose (GObject *object)
g_clear_object (&self->priv->qcdm); g_clear_object (&self->priv->qcdm);
g_clear_object (&self->priv->gps_control); g_clear_object (&self->priv->gps_control);
g_clear_object (&self->priv->gps); g_clear_object (&self->priv->gps);
g_clear_object (&self->priv->audio);
#if defined WITH_QMI #if defined WITH_QMI
/* We need to close the QMI port cleanly when disposing the modem object, /* We need to close the QMI port cleanly when disposing the modem object,
* otherwise the allocated CIDs will be kept allocated, and if we end up * otherwise the allocated CIDs will be kept allocated, and if we end up

View File

@@ -121,6 +121,7 @@ MMPortSerialAt *mm_base_modem_peek_port_secondary (MMBaseModem *self);
MMPortSerialQcdm *mm_base_modem_peek_port_qcdm (MMBaseModem *self); MMPortSerialQcdm *mm_base_modem_peek_port_qcdm (MMBaseModem *self);
MMPortSerialAt *mm_base_modem_peek_port_gps_control (MMBaseModem *self); MMPortSerialAt *mm_base_modem_peek_port_gps_control (MMBaseModem *self);
MMPortSerialGps *mm_base_modem_peek_port_gps (MMBaseModem *self); MMPortSerialGps *mm_base_modem_peek_port_gps (MMBaseModem *self);
MMPortSerial *mm_base_modem_peek_port_audio (MMBaseModem *self);
#if defined WITH_QMI #if defined WITH_QMI
MMPortQmi *mm_base_modem_peek_port_qmi (MMBaseModem *self); MMPortQmi *mm_base_modem_peek_port_qmi (MMBaseModem *self);
MMPortQmi *mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error); MMPortQmi *mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error);
@@ -138,6 +139,7 @@ MMPortSerialAt *mm_base_modem_get_port_secondary (MMBaseModem *self);
MMPortSerialQcdm *mm_base_modem_get_port_qcdm (MMBaseModem *self); MMPortSerialQcdm *mm_base_modem_get_port_qcdm (MMBaseModem *self);
MMPortSerialAt *mm_base_modem_get_port_gps_control (MMBaseModem *self); MMPortSerialAt *mm_base_modem_get_port_gps_control (MMBaseModem *self);
MMPortSerialGps *mm_base_modem_get_port_gps (MMBaseModem *self); MMPortSerialGps *mm_base_modem_get_port_gps (MMBaseModem *self);
MMPortSerial *mm_base_modem_get_port_audio (MMBaseModem *self);
#if defined WITH_QMI #if defined WITH_QMI
MMPortQmi *mm_base_modem_get_port_qmi (MMBaseModem *self); MMPortQmi *mm_base_modem_get_port_qmi (MMBaseModem *self);
MMPortQmi *mm_base_modem_get_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error); MMPortQmi *mm_base_modem_get_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error);

View File

@@ -93,6 +93,7 @@ struct _MMPortProbePrivate {
/* From udev tags */ /* From udev tags */
gboolean is_ignored; gboolean is_ignored;
gboolean is_gps; gboolean is_gps;
gboolean is_audio;
gboolean maybe_at_primary; gboolean maybe_at_primary;
gboolean maybe_at_secondary; gboolean maybe_at_secondary;
gboolean maybe_at_ppp; gboolean maybe_at_ppp;
@@ -1477,6 +1478,15 @@ mm_port_probe_run (MMPortProbe *self,
mm_port_probe_set_result_qcdm (self, FALSE); mm_port_probe_set_result_qcdm (self, FALSE);
} }
/* If this is a port flagged as an audio port, don't do any AT or QCDM probing */
if (self->priv->is_audio) {
mm_dbg ("(%s/%s) audio port detected",
mm_kernel_device_get_subsystem (self->priv->port),
mm_kernel_device_get_name (self->priv->port));
mm_port_probe_set_result_at (self, FALSE);
mm_port_probe_set_result_qcdm (self, FALSE);
}
/* If this is a port flagged as being an AT port, don't do any QCDM probing */ /* If this is a port flagged as being an AT port, don't do any QCDM probing */
if (self->priv->maybe_at_primary || self->priv->maybe_at_secondary || self->priv->maybe_at_ppp) { if (self->priv->maybe_at_primary || self->priv->maybe_at_secondary || self->priv->maybe_at_ppp) {
mm_dbg ("(%s/%s) no QCDM probing in possible AT port", mm_dbg ("(%s/%s) no QCDM probing in possible AT port",
@@ -1711,6 +1721,9 @@ mm_port_probe_get_port_type (MMPortProbe *self)
if (self->priv->is_gps) if (self->priv->is_gps)
return MM_PORT_TYPE_GPS; return MM_PORT_TYPE_GPS;
if (self->priv->is_audio)
return MM_PORT_TYPE_AUDIO;
return MM_PORT_TYPE_UNKNOWN; return MM_PORT_TYPE_UNKNOWN;
} }
@@ -1900,6 +1913,7 @@ set_property (GObject *object,
self->priv->port = g_value_dup_object (value); self->priv->port = g_value_dup_object (value);
self->priv->is_ignored = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_IGNORE); self->priv->is_ignored = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_IGNORE);
self->priv->is_gps = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_GPS); self->priv->is_gps = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_GPS);
self->priv->is_audio = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AUDIO);
self->priv->maybe_at_primary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PRIMARY); self->priv->maybe_at_primary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PRIMARY);
self->priv->maybe_at_secondary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_SECONDARY); self->priv->maybe_at_secondary = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_SECONDARY);
self->priv->maybe_at_ppp = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PPP); self->priv->maybe_at_ppp = mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_TYPE_AT_PPP);

View File

@@ -41,7 +41,8 @@ typedef enum { /*< underscore_name=mm_port_type >*/
MM_PORT_TYPE_GPS, MM_PORT_TYPE_GPS,
MM_PORT_TYPE_QMI, MM_PORT_TYPE_QMI,
MM_PORT_TYPE_MBIM, MM_PORT_TYPE_MBIM,
MM_PORT_TYPE_LAST = MM_PORT_TYPE_MBIM /*< skip >*/ MM_PORT_TYPE_AUDIO,
MM_PORT_TYPE_LAST = MM_PORT_TYPE_AUDIO /*< skip >*/
} MMPortType; } MMPortType;
#define MM_TYPE_PORT (mm_port_get_type ()) #define MM_TYPE_PORT (mm_port_get_type ())