[Kernel][GPL][4.4.1/2][Jan 12][0.1.3] m_plus kernel for mako

Search This thread

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
m_plus kernel for Nexus 4 (mako)!

Hi All,

After deciding to more or less abandon m_plus for 4.3 due to issues with JSS and JWR build compatibility, I have returned to work on it for 4.4. Google has now pushed the official sources for KitKat so the fun begins.

Disclaimer: As usual, I am not responsible for anything that may or may not happen to your device as a result of using this kernel or any other flashable zips posted by me in this thread.

Kernel Features:
  • Based on the latest Google Source for 4.4.1 (no changes were made to the kernel for 4.4.2)
  • Built with the Linaro 4.7 toolchain (2013.11)
  • Undervolt Interface (Undervolt to 600mV)
  • Gamma Control Interface (faux123 & _motley interfaces only)
  • USB fast charge
  • KGSL Simple GPU governor
  • Dynamic fsync
  • Faux Sound v3.2
  • Krait Retention for Mako
  • TCP Congestion Control (veno (default), reno, bic, westwood, vegas, yeah, illinois, cubic)

Builds:
Sources: https://github.com/thracemerin/kernel-Nexus4/tree/m_plus_44_exp

Personal Request: If you plan to make unofficial builds with features not included in the builds posted by me, please don't link them in the thread, all this does is result in confusion especially if someone has a problem with something you have added, it is much easier for me to provide support if I know that everyone in the thread is running the same builds I am. If you want to make a kernel with these features, feel free to start another thread so that they can be discussed and supported as appropriate.

Note: Starting with build 0.1.0, m_plus will go back to being distributed as a flashable zip, it will come in 2 versions. Zips with names ending in _any are anykernel versions and should work on any ROM even those with a modified ramdisk, zips with names ending in _rd come packed with the stock ramdisk for those on pure stock who want to have insecure ramdisk and init.d support.

Regarding CM Compatibility: Starting with build 0.1.1, m_plus will be compatible with CM, zips with names ending in _cm will be compatible with CyanogenMod 11 on an experimental basis, this is no guarantee that every CM feature will work with these builds, nor is it a guarantee that I will continue to support CM depending on what they do with their kernel that may or may not make it incompatible.
CM Compatible Source: https://github.com/thracemerin/kernel-Nexus4/tree/m_plus_44_cm

Latest:

m_plus-0.1.3 January 12, 2014

Changes:
  • Fix for s2w being active with s2sonly and dt2w (thanks to show-p1984)

Previous Versions

m_plus-0.1.2 January 7, 2014

Changes:
  • GPU governor reverted to ondemand (if you prefer simple, see post 2)
  • Sweep2Wake, Doubletap2Wake, Sweep2Sleep only
  • kexec hardboot for multiROM support

m_plus-0.1.1 December 18, 2013

Changes:
  • TCP Congestion Control (added veno (default), reno, bic, westwood, vegas, yeah, illinois)
  • Faux Sound v3.2
m_plus-0.1.0 December 6, 2013

Changes:
  • Added Krait Retention for Mako (thanks faux123)
  • Updated sources to AOSP (android-msm-mako-3.4-kitkat-mr1)
test 5 (named boot6.img) November 28, 2013

Changes:
  • Updated faux sound to v3
test 4 (named boot5.img) November 23, 2013

Changes:
  • Dynamic fsync
  • Faux Sound including PowerAmp
test 3 (named boot4.img) November 22, 2013

Changes:
  • USB fast charge
  • KGSL Simple GPU governor (thanks to faux123)
test 2 (named boot3.img) November 21, 2013

Changes:
  • Insecure ramdisk
  • Enabled init.d support in the ramdisk (in order for it to work you must have busybox installed to /system/xbin and you must create the directory /system/etc/init.d)
  • Added Undervolt Interface
  • Added Gamma Control Interface (faux123 & _motley interfaces only)

See the download section tab at the top of this page.

Or see here: http://xdaforums.com/devdb/project/?id=1660#downloads

Bug Reports:

Use the Bug Report feature at the top of this page.

Thanks:
  • Google
  • LG
  • Qualcomm/CodeAurora
  • CyanogenMod
  • _motley
  • faux123
  • show-p1984
  • franciscofranco
  • stratosk
  • anyone else I failed to mention (if you feel as though you deserved to be thanked by name, please PM me)

XDA:DevDB Information
m_plus kernel for mako, a Kernel for the Google Nexus 4

Contributors
thracemerin
Kernel Special Features:

Version Information
Status: Beta
Current Beta Version: 0.1.0
Beta Release Date: 2013-12-06

Created 2013-11-20
Last Updated 2014-01-12
 

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Setting custom Gamma settings via sysfs - thanks to faux123 for sharing his code
Warning: changing these values can be potentially be dangerous to your display if you make a mistake.

Important, please read!
There are ten digits in the string separated by one space
First digit is a checksum and is never stored. The checksum is simply the sum of the other 9 numbers. This is to make it harder to so the interface is respected and you are forced to think about what you are doing.

There are 3 sysfs interfaces for gamma, one for each color:

Code:
#!/system/bin/sh
# Show the current configuration and the checksum
cat /sys/devices/platform/mipi_lgit.1537/kgamma_red
cat /sys/devices/platform/mipi_lgit.1537/kgamma_green
cat /sys/devices/platform/mipi_lgit.1537/kgamma_blue

Update:
Recently molesarecoming started opening this up and showing us what the values can be used to adjust. Franco then suggested that the white and grays should be swapped in moles original work. So, for init.d values using this interface, we have the following "banks" if values if we agree with Franco on the swap of the whites and grays.

Code:
R: checksum, g_white, g_mids, g_black, 0, g_contrast, g_brightness, g_saturation, g_grey, 2
G: checksum, g_white, g_mids, g_black, 0, g_contrast, g_brightness, g_saturation, g_grey, 2
B: checksum, g_white, g_mids, g_black, 0, g_contrast, g_brightness, g_saturation, g_grey, 2
(the zero in position 5's and the 2's in position 10 are recommended to be left alone since they are currently unknowns)

Minus the checksum, the 27 values mirror the 3 color arrays (3 x 9 = 27) in the actual LG LCD driver. Minus the unknowns, we are left with 21 values. Note that every one of the variables can have their value tweaked by color (saturation for red, saturation for green etc.), however, it is recommended that you start with all the values of one type being the same and then tweak from there if you really want to fine tune.

You have a lot of power in your hands even without fine tuning. Many will argue that fine tuning isn't required. If you look at the stock settings by Google in post 2, they took advantage of fine tuning for whatever reason. Even though many don't like these settings by Google, it shows how flexible the interface can be.

Instructions:
1) Start with a preset config (LG or Google) as shown further below. This is a set of 3 lines, 10 numbers for each line.

2) Tweak columns for their values as above. For example, we tweak contrast and brightness as in faux's original app. We could also do the same for saturation, blacks, whites, grays etc.

Example: start with LG presets with numbers to adjust:
Code:
383 114 21 118 0 10 4 80 48 2
383 114 21 118 0 7 4 80 48 2
383 114 21 118 0 5 1 80 48 2

3) Now update the checksum in column 1 (first digit = sum of last 9 digits)

Code:
397 114 21 118 0 10 4 80 48 2
394 114 21 118 0 7 4 80 48 2
389 114 21 118 0 5 1 80 48 2

4) Create a script inside a text file - my recommendation for your first test

Code:
#!/system/bin/sh
# Set data color pro presets from shared Google spreadsheet (thanks user acer73!)
# Use LG presents as your starting values and then adjust columns 6 & 7 from the spreadsheet
echo "397 114 21 118 0 10 4 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
echo "394 114 21 118 0 7 4 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
echo "389 114 21 118 0 5 1 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue

#Set the complimentary RGB values for this calibration
echo "248 248 248" > /sys/devices/platform/kcal_ctrl.0/kcal
echo 1 > /sys/devices/platform/kcal_ctrl.0/kcal_ctrl
5) Run the script (or you can echo each line manually to test from adb if you prefer).

6) Turn the screen off and on for the gamma change to take effect.

7) Check the dmesg output for any clues and to see the output of the result.

8) Place the script into your /system/etc/init.d/ folder (or equivalent) for a permanent color change!

Screen refresh - this should only be called by apps or scripts while adjusting and testing colors "live" with the motley or faux sysfs interface. It should NOT be implemented on startup via init.d or by apps since it will compete with the normal power on process.


Code:
echo 1 > /sys/devices/platform/mipi_lgit.1537/refresh_screen

Presets:
Code:
#!/system/bin/sh
# Set LG presets (motley stock) - i.e. popular partial revert of Google's tweaks just before release
echo "383 114 21 118 0 0 0 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
echo "383 114 21 118 0 0 0 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
echo "383 114 21 118 0 0 0 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue
Code:
#!/system/bin/sh
# Set stock Google presets (from kernel source code)
echo "332 64 68 118 1 0 0 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
echo "332 64 68 118 1 0 0 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
echo "364 32 35 116 0 31 16 80 51 3" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue
Code:
#!/system/bin/sh
# Set faux Google presets (not sure why his numbers differ)
echo "460 64 68 118 1 32 96 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
echo "461 64 68 118 1 33 96 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
echo "445 32 35 116 0 32 96 80 51 3" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue

Voltage Control
Warning: Every chip is different, even those from the same bin may handle undervolting differently, proceed with caution until you know that your device can handle it.
Note: The minimum allowable undervolt is 600mV for all frequencies (this doesn't mean your device can handle this low voltage, see above)

The voltage table can be viewed by typing the following:

Code:
cat /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels

To make changes do the following:
Code:
echo 'X Y' > /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels

For example: (set the voltage for 384MHz to 850mV)
Code:
echo '384000 850000' > /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels

For those of you who are interested, here are the default voltage tables from Motley b49: https://docs.google.com/spreadsheet/ccc?key=0AlgoC5O8VXsLdFU4U2xnSUxwUlNyQ05TVHF3ZDJCdXc&usp=sharing

USB Fast Charge

Turn on: (off by default)
Code:
echo 1 > /sys/kernel/fast_charge/force_fast_charge
Turn Off:
Code:
echo 0 > /sys/kernel/fast_charge/force_fast_charge

Simple GPU Governor Tunables - Thanks to faux123

Switching the governor: (options are simple, ondemand (default) & performance)
Code:
echo 'ondemand' > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
Simple tunables:
Code:
/sys/module/msm_kgsl_core/parameters/simple_laziness
Laziness: Adjusts the number of times the governor skips ramp down requests. (Higher = better performance, higher battery drain)
Code:
/sys/module/msm_kgsl_core/parameters/simple_ramp_threshold
Threshold: Adjusts the threshold to ramp up or down the GPU frequencies. (Lower = better performance, higher battery drain)

C State Information

(thanks to faux123 - more info here: https://plus.google.com/109078966818501160423/posts/9R8fjQdHDXD)
faux123 recommends C0, C1 and C3 here: http://xdaforums.com/showpost.php?p=40151528&postcount=9775
C0 (WFI) - Shallowest Sleep (default enabled)
Code:
enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/wfi/idle_enabled
disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/wfi/idle_enabled
C1 (Retention) - slightly deeper sleep
Code:
enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/retention/idle_enabled
disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/retention/idle_enabled
C2 (Stand Alone Power Collapse) - deeper sleep
Code:
enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/idle_enabled
disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/idle_enabled
C3 (Power Collapse) - deepest sleep
Code:
enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled
disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled

TCP Congestion Control

Options: veno (default), reno, bic, westwood, vegas, yeah, illinois, cubic

Code:
echo 'cubic' > /proc/sys/net/ipv4/tcp_congestion_control

Sweep2Wake, Doubletap2Wake, Sweep2Sleep only

Sweep2Wake: (1 enable, 0 disable)
Code:
echo 1 > /sys/android_touch/sweep2wake

Doubletap2Wake: (1 enable, 0 disable)
Code:
echo 1 > /sys/android_touch/doubletap2wake

Sweep2Sleep Only: (1 enable, 0 disable) (sweep2wake must be enabled)
Code:
echo 1 > /sys/android_touch/s2w_s2sonly
 
Last edited:

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Frequently Asked Questions

Q: My battery life has significantly decreased vs stock, why would this be?
A: It would be rather foolish of me to create a custom kernel that decreases battery life. In my experience battery life issues are generally related to something in userspace rather than in the kernel. My suggestion is to get Better Battery Stats (there are kitkat versions in the XDA thread) and provide a dumpfile of a few hours worth of idle/standard use for me to look at so that I can help you identify the problem, if it is in fact an issue with the kernel I will do my best to fix it.

Q: I got a random reboot, freeze, sleep of death, other bug, what do I do?
A: Please review this post: http://xdaforums.com/showpost.php?p=23036410&postcount=1 and provide appropriate logs in the bug report tab at the top of the thread. I strongly advise that you remove your undervolt (if any) and attempt to reproduce the situation before posting as too much undervolting is often the cause.

Q: I saw a feature in another kernel that I'd really like for you to add to this one, how can I ask you to do that?
A: Go ahead and post it in the thread and I'll take a look, keep in mind that I would prefer to avoid filling the kernel with features that will be used by a very small number of users.
 
Last edited:

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
Test build 1 posted (boot.img format only until we're a little further along), see Download tab at the top of the thread.

It's basically just stock built with linaro, as a test to ensure everything went well. Builds with features will be coming shortly :D

Happy Flashing. :victory:

Note: This kernel is based on sources pushed for KRT16S, I'm not sure whether there will be problems with KRT16O or KRT16M builds as I didn't test them, the only problem that might be anticipated is that prima wlan was updated from 3.2.3.10 to 3.2.3.11 which may make WiFi not work, if this is the case let me know and I can put together a fix for that particular issue.
 
Last edited:

dEris

Senior Member
Nov 6, 2009
3,127
789
37
Dallas Texas
google.com
Awesome

5B8gBGw.png

[DEVICE:NEXUS⁴]❌[ROM:BEERGANG]❌[KERNEL:AK]
 

Spec-Chum

Senior Member
Mar 7, 2013
280
89
Awesome, was using your kernel on 4.3, now on psx 4.4 so looking forward to trying this on that :)

Sent from my Nexus 4 using Tapatalk
 

SkyBeam2048

Senior Member
Jan 25, 2011
217
98
Lucerne
Keeping in mind the design principles of the previous m_plus versions (4.2.x and 4.3), what features would you guys like to see for 4.4?

  • Undervolting (down to 600mV)
  • Dynamic fsync
  • Hotplug (control max. online CPUs)

Not sure if this is a feature which can be implemented in kernel. But I hate the Android default brightness control. You have to decide whether you use auto-brightness or manual one. I would like to see some control over auto-brightness as well. For example in many light conditions I would like to use a lower brightness than what is provided by auto-brightness. But when I go for manual brightness then I cannot even find the brightness control when I step out into the sunlight. So actually I would prefer to have auto-brightness but control the lower and upper limits and adjust the brightness adjustment sensitivity. Of course this would require also a change on the ROM since the ROM controls will disable brightness control when auto-brightness is active. But perhaps tuning the algorithm variables could be done via kernel variables or by very simple app then.

I just migrated to KRT16S factory image and looking forward to test this kernel.

These are just the features I would love most to see. Keep up the great work! Many thanks to you and also all the other kernel hackers allowing us to fine-tune where the Google default stops.
 

thracemerin

Senior Member
Oct 19, 2011
5,458
5,764
Toronto
  • Undervolting (down to 600mV)
  • Dynamic fsync
  • Hotplug (control max. online CPUs)

Not sure if this is a feature which can be implemented in kernel. But I hate the Android default brightness control. You have to decide whether you use auto-brightness or manual one. I would like to see some control over auto-brightness as well. For example in many light conditions I would like to use a lower brightness than what is provided by auto-brightness. But when I go for manual brightness then I cannot even find the brightness control when I step out into the sunlight. So actually I would prefer to have auto-brightness but control the lower and upper limits and adjust the brightness adjustment sensitivity. Of course this would require also a change on the ROM since the ROM controls will disable brightness control when auto-brightness is active. But perhaps tuning the algorithm variables could be done via kernel variables or by very simple app then.

I just migrated to KRT16S factory image and looking forward to test this kernel.

These are just the features I would love most to see. Keep up the great work! Many thanks to you and also all the other kernel hackers allowing us to fine-tune where the Google default stops.

The 3 things you listed are things that make my list too.

As far as the auto-brightness, this is mostly handled by the OS, though I have noticed that stratosk did some tweaks to the kernel side driver that could result in better auto-brightness, I'll look into that one.
 

ciprianruse88

Senior Member
Mar 14, 2012
4,561
9,659
Graceland
The 3 things you listed are things that make my list too.

As far as the auto-brightness, this is mostly handled by the OS, though I have noticed that stratosk did some tweaks to the kernel side driver that could result in better auto-brightness, I'll look into that one.

Don't forget gamma hack(faux's) and fauxsound and keep it ass minimal as possible just like on 4.3 :thumbup:
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 43
    m_plus kernel for Nexus 4 (mako)!

    Hi All,

    After deciding to more or less abandon m_plus for 4.3 due to issues with JSS and JWR build compatibility, I have returned to work on it for 4.4. Google has now pushed the official sources for KitKat so the fun begins.

    Disclaimer: As usual, I am not responsible for anything that may or may not happen to your device as a result of using this kernel or any other flashable zips posted by me in this thread.

    Kernel Features:
    • Based on the latest Google Source for 4.4.1 (no changes were made to the kernel for 4.4.2)
    • Built with the Linaro 4.7 toolchain (2013.11)
    • Undervolt Interface (Undervolt to 600mV)
    • Gamma Control Interface (faux123 & _motley interfaces only)
    • USB fast charge
    • KGSL Simple GPU governor
    • Dynamic fsync
    • Faux Sound v3.2
    • Krait Retention for Mako
    • TCP Congestion Control (veno (default), reno, bic, westwood, vegas, yeah, illinois, cubic)

    Builds:
    Sources: https://github.com/thracemerin/kernel-Nexus4/tree/m_plus_44_exp

    Personal Request: If you plan to make unofficial builds with features not included in the builds posted by me, please don't link them in the thread, all this does is result in confusion especially if someone has a problem with something you have added, it is much easier for me to provide support if I know that everyone in the thread is running the same builds I am. If you want to make a kernel with these features, feel free to start another thread so that they can be discussed and supported as appropriate.

    Note: Starting with build 0.1.0, m_plus will go back to being distributed as a flashable zip, it will come in 2 versions. Zips with names ending in _any are anykernel versions and should work on any ROM even those with a modified ramdisk, zips with names ending in _rd come packed with the stock ramdisk for those on pure stock who want to have insecure ramdisk and init.d support.

    Regarding CM Compatibility: Starting with build 0.1.1, m_plus will be compatible with CM, zips with names ending in _cm will be compatible with CyanogenMod 11 on an experimental basis, this is no guarantee that every CM feature will work with these builds, nor is it a guarantee that I will continue to support CM depending on what they do with their kernel that may or may not make it incompatible.
    CM Compatible Source: https://github.com/thracemerin/kernel-Nexus4/tree/m_plus_44_cm

    Latest:

    m_plus-0.1.3 January 12, 2014

    Changes:
    • Fix for s2w being active with s2sonly and dt2w (thanks to show-p1984)

    Previous Versions

    m_plus-0.1.2 January 7, 2014

    Changes:
    • GPU governor reverted to ondemand (if you prefer simple, see post 2)
    • Sweep2Wake, Doubletap2Wake, Sweep2Sleep only
    • kexec hardboot for multiROM support

    m_plus-0.1.1 December 18, 2013

    Changes:
    • TCP Congestion Control (added veno (default), reno, bic, westwood, vegas, yeah, illinois)
    • Faux Sound v3.2
    m_plus-0.1.0 December 6, 2013

    Changes:
    • Added Krait Retention for Mako (thanks faux123)
    • Updated sources to AOSP (android-msm-mako-3.4-kitkat-mr1)
    test 5 (named boot6.img) November 28, 2013

    Changes:
    • Updated faux sound to v3
    test 4 (named boot5.img) November 23, 2013

    Changes:
    • Dynamic fsync
    • Faux Sound including PowerAmp
    test 3 (named boot4.img) November 22, 2013

    Changes:
    • USB fast charge
    • KGSL Simple GPU governor (thanks to faux123)
    test 2 (named boot3.img) November 21, 2013

    Changes:
    • Insecure ramdisk
    • Enabled init.d support in the ramdisk (in order for it to work you must have busybox installed to /system/xbin and you must create the directory /system/etc/init.d)
    • Added Undervolt Interface
    • Added Gamma Control Interface (faux123 & _motley interfaces only)

    See the download section tab at the top of this page.

    Or see here: http://xdaforums.com/devdb/project/?id=1660#downloads

    Bug Reports:

    Use the Bug Report feature at the top of this page.

    Thanks:
    • Google
    • LG
    • Qualcomm/CodeAurora
    • CyanogenMod
    • _motley
    • faux123
    • show-p1984
    • franciscofranco
    • stratosk
    • anyone else I failed to mention (if you feel as though you deserved to be thanked by name, please PM me)

    XDA:DevDB Information
    m_plus kernel for mako, a Kernel for the Google Nexus 4

    Contributors
    thracemerin
    Kernel Special Features:

    Version Information
    Status: Beta
    Current Beta Version: 0.1.0
    Beta Release Date: 2013-12-06

    Created 2013-11-20
    Last Updated 2014-01-12
    15
    New Version 0.1.3 released!

    Changes
    • Fix for s2w being active with s2sonly and dt2w (thanks to show-p1984)

    Happy Flashing! :victory:
    11
    New Version! :D

    0.1.2 Release:

    Changes:
    • GPU Governor default back to ondemand (simple is still available, see post 2 for how to switch with scripts)
    • Sweep2Wake, Doubletap2wake, Sweep2sleep only
    • kexec hardboot for multiROM support

    Happy flashing! :victory:

    Anykernel version available now, if you need init.d support flash the 0.1.1 rd version then this.
    CM version shortly.
    11
    Quick update regarding development, I had another update ready to push but there was a huge ice storm here Saturday evening/Sunday morning and I lost power, sadly it hasn't come back yet and I'm not exactly sure when it will be back. Also I'm going on holidays on the 26th and won't be back until January 6th so if the power doesn't come back tonight the update may be delayed until then, sadly there is nothing I can do about situations beyond my control but I do plan to continue work when I can.

    Happy holidays to everyone, I will do my best to answer questions and assist if I can while on vacation but I likely won't be around like I normally am.



    Sent from my Nexus 5 using Tapatalk
    10
    Setting custom Gamma settings via sysfs - thanks to faux123 for sharing his code
    Warning: changing these values can be potentially be dangerous to your display if you make a mistake.

    Important, please read!
    There are ten digits in the string separated by one space
    First digit is a checksum and is never stored. The checksum is simply the sum of the other 9 numbers. This is to make it harder to so the interface is respected and you are forced to think about what you are doing.

    There are 3 sysfs interfaces for gamma, one for each color:

    Code:
    #!/system/bin/sh
    # Show the current configuration and the checksum
    cat /sys/devices/platform/mipi_lgit.1537/kgamma_red
    cat /sys/devices/platform/mipi_lgit.1537/kgamma_green
    cat /sys/devices/platform/mipi_lgit.1537/kgamma_blue

    Update:
    Recently molesarecoming started opening this up and showing us what the values can be used to adjust. Franco then suggested that the white and grays should be swapped in moles original work. So, for init.d values using this interface, we have the following "banks" if values if we agree with Franco on the swap of the whites and grays.

    Code:
    R: checksum, g_white, g_mids, g_black, 0, g_contrast, g_brightness, g_saturation, g_grey, 2
    G: checksum, g_white, g_mids, g_black, 0, g_contrast, g_brightness, g_saturation, g_grey, 2
    B: checksum, g_white, g_mids, g_black, 0, g_contrast, g_brightness, g_saturation, g_grey, 2
    (the zero in position 5's and the 2's in position 10 are recommended to be left alone since they are currently unknowns)

    Minus the checksum, the 27 values mirror the 3 color arrays (3 x 9 = 27) in the actual LG LCD driver. Minus the unknowns, we are left with 21 values. Note that every one of the variables can have their value tweaked by color (saturation for red, saturation for green etc.), however, it is recommended that you start with all the values of one type being the same and then tweak from there if you really want to fine tune.

    You have a lot of power in your hands even without fine tuning. Many will argue that fine tuning isn't required. If you look at the stock settings by Google in post 2, they took advantage of fine tuning for whatever reason. Even though many don't like these settings by Google, it shows how flexible the interface can be.

    Instructions:
    1) Start with a preset config (LG or Google) as shown further below. This is a set of 3 lines, 10 numbers for each line.

    2) Tweak columns for their values as above. For example, we tweak contrast and brightness as in faux's original app. We could also do the same for saturation, blacks, whites, grays etc.

    Example: start with LG presets with numbers to adjust:
    Code:
    383 114 21 118 0 10 4 80 48 2
    383 114 21 118 0 7 4 80 48 2
    383 114 21 118 0 5 1 80 48 2

    3) Now update the checksum in column 1 (first digit = sum of last 9 digits)

    Code:
    397 114 21 118 0 10 4 80 48 2
    394 114 21 118 0 7 4 80 48 2
    389 114 21 118 0 5 1 80 48 2

    4) Create a script inside a text file - my recommendation for your first test

    Code:
    #!/system/bin/sh
    # Set data color pro presets from shared Google spreadsheet (thanks user acer73!)
    # Use LG presents as your starting values and then adjust columns 6 & 7 from the spreadsheet
    echo "397 114 21 118 0 10 4 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
    echo "394 114 21 118 0 7 4 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
    echo "389 114 21 118 0 5 1 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue
    
    #Set the complimentary RGB values for this calibration
    echo "248 248 248" > /sys/devices/platform/kcal_ctrl.0/kcal
    echo 1 > /sys/devices/platform/kcal_ctrl.0/kcal_ctrl
    5) Run the script (or you can echo each line manually to test from adb if you prefer).

    6) Turn the screen off and on for the gamma change to take effect.

    7) Check the dmesg output for any clues and to see the output of the result.

    8) Place the script into your /system/etc/init.d/ folder (or equivalent) for a permanent color change!

    Screen refresh - this should only be called by apps or scripts while adjusting and testing colors "live" with the motley or faux sysfs interface. It should NOT be implemented on startup via init.d or by apps since it will compete with the normal power on process.


    Code:
    echo 1 > /sys/devices/platform/mipi_lgit.1537/refresh_screen

    Presets:
    Code:
    #!/system/bin/sh
    # Set LG presets (motley stock) - i.e. popular partial revert of Google's tweaks just before release
    echo "383 114 21 118 0 0 0 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
    echo "383 114 21 118 0 0 0 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
    echo "383 114 21 118 0 0 0 80 48 2" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue
    Code:
    #!/system/bin/sh
    # Set stock Google presets (from kernel source code)
    echo "332 64 68 118 1 0 0 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
    echo "332 64 68 118 1 0 0 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
    echo "364 32 35 116 0 31 16 80 51 3" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue
    Code:
    #!/system/bin/sh
    # Set faux Google presets (not sure why his numbers differ)
    echo "460 64 68 118 1 32 96 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
    echo "461 64 68 118 1 33 96 48 32 1" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
    echo "445 32 35 116 0 32 96 80 51 3" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue

    Voltage Control
    Warning: Every chip is different, even those from the same bin may handle undervolting differently, proceed with caution until you know that your device can handle it.
    Note: The minimum allowable undervolt is 600mV for all frequencies (this doesn't mean your device can handle this low voltage, see above)

    The voltage table can be viewed by typing the following:

    Code:
    cat /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels

    To make changes do the following:
    Code:
    echo 'X Y' > /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels

    For example: (set the voltage for 384MHz to 850mV)
    Code:
    echo '384000 850000' > /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels

    For those of you who are interested, here are the default voltage tables from Motley b49: https://docs.google.com/spreadsheet/ccc?key=0AlgoC5O8VXsLdFU4U2xnSUxwUlNyQ05TVHF3ZDJCdXc&usp=sharing

    USB Fast Charge

    Turn on: (off by default)
    Code:
    echo 1 > /sys/kernel/fast_charge/force_fast_charge
    Turn Off:
    Code:
    echo 0 > /sys/kernel/fast_charge/force_fast_charge

    Simple GPU Governor Tunables - Thanks to faux123

    Switching the governor: (options are simple, ondemand (default) & performance)
    Code:
    echo 'ondemand' > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
    Simple tunables:
    Code:
    /sys/module/msm_kgsl_core/parameters/simple_laziness
    Laziness: Adjusts the number of times the governor skips ramp down requests. (Higher = better performance, higher battery drain)
    Code:
    /sys/module/msm_kgsl_core/parameters/simple_ramp_threshold
    Threshold: Adjusts the threshold to ramp up or down the GPU frequencies. (Lower = better performance, higher battery drain)

    C State Information

    (thanks to faux123 - more info here: https://plus.google.com/109078966818501160423/posts/9R8fjQdHDXD)
    faux123 recommends C0, C1 and C3 here: http://xdaforums.com/showpost.php?p=40151528&postcount=9775
    C0 (WFI) - Shallowest Sleep (default enabled)
    Code:
    enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/wfi/idle_enabled
    disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/wfi/idle_enabled
    C1 (Retention) - slightly deeper sleep
    Code:
    enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/retention/idle_enabled
    disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/retention/idle_enabled
    C2 (Stand Alone Power Collapse) - deeper sleep
    Code:
    enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/idle_enabled
    disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/idle_enabled
    C3 (Power Collapse) - deepest sleep
    Code:
    enable: echo 1 > /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled
    disable: echo 0 > /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled

    TCP Congestion Control

    Options: veno (default), reno, bic, westwood, vegas, yeah, illinois, cubic

    Code:
    echo 'cubic' > /proc/sys/net/ipv4/tcp_congestion_control

    Sweep2Wake, Doubletap2Wake, Sweep2Sleep only

    Sweep2Wake: (1 enable, 0 disable)
    Code:
    echo 1 > /sys/android_touch/sweep2wake

    Doubletap2Wake: (1 enable, 0 disable)
    Code:
    echo 1 > /sys/android_touch/doubletap2wake

    Sweep2Sleep Only: (1 enable, 0 disable) (sweep2wake must be enabled)
    Code:
    echo 1 > /sys/android_touch/s2w_s2sonly