LBMsupport=yes
Level=4
BrtTable=1,20,40,50,60,70,80,90,95,100
-AodBrightnessLevel=40
#include <hal/device/hal-device-power.h>
#include <libsyscommon/log.h>
-#include "ambient-mode.h"
#include "core.h"
#include "poll.h"
#include "lock-detector.h"
.timeout_enable = true,
.input_support = true,
.display_init_direction = SYSCOMMON_DEVICED_DISPLAY_ORIENTATION_HORIZONTAL,
- .aod_enter_level = 40,
- .aod_tsp = true,
.touch_wakeup = false,
.display_on_usb_conn_changed = true,
.display_dpms_type = SYSCOMMON_DEVICED_DPMS_TYPE_WINDOW_MANAGER,
dp->config = &display_conf;
init_display_states(dp);
setup_display_plugin_backlight_ops(dp);
- dp->set_dim_state = NULL;
dp->get_device_flags = NULL;
dp->lcd_on_procedure = NULL;
dp->lcd_off_procedure = NULL;
#include <dlfcn.h>
#include <hal/device/hal-display.h>
-#include "ambient-mode.h"
#include <libsyscommon/log.h>
#include "shared/devices.h"
#include "shared/common.h"
static struct display_backlight_ops backlight_ops = {
.set_brightness = NULL,
.get_brightness = NULL,
- .transit_state = NULL,
- .transit_brt = NULL,
};
void setup_display_plugin_backlight_ops(struct display_plugin *dp)
#include <system/syscommon-plugin-deviced-display-interface.h>
#include <linux/input.h>
-#include "ambient-mode.h"
#include "core.h"
#include "poll.h"
#include "device-interface.h"
if (current_state_in_on())
return false;
- if (display_panel_get_dpms_cached_state() == SYSCOMMON_DEVICED_DPMS_ON) {
- if (ambient_get_state() == false)
- return false;
- }
-
if (flags & LCD_ON_BY_POWER_KEY)
broadcast_lcdon_by_powerkey();
else if (flags & LCD_ON_BY_TOUCH)
#include <system/syscommon-plugin-deviced-display-interface.h>
#include <hal/device/hal-device-power.h>
-#include "ambient-mode.h"
#include "core.h"
#include "poll.h"
#include "lock-detector.h"
.timeout_enable = true,
.input_support = true,
.display_init_direction = SYSCOMMON_DEVICED_DISPLAY_ORIENTATION_HORIZONTAL,
- .aod_enter_level = 40,
- .aod_tsp = true,
.touch_wakeup = false,
.display_on_usb_conn_changed = true,
.display_dpms_type = SYSCOMMON_DEVICED_DPMS_TYPE_WINDOW_MANAGER,
dp->config = &display_conf;
init_display_states(dp);
setup_display_plugin_backlight_ops(dp);
- dp->set_dim_state = NULL;
dp->get_device_flags = NULL;
dp->lcd_on_procedure = NULL;
dp->lcd_off_procedure = NULL;
#include <dlfcn.h>
#include <hal/device/hal-display.h>
-#include "ambient-mode.h"
#include <libsyscommon/log.h>
#include "shared/devices.h"
#include "shared/common.h"
static struct display_backlight_ops backlight_ops = {
.set_brightness = NULL,
.get_brightness = NULL,
- .transit_state = NULL,
- .transit_brt = NULL,
};
void setup_display_plugin_backlight_ops(struct display_plugin *dp)
#include <system/syscommon-plugin-deviced-display-interface.h>
#include <linux/input.h>
-#include "ambient-mode.h"
#include "core.h"
#include "poll.h"
#include "device-interface.h"
if (current_state_in_on())
return false;
- if (display_panel_get_dpms_cached_state() == SYSCOMMON_DEVICED_DPMS_ON) {
- if (ambient_get_state() == false)
- return false;
- }
-
if (flags & LCD_ON_BY_POWER_KEY)
broadcast_lcdon_by_powerkey();
else if (flags & LCD_ON_BY_TOUCH)
auto_brightness_control(BR_HBM_OFF, BR_IMPLICIT);
auto_brightness_control(BR_LBM_OFF, BR_IMPLICIT);
- /* For AOD -> LCDON, brightness effect is deferred to this point */
- if (current_brightness != default_brightness && !hold_brt && !lowdim) {
- change_brightness_transit(current_brightness, default_brightness);
- auto_brightness_control(BR_SET_BRIGHTNESS, default_brightness);
- }
-
break;
default:
/*
#include <libsyscommon/log.h>
#include "auto-brightness-sensorhub.h"
-#include "ambient-mode.h"
#include "core.h"
#include "poll.h"
#include "lock-detector.h"
* @{
*/
-#define LATE_LCD_TRANSIT 1
-
static struct display_plugin *disp_plgn;
static struct display_backlight_ops *backlight_ops;
static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-static guint transit_timer;
/*
* The two variables(lcdon_broadcast, pmstate_suspend) must be set initial
* state because it should be sent from previous state at booting time.
.timeout_enable = true,
.input_support = true,
.display_init_direction = SYSCOMMON_DEVICED_DISPLAY_ORIENTATION_HORIZONTAL,
- .aod_enter_level = 40,
- .aod_tsp = true,
.touch_wakeup = false,
.display_on_usb_conn_changed = true,
.display_dpms_type = SYSCOMMON_DEVICED_DPMS_TYPE_WINDOW_MANAGER,
return &states[state];
}
-static int display_auto_brightness_sensing(void *data)
-{
- if (!transit_timer)
- return 0;
-
- g_source_remove(transit_timer);
- transit_timer = 0;
-
- return 0;
-}
-
static int get_device_flags(unsigned long *device_flags)
{
if (!device_flags)
*device_flags |= TOUCH_SCREEN_OFF_MODE;
}
- if (ambient_get_state()) {
- *device_flags |= AMBIENT_MODE;
- *device_flags |= LCD_PHASED_TRANSIT_MODE;
- }
-
return 0;
}
-static gboolean late_transit_on(void *data)
-{
- if (!transit_timer)
- return G_SOURCE_REMOVE;
-
- g_source_remove(transit_timer);
- transit_timer = 0;
-
- display_backlight_change_brightness_by_dpms_state(SYSCOMMON_DEVICED_DPMS_ON);
- return G_SOURCE_REMOVE;
-}
-
static void lcd_on_procedure(int state, enum device_flags flag)
{
unsigned long flags = NORMAL_MODE;
_I("[lcdstep] 0x%lx", flags);
- if (flags & AMBIENT_MODE) {
- if (ambient_get_state() == false && display_panel_get_dpms_cached_state() == SYSCOMMON_DEVICED_DPMS_ON)
- return;
- ambient_set_state(false);
- }
-
/* send LCDOn dbus signal */
if (!lcdon_broadcast)
broadcast_lcd_on(SIGNAL_PRE, flags);
- if (!(flags & LCD_PHASED_TRANSIT_MODE)) {
- /* Update brightness level */
- if (state == LCD_DIM)
- display_backlight_set_brightness_by_dim_brightness();
- else if (state == LCD_NORMAL)
- display_backlight_update_by_default_brightness();
- }
+ /* Update brightness level */
+ if (state == LCD_DIM)
+ display_backlight_set_brightness_by_dim_brightness();
+ else if (state == LCD_NORMAL)
+ display_backlight_update_by_default_brightness();
if (state == LCD_NORMAL)
set_setting_pmstate(SYSCOMMON_DEVICED_DISPLAY_STATE_ON);
if (!lcdon_broadcast) {
broadcast_lcd_on(SIGNAL_POST, flags);
- if (flags & LCD_PHASED_TRANSIT_MODE)
- transit_timer = g_timeout_add_seconds(LATE_LCD_TRANSIT,
- late_transit_on, NULL);
lcdon_broadcast = true;
}
display_misc_set_touch_event_blocked(true);
- if (flags & AMBIENT_MODE) {
- if (ambient_get_state() == true)
- return;
- ambient_set_state(true);
- }
-
set_setting_pmstate(SYSCOMMON_DEVICED_DISPLAY_STATE_OFF);
- if (transit_timer) {
- g_source_remove(transit_timer);
- transit_timer = 0;
- }
-
- if (flags & LCD_PHASED_TRANSIT_MODE)
- display_backlight_change_brightness_by_dpms_state(SYSCOMMON_DEVICED_DPMS_OFF);
-
display_stop_dependent_device(flags);
- if (flags & AMBIENT_MODE) {
- broadcast_lcd_off_late(flags);
- } else {
- broadcast_lcd_off(SIGNAL_POST, flags);
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_LCD_OFF_COMPLETE, NULL);
- }
+ broadcast_lcd_off(SIGNAL_POST, flags);
+ syscommon_notifier_emit_notify(DEVICED_NOTIFIER_LCD_OFF_COMPLETE, NULL);
enter_doze();
}
-static void set_dim_state(bool on)
-{
- _I("Dim state is %d.", on);
- display_state_transition_update_display_state_timeout_by_priority();
- states[get_pm_cur_state()].trans(EVENT_INPUT);
-}
-
static inline bool check_lcd_is_on(void)
{
if (display_panel_get_dpms_cached_state() != SYSCOMMON_DEVICED_DPMS_ON)
dp->config = &display_conf;
init_display_states(dp);
setup_display_plugin_backlight_ops(dp);
- dp->set_dim_state = set_dim_state;
dp->get_device_flags = get_device_flags;
dp->lcd_on_procedure = lcd_on_procedure;
dp->lcd_off_procedure = lcd_off_procedure;
register_kernel_uevent_control(&sec_dsim_uevent_ops);
- syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_LCD_AUTOBRT_SENSING, display_auto_brightness_sensing);
-
init_setting(update_setting);
init_sysfs(flags);
init_lcd_operation();
#include <system/syscommon-plugin-deviced-display-interface.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
-#include "ambient-mode.h"
#include <libsyscommon/log.h>
#include "shared/devices.h"
#include "shared/common.h"
static struct display_backlight_ops backlight_ops;
static struct battery_plugin *battery_plgn;
-static int aod_max_level = -1;
-static int aod_normal_level = -1;
-static int aod_min_level = -1;
-static int aod_charging_level = -1;
static const struct syscommon_deviced_display_config *display_conf;
static struct battery_status *battery = NULL;
static struct battery_status* (*fp_get_var_battery_status)(void);
return hal_device_display_set_brightness(val);
}
-/* It was operated only AOD enter & leave */
-static int backlight_transit_state(int state)
-{
- int brt, val;
- int start, end;
- static int aod_brightness_level;
- int default_brightness = 0;
-
- display_backlight_get_default_brightness(&default_brightness);
-
- display_backlight_get_brightness(&brt);
-
- if (state == SYSCOMMON_DEVICED_DPMS_OFF) {
- start = brt;
-
- /*
- * The value of display_backlight_get_brightness is system brightness.
- * But when device is LBM, the value is not same with real brightness.
- * So it should be read exactly value for transit smooth effect
- */
- display_backlight_get_brightness(&val);
-
- /* AOD brightness
- *
- * Compare current brightness with threshold based on charger's charging state.
- * Charger charging state has 2 threshold: CHARGING, MIN
- * The other states has 3 threshold: MAX, NORMAL, MIN
- *
- * Select the highest threshold among the thresholds less then the current brightness.
- * If current brightness is less then MIN threshold, do not transit brightness.
- *
- * e.g.
- * threshold for | threshold for
- * charger CHARGING | the other charger states
- * |
- * |
- * |-----MAX(50)
- * |
- * |-----NORMAL(40)
- * |
- * |
- * CHARGING(20)-----|
- * |
- * MIN(10)-----|-----MIN(10)
- * if DISCHARGING and current brightness is 30, then AOD brightness will be 10.
- * if DISCHARGING and current brightness is 45, then AOD brightness will be 40.
- * if CHARGING and current brightness is 80, then AOD brightness will be 20.
- * if current brightness is 5, do not transit brightness.
- */
- if (aod_min_level > 0 && val < aod_min_level) {
- _W("Current brightness is already lower than minimum threshold.");
- return 0;
- }
-
- if (battery && battery->charge_now == CHARGER_CHARGING) {
- if (aod_charging_level > 0 && val >= aod_charging_level)
- aod_brightness_level = aod_charging_level;
- else if (aod_min_level > 0 && val >= aod_min_level)
- aod_brightness_level = aod_min_level;
- else
- aod_brightness_level = display_conf->aod_enter_level;
- } else {
- if (aod_max_level > 0 && val >= aod_max_level)
- aod_brightness_level = aod_max_level;
- else if (aod_normal_level > 0 && val >= aod_normal_level)
- aod_brightness_level = aod_normal_level;
- else if (aod_min_level > 0 && val >= aod_min_level)
- aod_brightness_level = aod_min_level;
- else
- aod_brightness_level = display_conf->aod_enter_level;
- }
-
- if (val > aod_brightness_level) {
- _D("backlight transit start %d end %d DPMS OFF", start, aod_brightness_level);
- display_backlight_change_brightness(start, aod_brightness_level, display_conf->brightness_change_step);
- }
- } else {
- /* prevent transit effect when another effect is already executed */
- if (brt != aod_brightness_level) {
- _W("effect is already executed brt(%d) aod_level(%d)",
- brt, aod_brightness_level);
- return 0;
- }
-
- start = aod_brightness_level;
- end = default_brightness;
- _D("backlight transit start %d end %d DPMS ON", start, end);
- display_backlight_change_brightness(start, end, display_conf->brightness_change_step);
- }
-
- return 0;
-}
-
static struct display_backlight_ops backlight_ops = {
.set_brightness = set_brightness,
.get_brightness = NULL,
- .transit_state = backlight_transit_state,
- .transit_brt = NULL,
};
int is_lcdon_blocked(void)
CHARGING_LCD_ON = 1,
};
-static struct display_backlight_ops *backlight_ops;
-static guint autobrt_timer;
-static int autobrtlevel;
-
-static bool aod_clock_displayed; /* True while AOD screen is displayed */
-
-static gboolean lcdon_from_aod_cb(gpointer data)
-{
- int level = (int)(intptr_t) data;
-
- autobrt_timer = 0;
-
- /* If it is still not turned on, do not apply auto brightness */
- if (display_panel_get_dpms_cached_state() != SYSCOMMON_DEVICED_DPMS_ON)
- return G_SOURCE_REMOVE;
-
- display_backlight_change_brightness_by_dpms_state(SYSCOMMON_DEVICED_DPMS_ON);
- set_brightness_level(level);
-
- /* lcdon is completed, aod disappered */
- aod_clock_displayed = false;
-
- return G_SOURCE_REMOVE;
-}
-
-/* For AOD state, there is race condition between
- * HomeScreen dbus signal and AutoBrightnessChanged dbus method call.
- * Cannot decide which one arrives first */
static GVariant *dbus_autobrightnesschanged(GDBusConnection *conn,
const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
g_variant_get(param, "(i)", &level);
- /* If received level is identical to autobrt timer reserved level, ignore it. */
- if (autobrt_timer && autobrtlevel == level) {
- _D("Ignore autobrightness change request as same request(%d) is pending.", level);
- return g_variant_new("(i)", ret);
- }
-
- if (autobrt_timer) {
- g_source_remove(autobrt_timer);
- autobrt_timer = 0;
- }
-
syscommon_notifier_emit_notify(DEVICED_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
- /* When display state changes from AOD to LCDON, brightness change
- * effect seems sluggish because of heavy load of jobs for turning on
- * display. So delay this brightness change a bit to avoid this
- * heavy loaded time and therefore make it change smoothly. */
- if (aod_clock_displayed) {
- autobrtlevel = level; /* reserve the level, defer applying */
- autobrt_timer = g_timeout_add(200, lcdon_from_aod_cb, (gpointer)(intptr_t) level);
- } else { /* SYSCOMMON_DEVICED_DISPLAY_STATE_ON state or LCDON from usual OFF state, not from AOD */
- set_brightness_level(level);
- }
+ set_brightness_level(level);
return g_variant_new("(i)", ret);
}
-static void aod_change_signal(GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- gpointer data)
-
-{
- char *screen = NULL;
-
- if (!g_variant_get_safe(param, "(s)", &screen)) {
- _E("failed to get params from gvariant. expected:%s, type:%s", "(s)", g_variant_get_type_string(param));
- goto out;
- }
-
- if (screen == NULL) {
- _E("screen is null.");
- goto out;
- }
-
- /* clock-viewer sends "clockchanged" as signal parameter when AOD->LCDON.
- * On catching this signal, do change brightness immediately. */
- if (!strcmp(screen, CLOCK_CHANGED)) {
- /* aod_clock_displayed can be false if this clockchanged siganl arrives after 200ms timeout.
- * In this situation, there is noting to do because all the
- * brightness-related task, which should have been done in this routine,
- * have been performed by timeout callback, lcdon_from_aod_cb(). */
- if (!aod_clock_displayed)
- return;
-
- display_backlight_change_brightness_by_dpms_state(SYSCOMMON_DEVICED_DPMS_ON);
- if (autobrt_timer) { /* if there is reserved level, apply it */
- g_source_remove(autobrt_timer);
- autobrt_timer = 0;
- set_brightness_level(autobrtlevel);
- }
- /* lcdon is completed, aod disappered */
- aod_clock_displayed = false;
- } else if (!strcmp(screen, CLOCK_END)) {
- /* lcdoff is completed, aod showed up */
- aod_clock_displayed = true;
- }
-
-out:
- if (screen)
- g_free(screen);
-}
-
static const dbus_method_s dbus_methods[] = {
{ "AutoBrightnessChanged", "i", "i", dbus_autobrightnesschanged },
};
prepare_level_handler();
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_LCD, display_state_changed);
- aod_clock_displayed = false;
- ret = gdbus_signal_subscribe(NULL,
- DEVICED_OBJECT_PATH,
- DEVICED_INTERFACE_NAME,
- SIGNAL_HOMESCREEN,
- aod_change_signal,
- NULL, NULL);
- if (ret <= 0)
- _E("Failed to register signal handler: %d", ret);
-
ret = sys_set_int(CHARGER_LCD_NODE, CHARGING_LCD_ON);
if (ret < 0)
_E("Can't write %s node.", CHARGER_LCD_NODE);
};
DISPLAY_OPS_REGISTER(&display_handler_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
- backlight_ops = get_var_backlight_ops();
- if (!backlight_ops)
- _E("Failed to get backlight operator variable.");
-}
#include <system/syscommon-plugin-deviced-common-interface.h>
#include <linux/input.h>
-#include "ambient-mode.h"
#include "core.h"
#include "poll.h"
#include "device-interface.h"
if (current_state_in_on())
return false;
- if (display_panel_get_dpms_cached_state() == SYSCOMMON_DEVICED_DPMS_ON) {
- if (ambient_get_state() == false)
- return false;
- }
-
if (flags & LCD_ON_BY_POWER_KEY)
broadcast_lcdon_by_powerkey();
else if (flags & LCD_ON_BY_TOUCH)
ignore = false;
break;
case EV_ABS:
- if (display_misc_is_touch_event_blocked() && !ambient_get_state()
+ if (display_misc_is_touch_event_blocked()
&& !g_display_plugin.config->touch_wakeup
&& pinput->value == KEY_BEING_PRESSED)
return;
.down_level = 0,
.brt_table_size = 0,
.brt_table = NULL,
- .aod_brightness_level = 0,
};
static struct display_backlight_ops *backlight_ops;
int down_level;
int brt_table_size;
int *brt_table;
- int aod_brightness_level;
};
int lbm_get_state(void);
+++ /dev/null
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <stdbool.h>
-#include <fcntl.h>
-#include <libsyscommon/libgdbus.h>
-#include <libsyscommon/common.h>
-#include <system/syscommon-plugin-deviced-common-interface.h>
-
-#include "core.h"
-#include "display.h"
-#include "display-lock.h"
-#include "display-ops.h"
-#include "display-panel.h"
-#include "display-plugin.h"
-#include "display-state-transition.h"
-#include "shared/log.h"
-#include "shared/device-notifier.h"
-#include "shared/devices.h"
-#include "shared/plugin.h"
-
-#define ON "on"
-#define OFF "off"
-
-#define SIGNAL_HOMESCREEN "HomeScreen"
-
-#define SIGNAL_ALPMLCDOFF "ALPMLCDOff"
-#define SIGNAL_ALPM_ON "ALPMOn"
-#define SIGNAL_ALPM_OFF "ALPMOff"
-
-#define CLOCK_START "clockstart"
-#define CLOCK_END "clockend"
-#define CLOCK_CHANGED "clockchanged"
-#define AMBIENT_CLOCK_WAITING_TIME 5000 /* ms */
-
-static struct display_plugin *disp_plgn;
-static int ambient_state;
-static int ambient_condition; /* Setting Value */
-static pid_t ambient_pid; /* Ambient Clock pid */
-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 = gdbus_signal_emit(NULL,
- DEVICED_PATH_DISPLAY,
- DEVICED_INTERFACE_DISPLAY,
- signal,
- NULL);
- if (ret < 0)
- _E("Failed to send dbus signal(%s).", signal);
-}
-
-int ambient_get_condition(void)
-{
- return ambient_condition;
-}
-
-int ambient_get_state(void)
-{
- return ambient_state;
-}
-
-static void ambient_set_condition(keynode_t *key_nodes, void *data)
-{
- int state, val;
-
- if (key_nodes == NULL) {
- _E("Wrong parameter, key_nodes is null.");
- return;
- }
-
- val = vconf_keynode_get_bool(key_nodes);
- if (val != ambient_condition) {
- if (display_panel_get_dpms_cached_state() != SYSCOMMON_DEVICED_DPMS_ON)
- display_state_transition_request_state_transition_with_option(DEVICED_EVENT_DISPLAY_AMBIENT, LCD_NORMAL);
- }
-
- ambient_condition = val;
- _I("Ambient mode condition is %d.", ambient_condition);
-
- state = (ambient_condition == 0 ? 0 : 1);
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_DISPLAY_AMBIENT_CONDITION, (void *)&state);
-
- display_plugin_set_dim_state(state);
-}
-
-int ambient_set_state(int on)
-{
- if (!ambient_condition)
- return 0;
-
- broadcast_ambient_state(on);
-
- update_count = 0;
-
- /**
- * 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) {
- display_lock_request_lock_with_option(DEVICED_EVENT_DISPLAY_AMBIENT,
- LCD_OFF, STAY_CUR_STATE, AMBIENT_CLOCK_WAITING_TIME);
- } else
- ambient_pid = 0;
-
- _D("AMBIENT is %s.", (on ? ON : OFF));
-
- ambient_state = on;
-
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_DISPLAY_AMBIENT_STATE, (void *)&ambient_state);
-
- return 0;
-}
-
-void ambient_check_invalid_state(pid_t pid)
-{
- if (pid != DEVICED_EVENT_DISPLAY_AMBIENT)
- return;
-
- if (syscommon_is_emulator()) {
- /* In emulator, deviced does not turn off the display. */
- if (display_panel_get_dpms_cached_state() == SYSCOMMON_DEVICED_DPMS_ON)
- return;
- }
-
- if (ambient_get_state() == false)
- return;
-
- _I("Invalid state. Ambient state is change to off.");
-
- /* If lcd_power is on and ambient state is true
- * when pm state is changed to sleep,
- * deviced doesn't get the clock signal.
- * deviced just turns off lcd in this case.
- */
-
- display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
- lcd_direct_control(SYSCOMMON_DEVICED_DPMS_OFF, NORMAL_MODE);
-
- broadcast_lcd_off_late(LCD_OFF_LATE_MODE);
-}
-
-static void ambient_start_clock(void)
-{
- int ret;
- enum syscommon_deviced_display_state current;
-
- ret = display_state_get_current(¤t);
- if (ret < 0)
- return;
-
- if ((current == SYSCOMMON_DEVICED_DISPLAY_STATE_ON) ||
- (current == SYSCOMMON_DEVICED_DISPLAY_STATE_DIM) ||
- (ambient_state == false))
- return;
-
- display_lock_request_lock_with_option(DEVICED_EVENT_DISPLAY_AMBIENT, LCD_OFF, STAY_CUR_STATE,
- AMBIENT_CLOCK_WAITING_TIME);
-}
-
-static void ambient_end_clock(pid_t pid)
-{
- int ret;
- enum syscommon_deviced_display_state current;
-
- ret = display_state_get_current(¤t);
- if (ret < 0)
- return;
-
- if ((current == SYSCOMMON_DEVICED_DISPLAY_STATE_ON) ||
- (current == SYSCOMMON_DEVICED_DISPLAY_STATE_DIM) ||
- (ambient_state == false))
- return;
-
- if (update_count == 0) {
- _D("lcd off");
-
- display_panel_set_panel_state_by_off_state(NORMAL_MODE);
- broadcast_lcd_off_late(LCD_OFF_LATE_MODE);
- display_lock_request_unlock_with_option(DEVICED_EVENT_DISPLAY_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN);
- }
-
- update_count++;
- if (update_count == UINT_MAX)
- update_count = 1;
- ambient_pid = pid;
-
- _I("Enter real ambient state by process(%d).",
- ambient_pid);
-}
-
-static void homescreen_signal_handler(GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- gpointer data)
-{
- char *screen = NULL;
- pid_t pid;
-
- if (!g_variant_get_safe(param, "(s)", &screen)) {
- _E("failed to get params from gvariant. expected:%s, type:%s", "(s)", g_variant_get_type_string(param));
- goto out;
- }
-
- if (screen == NULL) {
- _E("screen is null.");
- goto out;
- }
- _D("screen : %s", screen);
-
- pid = gdbus_connection_get_sender_pid(conn, sender);
-
- if (!strncmp(screen, CLOCK_START, strlen(CLOCK_START)))
- ambient_start_clock();
- else if (!strncmp(screen, CLOCK_END, strlen(CLOCK_END)))
- ambient_end_clock(pid);
-
-out:
- if (screen)
- g_free(screen);
-}
-
-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;
- }
-
- display_lock_request_lock_with_option(DEVICED_EVENT_DISPLAY_AMBIENT, LCD_OFF, GOTO_STATE_NOW, 0);
-
- _I("Display off in suspend state.");
-
- ambient_set_state(false);
- lcd_direct_control(SYSCOMMON_DEVICED_DPMS_OFF, NORMAL_MODE);
-
- broadcast_lcd_off_late(LCD_OFF_LATE_MODE);
- display_lock_request_unlock_with_option(DEVICED_EVENT_DISPLAY_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN);
-}
-
-static void ambient_init(void *data)
-{
- int ret;
-
- ret = vconf_get_bool("db/starter/always_on_display", &ambient_condition);
- if (ret < 0) {
- _E("Failed to get initial AOD condition. AOD is not going to work.");
- return;
- } else {
- _I("Ambient mode condition is %d.", ambient_condition);
-
- vconf_notify_key_changed("db/starter/always_on_display",
- ambient_set_condition, NULL);
- }
- ret = gdbus_signal_subscribe(NULL,
- DEVICED_OBJECT_PATH,
- DEVICED_INTERFACE_NAME,
- SIGNAL_HOMESCREEN,
- homescreen_signal_handler,
- NULL, NULL);
- if (ret <= 0)
- _E("Failed to register signal handler: %d", ret);
-
- ret = gdbus_signal_subscribe(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)
-{
- ambient_set_state(false);
- vconf_ignore_key_changed("db/starter/always_on_display", ambient_set_condition);
-}
-
-static const struct display_ops ambient_ops = {
- .name = "ambient",
- .init = ambient_init,
- .exit = ambient_exit,
-};
-
-DISPLAY_OPS_REGISTER(&ambient_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
- disp_plgn = get_var_display_plugin();
- if (!disp_plgn)
- _E("Failed to get display plugin variable.");
-}
+++ /dev/null
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AMBIENT_MODE_H__
-#define __AMBIENT_MODE_H__
-
-#define AMBIENT_CLOCK_WAITING_TIME 5000 /* ms */
-
-int ambient_get_condition(void);
-int ambient_get_state(void);
-int ambient_set_state(int on);
-void ambient_check_invalid_state(pid_t pid);
-
-#endif /* __AMBIENT_MODE_H__ */
/* core.c */
int delete_condition(enum syscommon_deviced_display_state state);
int custom_lcdoff(enum device_flags flag);
-void broadcast_lcd_off_late(enum device_flags flags);
/* auto-brightness.c */
void set_brightness_changed_state(void);
display_backlight_set_brightness_with_delay(start, LCD_PHASED_DELAY);
}
}
-
-/* FIXME: display_backlight_get_brightness is duplicated, this code structure should be changed */
-/* It was operated only AOD enter & leave. */
-int display_backlight_change_brightness_by_dpms_state(enum syscommon_deviced_dpms_state state)
-{
- int brt, val;
- int start, end;
- int default_brightness;
- int ret;
-
- assert(g_display_plugin.config);
-
- display_backlight_get_default_brightness(&default_brightness);
-
- ret = display_plugin_backlight_transit_state((int) state);
- if (ret == 0)
- return 0;
-
- display_backlight_get_brightness(&brt);
-
- if (state == SYSCOMMON_DEVICED_DPMS_OFF) {
- start = brt;
- end = g_display_plugin.config->aod_enter_level;
-
- /*
- * The value of display_backlight_get_brightness is system brightness.
- * But when device is LBM, the value is not same with real brightness.
- * So it should be read exactly value for transit smooth effect
- */
- display_backlight_get_brightness(&val);
-
- if (val > g_display_plugin.config->aod_enter_level)
- display_backlight_change_brightness(start, end, g_display_plugin.config->brightness_change_step);
- } else {
- /* prevent transit effect when another effect is already executed */
- if (brt != g_display_plugin.config->aod_enter_level) {
- _W("effect is already executed brt(%d) aod_level(%d)",
- brt, g_display_plugin.config->aod_enter_level);
- return 0;
- }
-
- start = g_display_plugin.config->aod_enter_level;
- end = default_brightness;
- display_backlight_change_brightness(start, end, g_display_plugin.config->brightness_change_step);
- }
-
- return 0;
-}
-
int display_backlight_set_default_brightness(int brightness)
{
if (brightness < PM_MIN_BRIGHTNESS || brightness > PM_MAX_BRIGHTNESS) {
struct display_backlight_ops {
int (*set_brightness)(int val);
int (*get_brightness)(int *val);
- int (*transit_state)(int state);
void (*transit_brt)(int start, int end, int step);
};
int display_backlight_set_brightness(int brightness);
int display_backlight_get_brightness(int *brightness);
void display_backlight_change_brightness(int start, int end, int step);
-int display_backlight_change_brightness_by_dpms_state(enum syscommon_deviced_dpms_state state);
int display_backlight_set_default_brightness(int brightness);
int display_backlight_get_default_brightness(int *brightness);
int display_backlight_update_by_default_brightness(void);
} else if (MATCH(result->name, "InputSupport")) {
c->input_support = (MATCH(result->value, "yes") ? true : false);
_D("Input is %s", c->input_support ? "supported" : "NOT supported");
- } else if (MATCH(result->name, "AODTSP")) {
- c->aod_tsp = (MATCH(result->value, "yes") ? true : false);
- _D("TSP control at is %d at aod", c->aod_tsp);
} else if (MATCH(result->name, "DisplayOnUsbConnChanged")) {
c->display_on_usb_conn_changed = (MATCH(result->value, "yes") ? true : false);
} else if (MATCH(result->name, "DisplayInitDirection")) {
#include <device/display.h>
#include <device/power.h>
-#include "ambient-mode.h"
#include "core/log.h"
#include "core.h"
#include "lock-detector.h"
#include <system/syscommon-plugin-deviced-common-interface.h>
#include "shared/common.h"
-#include "ambient-mode.h"
#include "device-interface.h"
#include "poll.h"
//#include "display.h"
display_plugin_state_get_name(dl->state, &stname);
_I("Display lock expired, state=%s pid=%d", stname, dl->pid);
- if (dl->pid == DEVICED_EVENT_DISPLAY_AMBIENT)
- ambient_check_invalid_state(dl->pid);
-
if (dl->state == SYSCOMMON_DEVICED_DISPLAY_STATE_OFF)
set_process_active(false, dl->pid);
#include "power/power.h"
#include "power/power-suspend.h"
#include "power/power-doze.h"
-#include "ambient-mode.h"
#include "device-interface.h"
#include "display-lock.h"
#include "display-misc.h"
int display_panel_set_panel_state_by_off_state(enum device_flags flags)
{
int ret = -1;
- static int cnt, ambient_cnt;
+ static int cnt;
int default_brightness = 0;
display_backlight_get_default_brightness(&default_brightness);
- if (flags & AMBIENT_MODE) {
- _I("[DPMS XLIB Backlight] LCD suspend %#x cnt:%d", flags, ambient_cnt);
- ambient_cnt++;
- return 0;
- }
-
_I("[DPMS XLIB Backlight] LCD off %#x cnt:%d", flags, cnt);
cnt++;
- if (flags & LCD_PHASED_TRANSIT_MODE)
- display_backlight_change_brightness(default_brightness,
- LCD_PHASED_MIN_BRIGHTNESS, LCD_PHASED_CHANGE_STEP);
-
if (flags & FORCE_OFF_MODE)
ret = display_panel_set_dpms_state(SYSCOMMON_DEVICED_DPMS_FORCE_OFF, flags);
else
if (ret < 0)
return ret;
- /**
- * FIXME: Ambient mode is currently not the display core feature but wearable profile exclusive
- * feature. Therefore exclude this condition statement from the display core logic.
- * Please consider this condition statement when the ambient feature comes into the display core.
- */
- //if (val == DISPLAY_ON && ambient_get_state())
- // return SYSCOMMON_DEVICED_DPMS_OFF;
-
switch (val) {
case DISPLAY_ON:
return SYSCOMMON_DEVICED_DPMS_ON;
return -EOPNOTSUPP;
}
-int display_plugin_backlight_transit_state(int state)
-{
- if (g_display_plugin.backlight && g_display_plugin.backlight->transit_state)
- return g_display_plugin.backlight->transit_state(state);
-
- return -EOPNOTSUPP;
-}
-
int display_plugin_backlight_transit_brightness(int start, int end, int step)
{
if (g_display_plugin.backlight && g_display_plugin.backlight->transit_brt) {
return 0;
}
-int display_plugin_set_dim_state(bool on)
-{
- if (g_display_plugin.set_dim_state) {
- g_display_plugin.set_dim_state(on);
- return 0;
- }
-
- return -EOPNOTSUPP;
-}
-
int display_plugin_get_device_flags(unsigned long *device_flags)
{
if (!device_flags)
bool system_wakeup_flag;
int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
/* FIXME: function names will be redefined */
- void (*set_dim_state) (bool on);
int (*get_device_flags) (unsigned long *device_flags);
void (*lcd_on_procedure) (int state, enum device_flags flag);
void (*lcd_off_procedure) (enum device_flags flag);
int display_plugin_get_system_wakeup_flag(bool *flag);
int display_plugin_set_system_wakeup_flag(bool flag);
int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness);
-int display_plugin_set_dim_state(bool on);
int display_plugin_get_device_flags(unsigned long *device_flags);
int display_plugin_lcd_on_procedure(int state, enum device_flags flag);
int display_plugin_lcd_off_procedure(enum device_flags flag);
int display_plugin_backlight_set_brightness(int brightness);
int display_plugin_backlight_get_brightness(int *brightness);
-int display_plugin_backlight_transit_state(int state);
int display_plugin_backlight_transit_brightness(int start, int end, int step);
/* FIXME: function names will be redefined */
_E("Failed to send dbus signal(%s)", signal);
}
-void broadcast_lcd_off_late(enum device_flags flags)
-{
- static enum device_flags late_flags;
-
- if (flags & LCD_OFF_LATE_MODE) {
- broadcast_lcd_off(SIGNAL_POST, late_flags);
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_LCD_OFF_COMPLETE, NULL);
- } else {
- late_flags = flags;
- }
-}
-
void set_process_active(bool flag, pid_t pid)
{
int ret;
void broadcast_lcd_on(enum signal_type type, enum device_flags flags);
void broadcast_lcd_off(enum signal_type type, enum device_flags flags);
-void broadcast_lcd_off_late(enum device_flags flags);
void set_process_active(bool flag, pid_t pid);
void display_signal_register_display_brightness_notifier(void);
#include <errno.h>
#include <stdbool.h>
-#include "ambient-mode.h"
#include "core.h"
#include "device-interface.h"
#include "setting.h"
return;
}
- if (!g_display_plugin.config->dimming || ambient_get_condition()) {
+ if (!g_display_plugin.config->dimming) {
*dim_timeout = LCD_MIN_DIM_TIMEOUT;
return;
}
enum device_flags {
NORMAL_MODE = 0x00000001,
- AMBIENT_MODE = 0x00000002,
FORCE_OFF_MODE = 0x00000004,
TOUCH_SCREEN_OFF_MODE = 0x00002000,
LCD_PANEL_OFF_MODE = 0x00004000,
- LCD_PHASED_TRANSIT_MODE = 0x00008000,
LCD_ON_BY_GESTURE = 0x00010000,
LCD_ON_BY_POWER_KEY = 0x00020000,
LCD_ON_BY_BACK_KEY = 0x00040000,
LCD_OFF_BY_POWER_KEY = 0x02000000,
LCD_OFF_BY_TIMEOUT = 0x04000000,
LCD_OFF_BY_EVENT = 0x08000000,
- LCD_OFF_LATE_MODE = 0x10000000,
LCD_OFF_BY_PROXIMITY = 0x20000000,
LCD_OFF_BY_GESTURE = 0x40000000,
LCD_OFF_BY_PALM = 0x80000000,