broadband-modem-mbim: preallocate QMI clients if QMI over MBIM supported
This commit is contained in:

committed by
Dan Williams

parent
8a364c4dfd
commit
5e6980c7fc
@@ -1694,6 +1694,10 @@ enabling_started (MMBroadbandModem *self,
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MMPortMbim *mbim;
|
MMPortMbim *mbim;
|
||||||
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
QmiService qmi_services[32];
|
||||||
|
guint qmi_service_index;
|
||||||
|
#endif
|
||||||
} InitializationStartedContext;
|
} InitializationStartedContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1705,17 +1709,17 @@ initialization_started_context_free (InitializationStartedContext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
initialization_started_finish (MMBroadbandModem *self,
|
initialization_started_finish (MMBroadbandModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
return g_task_propagate_pointer (G_TASK (res), error);
|
return g_task_propagate_pointer (G_TASK (res), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parent_initialization_started_ready (MMBroadbandModem *self,
|
parent_initialization_started_ready (MMBroadbandModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
gpointer parent_ctx;
|
gpointer parent_ctx;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -1748,6 +1752,55 @@ parent_initialization_started (GTask *task)
|
|||||||
task);
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
|
||||||
|
static void allocate_next_qmi_client (GTask *task);
|
||||||
|
|
||||||
|
static void
|
||||||
|
mbim_port_allocate_qmi_client_ready (MMPortMbim *mbim,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
|
InitializationStartedContext *ctx;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
|
||||||
|
if (!mm_port_mbim_allocate_qmi_client_finish (mbim, res, &error)) {
|
||||||
|
mm_dbg ("Couldn't allocate QMI client for service '%s': %s",
|
||||||
|
qmi_service_get_string (ctx->qmi_services[ctx->qmi_service_index]),
|
||||||
|
error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->qmi_service_index++;
|
||||||
|
allocate_next_qmi_client (task);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
allocate_next_qmi_client (GTask *task)
|
||||||
|
{
|
||||||
|
InitializationStartedContext *ctx;
|
||||||
|
MMBroadbandModemMbim *self;
|
||||||
|
|
||||||
|
self = g_task_get_source_object (task);
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
|
||||||
|
if (ctx->qmi_services[ctx->qmi_service_index] == QMI_SERVICE_UNKNOWN) {
|
||||||
|
parent_initialization_started (task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, allocate next client */
|
||||||
|
mm_port_mbim_allocate_qmi_client (ctx->mbim,
|
||||||
|
ctx->qmi_services[ctx->qmi_service_index],
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)mbim_port_allocate_qmi_client_ready,
|
||||||
|
task);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
query_device_services_ready (MbimDevice *device,
|
query_device_services_ready (MbimDevice *device,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -1822,7 +1875,11 @@ query_device_services_ready (MbimDevice *device,
|
|||||||
if (response)
|
if (response)
|
||||||
mbim_message_unref (response);
|
mbim_message_unref (response);
|
||||||
|
|
||||||
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
allocate_next_qmi_client (task);
|
||||||
|
#else
|
||||||
parent_initialization_started (task);
|
parent_initialization_started (task);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1848,7 +1905,7 @@ query_device_services (GTask *task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mbim_device_removed_cb (MbimDevice *device,
|
mbim_device_removed_cb (MbimDevice *device,
|
||||||
MMBroadbandModemMbim *self)
|
MMBroadbandModemMbim *self)
|
||||||
{
|
{
|
||||||
/* We have to do a full re-probe here because simply reopening the device
|
/* We have to do a full re-probe here because simply reopening the device
|
||||||
@@ -1866,7 +1923,7 @@ mbim_device_removed_cb (MbimDevice *device,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
track_mbim_device_removed (MMBroadbandModemMbim *self,
|
track_mbim_device_removed (MMBroadbandModemMbim *self,
|
||||||
MMPortMbim *mbim)
|
MMPortMbim *mbim)
|
||||||
{
|
{
|
||||||
MbimDevice *device;
|
MbimDevice *device;
|
||||||
|
|
||||||
@@ -1883,7 +1940,7 @@ track_mbim_device_removed (MMBroadbandModemMbim *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
untrack_mbim_device_removed (MMBroadbandModemMbim *self,
|
untrack_mbim_device_removed (MMBroadbandModemMbim *self,
|
||||||
MMPortMbim *mbim)
|
MMPortMbim *mbim)
|
||||||
{
|
{
|
||||||
MbimDevice *device;
|
MbimDevice *device;
|
||||||
|
|
||||||
@@ -1899,11 +1956,10 @@ untrack_mbim_device_removed (MMBroadbandModemMbim *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mbim_port_open_ready (MMPortMbim *mbim,
|
mbim_port_open_ready (MMPortMbim *mbim,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
MMBroadbandModemMbim *self;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_port_mbim_open_finish (mbim, res, &error)) {
|
if (!mm_port_mbim_open_finish (mbim, res, &error)) {
|
||||||
@@ -1914,18 +1970,17 @@ mbim_port_open_ready (MMPortMbim *mbim,
|
|||||||
|
|
||||||
/* Make sure we know if mbim-proxy dies on us, and then do the parent's
|
/* Make sure we know if mbim-proxy dies on us, and then do the parent's
|
||||||
* initialization */
|
* initialization */
|
||||||
self = MM_BROADBAND_MODEM_MBIM (g_task_get_source_object (task));
|
track_mbim_device_removed (MM_BROADBAND_MODEM_MBIM (g_task_get_source_object (task)), mbim);
|
||||||
track_mbim_device_removed (self, mbim);
|
|
||||||
query_device_services (task);
|
query_device_services (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initialization_started (MMBroadbandModem *self,
|
initialization_started (MMBroadbandModem *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
InitializationStartedContext *ctx;
|
InitializationStartedContext *ctx;
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
ctx = g_slice_new0 (InitializationStartedContext);
|
ctx = g_slice_new0 (InitializationStartedContext);
|
||||||
ctx->mbim = mm_base_modem_get_port_mbim (MM_BASE_MODEM (self));
|
ctx->mbim = mm_base_modem_get_port_mbim (MM_BASE_MODEM (self));
|
||||||
@@ -1951,6 +2006,12 @@ initialization_started (MMBroadbandModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
/* Setup services to open */
|
||||||
|
ctx->qmi_services[0] = QMI_SERVICE_DMS;
|
||||||
|
ctx->qmi_services[1] = QMI_SERVICE_UNKNOWN;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Now open our MBIM port */
|
/* Now open our MBIM port */
|
||||||
mm_port_mbim_open (ctx->mbim,
|
mm_port_mbim_open (ctx->mbim,
|
||||||
#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
#if WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
Reference in New Issue
Block a user