Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow going to lpm mode when display off request is made over D-Bus
If set to "use-lpm", any display off requests made over D-Bus are
handled as if MCE_DISPLAY_LPM_ON were requested.

Default to "disabled", i.e. display off requests are honored.

[mce] Allow going to lpm mode when display off request is made over D-Bus. Fixes JB#21918
  • Loading branch information
spiiroin committed Aug 12, 2014
1 parent 2e91251 commit 07df23b
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 23 deletions.
12 changes: 0 additions & 12 deletions .depend
Expand Up @@ -481,7 +481,6 @@ modules/display.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.h\

modules/display.pic.o:\
Expand All @@ -499,7 +498,6 @@ modules/display.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.h\

modules/doubletap.o:\
Expand Down Expand Up @@ -781,7 +779,6 @@ tests/ut/ut_display.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -801,7 +798,6 @@ tests/ut/ut_display.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -822,7 +818,6 @@ tests/ut/ut_display_blanking_inhibit.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -843,7 +838,6 @@ tests/ut/ut_display_blanking_inhibit.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -864,7 +858,6 @@ tests/ut/ut_display_conf.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -885,7 +878,6 @@ tests/ut/ut_display_conf.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -906,7 +898,6 @@ tests/ut/ut_display_filter.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -927,7 +918,6 @@ tests/ut/ut_display_filter.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -948,7 +938,6 @@ tests/ut/ut_display_stm.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand All @@ -969,7 +958,6 @@ tests/ut/ut_display_stm.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
powerkey.h\
modules/display.c\
modules/display.h\
tests/ut/common.h\
Expand Down
6 changes: 6 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1258,6 +1258,12 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = "90",
},
{
// MCE_GCONF_DISPLAY_OFF_OVERRIDE @ modules/display.h
.key = "/system/osso/dsm/display/display_off_override",
.type = "i",
.def = "0", // = DISPLAY_OFF_OVERRIDE_DISABLED
},
{
// MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH @ tklock.h
.key = "/system/osso/dsm/locks/tklock_blank_disable",
Expand Down
31 changes: 20 additions & 11 deletions modules/display.c
Expand Up @@ -26,8 +26,6 @@
* as soon as lipstick has been modified to use actual lpm mode dbus
* requests.
*/
#define ENABLE_LPM_HACK 1

#include "display.h"

#include "../mce.h"
Expand All @@ -48,10 +46,6 @@
# include "../libwakelock.h"
#endif

#if ENABLE_LPM_HACK
#include "../powerkey.h"
#endif

#include <linux/fb.h>

#include <sys/ptrace.h>
Expand Down Expand Up @@ -6638,6 +6632,12 @@ static gboolean mdy_dbus_handle_display_dim_req(DBusMessage *const msg)
return status;
}

/** Override mode for display off requests made over D-Bus */
static gint mdy_dbus_display_off_override = DISPLAY_OFF_OVERRIDE_DISABLED;

/** GConf notifier id for mdy_dbus_display_off_override */
static guint mdy_dbus_display_off_override_gconf_cb_id = 0;

/**
* D-Bus callback for the display off method call
*
Expand All @@ -6646,12 +6646,8 @@ static gboolean mdy_dbus_handle_display_dim_req(DBusMessage *const msg)
*/
static gboolean mdy_dbus_handle_display_off_req(DBusMessage *const msg)
{
#if ENABLE_LPM_HACK
gint blanking_mode = PWRKEY_BLANK_TO_OFF;
mce_gconf_get_int(MCE_GCONF_POWERKEY_BLANKING_MODE, &blanking_mode);
if( blanking_mode == PWRKEY_BLANK_TO_LPM )
if( mdy_dbus_display_off_override == DISPLAY_OFF_OVERRIDE_USE_LPM )
return mdy_dbus_handle_display_lpm_req(msg);
#endif

dbus_bool_t no_reply = dbus_message_get_no_reply(msg);
gboolean status = FALSE;
Expand Down Expand Up @@ -7693,6 +7689,11 @@ static void mdy_gconf_cb(GConfClient *const gcc, const guint id,
mce_log(LL_NOTICE, "fade duration / unblank = %d",
mdy_brightness_fade_duration_unblank_ms);
}
else if( id == mdy_dbus_display_off_override_gconf_cb_id ) {
mdy_dbus_display_off_override = gconf_value_get_int(gcv);
mce_log(LL_NOTICE, "display off override = %d",
mdy_dbus_display_off_override);
}
else {
mce_log(LL_WARN, "Spurious GConf value received; confused!");
}
Expand Down Expand Up @@ -7937,6 +7938,14 @@ static void mdy_gconf_init(void)
&mdy_brightness_fade_duration_unblank_ms_gconf_cb_id);
mce_gconf_get_int(MCE_GCONF_BRIGHTNESS_FADE_UNBLANK_MS,
&mdy_brightness_fade_duration_unblank_ms);

/* Override mode for display off requests made over D-Bus */
mce_gconf_notifier_add(MCE_GCONF_DISPLAY_PATH,
MCE_GCONF_DISPLAY_OFF_OVERRIDE,
mdy_gconf_cb,
&mdy_dbus_display_off_override_gconf_cb_id);
mce_gconf_get_int(MCE_GCONF_DISPLAY_OFF_OVERRIDE,
&mdy_dbus_display_off_override);
}

static void mdy_gconf_quit(void)
Expand Down
13 changes: 13 additions & 0 deletions modules/display.h
Expand Up @@ -146,6 +146,19 @@
/** Unresponsive lipstick core dump delay */
#define MCE_GCONF_LIPSTICK_CORE_DELAY MCE_GCONF_DISPLAY_PATH "/lipstick_core_dump_delay"

/** Blanking mode for display off requests GConf setting */
# define MCE_GCONF_DISPLAY_OFF_OVERRIDE MCE_GCONF_DISPLAY_PATH"/display_off_override"

/** Values for MCE_GCONF_DISPLAY_OFF_OVERRIDE setting */
typedef enum
{
/** Display off request turns display off */
DISPLAY_OFF_OVERRIDE_DISABLED,

/** Display off request puts display to lpm state */
DISPLAY_OFF_OVERRIDE_USE_LPM,
} display_off_blanking_mode_t;

/** Default brightness fade duration [ms]
*
* Used for all display state changes that do not have
Expand Down
48 changes: 48 additions & 0 deletions tools/mcetool.c
Expand Up @@ -2330,6 +2330,45 @@ static void xmce_get_powerkey_blanking(void)
printf("%-"PAD1"s %s \n", "Powerkey blanking mode:", txt ?: "unknown");
}

/* ------------------------------------------------------------------------- *
* display off request override
* ------------------------------------------------------------------------- */

/** Lookup table for display off request override values
*/
static const symbol_t display_off_override[] = {
{ "disabled", DISPLAY_OFF_OVERRIDE_DISABLED },
{ "use-lpm", DISPLAY_OFF_OVERRIDE_USE_LPM },
{ NULL, -1 }
};

/** Set display off override
*
* @param args string that can be parsed to display off override value
*/
static bool xmce_set_display_off_override(const char *args)
{
debugf("%s(%s)\n", __FUNCTION__, args);
int val = lookup(display_off_override, args);
if( val < 0 ) {
errorf("%s: invalid display off override value\n", args);
exit(EXIT_FAILURE);
}
mcetool_gconf_set_int(MCE_GCONF_DISPLAY_OFF_OVERRIDE, val);
return true;
}

/** Get current display off override from mce and print it out
*/
static void xmce_get_display_off_override(void)
{
gint val = 0;
const char *txt = 0;
if( mcetool_gconf_get_int(MCE_GCONF_DISPLAY_OFF_OVERRIDE, &val) )
txt = rlookup(display_off_override, val);
printf("%-"PAD1"s %s \n", "Display off override mode:", txt ?: "unknown");
}

/* ------------------------------------------------------------------------- *
* doubletab
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -3041,6 +3080,7 @@ static bool xmce_get_status(const char *args)
xmce_get_doubletap_wakeup();
xmce_get_powerkey_action();
xmce_get_powerkey_blanking();
xmce_get_display_off_override();
xmce_get_low_power_mode();
xmce_get_als_mode();
xmce_get_ps_mode();
Expand Down Expand Up @@ -3374,6 +3414,14 @@ static const mce_opt_t options[] =
"set the doubletap blanking mode; valid modes are:\n"
"'off', 'lpm'\n"
},
{
.name = "set-display-off-override",
.with_arg = xmce_set_display_off_override,
.values = "disabled|use-lpm",
.usage =
"set the display off request override; valid modes are:\n"
"'disabled', 'use-lpm'\n"
},
{
.name = "enable-radio",
.flag = 'r',
Expand Down

0 comments on commit 07df23b

Please sign in to comment.