Skip to content

Commit

Permalink
[display] Add setting for kbd slide inhibit mode. Contributes to MER#…
Browse files Browse the repository at this point in the history
…1321

There are users that wish that the display would not blank when keyboard
slide is in open state.

Add inhibit mode setting that can be used to disable dimming / blanking
blanking timers when kbd slide is in open position.

By default kbd slide status does not affect display blanking timers.

The default can be changed by installing configuration files to
/etc/mce directory or via mcetool option:
  --set-kbd-slide-inhibit-mode=<disabled|stay-on-when-open|
                                stay-dim-when-open>

The value of the setting persists over mce / device restarts.
  • Loading branch information
spiiroin committed Sep 29, 2015
1 parent 3f7fd53 commit 4af454d
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 1 deletion.
6 changes: 6 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1313,6 +1313,12 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = "0",
},
{
.key = MCE_GCONF_KBD_SLIDE_INHIBIT,
.type = "i",
.def = G_STRINGIFY(DEFAULT_KBD_SLIDE_INHIBIT),
},

#if GCONF_ADD_DEBUG_VALUES
{
.key = "/test/string",
Expand Down
78 changes: 77 additions & 1 deletion modules/display.c
Expand Up @@ -271,6 +271,7 @@ static void mdy_datapipe_submode_cb(gconstpointer data);
static gpointer mdy_datapipe_display_state_filter_cb(gpointer data);
static void mdy_datapipe_display_state_cb(gconstpointer data);
static void mdy_datapipe_display_state_next_cb(gconstpointer data);
static void mdy_datapipe_keyboard_slide_input_cb(gconstpointer const data);
static void mdy_datapipe_display_brightness_cb(gconstpointer data);
static void mdy_datapipe_lpm_brightness_cb(gconstpointer data);
static void mdy_datapipe_display_state_req_cb(gconstpointer data);
Expand Down Expand Up @@ -974,6 +975,10 @@ static guint mdy_use_low_power_mode_gconf_cb_id = 0;
/** Display blanking inhibit mode */
static inhibit_t mdy_blanking_inhibit_mode = DEFAULT_BLANKING_INHIBIT_MODE;

/** Kbd slide display blanking inhibit mode */
static gint mdy_kbd_slide_inhibit_mode = DEFAULT_KBD_SLIDE_INHIBIT;
static guint mdy_kbd_slide_inhibit_mode_cb_id = 0;

/** GConf callback ID for display blanking inhibit mode setting */
static guint mdy_blanking_inhibit_mode_gconf_cb_id = 0;

Expand Down Expand Up @@ -1313,6 +1318,33 @@ static void mdy_datapipe_display_state_next_cb(gconstpointer data)
return;
}

/** Keypad slide input state; assume closed */
static cover_state_t kbd_slide_input_state = COVER_CLOSED;

/** Change notifications from keyboard_slide_pipe
*/
static void mdy_datapipe_keyboard_slide_input_cb(gconstpointer const data)
{
cover_state_t prev = kbd_slide_input_state;
kbd_slide_input_state = GPOINTER_TO_INT(data);

if( kbd_slide_input_state == COVER_UNDEF )
kbd_slide_input_state = COVER_CLOSED;

if( kbd_slide_input_state == prev )
goto EXIT;

mce_log(LL_DEVEL, "kbd_slide_input_state = %s -> %s",
cover_state_repr(prev),
cover_state_repr(kbd_slide_input_state));

/* force blanking reprogramming */
mdy_blanking_rethink_timers(true);

EXIT:
return;
}

/** Handle display_brightness_pipe notifications
*
* @note A brightness request is only sent if the value changed
Expand Down Expand Up @@ -1698,6 +1730,10 @@ static datapipe_handler_t mdy_datapipe_handlers[] =
.datapipe = &display_state_next_pipe,
.input_cb = mdy_datapipe_display_state_next_cb,
},
{
.datapipe = &keyboard_slide_pipe,
.input_cb = mdy_datapipe_keyboard_slide_input_cb,
},
// output triggers
{
.datapipe = &display_state_req_pipe,
Expand Down Expand Up @@ -3934,6 +3970,7 @@ static bool mdy_blanking_inhibit_off_p(void)
{
bool inhibit = false;

/* Blanking inhibit is explicitly ignored in act dead */
switch( system_state ) {
case MCE_STATE_ACTDEAD:
goto EXIT;
Expand All @@ -3942,6 +3979,7 @@ static bool mdy_blanking_inhibit_off_p(void)
break;
}

/* Evaluate charger related blanking inhibit policy */
switch( mdy_blanking_inhibit_mode ) {
case INHIBIT_STAY_DIM:
inhibit = true;
Expand All @@ -3956,6 +3994,17 @@ static bool mdy_blanking_inhibit_off_p(void)
break;
}

/* Evaluate kbd slide related blanking inhibit policy */
switch( mdy_kbd_slide_inhibit_mode ) {
case KBD_SLIDE_INHIBIT_STAY_DIM_WHEN_OPEN:
if( kbd_slide_input_state == COVER_OPEN )
inhibit = true;
break;

default:
break;
}

EXIT:
return inhibit;
}
Expand All @@ -3968,6 +4017,7 @@ static bool mdy_blanking_inhibit_dim_p(void)
{
bool inhibit = false;

/* Blanking inhibit is explicitly ignored in act dead */
switch( system_state ) {
case MCE_STATE_ACTDEAD:
goto EXIT;
Expand All @@ -3976,6 +4026,7 @@ static bool mdy_blanking_inhibit_dim_p(void)
break;
}

/* Evaluate charger related blanking inhibit policy */
switch( mdy_blanking_inhibit_mode ) {
case INHIBIT_STAY_ON:
inhibit = true;
Expand All @@ -3990,6 +4041,17 @@ static bool mdy_blanking_inhibit_dim_p(void)
break;
}

/* Evaluate kbd slide related blanking inhibit policy */
switch( mdy_kbd_slide_inhibit_mode ) {
case KBD_SLIDE_INHIBIT_STAY_ON_WHEN_OPEN:
if( kbd_slide_input_state == COVER_OPEN )
inhibit = true;
break;

default:
break;
}

EXIT:
return inhibit;
}
Expand Down Expand Up @@ -8497,6 +8559,11 @@ static void mdy_gconf_cb(GConfClient *const gcc, const guint id,
/* force blanking reprogramming */
mdy_blanking_rethink_timers(true);
}
else if (id == mdy_kbd_slide_inhibit_mode_cb_id) {
mdy_kbd_slide_inhibit_mode = gconf_value_get_int(gcv);
/* force blanking reprogramming */
mdy_blanking_rethink_timers(true);
}
else if( id == mdy_disp_never_blank_gconf_cb_id ) {
mdy_disp_never_blank = gconf_value_get_int(gcv);
mce_log(LL_NOTICE, "never_blank = %d", mdy_disp_never_blank);
Expand Down Expand Up @@ -8850,13 +8917,19 @@ static void mdy_gconf_init(void)
mdy_gconf_cb,
&mdy_use_low_power_mode_gconf_cb_id);

/* Blanking inhibit mode */
/* Blanking inhibit modes */
mce_gconf_track_int(MCE_GCONF_BLANKING_INHIBIT_MODE,
&mdy_blanking_inhibit_mode,
DEFAULT_BLANKING_INHIBIT_MODE,
mdy_gconf_cb,
&mdy_blanking_inhibit_mode_gconf_cb_id);

mce_gconf_track_int(MCE_GCONF_KBD_SLIDE_INHIBIT,
&mdy_kbd_slide_inhibit_mode,
DEFAULT_KBD_SLIDE_INHIBIT,
mdy_gconf_cb,
&mdy_kbd_slide_inhibit_mode_cb_id);

/* Delay for killing unresponsive compositor */
mce_gconf_track_int(MCE_GCONF_LIPSTICK_CORE_DELAY,
&mdy_compositor_core_delay,
Expand Down Expand Up @@ -8994,6 +9067,9 @@ static void mdy_gconf_quit(void)
mce_gconf_notifier_remove(mdy_blanking_inhibit_mode_gconf_cb_id),
mdy_blanking_inhibit_mode_gconf_cb_id = 0;

mce_gconf_notifier_remove(mdy_kbd_slide_inhibit_mode_cb_id),
mdy_kbd_slide_inhibit_mode_cb_id = 0;

mce_gconf_notifier_remove(mdy_compositor_core_delay_gconf_cb_id),
mdy_compositor_core_delay_gconf_cb_id = 0;

Expand Down
16 changes: 16 additions & 0 deletions modules/display.h
Expand Up @@ -177,6 +177,22 @@
/** Blanking inhibit GConf setting */
#define MCE_GCONF_BLANKING_INHIBIT_MODE MCE_GCONF_DISPLAY_PATH "/inhibit_blank_mode"

/** Kbd slide inhibit type */
typedef enum {
/** Kbd slide state does not affect display blanking */
KBD_SLIDE_INHIBIT_OFF = 0,

/** Keep display on while kbd slide is open */
KBD_SLIDE_INHIBIT_STAY_ON_WHEN_OPEN = 1,

/** Allow dimming but not blanking while kbd slide is open */
KBD_SLIDE_INHIBIT_STAY_DIM_WHEN_OPEN = 2,
} kbd_slide_inhibit_t;

/** Kbd slide blanking inhibit GConf setting */
#define MCE_GCONF_KBD_SLIDE_INHIBIT MCE_GCONF_DISPLAY_PATH "/kbd_slide_inhibit_blank_mode"
#define DEFAULT_KBD_SLIDE_INHIBIT 0 // = KBD_SLIDE_INHIBIT_OFF

/** Use Low Power Mode GConf setting */
#define MCE_GCONF_USE_LOW_POWER_MODE MCE_GCONF_DISPLAY_PATH "/use_low_power_mode"

Expand Down
48 changes: 48 additions & 0 deletions tools/mcetool.c
Expand Up @@ -4355,6 +4355,43 @@ static void xmce_get_inhibit_mode(void)
printf("%-"PAD1"s %s \n", "Blank inhibit:", txt ?: "unknown");
}

/** Lookup table kbd slide inhibit modes */
static const symbol_t kbd_slide_inhibitmode_lut[] =
{
{ "disabled", KBD_SLIDE_INHIBIT_OFF },
{ "stay-on-when-open", KBD_SLIDE_INHIBIT_STAY_ON_WHEN_OPEN },
{ "stay-dim-when-open", KBD_SLIDE_INHIBIT_STAY_DIM_WHEN_OPEN },
{ 0, -1 }

};

/** Set kbd slide inhibit mode
*
* @param args name of inhibit mode
*/
static bool xmce_set_kbd_slide_inhibit_mode(const char *args)
{
int val = lookup(kbd_slide_inhibitmode_lut, args);
if( val < 0 ) {
errorf("%s: Invalid kbd slide blank inhibit mode\n", args);
return false;
}

mcetool_gconf_set_int(MCE_GCONF_KBD_SLIDE_INHIBIT, val);
return true;
}

/** Show current kbd slide inhibit mode
*/
static void xmce_get_kbd_slide_inhibit_mode(void)
{
gint val = 0;
const char *txt = 0;
if( mcetool_gconf_get_int(MCE_GCONF_KBD_SLIDE_INHIBIT, &val) )
txt = rlookup(kbd_slide_inhibitmode_lut, val);
printf("%-"PAD1"s %s \n", "Kbd slide blank inhibit:", txt ?: "unknown");
}

/* ------------------------------------------------------------------------- *
* lipstick killer
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -4969,6 +5006,7 @@ static bool xmce_get_status(const char *args)
xmce_get_never_blank();
xmce_get_blank_timeout();
xmce_get_inhibit_mode();
xmce_get_kbd_slide_inhibit_mode();
xmce_get_blank_prevent_mode();
xmce_get_keyboard_backlight_state();
xmce_get_inactivity_state();
Expand Down Expand Up @@ -5303,6 +5341,16 @@ static const mce_opt_t options[] =
"'stay-on-with-charger', 'stay-on',\n"
"'stay-dim-with-charger', 'stay-dim'\n"
},
{
.name = "set-kbd-slide-inhibit-mode",
.with_arg = xmce_set_kbd_slide_inhibit_mode,
.values = "disabled|stay-on-when-open|stay-dim-when-open",
.usage =
"Set the kbd slide blanking inhibit mode:\n"
" disabled kbd slide status does not prevent blanking\n"
" stay-on-when-open prevent dimming while kbd slide is open\n"
" stay-dim-when-open prevent blanking while kbd slide is open\n"
},
{
.name = "set-tklock-mode",
.flag = 'k',
Expand Down

0 comments on commit 4af454d

Please sign in to comment.