Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Provide visibility to cached display state polling
The transient power up/down states do not show up in datapipe
output triggers, but code that reads directly from datapipe
might see them and cause problems. These changes make it easier
to find the places where this happens.
  • Loading branch information
spiiroin committed Oct 28, 2013
1 parent 822118a commit 44bb81c
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 26 deletions.
6 changes: 4 additions & 2 deletions event-input.c
Expand Up @@ -960,7 +960,7 @@ static int doubletap_emulate(const struct input_event *eve)
*/
static gboolean touchscreen_iomon_cb(gpointer data, gsize bytes_read)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
submode_t submode = mce_get_submode_int32();
struct input_event *ev;
gboolean flush = FALSE;
Expand All @@ -979,7 +979,7 @@ static gboolean touchscreen_iomon_cb(gpointer data, gsize bytes_read)

#ifdef ENABLE_DOUBLETAP_EMULATION
if( fake_doubletap_enabled ) {
switch( datapipe_get_gint(display_state_pipe) ) {
switch( display_state ) {
case MCE_DISPLAY_OFF:
case MCE_DISPLAY_LPM_OFF:
case MCE_DISPLAY_LPM_ON:
Expand All @@ -991,6 +991,8 @@ static gboolean touchscreen_iomon_cb(gpointer data, gsize bytes_read)
}
break;
default:
case MCE_DISPLAY_POWER_UP:
case MCE_DISPLAY_POWER_DOWN:
break;
}
}
Expand Down
6 changes: 6 additions & 0 deletions mce.h
Expand Up @@ -353,4 +353,10 @@ gboolean mce_rem_submode_int32(const submode_t submode);
void mce_abort(void) __attribute__((noreturn));
void mce_quit_mainloop(void);

#define display_state_get() ({\
gint res = GPOINTER_TO_INT(display_state_pipe.cached_data);\
mce_log(LL_DEBUG, "display_state=%d", res);\
res;\
})

#endif /* _MCE_H_ */
18 changes: 9 additions & 9 deletions modules/display.c
Expand Up @@ -949,7 +949,7 @@ GTimer *hbm_timer;
*/
static void update_display_timers(gboolean force_flush)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
gdouble display_elapsed = 0;
gdouble hbm_elapsed = 0;
gboolean flush_cal = FALSE;
Expand Down Expand Up @@ -1174,7 +1174,7 @@ static void setup_hbm_timeout(void)
*/
static void update_high_brightness_mode(gint hbm_level)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();

if (high_brightness_mode_supported == FALSE)
goto EXIT;
Expand Down Expand Up @@ -1625,7 +1625,7 @@ static void display_unblank(void)
*/
static void display_brightness_trigger(gconstpointer data)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
gint new_brightness = GPOINTER_TO_INT(data) & 0xff;
gint new_hbm_level = (GPOINTER_TO_INT(data) >> 8) & 0xff;

Expand Down Expand Up @@ -1952,7 +1952,7 @@ static void setup_dim_timeout(void)
system_state_t system_state = datapipe_get_gint(system_state_pipe);
gint dim_timeout = disp_dim_timeout + bootup_dim_additional_timeout;
submode_t submode = datapipe_get_gint(submode_pipe);;
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();

cancel_blank_timeout();
cancel_adaptive_dimming_timeout();
Expand Down Expand Up @@ -2046,7 +2046,7 @@ static void request_display_blanking_pause(void)
*/
static void update_blanking_inhibit(gboolean timed_inhibit)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
system_state_t system_state = datapipe_get_gint(system_state_pipe);
alarm_ui_state_t alarm_ui_state =
datapipe_get_gint(alarm_ui_state_pipe);
Expand Down Expand Up @@ -2268,7 +2268,7 @@ static void display_gconf_cb(GConfClient *const gcc, const guint id,
USE_INDATA, CACHE_INDATA);
} else if (id == use_low_power_mode_gconf_cb_id) {
display_state_t display_state =
datapipe_get_gint(display_state_pipe);
display_state_get();

use_low_power_mode = gconf_value_get_bool(gcv);

Expand Down Expand Up @@ -2500,7 +2500,7 @@ static gboolean renderer_set_state(renderer_state_t state)
static gboolean send_display_status(DBusMessage *const method_call)
{
static const gchar *prev_state = "";
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
DBusMessage *msg = NULL;
const gchar *state = NULL;
gboolean status = FALSE;
Expand Down Expand Up @@ -3415,7 +3415,7 @@ static gboolean desktop_startup_dbus_cb(DBusMessage *const msg)
*/
static gboolean display_orientation_change_dbus_cb(DBusMessage *const msg)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
gboolean status = FALSE;

(void)msg;
Expand Down Expand Up @@ -4609,7 +4609,7 @@ static void system_state_trigger(gconstpointer data)
*/
static void proximity_sensor_trigger(gconstpointer data)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
cover_state_t proximity_sensor_state = GPOINTER_TO_INT(data);

/* If the display is on in low power mode,
Expand Down
4 changes: 2 additions & 2 deletions modules/displaymeego.c
Expand Up @@ -751,7 +751,7 @@ static void request_display_blanking_pause(void)
*/
static void update_blanking_inhibit(gboolean timed_inhibit)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
system_state_t system_state = datapipe_get_gint(system_state_pipe);
alarm_ui_state_t alarm_ui_state =
datapipe_get_gint(alarm_ui_state_pipe);
Expand Down Expand Up @@ -949,7 +949,7 @@ static void display_gconf_cb(GConfClient *const gcc, const guint id,
*/
static gboolean send_display_status(DBusMessage *const method_call)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
DBusMessage *msg = NULL;
const gchar *state = NULL;
gboolean status = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion modules/filter-brightness-als.c
Expand Up @@ -1060,7 +1060,7 @@ const gchar *g_module_check_init(GModule *module)
als_filter_load_config(&lut_key);

/* Get intial display state */
display_state = datapipe_get_gint(display_state_pipe);
display_state = display_state_get();

/* Append triggers/filters to datapipes */
append_filter_to_datapipe(&display_brightness_pipe,
Expand Down
2 changes: 1 addition & 1 deletion modules/led.c
Expand Up @@ -1140,7 +1140,7 @@ static void program_led(const pattern_struct *const pattern)
*/
static void led_update_active_pattern(void)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
system_state_t system_state = datapipe_get_gint(system_state_pipe);
pattern_struct *new_active_pattern;
gint i = 0;
Expand Down
2 changes: 1 addition & 1 deletion modules/proximity.c
Expand Up @@ -1020,7 +1020,7 @@ const gchar *g_module_check_init(GModule *module)
/* Get initial state of datapipes */
call_state = datapipe_get_gint(call_state_pipe);
alarm_ui_state = datapipe_get_gint(alarm_ui_state_pipe);
display_state = datapipe_get_gint(display_state_pipe);
display_state = display_state_get();
submode = datapipe_get_gint(submode_pipe);

/* Append triggers/filters to datapipes */
Expand Down
4 changes: 2 additions & 2 deletions tests/ut/ut_display.c
Expand Up @@ -1476,7 +1476,7 @@ START_TEST (ut_check_basic_state_change_no_lpm)

for( int i = 0; state_changes[i].required != MCE_DISPLAY_UNDEF; ++i ) {
mce_log(LL_DEBUG, "%d: %s -> %s, expect %s", i,
display_state_name(datapipe_get_gint(display_state_pipe)),
display_state_name(display_state_get()),
display_state_name(state_changes[i].required),
display_state_name(state_changes[i].expected));

Expand Down Expand Up @@ -1524,7 +1524,7 @@ START_TEST (ut_check_basic_state_change)

for( int i = 0; state_changes[i].required != MCE_DISPLAY_UNDEF; ++i ) {
mce_log(LL_DEBUG, "%d: %s -> %s, expect %s", i,
display_state_name(datapipe_get_gint(display_state_pipe)),
display_state_name(display_state_get()),
display_state_name(state_changes[i].required),
display_state_name(state_changes[i].expected));

Expand Down
16 changes: 8 additions & 8 deletions tklock.c
Expand Up @@ -823,7 +823,7 @@ static void ts_kp_enable_policy(void)
*/
static void ts_kp_disable_policy(void)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
system_state_t system_state = datapipe_get_gint(system_state_pipe);
alarm_ui_state_t alarm_ui_state =
datapipe_get_gint(alarm_ui_state_pipe);
Expand Down Expand Up @@ -1132,7 +1132,7 @@ static void tklock_reply_dbus_cb(DBusPendingCall *pending_call,
*/
static gboolean open_tklock_ui(dbus_uint32_t mode)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
const gchar *const cb_service = MCE_SERVICE;
const gchar *const cb_path = MCE_REQUEST_PATH;
const gchar *const cb_interface = MCE_REQUEST_IF;
Expand Down Expand Up @@ -1445,7 +1445,7 @@ static void setup_tklock_dim_timeout(void)
*/
static void setup_dim_blank_timeout_policy(display_state_t force)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();

cancel_tklock_visual_blank_timeout();
cancel_tklock_unlock_timeout();
Expand Down Expand Up @@ -1873,7 +1873,7 @@ static void trigger_visual_tklock(gboolean powerkey)
alarm_ui_state_t alarm_ui_state =
datapipe_get_gint(alarm_ui_state_pipe);
system_state_t system_state = datapipe_get_gint(system_state_pipe);
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
submode_t submode = mce_get_submode_int32();

if ((is_malf_state_enabled() == TRUE) ||
Expand Down Expand Up @@ -2173,7 +2173,7 @@ static void return_from_proximity(void)
*/
static void process_proximity_state(void)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
cover_state_t slide_state = datapipe_get_gint(keyboard_slide_pipe);
cover_state_t proximity_sensor_state =
datapipe_get_gint(proximity_sensor_pipe);
Expand Down Expand Up @@ -2325,7 +2325,7 @@ static void device_inactive_trigger(gconstpointer const data)
*/
static void keyboard_slide_trigger(gconstpointer const data)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
system_state_t system_state = datapipe_get_gint(system_state_pipe);
cover_state_t kbd_slide_state = GPOINTER_TO_INT(data);

Expand Down Expand Up @@ -2404,7 +2404,7 @@ static void lockkey_trigger(gconstpointer const data)
*/
static void keypress_trigger(gconstpointer const data)
{
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
static gboolean skip_release = FALSE;
struct input_event const *const *evp;
struct input_event const *ev;
Expand Down Expand Up @@ -2967,7 +2967,7 @@ static void call_state_trigger(gconstpointer data)
{
static call_state_t old_call_state = CALL_STATE_INVALID;
call_state_t call_state = GPOINTER_TO_INT(data);
display_state_t display_state = datapipe_get_gint(display_state_pipe);
display_state_t display_state = display_state_get();
/* Saving the state for not to interfere with old call paths */
gboolean proximity_locked = is_tklock_enabled_by_proximity();

Expand Down

0 comments on commit 44bb81c

Please sign in to comment.