Skip to content

Commit

Permalink
Add never-blank-display mode
Browse files Browse the repository at this point in the history
Debugging feature that allows blocking of display state transitions
so that the display is never blanked.

Control via mcetool --set-never-blank=enabled/disabled.

The setting persists over mce restarts and device reboots.

[mce] Support for never-blank-display mode added
  • Loading branch information
spiiroin committed Aug 6, 2013
1 parent afa1086 commit 653ea12
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
6 changes: 6 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1186,6 +1186,12 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = "3",
},
{
// MCE_GCONF_DISPLAY_NEVER_BLANK_PATH @ modules/display.h
.key = "/system/osso/dsm/display/display_never_blank",
.type = "i",
.def = "0",
},
{
// MCE_GCONF_DISPLAY_BRIGHTNESS_PATH @ modules/display.h
.key = "/system/osso/dsm/display/display_brightness",
Expand Down
24 changes: 23 additions & 1 deletion modules/display.c
Expand Up @@ -199,10 +199,15 @@ static guint disp_dim_timeout_gconf_cb_id = 0;

/** Display blanking timeout setting */
static gint disp_blank_timeout = DEFAULT_BLANK_TIMEOUT;
/** Never blank display setting */
static gint disp_never_blank = 0;

/** Display blank timeout setting when low power mode is supported */
static gint disp_lpm_blank_timeout = DEFAULT_LPM_BLANK_TIMEOUT;
/** GConf callback ID for display blanking timeout setting */
static guint disp_blank_timeout_gconf_cb_id = 0;
/** GConf callback ID for display never blank setting */
static guint disp_never_blank_gconf_cb_id = 0;

/** Use low power mode setting */
static gboolean use_low_power_mode = FALSE;
Expand Down Expand Up @@ -2269,6 +2274,9 @@ static void display_gconf_cb(GConfClient *const gcc, const guint id,

/* Update blank prevent */
update_blanking_inhibit(FALSE);
} else if( id == disp_never_blank_gconf_cb_id ) {
disp_never_blank = gconf_value_get_int(gcv);
mce_log(LL_NOTICE, "never_blank = %d", disp_never_blank);
} else {
mce_log(LL_WARN,
"Spurious GConf value received; confused!");
Expand Down Expand Up @@ -3582,6 +3590,11 @@ static gpointer display_state_filter(gpointer data)
submode_t submode = mce_get_submode_int32();
gpointer new_data;

if( disp_never_blank ) {
display_state = MCE_DISPLAY_ON;
goto UPDATE;
}

/* Ignore display on requests during transition to shutdown
* and reboot, when in acting dead and when system state is unknown
*/
Expand Down Expand Up @@ -3615,7 +3628,7 @@ static gpointer display_state_filter(gpointer data)
(system_state == MCE_STATE_USER))
display_state = MCE_DISPLAY_LPM_ON;
}

UPDATE:
new_data = GINT_TO_POINTER(display_state);
cached_display_state = display_state;

Expand Down Expand Up @@ -4224,6 +4237,15 @@ const gchar *g_module_check_init(GModule *module)
&disp_blank_timeout_gconf_cb_id) == FALSE)
goto EXIT;

/* Never blank */
/* Since we've set a default, error handling is unnecessary */
mce_gconf_get_int(MCE_GCONF_DISPLAY_NEVER_BLANK_PATH,
&disp_never_blank);
mce_gconf_notifier_add(MCE_GCONF_DISPLAY_PATH,
MCE_GCONF_DISPLAY_NEVER_BLANK_PATH,
display_gconf_cb,
&disp_never_blank_gconf_cb_id);

/* Use adaptive display dim timeout */
/* Since we've set a default, error handling is unnecessary */
(void)mce_gconf_get_bool(MCE_GCONF_DISPLAY_ADAPTIVE_DIMMING_PATH,
Expand Down
2 changes: 2 additions & 0 deletions modules/display.h
Expand Up @@ -127,6 +127,8 @@
#define MCE_GCONF_DISPLAY_DIM_TIMEOUT_PATH MCE_GCONF_DISPLAY_PATH "/display_dim_timeout"
/** Path to the blank timeout GConf setting */
#define MCE_GCONF_DISPLAY_BLANK_TIMEOUT_PATH MCE_GCONF_DISPLAY_PATH "/display_blank_timeout"
/** Path to the never blank GConf setting */
#define MCE_GCONF_DISPLAY_NEVER_BLANK_PATH MCE_GCONF_DISPLAY_PATH "/display_never_blank"
/** Path to the adaptive display dimming GConf setting */
#define MCE_GCONF_DISPLAY_ADAPTIVE_DIMMING_PATH MCE_GCONF_DISPLAY_PATH "/use_adaptive_display_dimming"
/** Path to the adaptive display threshold timeout GConf setting */
Expand Down
41 changes: 40 additions & 1 deletion tools/mcetool.c
Expand Up @@ -1214,6 +1214,13 @@ static const symbol_t governor_values[] = {
{ NULL, -1 }
};

/** Lookup table for never blank options
*/
static const symbol_t never_blank_values[] = {
{ "enabled", 1 },
{ "disabled", 0 },
{ NULL, -1 }
};

/** Lookup table for fake doubletap policies
*/
Expand Down Expand Up @@ -2224,6 +2231,31 @@ static void xmce_get_cpu_scaling_governor(void)
printf("%-40s %s \n", "CPU Scaling Governor:", txt ?: "unknown");
}


/* ------------------------------------------------------------------------- *
* never blank
* ------------------------------------------------------------------------- */

static void xmce_set_never_blank(const char *args)
{
debugf("%s(%s)\n", __FUNCTION__, args);
int val = lookup(never_blank_values, args);
if( val < 0 ) {
errorf("%s: invalid never blank value\n", args);
exit(EXIT_FAILURE);
}
mcetool_gconf_set_int(MCE_GCONF_DISPLAY_NEVER_BLANK_PATH, val);
}

static void xmce_get_never_blank(void)
{
gint val = 0;
const char *txt = 0;
if( mcetool_gconf_get_int(MCE_GCONF_DISPLAY_NEVER_BLANK_PATH, &val) )
txt = rlookup(never_blank_values, val);
printf("%-40s %s \n", "Display never blank:", txt ?: "unknown");
}

/* ------------------------------------------------------------------------- *
* autosuspend on display blank policy
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -2388,6 +2420,7 @@ static void xmce_get_status(void)
xmce_get_dim_timeout();
xmce_get_adaptive_dimming_mode();
xmce_get_adaptive_dimming_time();
xmce_get_never_blank();
xmce_get_blank_timeout();
xmce_get_inhibit_mode();
xmce_get_keyboard_backlight_state();
Expand Down Expand Up @@ -2480,6 +2513,9 @@ static const char usage_text[] =
" set the adaptive dimming threshold\n"
" -H, --set-blank-timeout=SECS\n"
" set the automatic blanking timeout\n"
" -j, --set-never-blank=MODE\n"
" set never blank mode; valid modes are:\n"
" 'disabled', 'enabled'\n"
" -K, --set-autolock-mode=MODE\n"
" set the autolock mode; valid modes are:\n"
" 'enabled' and 'disabled'\n"
Expand Down Expand Up @@ -2591,7 +2627,7 @@ PROG_NAME" v"G_STRINGIFY(PRG_VERSION)"\n"
;

// Unused short options left ....
// - - - - - - - - - j - - m - o - q - - - u - w x - z
// - - - - - - - - - - - - m - o - q - - - u - w x - z
// - - - - - - - - - - - - - - - - Q - - - - - W X - Z

const char OPT_S[] =
Expand Down Expand Up @@ -2627,6 +2663,7 @@ const char OPT_S[] =
"g:" // --set-als-mode
"G:" // --set-dim-timeout
"H:" // --set-blank-timeout
"j:" // --set-never-blank
"J:" // --set-adaptive-dimming-time
"K:" // --set-autolock-mode
"M:" // --set-doubletap-mode
Expand Down Expand Up @@ -2674,6 +2711,7 @@ struct option const OPT_L[] =
{ "set-low-power-mode", 1, 0, 'E' }, // xmce_set_low_power_mode()
{ "set-als-mode", 1, 0, 'g' }, // xmce_set_als_mode()
{ "set-dim-timeout", 1, 0, 'G' }, // xmce_set_dim_timeout()
{ "set-never-blank", 1, 0, 'j' }, // xmce_set_never_blank()
{ "set-blank-timeout", 1, 0, 'H' }, // xmce_set_blank_timeout()
{ "set-autolock-mode", 1, 0, 'K' }, // xmce_set_autolock_mode()
{ "set-doubletap-mode", 1, 0, 'M' }, // xmce_set_doubletap_mode()
Expand Down Expand Up @@ -2725,6 +2763,7 @@ int main(int argc, char **argv)
case 'f': xmce_set_adaptive_dimming_mode(optarg); break;
case 'J': xmce_set_adaptive_dimming_time(optarg); break;

case 'j': xmce_set_never_blank(optarg); break;
case 'H': xmce_set_blank_timeout(optarg); break;

case 'K': xmce_set_autolock_mode(optarg); break;
Expand Down

0 comments on commit 653ea12

Please sign in to comment.