Skip to content

Commit

Permalink
Allow fine tuning ALS usage via mce settings
Browse files Browse the repository at this point in the history
MCE has one setting that dictates whether ambient light sensor is used
or not. This was ok as long as ALS was used only for display brightness
tuning, but now that there are other reasons for using ALS functionality
of those too depend on whether automatic brightness tuning is in use or
not.

Leave the existing setting in place, use it as ALS master toggle and
add separate settings for:
- Use ALS automatic display brightness tuning
- Use ALS for filtering false positive lid closed events

If the master toggle is set to disabled, ALS is not used by mce.

If the master toggle is set to enabled, ALS is powered up/down depending
on feature specific settings and device state.

Refactor ALS data processing so that:
- callback for passing lux value from sensorfw uses int, not unsigned int
- als power up depends on all three settings
- variables holding cached lux values are given more descriptive names
- all auto brightness filters use similar logic for testing whether the
  feature is enabled & als data is available
- move all constants related to display settings to display.h

ALS data is used for filtering out potential false positive lid close
events only if the relevant settings are enabled.

Options for mcetool:
  --set-als-mode=<enabled|disabled>
  Now works as use als master toggle.

  --set-als-autobrightness=<enabled|disabled>
  Can be used to disable automatic brightness tuning even if using ALS
  is otherwise enabled.

  --set-filter-lid-with-als=<enabled|disabled>
  Can be used to disable lid close filtering even if using ALS is
  otherwise enabled.

[mce] Allow fine tuning ALS usage via mce settings. Fixes JB#29892
  • Loading branch information
spiiroin committed Jun 16, 2015
1 parent a567675 commit 41f1e2e
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 129 deletions.
2 changes: 2 additions & 0 deletions .depend
Expand Up @@ -595,6 +595,7 @@ modules/filter-brightness-als.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
tklock.h\
modules/display.h\
modules/filter-brightness-als.h\

Expand All @@ -609,6 +610,7 @@ modules/filter-brightness-als.pic.o:\
mce-log.h\
mce-sensorfw.h\
mce.h\
tklock.h\
modules/display.h\
modules/filter-brightness-als.h\

Expand Down
21 changes: 14 additions & 7 deletions builtin-gconf.c
Expand Up @@ -1089,20 +1089,22 @@ static const setting_t gconf_defaults[] =
.def = "10,20,30,40,50",
},
{
// MCE_GCONF_DISPLAY_ALS_ENABLED @ modules/display.h
.key = "/system/osso/dsm/display/als_enabled",
.key = MCE_GCONF_DISPLAY_ALS_ENABLED,
.type = "b",
.def = "true",
.def = G_STRINGIFY(ALS_ENABLED_DEFAULT),
},
{
.key = MCE_GCONF_DISPLAY_ALS_AUTOBRIGHTNESS,
.type = "b",
.def = G_STRINGIFY(ALS_AUTOBRIGHTNESS_DEFAULT),
},
{
// MCE_GCONF_DISPLAY_ALS_INPUT_FILTER @ modules/display.h
.key = "/system/osso/dsm/display/als_input_filter",
.key = MCE_GCONF_DISPLAY_ALS_INPUT_FILTER,
.type = "s",
.def = ALS_INPUT_FILTER_DEFAULT,
},
{
// MCE_GCONF_DISPLAY_ALS_SAMPLE_TIME @ modules/display.h
.key = "/system/osso/dsm/display/als_sample_time",
.key = MCE_GCONF_DISPLAY_ALS_SAMPLE_TIME,
.type = "i",
.def = G_STRINGIFY(ALS_SAMPLE_TIME_DEFAULT),
},
Expand Down Expand Up @@ -1224,6 +1226,11 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(DEFAULT_LID_SENSOR_ENABLED),
},
{
.key = MCE_GCONF_FILTER_LID_WITH_ALS,
.type = "b",
.def = G_STRINGIFY(DEFAULT_FILTER_LID_WITH_ALS),
},
{
.key = MCE_GCONF_AUTOLOCK_DELAY,
.type = "i",
Expand Down
4 changes: 2 additions & 2 deletions mce-sensorfw.c
Expand Up @@ -3113,7 +3113,7 @@ static guint als_evdev_id = 0;
static void (*sfw_notify_ps_cb)(bool covered) = 0;

/** Ambient light change callback used for notifying upper level logic */
static void (*sfw_notify_als_cb)(unsigned lux) = 0;
static void (*sfw_notify_als_cb)(int lux) = 0;

/** Orientation change callback used for notifying upper level logic */
static void (*sfw_notify_orient_cb)(int state) = 0;
Expand Down Expand Up @@ -3406,7 +3406,7 @@ mce_sensorfw_resume(void)
* @param cb function to call when ALS events are received
*/
void
mce_sensorfw_als_set_notify(void (*cb)(unsigned lux))
mce_sensorfw_als_set_notify(void (*cb)(int lux))
{
if( (sfw_notify_als_cb = cb) )
sfw_notify_als(NOTIFY_REPEAT, 0);
Expand Down
2 changes: 1 addition & 1 deletion mce-sensorfw.h
Expand Up @@ -16,7 +16,7 @@ void mce_sensorfw_suspend(void);
void mce_sensorfw_resume(void);

void mce_sensorfw_als_attach(int fd);
void mce_sensorfw_als_set_notify(void (*cb)(unsigned lux));
void mce_sensorfw_als_set_notify(void (*cb)(int lux));
void mce_sensorfw_als_enable(void);
void mce_sensorfw_als_disable(void);

Expand Down
19 changes: 17 additions & 2 deletions modules/display.h
Expand Up @@ -111,14 +111,29 @@
/** Path to the GConf settings for the display */
#define MCE_GCONF_DISPLAY_PATH "/system/osso/dsm/display"

/** Path to the ALS enabled GConf setting */
/** ALS enabled setting */
#define MCE_GCONF_DISPLAY_ALS_ENABLED MCE_GCONF_DISPLAY_PATH "/als_enabled"

/** ALS input filter GConf setting */
/** Default value for MCE_GCONF_DISPLAY_ALS_ENABLED */
#define ALS_ENABLED_DEFAULT true

/** ALS constrols brightness setting */
#define MCE_GCONF_DISPLAY_ALS_AUTOBRIGHTNESS MCE_GCONF_DISPLAY_PATH "/als_autobrightness"

/** Default value for MCE_GCONF_DISPLAY_ALS_AUTOBRIGHTNESS settings */
#define ALS_AUTOBRIGHTNESS_DEFAULT true

/** ALS input filter setting */
#define MCE_GCONF_DISPLAY_ALS_INPUT_FILTER MCE_GCONF_DISPLAY_PATH "/als_input_filter"

/** Default value for MCE_GCONF_DISPLAY_ALS_INPUT_FILTER */
#define ALS_INPUT_FILTER_DEFAULT "median"

/** ALS sample time GConf setting */
#define MCE_GCONF_DISPLAY_ALS_SAMPLE_TIME MCE_GCONF_DISPLAY_PATH "/als_sample_time"
#define ALS_SAMPLE_TIME_DEFAULT 125
#define ALS_SAMPLE_TIME_MIN 50
#define ALS_SAMPLE_TIME_MAX 1000

/** Path to the color profile GConf setting */
#define MCE_GCONF_DISPLAY_COLOR_PROFILE MCE_GCONF_DISPLAY_PATH "/color_profile"
Expand Down

0 comments on commit 41f1e2e

Please sign in to comment.