Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[datapipe] Add init_done_pipe. JB#22475
The "init_done" condition is tracked only internally within the
display plugin eventhough it would be needed in other modules
too.

Add init_done -datapipe and feed it from the display plugin.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 16, 2018
1 parent 9aa28fd commit 2495224
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
6 changes: 6 additions & 0 deletions datapipe.c
Expand Up @@ -87,6 +87,9 @@ datapipe_struct touchscreen_event_pipe;
/** The lock-key has been pressed; read only */
datapipe_struct lockkey_state_pipe;

/** The init-done condition has been reached; read only */
datapipe_struct init_done_pipe;

/** Keyboard open/closed; read only */
datapipe_struct keyboard_slide_state_pipe;

Expand Down Expand Up @@ -787,6 +790,8 @@ void mce_datapipe_init(void)
0, GINT_TO_POINTER(TRUE));
datapipe_init(&lockkey_state_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(KEY_STATE_UNDEF));
datapipe_init(&init_done_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(TRISTATE_UNKNOWN));
datapipe_init(&keyboard_slide_state_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(COVER_CLOSED));
datapipe_init(&keyboard_available_state_pipe, READ_ONLY, DONT_FREE_CACHE,
Expand Down Expand Up @@ -910,6 +915,7 @@ void mce_datapipe_quit(void)
datapipe_free(&keyboard_slide_state_pipe);
datapipe_free(&keyboard_available_state_pipe);
datapipe_free(&lockkey_state_pipe);
datapipe_free(&init_done_pipe);
datapipe_free(&device_inactive_pipe);
datapipe_free(&inactivity_event_pipe);
datapipe_free(&touchscreen_event_pipe);
Expand Down
1 change: 1 addition & 0 deletions datapipe.h
Expand Up @@ -105,6 +105,7 @@ extern datapipe_struct key_backlight_brightness_pipe;
extern datapipe_struct keypress_event_pipe;
extern datapipe_struct touchscreen_event_pipe;
extern datapipe_struct lockkey_state_pipe;
extern datapipe_struct init_done_pipe;
extern datapipe_struct keyboard_slide_state_pipe;
extern datapipe_struct keyboard_available_state_pipe;
extern datapipe_struct lid_sensor_is_working_pipe;
Expand Down
35 changes: 24 additions & 11 deletions modules/display.c
Expand Up @@ -987,7 +987,7 @@ static bootstate_t mdy_bootstate = BOOTSTATE_UNKNOWN;
static filewatcher_t *mdy_bootstate_watcher = 0;

/** Is the init-done flag file present in the file system */
static gboolean mdy_init_done = FALSE;
static tristate_t mdy_init_done = TRISTATE_UNKNOWN;

/** Content change watcher for the init-done flag file */
static filewatcher_t *mdy_init_done_watcher = 0;
Expand Down Expand Up @@ -3389,7 +3389,8 @@ static void mdy_cabc_mode_set(const gchar *const mode)
*/
static void mdy_poweron_led_rethink(void)
{
bool want_led = (!mdy_init_done && mdy_bootstate == BOOTSTATE_USER);
bool want_led = (mdy_init_done != TRISTATE_TRUE &&
mdy_bootstate == BOOTSTATE_USER);

mce_log(LL_DEBUG, "%s MCE_LED_PATTERN_POWER_ON",
want_led ? "activate" : "deactivate");
Expand Down Expand Up @@ -4622,7 +4623,7 @@ static void mdy_blanking_rethink_afterboot_delay(void)
int64_t want_limit = 0;

/* Bootup has not yet finished */
if( mdy_init_done )
if( mdy_init_done != TRISTATE_TRUE )
goto DONE;

/* We are booting to USER mode */
Expand Down Expand Up @@ -6576,7 +6577,7 @@ static int mdy_autosuspend_get_allowed_level(void)
block_late = true;

/* no late suspend during bootup */
if( mdy_desktop_ready_id || !mdy_init_done )
if( mdy_desktop_ready_id || mdy_init_done != TRISTATE_TRUE )
block_late = true;

/* no late suspend during shutdown */
Expand Down Expand Up @@ -8263,7 +8264,7 @@ static void mdy_governor_rethink(void)
}

/* Use default during bootup */
if( mdy_desktop_ready_id || !mdy_init_done ) {
if( mdy_desktop_ready_id || mdy_init_done != TRISTATE_TRUE ) {
governor_want = GOVERNOR_DEFAULT;
}

Expand Down Expand Up @@ -9461,18 +9462,25 @@ static void mdy_flagfiles_init_done_cb(const char *path,
char full[256];
snprintf(full, sizeof full, "%s/%s", path, file);

gboolean flag = access(full, F_OK) ? FALSE : TRUE;
tristate_t prev = mdy_init_done;
mdy_init_done = access(full, F_OK) ? TRISTATE_FALSE : TRISTATE_TRUE;

if( mdy_init_done != prev ) {
mce_log(LL_DEVEL, "init_done flag file present: %s -> %s",
tristate_repr(prev),
tristate_repr(mdy_init_done));

if( mdy_init_done != flag ) {
mdy_init_done = flag;
mce_log(LL_NOTICE, "init_done flag file present: %s",
mdy_init_done ? "true" : "false");
mdy_stm_schedule_rethink();
#ifdef ENABLE_CPU_GOVERNOR
mdy_governor_rethink();
#endif
mdy_poweron_led_rethink();
mdy_blanking_rethink_afterboot_delay();

/* broadcast change within mce */
datapipe_exec_full(&init_done_pipe,
GINT_TO_POINTER(mdy_init_done),
USE_INDATA, CACHE_INDATA);
}
}

Expand Down Expand Up @@ -9613,7 +9621,12 @@ static void mdy_flagfiles_start_tracking(void)
delay = ready - uptime;

/* do not wait for the init-done flag file */
mdy_init_done = TRUE;
if( mdy_init_done != TRISTATE_TRUE ) {
mdy_init_done = TRISTATE_TRUE;
datapipe_exec_full(&init_done_pipe,
GINT_TO_POINTER(mdy_init_done),
USE_INDATA, CACHE_INDATA);
}
}

mce_log(LL_NOTICE, "suspend delay %d seconds", (int)delay);
Expand Down

0 comments on commit 2495224

Please sign in to comment.