diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2019-07-02 21:57:11 +0900 |
---|---|---|
committer | lokilee73 <changjoo.lee@samsung.com> | 2019-07-03 20:30:33 +0900 |
commit | 1573e8d1cbcc97e0cd2be348264864da001f14fd (patch) | |
tree | 16830d9b3d170136a210fa9add128f4131470652 | |
parent | 165cba04a67189aa95c78374ea3be355dce70c74 (diff) | |
download | deviced-1573e8d1cbcc97e0cd2be348264864da001f14fd.tar.gz deviced-1573e8d1cbcc97e0cd2be348264864da001f14fd.tar.bz2 deviced-1573e8d1cbcc97e0cd2be348264864da001f14fd.zip |
Apply changes for ambient modesubmit/tizen/20190703.113545
1. add ambient_lcdoff_signal_handler for signal from clock-viewer
2. change broadcasted signal from integer to string
ex) 0, 1 -> ALPMOff, ALPMOn
3. move ambient_check_invalid_state to del_state_cond
4. add lcd_direct_control for lcd control
Change-Id: Ice5f37124ad90f49ea21b618b99dade6901b8686
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r-- | plugins/wearable/display/core.c | 26 | ||||
-rw-r--r-- | src/display/ambient-mode.c | 79 | ||||
-rw-r--r-- | src/display/core.h | 2 | ||||
-rw-r--r-- | src/display/poll.h | 2 |
4 files changed, 92 insertions, 17 deletions
diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 776ccf69..2c171f66 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -383,6 +383,26 @@ bool touch_event_blocked(void) return touch_blocked; } +void lcd_direct_control(enum dpms_state state, int flags) +{ + const struct device_ops *ops = NULL; + dd_list *l = NULL; + + switch (state) { + case DPMS_ON: + DD_LIST_FOREACH(lcdon_ops, l, ops) + ops->start(flags); + break; + case DPMS_OFF: + DD_LIST_FOREACH(lcdon_ops, l, ops) + ops->stop(flags); + break; + default: + _E("state is wrong value %d", state); + break; + } +} + void lcd_on_procedure(int state, enum device_flags flag) { dd_list *l = NULL; @@ -648,6 +668,9 @@ static void del_state_cond(void *data, enum state_t state) pid = (pid_t)((intptr_t)data); _I("Delete process(%d)'s prohibit dim condition by timeout.", pid); + if (pid == INTERNAL_LOCK_AMBIENT) + ambient_check_invalid_state(pid); + tmp = find_node(state, pid); del_node(state, tmp); get_pname(pid, pname); @@ -1027,9 +1050,6 @@ static void proc_condition_unlock(PMMsg *data) if (state == S_LCDOFF) set_process_active(FALSE, pid); - if (ambient_get_state()) - ambient_check_invalid_state(pid); - _SD("[%s] Unlocked by pid=%d process=%s\n", states[state].name, pid, pname); set_unlock_time(pname, state); diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index f07a34a9..4223dc59 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -30,7 +30,10 @@ #define ON "on" #define OFF "off" -#define SIGNAL_AMBIENT_MODE "AmbientMode" +#define SIGNAL_ALPMLCDOFF "ALPMLCDOff" +#define SIGNAL_ALPM_ON "ALPMOn" +#define SIGNAL_ALPM_OFF "ALPMOff" + #define CLOCK_START "clockstart" #define CLOCK_END "clockend" #define TIMEOUT_NONE (-1) @@ -44,13 +47,15 @@ static unsigned int update_count; void broadcast_ambient_state(int state) { int ret; + char *signal; + signal = (state == true ? SIGNAL_ALPM_ON : SIGNAL_ALPM_OFF); ret = dbus_handle_broadcast_dbus_signal_var(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - SIGNAL_AMBIENT_MODE, - g_variant_new("(i)", (state == 0 ? 0 : 1))); + signal, + NULL); if (ret < 0) - _E("Failed to send dbus signal(%s)", SIGNAL_AMBIENT_MODE); + _E("Failed to send dbus signal(%s)", signal); } int ambient_get_condition(void) @@ -96,7 +101,17 @@ int ambient_set_state(int on) update_count = 0; - if (!on) + /** + * When display is turned off before going to AOD, Generally pm receives + * clock signal or ALPMLCDOFF signal and decides to go to AOD or not. + * But a specific case, the signal is not received. + * So at that time deviced should turn off display to match the pair. + */ + if (on) { + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_AMBIENT, + LCD_OFF, STAY_CUR_STATE, AMBIENT_CLOCK_WAITING_TIME); + } else ambient_pid = 0; _D("AMBIENT is %s.", (on ? ON : OFF)); @@ -113,9 +128,6 @@ void ambient_check_invalid_state(pid_t pid) if (pid != INTERNAL_LOCK_AMBIENT) return; - if (backlight_ops.get_lcd_power() == DPMS_OFF) - return; - if (is_emulator()) { /* In emulator, deviced does not turn off the display. */ if (backlight_ops.get_lcd_power() == DPMS_ON) @@ -132,8 +144,11 @@ void ambient_check_invalid_state(pid_t pid) * deviced doesn't get the clock signal. * deviced just turns off lcd in this case. */ + reset_timeout(TIMEOUT_NONE); ambient_set_state(false); - backlight_ops.off(NORMAL_MODE); + lcd_direct_control(DPMS_OFF, NORMAL_MODE); + + broadcast_lcd_off_late(LCD_OFF_LATE_MODE); } static void ambient_start_clock(void) @@ -155,11 +170,14 @@ static void ambient_end_clock(pid_t pid) ambient_state == false) return; - if (update_count == 0) - broadcast_lcd_off_late(LCD_OFF_LATE_MODE); + if (update_count == 0) { + _D("lcd off"); - if (disp_plgn.pm_unlock_internal) - disp_plgn.pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); + backlight_ops.off(NORMAL_MODE); + broadcast_lcd_off_late(LCD_OFF_LATE_MODE); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); + } update_count++; if (update_count == UINT_MAX) @@ -183,6 +201,32 @@ int ambient_set_screen(char *screen, pid_t pid) return 0; } +static void ambient_lcdoff_signal_handler(GDBusConnection *conn, + const gchar *sender, + const gchar *path, + const gchar *iface, + const gchar *name, + GVariant *param, + gpointer data) +{ + if (ambient_state == false) { + _E("It is not alpm mode"); + return; + } + + if (disp_plgn.pm_lock_internal) + disp_plgn.pm_lock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, GOTO_STATE_NOW, 0); + + _I("Display off in suspend state"); + + ambient_set_state(false); + lcd_direct_control(DPMS_OFF, NORMAL_MODE); + + broadcast_lcd_off_late(LCD_OFF_LATE_MODE); + if (disp_plgn.pm_unlock_internal) + disp_plgn.pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); +} + static void ambient_init(void *data) { int ret; @@ -197,6 +241,15 @@ static void ambient_init(void *data) vconf_notify_key_changed(VCONFKEY_SETAPPL_AMBIENT_MODE_BOOL, ambient_set_condition, NULL); + + ret = subscribe_dbus_signal(NULL, + DEVICED_OBJECT_PATH, + DEVICED_INTERFACE_NAME, + SIGNAL_ALPMLCDOFF, + ambient_lcdoff_signal_handler, + NULL, NULL); + if (ret <= 0) + _E("Failed to register signal handler: %d", ret); } static void ambient_exit(void *data) diff --git a/src/display/core.h b/src/display/core.h index 3f656eb0..a58543c3 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -195,11 +195,13 @@ void set_lcd_paneloff_mode(int val); void lcd_on_direct(enum device_flags flags); void lcd_on_procedure(int state, enum device_flags flag); void lcd_off_procedure(enum device_flags flag); +void lcd_direct_control(enum dpms_state state, int flags); int check_holdkey_block(enum state_t state); bool touch_event_blocked(void); int device_poweroff(void *data); void broadcast_lcd_off_late(enum device_flags flags); void set_dim_state(bool on); +void reset_timeout(int timeout); /* poll.c */ int check_dimstay(int next_state, int flag); diff --git a/src/display/poll.h b/src/display/poll.h index 736e20fe..93afe57b 100644 --- a/src/display/poll.h +++ b/src/display/poll.h @@ -42,6 +42,7 @@ enum { enum { INTERNAL_LOCK_BASE = 100000, + INTERNAL_LOCK_AMBIENT, INTERNAL_LOCK_BATTERY, INTERNAL_LOCK_BATTERY_FULL, INTERNAL_LOCK_BOOTING, @@ -61,7 +62,6 @@ enum { INTERNAL_LOCK_POWERKEY, INTERNAL_LOCK_PM, INTERNAL_LOCK_HALLIC, - INTERNAL_LOCK_AMBIENT, INTERNAL_LOCK_SWIM, }; |