Skip to content

Commit

Permalink
Support 100 brightness levels and up to 21 ALS profiles
Browse files Browse the repository at this point in the history
Previously mce used brightness levels 1-5, that corresponded to 20, 40,
60, 80 or 100 percent brightness (manual mode) or selected one of the 5
ALS profiles available (automatic mode).

Now brightness level setting itself is percentage in manual mode and thus
allows user to have more freedom to select suitable brightness.

In automatic mode the percentage is mapped to one of the maximum of 21
ALS profiles. The profiles follow the same logic as the previous five
did, but having more of them allows user to select suitable compromise
between how low the brightness is allowed to go vs. how fast it should go
to the maximum brightness. There is also greater difference between the
profiles in "office lightning" conditions, which hopefully makes it more
apparent to users that the automatic mode is actually doing something.

Existing brightness settings in the 1-5 range are migrated on during mce
start up.

Also the dimmed display brightness is now dynamic and is always less
bright than the display on brightness.

[mce] Support 100 brightness levels and 21 ALS profiles. Fixes JB#13670
  • Loading branch information
spiiroin committed Apr 11, 2014
1 parent 32c586b commit c749d9f
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 173 deletions.
10 changes: 5 additions & 5 deletions builtin-gconf.c
Expand Up @@ -1226,19 +1226,19 @@ static const setting_t gconf_defaults[] =
// MCE_GCONF_DISPLAY_BRIGHTNESS_PATH @ modules/display.h
.key = "/system/osso/dsm/display/display_brightness",
.type = "i",
.def = "3",
.def = "3", // Note: Legacy value, migrated at mce startup
},
{
// Hint for settings UI. Not used by MCE itself.
// MCE_GCONF_DISPLAY_BRIGHTNESS_LEVEL_SIZE_PATH @ modules/display.h
.key = "/system/osso/dsm/display/display_brightness_level_step",
.type = "i",
.def = "1",
.def = "1", // Note: Legacy value, migrated at mce startup
},
{
// Hint for settings UI. Not used by MCE itself.
// MCE_GCONF_DISPLAY_BRIGHTNESS_LEVEL_COUNT_PATH @ modules/display.h
.key = "/system/osso/dsm/display/max_display_brightness_levels",
.type = "i",
.def = "5",
.def = "5", // Note: Legacy value, migrated at mce startup
},
{
// MCE_GCONF_DISPLAY_DIM_TIMEOUT_LIST_PATH @ modules/display.h
Expand Down
76 changes: 62 additions & 14 deletions inifiles/als-defaults.ini
Expand Up @@ -8,28 +8,76 @@

[BrightnessDisplay]

LimitsMinimum=1;2;3;6;11;20;36;66;121;220;515;663;853;1099;1414;1821;2344;3017;3884;5000
LevelsMinimum=5;8;10;13;15;18;20;23;25;28;37;44;51;58;65;72;79;86;93;100
LimitsProfile0=1;2;4;6;11;19;34;61;109;195;350;457;596;778;1014;1323;1726;2252;2938;3833;5000
LevelsProfile0=1;3;5;7;9;11;13;15;17;19;20;28;36;44;52;60;68;76;84;92;100

LimitsEconomy=1;2;3;6;11;20;36;66;121;220;504;634;798;1005;1265;1592;2005;2524;3177;4000
LevelsEconomy=15;18;21;24;27;30;33;36;39;42;51;56;62;67;73;78;84;89;95;100
LimitsProfile1=1;2;4;6;11;19;34;61;109;195;350;454;589;764;990;1284;1665;2159;2800;3631;4708
LevelsProfile1=1;4;6;8;10;12;15;17;19;21;23;31;39;47;54;62;70;77;85;93;100

LimitsNormal=1;2;3;6;11;20;36;66;121;220;489;599;732;896;1095;1340;1639;2005;2453;3000
LevelsNormal=30;33;36;39;42;45;48;51;54;57;64;68;72;76;80;84;88;92;96;100
LimitsProfile2=1;2;4;6;11;19;34;61;109;195;350;452;582;750;967;1246;1606;2070;2668;3440;4433
LevelsProfile2=2;5;7;10;12;14;17;19;22;24;26;34;41;49;56;63;71;78;86;93;100

LimitsBright=1;2;3;6;11;20;36;66;121;220;470;552;648;761;894;1051;1234;1450;1703;2000
LevelsBright=55;57;59;61;63;65;67;69;71;73;78;80;83;85;88;90;93;95;98;100
LimitsProfile3=1;2;4;6;11;19;34;61;109;195;350;449;575;737;944;1209;1549;1985;2543;3258;4174
LevelsProfile3=2;5;8;11;13;16;19;21;24;27;29;37;44;51;58;65;72;79;86;93;100

LimitsMaximum=1;2;3;6;11;20;36;66;121;220;438;480;527;577;632;693;760;833;912;1000
LevelsMaximum=80;81;82;83;84;85;86;87;88;89;91;92;93;94;95;96;97;98;99;100
LimitsProfile4=1;2;4;6;11;19;34;61;109;195;350;446;568;724;921;1173;1494;1903;2423;3086;3930
LevelsProfile4=2;5;8;11;14;17;20;23;26;29;32;39;46;53;60;66;73;80;87;94;100

LimitsProfile5=1;2;4;6;11;19;34;61;109;195;350;444;561;711;899;1138;1441;1824;2309;2923;3700
LevelsProfile5=3;7;10;13;16;19;23;26;29;32;35;42;48;55;61;68;74;81;87;94;100

LimitsProfile6=1;2;4;6;11;19;34;61;109;195;350;441;555;698;878;1105;1390;1749;2201;2769;3484
LevelsProfile6=4;8;11;15;18;21;25;28;32;35;38;45;51;57;63;69;76;82;88;94;100

LimitsProfile7=1;2;4;6;11;19;34;61;109;195;350;438;548;685;857;1072;1341;1677;2098;2624;3281
LevelsProfile7=4;8;12;16;19;23;27;30;34;38;41;47;53;59;65;71;77;83;89;95;100

LimitsProfile8=1;2;4;6;11;19;34;61;109;195;350;436;542;673;837;1040;1293;1608;1999;2485;3089
LevelsProfile8=5;9;13;17;21;25;29;33;37;41;44;50;56;61;67;72;78;84;89;95;100

LimitsProfile9=1;2;4;6;11;19;34;61;109;195;350;433;535;661;817;1010;1248;1542;1905;2354;2909
LevelsProfile9=7;11;15;19;23;27;31;35;39;43;47;53;58;63;69;74;79;85;90;95;100

LimitsProfile10=1;2;4;6;11;19;34;61;109;195;350;430;529;649;798;980;1203;1478;1816;2230;2739
LevelsProfile10=8;13;17;21;25;29;34;38;42;46;50;55;60;65;70;75;80;85;90;95;100

LimitsProfile11=1;2;4;6;11;19;34;61;109;195;350;428;522;638;779;951;1161;1417;1730;2113;2579
LevelsProfile11=10;15;19;23;28;32;36;41;45;49;53;58;63;68;72;77;82;86;91;96;100

LimitsProfile12=1;2;4;6;11;19;34;61;109;195;350;425;516;626;760;922;1119;1358;1649;2001;2428
LevelsProfile12=13;18;22;26;31;35;39;44;48;52;56;61;65;70;74;78;83;87;92;96;100

LimitsProfile13=1;2;4;6;11;19;34;61;109;195;350;423;510;615;742;895;1080;1302;1571;1895;2286
LevelsProfile13=16;21;25;29;34;38;42;47;51;55;59;64;68;72;76;80;84;88;92;96;100

LimitsProfile14=1;2;4;6;11;19;34;61;109;195;350;420;504;604;724;869;1041;1249;1498;1796;2153
LevelsProfile14=20;25;29;33;37;41;46;50;54;58;62;66;70;74;78;81;85;89;93;97;100

LimitsProfile15=1;2;4;6;11;19;34;61;109;195;350;418;498;593;707;843;1005;1197;1427;1701;2027
LevelsProfile15=24;29;33;37;41;45;49;53;57;61;65;69;72;76;79;83;86;90;93;97;100

LimitsProfile16=1;2;4;6;11;19;34;61;109;195;350;415;492;583;690;818;969;1148;1360;1611;1908
LevelsProfile16=30;34;38;42;46;49;53;57;61;65;68;72;75;78;81;84;88;91;94;97;100

LimitsProfile17=1;2;4;6;11;19;34;61;109;195;350;413;486;572;674;794;935;1101;1296;1526;1797
LevelsProfile17=37;41;44;48;51;54;58;61;65;68;71;74;77;80;83;86;89;92;95;98;100

LimitsProfile18=1;2;4;6;11;19;34;61;109;195;350;410;480;562;658;770;901;1055;1235;1446;1692
LevelsProfile18=46;49;52;55;58;60;63;66;69;72;74;77;80;82;85;87;90;93;95;98;100

LimitsProfile19=1;2;4;6;11;19;34;61;109;195;350;408;474;552;642;747;869;1012;1177;1369;1593
LevelsProfile19=57;59;61;63;65;67;69;71;73;75;77;80;82;84;87;89;91;94;96;98;100

LimitsProfile20=1;2;4;6;11;19;34;61;109;195;350;405;469;542;627;725;839;970;1122;1297;1500
LevelsProfile20=70;71;72;73;74;75;76;77;78;79;80;82;84;86;88;90;92;94;96;98;100

[BrightnessLed]

LimitsNormal=1;2;3;6;11;20;36;66;121;220;489;599;732;896;1095;1340;1639;2005;2453;3000
LevelsNormal=30;33;36;39;42;45;48;51;54;57;64;68;72;76;80;84;88;92;96;100
LimitsProfile0=1;2;3;6;11;20;36;66;121;220;489;599;732;896;1095;1340;1639;2005;2453;3000
LevelsProfile0=30;33;36;39;42;45;48;51;54;57;64;68;72;76;80;84;88;92;96;100

[BrightnessKeypad]

LimitsNormal=1;2;3;6;11;20;36;66;121;220;489;599;732;896;1095;1340;1639;2005;2453;3000
LevelsNormal=30;33;36;39;42;45;48;51;54;57;64;68;72;76;80;84;88;92;96;100
LimitsProfile0=1;2;3;6;11;20;36;66;121;220;489;599;732;896;1095;1340;1639;2005;2453;3000
LevelsProfile0=30;33;36;39;42;45;48;51;54;57;64;68;72;76;80;84;88;92;96;100

36 changes: 36 additions & 0 deletions mce.h
Expand Up @@ -409,4 +409,40 @@ void mce_quit_mainloop(void);
res;\
})

/** Translate integer value from one range to another
*
* Linear conversion of a value in [src_lo, src_hi] range
* to [dst_lo, dst_hi] range.
*
* Uses rounding, so that 55 [0,100] -> 6 [0, 10].
*
* @param src_lo lower bound for source range
* @param src_hi upper bound for source range
* @param dst_lo lower bound for destination range
* @param dst_hi upper bound for destination range
* @param val value in source range to be translated
*
* @return input value mapped to destination range
*/
static inline int
mce_xlat_int(int src_lo, int src_hi, int dst_lo, int dst_hi, int val)
{
/* Deal with empty ranges first; assume that the
* low bound is sanest choise available */
if( src_lo >= src_hi || dst_lo >= dst_hi )
return dst_lo;

int src_range = src_hi - src_lo;
int dst_range = dst_hi - dst_lo;

val -= src_lo;
val = (val * dst_range + src_range / 2) / src_range;
val += dst_lo;

if( val > dst_hi ) val = dst_hi; else
if( val < dst_lo ) val = dst_lo;

return val;
}

#endif /* _MCE_H_ */

0 comments on commit c749d9f

Please sign in to comment.