yashsingh1/xdaforums huggingface dataset:
[Atrix 4G Android Development] RogerPodacter:
Dude where the hell did you find that? I've been looking everywhere for that! You just solved the thread! Obviously you got it on the same manufacturers site, but I couldn't find the damn thing...outstanding. and i'm sure you just typed in the same link from the first post, with the proper name. damn i feel dumb for not trying that.

i'm reading it, this has everything we need. i was using the LM3530 data sheet and trying to reverse engineer the registers because that's all i could find. now it's time to tweak..
[Atrix 4G Android Development] saltinbas:
Glad to hear that.
[Atrix 4G Android Development] saltinbas:
As far as i understand, the data sheet does not contain duty cycle info about changing the value. There is no register associated with duty cycle
[Atrix 4G Android Development] RogerPodacter:
Yeah it looks that way. Its either on or off, and we know its already turned on by default.
[Atrix 4G Android Development] saltinbas:
Well, I also see that register 0x1A has default value of;

0 = ALS Current Control

1 = I2C Current Control (default)

Which one is more battery friendly. ALS or I2C current control?
[Atrix 4G Android Development] RogerPodacter:
One of the goals I think should be enabling ALS because I think its not not being used.

If you notice in the config function in leds-lm3532.c, when they set reg 16 they use bitwiseOR with I2C | Ctrl_a_mapping_mode. So I'd like to try that but with als.
[Atrix 4G Android Development] saltinbas:
I will wait you, since when i change the register to als it reverts back to i2c automatically after turn off and on screen. When can we try your kernel?
[Atrix 4G Android Development] RogerPodacter:
I can make the kernel anytime you guys want, I didn't make anymore changes yet once I started setting registers. When screen goes off it resets back until we change the code and compile.

Now I'm unable to set als because it actually is 0x00 so when I bitwise OR with linear or exp I don't see any change either.

Side note, any code change in mind I'll compile if we want. I'm going thru data sheet now in detail.
[Atrix 4G Android Development] saltinbas:
Do not forget to configure register 23
[Atrix 4G Android Development] saltinbas:
If possible, i would like to try your kernel
[Atrix 4G Android Development] FtaWolf:
Then what does Custom Battery Saver do then . There option in there to lower brightest of lcd down also...
[Atrix 4G Android Development] Rickroller:
Did you even read the thread? Alls those apps do is mask brightness..this actually lowers screen brightness AND lessens battery consumption by limiting the amount the screen is drawing current wise.
[Atrix 4G Android Development] pukemon:
For anybody that hasn't read the thread the gist of it is, it is very possible to lower on the brightness and the current used to power the backlight

Iphone > galaxy s 2.
[Atrix 4G Android Development] tight686:
Please upload your kernel. Very excited to try this.
[Atrix 4G Android Development] pukemon:
Its not kernel based. Framework. He's still looking it over. Gptnsomething going for auto brightness but looking for a manual solution or power settings bar.

Iphone > galaxy s 2.
[Atrix 4G Android Development] UnCommonGrafx:
slick!

Thanks for tinkering! A fun little thing with great potential. Love how dim I can get it. I mean, unsee-ably dim!

Very cool.
[Atrix 4G Android Development] RogerPodacter:
Ok I will compile the kernel and upload it.

So that was my dilemma, what kernel change do I make as the default now that we can set any register with any display mode at will.

So what I'm gonna do is compile the kernel with the lowest 5mA mode as the default. So that's a huge savings, 5ma vs 26mA stock setting. And if that is too dim for anyone during the day then you just manually bump up to a higher mode by echoing the register.

Then there is the frameworks fix which removes the brightness of 30. The frameworks is not part of the kernel though, it has to be flashed separately. I attached the fixed frameworks to the first post.

In the mean time, version 2 of the kernel can have more fixes. I just haven't had a chance to use the new data sheet yet to try the newly learned info cause I've been so busy. So we'll save that for version #2. Version #1 will be lowered 5ma mode.
[Atrix 4G Android Development] kbello:
Will be great if you can recompile framework-res.apk for new CM7 pre-beta #4.

Thank you :)
[Atrix 4G Android Development] primeboss:
Does the AdjBrightness do the same thing as this?
[Atrix 4G Android Development] pukemon:
Read the thread.

Iphone > galaxy s 2.
[Atrix 4G Android Development] NFHimself:
Hi,

I am currently using this below, works out well, I can still see the screen, a value of 2 is too dark for me. I am thinking not all phones will have the exact same hardware, how bright something is a value x on one phone might be a bit different than another phone.

One issue is that just before turning off the screen, the phone get brighter before turning dark. There is probably another 20 hanging around somewhere, if not just a hard value in code.

Cheers!

<integer-array name="config_autoBrightnessLcdBacklightValues">
[COLOR=Green] <item>6</item>
<item>16</item>[/COLOR]
<item>34</item>
<item>46</item>
<item>62</item>
<item>81</item>
<item>100</item>
<item>119</item>
<item>137</item>
<item>138</item>
<item>153</item>
<item>170</item>
<item>187</item>
<item>206</item>
<item>221</item>
<item>255</item>
</integer-array>
<integer-array name="config_autoBrightnessButtonBacklightValues">
<item>255</item>
<item>255</item>
<item>255</item>
<item>192</item>
<item>128</item>
[COLOR=Green] <item>64</item>
<item>32</item>
<item>16</item>
<item>8</item>[/COLOR]
<item>0</item>
<item>0</item>
<item>0</item>
<item>0</item>
<item>0</item>
<item>0</item>
<item>0</item>
</integer-array>
[Atrix 4G Android Development] RogerPodacter:
I apologize for taking so long. I recompiled for pre beta 4, flashed to my phone and worked great. But then my phone had issues with bootloops so I lost the framework. Now I have to fix my issue first before I can do the fix framework, which this weekend I should have time.
[Atrix 4G Android Development] d3athsd00r:
You could have just booted into CWM and adb pulled it from your phone. I have adb access while in romracer's CWM so I would assume everyone does.
[Atrix 4G Android Development] RogerPodacter:
Yeah I was forced to restore a working nand backup during work so I couldn't grab it. But its all good now so I'll post it tonight after work.
[Atrix 4G Android Development] d3athsd00r:
Sweet. Looking forward to it. Already getting great battery life with CM7 pb4 :)
[Atrix 4G Android Development] tight686:
So with the modified frameworks will the standard android brightness toggle "reflect" the modifications?
[Atrix 4G Android Development] RogerPodacter:
Update

I have updated the first post to add cyanogen pre beta 4 frameworks edited, minimum brightness of 2.

I also added the modified frameworks for HOME BASE ROM, just in case it was different. so we pulled a frameworks directly from that ROM and modified it.

also i compiled the kernel with minimum brightness mode of 5mA set as the default. so upon boot up, the screen defaults right to lowest 5mA setting so you dont have to change it everytime. then if you need the higher setting you can manually set it, which will stay set until you change it back yourself, or you reboot.

i've been finding that the lowest setting is good even in daylight, but in the sun i just set to 255 brightness. i've been getting super display-on times with this. seems like i can browse the web for 1.5 hours and still have 82% battery left.

HAVE A NAND BACKUP READY JUST IN CASE.

let me know of any issues. thanks.
[Atrix 4G Android Development] RogerPodacter:
the standard android toggle obeys the now new lower brightness setting when in auto brightness mode. when i use the power widget to manually set 0%, 40%, or 100%, at 0% still seems to be locked at 30. not sure why. i think we just need to find the additional number and change it.

for now its perfect for me. screen is great in all conditions, and only in very dark night time is when the new low sets in, and i just leave in auto brightness the whole time.
[Atrix 4G Android Development] tight686:
Can I just use root explorer to copy the file or do I have to use adb??
[Atrix 4G Android Development] xangma:
Been thinking ... when the CM Beta gets a new update, we can just decompile frameworks.apk or whatever and change it again right? Should we get a script running? =P

Also, is this just changing the display values? I heard about the changing of the display method to a much more battery friendly one. What happened with this?
[Atrix 4G Android Development] xangma:
Also, can we not just set this up in cyanogen mod settings. Like in custom light levels?
[Atrix 4G Android Development] kwick60073:
I am using Cherry Pi and would like to try this mod. The kernel is easy enough to update. I'm guessing that I can't just drop on of the other frameworks into this ROM and I certainly don't expect rog to modify the framework for each ROM.

Can the framework be updated by

- pull framework-res.apk from phone

- unzip the apk

- insert/update the array.xml file

- zip the apk

- push the apk back to phone
[Atrix 4G Android Development] RogerPodacter:
You can use root explorer to copy the file FROM your phone TO your sdcard, but not to paste it back in. I tried already. The phone can't be running to install the framework.
[Atrix 4G Android Development] RogerPodacter:
Yes that's exactly what we have to do. I just attached the new pre beta modified version to first post for those who can't do the mod.

This thread has 2 mods happening. The first one, and the one which gives a big reduction in power draw, is setting the register values in the kernel, the 5mA mode, using the echo commands etc.

Then the second thing we found is how to remove the brightness cap of 30. That ended up being in frameworks.

So you want to do both mods in first post.

Basically the kernel mod is lower level, controlling the display underneath the framework. Then on the top level we had to fix the frameworks remove that cap.

So top level there is brightness range of 00-255. Whether you set any register on low level in the kernel, up in user space will still use 00-255 range. So at the register setting of 26mA (stock), the frameworks has usable range of 00-255. At register setting of 5mA (much lower power), the frameworks still has range of 00-255, but now with the 5mA as the base (low level kernel space).

I should prob explain this better or make a guide. Should have reserved post #2.
[Atrix 4G Android Development] RogerPodacter:
No I tried that. Just using unzip doesn't work unfortunately. It has to actually be decompiled with apk manager, then recompiled.

Yeah it would be nice if we could have the frameworks from each rom, but I can't do that myself. Though I bet all roms are just stock framework anyway so it could maybe work on any rom. I just didn't test.

But for example with cyan beta 3 vs 4, they changed the framework so I had to make the mod again for it. Once it stays the same we could prob just use it for each time without modding it again.
[Atrix 4G Android Development] mrphil101:
not sure which way the display works when in the dock, but it has an adjustment that allows the screen to be turned down low enough that it can't hardly be seen in daylight. not sure if it is dimming or masking,
[Atrix 4G Android Development] RogerPodacter:
Its actually dimming properly using the stuff in this thread. You can see it in the driver code.
[Atrix 4G Android Development] Clienterror:
So when you flash the new kernel do you loose your ability to oc about uv? Or does this just modify the kernel your running a little?
[Atrix 4G Android Development] RogerPodacter:
Well I just compiled faux's kernel and I'm almost positive I left the oc and UV configured. But I did get one report that a user couldn't flash it and got the error 30003. I had the same error and it was cause of wrong ramdisk.

I know its possible to just use your favorite kernel zip, extract it, replace the zimage with this one, and zip it up and flash it. But it might be tricky to do that, haven't tried that yet. I just heard its possible.
[Atrix 4G Android Development] Clienterror:
Ah gotcha this looks awesome man great job with this BTW!
[Atrix 4G Android Development] m0biusace:
This. CM makes this mod redundant (at least on CM. I can see why someone would want to do this on a blur rom.) I can lower the brightness down to 1 with CM by going into settings>cyanogenmod settings>display>automatic backlight>screen dim levels
[Atrix 4G Android Development] RogerPodacter:
Again, this thread is changing kernel settings by setting registers directly controlling the lm3532 chip. Cyanogen display settings is simply not controlling on this level unless we added this into cyan, which is actually a great idea. The cyan settings simply cannot set the 5mA mode, or exponential, or PWM, etc.

But it probably can lower the general brightness 0-255 level as that is a standard naming scheme across android devices.
[Atrix 4G Android Development] RogerPodacter:
Anyone who tried to flash the kernel and got error x00030003 I updated the thread with correct command. It was supposed to be:

moto-fastboot flash:raw boot zImage ramdisk.gz

The old one was:

moto-fastboot flash:raw zImage ramdisk.gz

Thanks byoo511 for this info!
[Atrix 4G Android Development] primeboss:
I did read the thread, could find information. Can someone answer answer the question above?
[Atrix 4G Android Development] RogerPodacter:
AdjBrightness is no longer needed as the modified frameworks completely takes care of this.
[Atrix 4G Android Development] primeboss:
Is all i need is to replace the framework, or do i have to install the kernel as well?
[Atrix 4G Android Development] amwbt:
Can we get Faux's latest kernel modded to include this? I love this mod. Its a must have.
[Atrix 4G Android Development] RogerPodacter:
Just need the framework. The modified framework allows brightness to go down to 02 at night just using the built in auto brightness setting.

You could even let it go to 01 or 00 if you want to mod your own frameworks. I just figured 02 was good enough.
[Atrix 4G Android Development] amwbt:
Roger,

How low does the kernel that you posted set it to?
[Atrix 4G Android Development] RogerPodacter:
I'll try to sync to his latest repo. I've been so busy I've slacked on this project. I think the kernel is faux's from like a month ago, missing all his latest work.

With the new data sheet there's a bunch more stuff to try that I haven't had time to do.
[Atrix 4G Android Development] RogerPodacter:
The attached kernel sets it to the lowest 5mA brightness mode as default on boot, rather than 25mA stock.

Its the same as echo reg 17 with 00.
[Atrix 4G Android Development] amwbt:
Ah, ok. Well if the brightness can be automatically controlled using the edited frameworks then a kernel isn't really needed. I prefer the kernel because I prefer the no carrier framework. The AT&T takes up 1/4 of my notification bar. Plus I like the brightness the edited kernel sets without having to open terminal and reset it to my desired setting.
[Atrix 4G Android Development] RogerPodacter:
Well that's the question, how to bounce between brightness modes easily. The framework fixes the auto brightness so it uses the full low end range.

But the kernel sets the 5mA mode. I can't think of a way to switch brightness modes easily without using terminal. We'd have to add some major code changes to conditionally set the register. But what condition to use?

Could just write a small Java app toggle, but I don't like that idea. So for now the lowest mode makes sense for the kernel.

Remember there are 2 mods here that do 2 different things. Frameworks everyone should be using. The kernel for those who want lower power draw from the screen.
[Atrix 4G Android Development] jcorio:
I made a simple script.sh

cd /sys/bus/i2c/drivers/lm3532/0-0038/leds/lcd-backlight/

echo 16 01 > registers

echo 185 > brightness

And downloaded script manager, which has a widget and is free, to execute the script from the home screen.

https://market.android.com/details?id=os.tools.scriptmanager

Works.
[Atrix 4G Android Development] bull8042:
This is the only thing stopping me from doing this mod. I am already running Faux123's 0.1.7 kernel with Cherry Pi. But I really, really don't want the branding back in the notification bar.
[Atrix 4G Android Development] jcorio:
Aside from my post above, I also got Tasker to run the script from /sdcard/sl4v/scripts/script.sh on a screen on event

su

cd /sys/bus/i2c/drivers/lm3532/0-0038/leds/lcd-backlight/

echo 16 01 > registers

echo 185 > brightness

EDIT: apparently I did not. I swear I saw the screen change. I modified the script slightly, but even changing it back fails.
[Atrix 4G Android Development] 1username4thisforum:
Anyone have any idea if this will work with Ninja Speed freak .45?

Thanks!
[Atrix 4G Android Development] eriktch:
Roger, if you bring it up to 10mA does it make a big difference in visibility during the day?
[Atrix 4G Android Development] pukemon:
try it manually and see. everybody conditions are really dynamic. echo 17 05 seems to be pretty good with no direct light around.
[Atrix 4G Android Development] eriktch:
Im sorry im a noob. When I go into terminal on my phone and try to change it, it says "cannot create registers: read-only file system". Any ideas?
[Atrix 4G Android Development] pukemon:
Did you read the first post thoroughly? Are you rooted? Did you type su first to get the privilege?

I voided my warranty and your mum.
[Atrix 4G Android Development] eriktch:
Nevermind guys, I got it. I was using a bad emulator. I downloaded Android Terminal Emulator and it worked. Thanks anyways
[Atrix 4G Android Development] huanyu:
RogerPodacter great work on finding all the information.

The other approach is set the reg 17 base on the pwm value in the driver.

here is a quick hack i did to change reg 17 based on the pwm value.

Patch for those interested.

diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index c97b43d..d50c9a4 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -43,6 +43,7 @@
#include <linux/earlysuspend.h>
#endif

+#define LM3532_CRTL_A_BASE_FS_CURRENT LM3532_6p6mA_FS_CURRENT
#define MODULE_NAME "leds_lm3532"

#define LM3532_INIT_REQUESTS 8
@@ -393,6 +394,7 @@ static void lm3532_brightness_set (struct led_classdev *led_cdev,
unsigned is_tcmd = 0;
struct lm3532_data *driver_data;
struct i2c_client *client;
+ uint8_t crtrl_a_fs_reg_value;

if (strstr(led_cdev->name, "tcmd"))
is_tcmd = 1;
@@ -438,6 +440,15 @@ static void lm3532_brightness_set (struct led_classdev *led_cdev,
}
driver_data->bvalue = value;

+ crtrl_a_fs_reg_value = ( value >> 5 ) + LM3532_CRTL_A_BASE_FS_CURRENT;
+ if ( driver_data->pdata->ctrl_a_fs_current != crtrl_a_fs_reg_value ) {
+ driver_data->pdata->ctrl_a_fs_current = crtrl_a_fs_reg_value;
+ printk_request ("%s: %s, 0x%x(%d), reg 0x17 : %d\n", __func__,
+ led_cdev->name, value, value, crtrl_a_fs_reg_value);
+ lm3532_write_reg (client, LM3532_CTRL_A_FS_CURR_REG,
+ crtrl_a_fs_reg_value, __func__);
+ }
+
mutex_unlock (&lm3532_mutex);
}
[Atrix 4G Android Development] amwbt:
You would have to have a modded framework for Ninja Speed freak. 45
[Atrix 4G Android Development] huanyu:
i just make this kernel for those who may wanna to try the patch. This kernel provides a dynamic range (LM3532_6p6mA_FS_CURRENT to LM3532_12p2mA_FS_CURRENT) for register 17 based on the pwm value set by android.

pwm value vs Brightness Config Value table

0-31: LM3532_6p6mA_FS_CURRENT

32-63: LM3532_7p4mA_FS_CURRENT

...

223-255: LM3532_12p2mA_FS_CURRENT

this mean if you set your pwm/brightness value between 0-31 the reg 17 should set to 0x2.

kernel build based on this patch:

diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index c97b43d..d50c9a4 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -43,6 +43,7 @@
#include <linux/earlysuspend.h>
#endif

+#define LM3532_CRTL_A_BASE_FS_CURRENT LM3532_6p6mA_FS_CURRENT
#define MODULE_NAME "leds_lm3532"

#define LM3532_INIT_REQUESTS 8
@@ -393,6 +394,7 @@ static void lm3532_brightness_set (struct led_classdev *led_cdev,
unsigned is_tcmd = 0;
struct lm3532_data *driver_data;
struct i2c_client *client;
+ uint8_t crtrl_a_fs_reg_value;

if (strstr(led_cdev->name, "tcmd"))
is_tcmd = 1;
@@ -438,6 +440,15 @@ static void lm3532_brightness_set (struct led_classdev *led_cdev,
}
driver_data->bvalue = value;

+ crtrl_a_fs_reg_value = ( value >> 5 ) + LM3532_CRTL_A_BASE_FS_CURRENT;
+ if ( driver_data->pdata->ctrl_a_fs_current != crtrl_a_fs_reg_value ) {
+ driver_data->pdata->ctrl_a_fs_current = crtrl_a_fs_reg_value;
+ lm3532_write_reg (client, LM3532_CTRL_A_FS_CURR_REG,
+ crtrl_a_fs_reg_value, __func__);
+ }
+
mutex_unlock (&lm3532_mutex);
}
[Atrix 4G Android Development] axial_pro:
This is a fantastic mod. I used the commands for terminal mode to greatly improve nighttime brightness.

I have a comment and a question, though.

Q: Can someone make something like a batch file from the good old DOS days to run this upon clicking?

In the same vein, couldn't this be a widget that could trigger the script (batch file) to change the registers to the low power mode and then change it back with another click?

The comment hails from the question: When I set the registers to low power mode it also reduced max brightness to the point I need to reset the register for use in my car. The brightest setting is no longer bright enough.

A toggle widget would rock for this. Of course, I haven't the slightest clue how to do this...

Cheers
[Atrix 4G Android Development] yeahmann:
Okay, I'm not computer illiterate but the OP is a mess. I pushed the framework. Now what's all this talk about register 16, register 17, the 30 limit, and the 2 and the 01? And what about the buttons?
[Atrix 4G Android Development] pukemon:
Its to tinker with for the noobs and for ones not scared to tinker around a bit deeper and hopefully somebody with some skills will pick up on this and integrate it into cyanogen and/or make an app or widget. The op found all this by tinkering on his own and has amateur coding skills at best. We are hoping somebody would and make this a more permanent/built in solution for those that would like to benefit from longer battery during the day. The default brightness is too bright at night and its more than adequate for daytime use but can be set to use less current.

I voided my warranty and your mum.
[Atrix 4G Android Development] jcorio:
I use "script manager". Works well.

I want to get scripts working with Tasker, but I haven't put much effort into it, yet.

http://xdaforums.com/showthread.php?p=17532225
[Atrix 4G Android Development] Nottach:
This is an indispensable MOD and I've been implementing it, to the best of my ability, into my ROMs by using framework array edits.

I've found a value of 6 works well for autoBrightnessLcdBacklightValues

but I've been trying to find a Button Backlight value to match by changing autoBrightnessButtonBacklightValues to 6 as well and I don't notice any difference. Is that the wrong array to edit?

Beyond that are those the only edit ROM devs can integrate besides compiling their own kernel?

I've found the LCD setting of 6 to increase battery life and that's really my main goal.

Any help or ideas, greatly appreciated.
[Atrix 4G Android Development] seanzscreams:
which file is being edited in the framework so i can compile this for orange.. thanks

arrays.xml?

bad ass mod i love it
[Atrix 4G Android Development] neotekz:
will this mod reset when i boot? is this mod no longer being worked on?
[Atrix 4G Android Development] kenyloveg:
anybody know how to use this great mod in cm9/MIUI?

Thanks.