• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

[Info/Guide] ALC, Automatic Brightness and You (and Me and your Cat)

Septfox

Lurker
Sep 21, 2013
7
1
Note to mods: I'm aware of the All Things Root subforum, but I'm posting this in the general board for better visibility and since both boards are pretty dead anyway. No hard feelings if you decide to move it to the subforum regardless.

Edit 4/19: alc_stepup figured out, some minor LED settings tested at the bottom

So as users of this phone may (or may not, if you've never tried tinkering with it) know, the light sensor isn't accessible by apps. Or rather, I think, they don't access it properly. Anyone who has dug deeper will also have found out that Android's auto-brightness arrays are empty and non-functional in both stock and Velocity ROMs.

So, with the help of Total Commander and vague pointers from various online posts, I started poking around to figure out what was up. The automatic brightness had to be controlled by something, after all. And lo, in /sys/classes/leds/lcd-backlight, I found out why and what respectively.

The light sensor in the Ally has its output run through an ALC (Automatic Luminescence Control) chip of an unknown make and model (probably made by Sharp, I distinctly remember finding both recorded in a file somewhere, but I forget where). And if I'm understanding right how it's set up, it's not possible for apps to monitor it without being specifically designed to do so (instead they find and try to use a useless stub; "Temporary v1"). I'm not a developer and only have the faintest clue as to what I'm doing, so I'm not even going to try taking a stab at changing that.

Even if apps could read the ALC output, it only outputs luminescence/lighting steps (around step 0-3 for dim rooms, up to step 13+ for direct sunlight), rather than Lux readings like a normal light sensor. So you could say, use an app for custom brightness control (once it's been calibrated for the unusual output), but doing things like getting actual light intensity (lux) readings is probably out of the question.

So, you're probably wishing I would shut up and get on to the juicy bits wondering what exactly I found. Well, a handful of relevant files/classes/settings/whathaveyou:

  • alc: This is the toggle for Automatic Brightness, presumably doing the exact same thing as the checkbox in Settings>Display>Screen Brightness does. Sending 1 to it turns it on, 0 off. Recommended not to edit this directly, see Red Text Note.

  • alc_min: This is the minimum brightness that Automatic Brightness will use; the bottom of the ramp. I'd ballpark it at a default of 50, about 20% brightness.

  • alc_max: This is the maximum brightness that Automatic Brightness will use; the top of the ramp. My guess is a default of 180-200, about 80% brightness.

Note that the above two accept a number in the 0-255 range; probably should stay in 1-254 for safety. I would suggest not trying numbers outside of either range, at best nothing will happen, at worst the backlight will become inoperative and/or the phone will crash.


  • alc_level: The current lighting step that the ALC chip is outputting. As I said above, a dim room will read 0-3, sunlight reads about 13 on up, a moderately bright green LED shone directly into the sensor reads 10-12. Maximum output is 16, but it would probably take uncomfortably bright light to achieve this. Can also be found and more easily monitored in the LG Service Menu (##lgservicemenu via the dialpad, service code 000000) under Folder>ALC/Proximity Test.

  • alc_curve: I have no idea what this does. Presumably it contains an array or something to control the brightness at each lighting step; I have no idea how you would go about editing it, and by default the brightness appears to increase in a linear fashion. Needs testing that I'm too lazy not knowledgeable enough to do. Feeding it single numbers seems, predictably, to have no effect.

  • alc_stepup: Again, no idea, but probably works in concert with the above. Current theory is that it's an array which controls how long it takes to fade up/down in brightness for each step. By default, the brightness increases quickly/sharply at each step (to reach readability as fast as possibly I'd guess) and fades down slowly/smoothly. Controls how much the backlight brightness increases with each ALC step. Default is in the 1-5 range. Increase in small increments (e.g. try stacking another 1-5 on) to get a brighter screen at a given ambient light level and max the backlight brightness sooner. Note that as with anything that makes the backlight brighter, increasing this will use more power over the default (somewhat dim) setting.

  • brightness: Currently set non-automatic brightness of the backlight LEDs. Accepts a number in the 0-255 range. You could, if you wanted, write to this to manually set a brightness lower or higher than the normal limits; note that it has no effect while auto-brightness is on. Recommended not to edit this directly, see Red Text Note.
It's worth noting that there doesn't seem to be any setting for filtering the ALC output (to prevent flickering between ALC outputs resulting in rapidly switching between two backlight levels). Probably the biggest issue with the system's handling of the backlight.


Red Text Note: While screwing around, I managed to arguably ruin the brightness settings on my phone. Each time it was locked and unlocked, brightness would be set to 0 (very dim, not off) and apps would no longer be able to affect it. Auto-brightness would always be automatically disabled when the phone was locked. Essentially, it made the whole brightness affair a pain in the ass.
!
The only way to fix it was restoring a nandroid that I'd made a few days prior to my first round of testing. !
I don't know what exactly caused it to happen, but if I had to guess, either manually editing brightness or alc, or using values 0 and 255. So don't do any of that. Sticking to the edits described below has proven safe so far.

So what's a person to do if they want automatic brightness without the ridiculously small range that it has by default? After all, the screen is way the hell too bright in total darkness, and nearly unreadable in broad daylight.

Well, increase the range, naturally. And it's actually very easy. Reading the above gave you 90% of what you need. The rest is to simply write to alc_min and alc_max.

Tools needed:
Root, we're playing with system files
A terminal emulator (Velocity has one built in, in Settings>Velocity Toolkit)
Some way to make a nandroid backup, as mentioned above we're playing with system files
30 seconds' worth of patience: read all three steps in their entirety before doing anything


  1. Make a nandroid backup. There's always the chance that something will break.
  2. Open your terminal emulator. Obtain superuser rights if needed ("su", enter). Velocity's emulator has SU by default.
  3. Input the following two lines, pressing the enter key after each:
Code:
echo [COLOR=Red]#[/COLOR] > /sys/class/leds/lcd-backlight/alc_min
echo [COLOR=Red]#[/COLOR] > /sys/class/leds/lcd-backlight/alc_max
Replace the # in each with your minimum/maximum desired brightness (5 is a good start for minimum (1 is really quite dim), 254 is the top end, about maxes the screen brightness in sunlight)
Done. No, really, that's it. If you find that it's too dim while in a dark room, increase alc_min until it's comfortable. The sensor isn't very sensitive in low-light conditions and it's recessed, so there needs to be a decent amount of ambient light before it starts ramping up. Might be possible to physically shave the inside of the front plate where the sensor mounts to bring it closer to the glass, so light reaches it more easily. Hmm...


Observed issues

  • Settings are restored to default when the phone is rebooted. If you find yourself rebooting a lot, you might want to write an init.d script or something.
  • The phone is still a bit dim in full sunlight. Sorry, but the backlight is only so strong. At least it's usable without having to use manual brightness.
  • The backlight takes a moment to "warm up" in full sunlight. I'm not sure about this, but it seems like the brightness is set to the default maximum when the phone is locked, and then ramps up to your set maximum when it's unlocked. It's quick, but noticeable.
  • The brightness curve is less than ideal. I have no idea how to change alc_curve (primarily because I don't know how it's laid out by default). Until someone figures it out, the brightness curve is linear, and due to the somewhat poor sensitivity of the light sensor this means that a low alc_min will result is a slightly dim (but still perfectly usable) screen indoors/in low-light conditions.
  • No sensor filtering. If you get in a spot where the lighting is just bright enough that it's on the edge of two ALC levels, then the backlight will step up and down as the value flickers back and forth. Unfortunately, as noted above, LG didn't seem to think that people might find this incredibly annoying, so (unless it's contained in alc_curve) there is really no way to prevent this.

That's it. Hope this documentation of my mucking about helps someone; certainly did get my own brightness stuff satisfactorily sorted out. sss



Somewhat related: LED settings

In /sys/classes/leds, there's a folder for each of the red/green/blue LEDs in the notification light, and contained in each of those folders is a brightness setting that kicks the associated LED on/off when set to >1/0 respectively.
Theoretically, if you could set it to read-only, you could probably disable that color. Food for thought. Not going to mess with it, myself...for now.
Actually did try this myself, as I had just made a backup prior to messing with alc_step. Setting the permissions on the brightness setting for the red LED to 444/r--r--r-- (default is 644/rw-r--r--) and plugging it in resulted in charging with no red charging light. Of course, it probably threw several errors to the system log, and the light would still go bright green above 90% charge, but it does show that you can indeed disable notification LEDs.
The same is true for the front button backlights (including the Back/Search buttons); you can shut them completely off and keep them off. This might be more useful, since the backlight on them is pretty useless and a waste of power once you know the phone.

Also possible is changing the keyboard backlight brightness, which appears to have at least three brightness settings: 40, 80 and 255 (the difference between 80 and 255 is extremely hard to see, though), 0-39 being completely off. Unfortunately, the phone seems to always max it out while in use, and I haven't yet figured out how to write to brightness_max to limit it.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones