iface-modem: ensure we're in low power mode when initializing

The power-down command defined by the plugin will be run *only* after having
checked for current and modem capabilities, as plugins (e.g. Sierra) may have
different commands for that depending on whether they are 3GPP or 3GPP2.

We do not reuse the 'modem_power_down' callback from the disabling sequence, as
some plugins really behave pretty badly with this (e.g. Samsung CFUN=4 may take
up to 30s to complete). So, we let plugins use the power-down command when
disabling but avoid launching it during init.
This commit is contained in:
Aleksander Morgado
2012-10-01 16:40:51 +02:00
parent b622424d2f
commit 77208f66ab
2 changed files with 43 additions and 0 deletions
+35
View File
@@ -2941,6 +2941,7 @@ typedef enum {
INITIALIZATION_STEP_FIRST,
INITIALIZATION_STEP_CURRENT_CAPABILITIES,
INITIALIZATION_STEP_MODEM_CAPABILITIES,
INITIALIZATION_STEP_POWER_DOWN,
INITIALIZATION_STEP_BEARERS,
INITIALIZATION_STEP_MANUFACTURER,
INITIALIZATION_STEP_MODEL,
@@ -3073,6 +3074,26 @@ initialization_context_complete_and_free_if_cancelled (InitializationContext *ct
UINT_REPLY_READY_FN (current_capabilities, "Current Capabilities", TRUE)
UINT_REPLY_READY_FN (modem_capabilities, "Modem Capabilities", FALSE)
static void
initialization_modem_power_down_ready (MMIfaceModem *self,
GAsyncResult *res,
InitializationContext *ctx)
{
GError *error = NULL;
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_init_power_down_finish (self, res, &error);
if (error) {
mm_dbg ("Couldn't power down the modem during initialization: '%s'", error->message);
g_error_free (error);
} else
mm_dbg ("Modem initially powered down...");
/* Go on to next step */
ctx->step++;
interface_initialization_step (ctx);
}
STR_REPLY_READY_FN (manufacturer, "Manufacturer")
STR_REPLY_READY_FN (model, "Model")
STR_REPLY_READY_FN (revision, "Revision")
@@ -3323,6 +3344,20 @@ interface_initialization_step (InitializationContext *ctx)
/* Fall down to next step */
ctx->step++;
case INITIALIZATION_STEP_POWER_DOWN:
/* We run the power down command during initialization, to ensure we
* start with radio off, when possible */
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init_power_down &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init_power_down_finish) {
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init_power_down (
ctx->self,
(GAsyncReadyCallback)initialization_modem_power_down_ready,
ctx);
return;
}
/* Fall down to next step */
ctx->step++;
case INITIALIZATION_STEP_BEARERS: {
MMBearerList *list = NULL;
+8
View File
@@ -57,6 +57,14 @@ struct _MMIfaceModem {
GAsyncResult *res,
GError **error);
/* Asynchronous modem power-down operation run during initialization */
void (*modem_init_power_down) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*modem_init_power_down_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Loading of the Manufacturer property */
void (*load_manufacturer) (MMIfaceModem *self,
GAsyncReadyCallback callback,