shared-qmi: Lock and unlock GPS engine when starting and stopping
Newer modem firmware requires the use of the GPS engine lock, which controls what the GPS engine can do. Set the GPS engine lock when appropriate to handle this newer firmware. Signed-off-by: Richard Acayan <mailingradian@gmail.com>
This commit is contained in:
committed by
Dan Williams
parent
b529b69fb6
commit
90843b7a0d
+110
-29
@@ -5092,15 +5092,59 @@ pds_gps_service_state_stop_ready (QmiClientPds *client,
|
|||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
loc_lock_engine_ready (QmiClientLoc *client,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
|
MMSharedQmi *self;
|
||||||
|
Private *priv;
|
||||||
|
QmiMessageLocSetEngineLockOutput *output;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
output = qmi_client_loc_set_engine_lock_finish (client, res, &error);
|
||||||
|
if (!output) {
|
||||||
|
g_prefix_error (&error, "QMI operation failed: ");
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
g_object_unref (task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!qmi_message_loc_set_engine_lock_output_get_result (output, &error)
|
||||||
|
&& !g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_NO_PERMISSION)) {
|
||||||
|
g_prefix_error (&error, "Couldn't lock GPS engine: ");
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
g_object_unref (task);
|
||||||
|
qmi_message_loc_set_engine_lock_output_unref (output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
|
qmi_message_loc_set_engine_lock_output_unref (output);
|
||||||
|
|
||||||
|
self = g_task_get_source_object (task);
|
||||||
|
priv = get_private (self);
|
||||||
|
|
||||||
|
if (priv->loc_client) {
|
||||||
|
if (priv->loc_location_nmea_indication_id != 0) {
|
||||||
|
g_signal_handler_disconnect (priv->loc_client, priv->loc_location_nmea_indication_id);
|
||||||
|
priv->loc_location_nmea_indication_id = 0;
|
||||||
|
}
|
||||||
|
g_clear_object (&priv->loc_client);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_task_return_boolean (task, TRUE);
|
||||||
|
g_object_unref (task);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
loc_stop_ready (QmiClientLoc *client,
|
loc_stop_ready (QmiClientLoc *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
MMSharedQmi *self;
|
QmiMessageLocStopOutput *output;
|
||||||
Private *priv;
|
QmiMessageLocSetEngineLockInput *input;
|
||||||
QmiMessageLocStopOutput *output;
|
GError *error = NULL;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
output = qmi_client_loc_stop_finish (client, res, &error);
|
output = qmi_client_loc_stop_finish (client, res, &error);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
@@ -5120,19 +5164,16 @@ loc_stop_ready (QmiClientLoc *client,
|
|||||||
|
|
||||||
qmi_message_loc_stop_output_unref (output);
|
qmi_message_loc_stop_output_unref (output);
|
||||||
|
|
||||||
self = g_task_get_source_object (task);
|
input = qmi_message_loc_set_engine_lock_input_new ();
|
||||||
priv = get_private (self);
|
qmi_message_loc_set_engine_lock_input_set_lock_type (input, QMI_LOC_LOCK_TYPE_ALL, NULL);
|
||||||
|
qmi_client_loc_set_engine_lock (QMI_CLIENT_LOC (client),
|
||||||
|
input,
|
||||||
|
10,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback) loc_lock_engine_ready,
|
||||||
|
task);
|
||||||
|
qmi_message_loc_set_engine_lock_input_unref (input);
|
||||||
|
|
||||||
if (priv->loc_client) {
|
|
||||||
if (priv->loc_location_nmea_indication_id != 0) {
|
|
||||||
g_signal_handler_disconnect (priv->loc_client, priv->loc_location_nmea_indication_id);
|
|
||||||
priv->loc_location_nmea_indication_id = 0;
|
|
||||||
}
|
|
||||||
g_clear_object (&priv->loc_client);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_task_return_boolean (task, TRUE);
|
|
||||||
g_object_unref (task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -5666,6 +5707,49 @@ loc_start_ready (QmiClientLoc *client,
|
|||||||
qmi_message_loc_register_events_input_unref (input);
|
qmi_message_loc_register_events_input_unref (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
loc_unlock_engine_ready (QmiClientLoc *client,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
|
QmiMessageLocStartInput *input;
|
||||||
|
QmiMessageLocSetEngineLockOutput *output;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
output = qmi_client_loc_set_engine_lock_finish (client, res, &error);
|
||||||
|
if (!output) {
|
||||||
|
g_prefix_error (&error, "QMI operation failed: ");
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
g_object_unref (task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!qmi_message_loc_set_engine_lock_output_get_result (output, &error)
|
||||||
|
&& !g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_NO_PERMISSION)) {
|
||||||
|
g_prefix_error (&error, "Couldn't unlock GPS engine: ");
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
g_object_unref (task);
|
||||||
|
qmi_message_loc_set_engine_lock_output_unref (output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
|
qmi_message_loc_set_engine_lock_output_unref (output);
|
||||||
|
|
||||||
|
input = qmi_message_loc_start_input_new ();
|
||||||
|
qmi_message_loc_start_input_set_session_id (input, DEFAULT_LOC_SESSION_ID, NULL);
|
||||||
|
qmi_message_loc_start_input_set_intermediate_report_state (input, QMI_LOC_INTERMEDIATE_REPORT_STATE_DISABLE, NULL);
|
||||||
|
qmi_message_loc_start_input_set_minimum_interval_between_position_reports (input, 1000, NULL);
|
||||||
|
qmi_message_loc_start_input_set_fix_recurrence_type (input, QMI_LOC_FIX_RECURRENCE_TYPE_REQUEST_PERIODIC_FIXES, NULL);
|
||||||
|
qmi_client_loc_start (QMI_CLIENT_LOC (client),
|
||||||
|
input,
|
||||||
|
10,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback) loc_start_ready,
|
||||||
|
task);
|
||||||
|
qmi_message_loc_start_input_unref (input);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
start_gps_engine (MMSharedQmi *self,
|
start_gps_engine (MMSharedQmi *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
@@ -5703,20 +5787,17 @@ start_gps_engine (MMSharedQmi *self,
|
|||||||
MM_PORT_QMI_FLAG_DEFAULT,
|
MM_PORT_QMI_FLAG_DEFAULT,
|
||||||
NULL);
|
NULL);
|
||||||
if (client) {
|
if (client) {
|
||||||
QmiMessageLocStartInput *input;
|
QmiMessageLocSetEngineLockInput *input;
|
||||||
|
|
||||||
input = qmi_message_loc_start_input_new ();
|
input = qmi_message_loc_set_engine_lock_input_new ();
|
||||||
qmi_message_loc_start_input_set_session_id (input, DEFAULT_LOC_SESSION_ID, NULL);
|
qmi_message_loc_set_engine_lock_input_set_lock_type (input, QMI_LOC_LOCK_TYPE_MT, NULL);
|
||||||
qmi_message_loc_start_input_set_intermediate_report_state (input, QMI_LOC_INTERMEDIATE_REPORT_STATE_DISABLE, NULL);
|
qmi_client_loc_set_engine_lock (QMI_CLIENT_LOC (client),
|
||||||
qmi_message_loc_start_input_set_minimum_interval_between_position_reports (input, 1000, NULL);
|
input,
|
||||||
qmi_message_loc_start_input_set_fix_recurrence_type (input, QMI_LOC_FIX_RECURRENCE_TYPE_REQUEST_PERIODIC_FIXES, NULL);
|
10,
|
||||||
qmi_client_loc_start (QMI_CLIENT_LOC (client),
|
NULL,
|
||||||
input,
|
(GAsyncReadyCallback) loc_unlock_engine_ready,
|
||||||
10,
|
task);
|
||||||
NULL,
|
qmi_message_loc_set_engine_lock_input_unref (input);
|
||||||
(GAsyncReadyCallback) loc_start_ready,
|
|
||||||
task);
|
|
||||||
qmi_message_loc_start_input_unref (input);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user