[DEV][PATCH] KCAL - Advanced color control for Qualcomm MDSS 8x10/8x26/8974/8084/8939

Search This thread

savoca

Inactive Recognized Developer
Oct 28, 2011
1,784
5,703
Pasadena
downloads.codefi.re
Google Pixel 7
Hello! If you're keen on custom kernels, especially for Nexus devices, you've probably heard the term Color/Gamma Control thrown around a bit. A once *very* device dependent feature now made available for the following chipsets:
8x10
8974 v1.0
8x26 v1.0
8x26 v2.0, 8926 v1.0
8926 v2.0
8974 v2.0
8974 v3.0 (Pro)
8084 v1.0
8084 v1.1
8994 v1.0
8916 v1.0
8939 v1.0
8092 v1.0

Color calibration allows you to use an app (or root shell) to manipulate the following post-processing features of the Qualcomm MDSS:
RGB Multipliers (Polynomial Color Correction)
Display Color Inversion (Inverse Gamma Correction)
Hue/Saturation/Value/Contrast Manipulation (Picture Adjustment)

Too confusing? Here's a video demonstration by @Andromjb:

Sysfs paths/variables:
/sys/devices/platform/kcal_ctrl.0/kcal - (0-256 0-256 0-256) - Controls R/G/B Multipliers
/sys/devices/platform/kcal_ctrl.0/kcal_min - (0-256) - Controls minimum RGB Multiplier value
/sys/devices/platform/kcal_ctrl.0/kcal_enable - (0-1) - Enables/Disables RGB Multiplier Control
/sys/devices/platform/kcal_ctrl.0/kcal_invert - (0-1) - Enables/Disables Display Inversion Mode
/sys/devices/platform/kcal_ctrl.0/kcal_sat - (224-383 or 128) - Controls saturation intensity - use 128 for grayscale mode
/sys/devices/platform/kcal_ctrl.0/kcal_hue - (0-1536) - Controls display hue - may have issues with msm8x26 in the higher values
/sys/devices/platform/kcal_ctrl.0/kcal_val - (128-383) - Controls display value
/sys/devices/platform/kcal_ctrl.0/kcal_cont - (128-383) - Controls display contrast

Link your favorite kernel developer back to this thread and ask them to add support!

KCAL for MDP5
https://github.com/savoca/kcal/commits/mdp5

KCAL for MDP3 (Only supports RGB multipliers):
https://github.com/savoca/kcal/commits/mdp3

And finally, an app to control your display - available for free here:
http://downloads.codefi.re/savoca/kcal

Thank you to LG for the display inversion control and code reference, also thank you to @faux123 for insight/reference with MDP3 RGB multipliers and @eng.stk for testing on APQ8084
 
Last edited:

savoca

Inactive Recognized Developer
Oct 28, 2011
1,784
5,703
Pasadena
downloads.codefi.re
Google Pixel 7
On Shamu I can't get anything to work besides the usual RGB and inverted.

Sweet. I'll try it on HTC m8 and Nexus 6 this week.

Sat/Hue/Val/Cont use the picture adjustment feature, and on APQ8084 and beyond it's been moved to a 2nd version of Qcom's picture adjustment. I don't have any of those devices so I didn't attempt to add support - but here's a blind patch you can try to add support or use for reference:
https://github.com/savoca/kernel-msm/commit/7dbc9ba0fd18279cde564c1631e52b448b39fc98
(This patch is assuming the scaling for PA v2 is the same as v1, it's very possible that has changed - but again, no device in hand, not much I can find out)

Great work @savoca
How to check MDSS_MDP_HW_REV? Any idea which is for Hammerhead and Shamu?

First code block in the OP has a reference list. :good:
 
Last edited:

Snepsts

Senior Member
Apr 16, 2014
638
554
St. Louis, MO
Looks like for newer Qualcomms, good work! Unfortunately my device is back on APQ8064T, but always nice to see innovation for all devices! :)
 

eng.stk

Senior Member
Mar 29, 2011
7,226
61,225
OnePlus 5T
OnePlus 6
@savoca I merged your patches on shamu, at least RGB, invert and so on work echo values.
Can't test your app, it crashes when opening...
 

Attachments

  • color_control.txt
    5.3 KB · Views: 734
Last edited:
  • Like
Reactions: jawz101

savoca

Inactive Recognized Developer
Oct 28, 2011
1,784
5,703
Pasadena
downloads.codefi.re
Google Pixel 7
Sorry mate I added a log but was on .log and now I put .txt so xda upload doesn't derp it

I added the said patch also, but would like to test with the app.

Are you using a ROM with support for RGB calibration? If so the selinux/contexts it may hold with the kcal sysfs path could prevent the app from using them. You can either pull all references to kcal out of the ramdisk, or use a root shell for now.

I'd also like to hear your results on pa_v2 control with N6.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 272
    Hello! If you're keen on custom kernels, especially for Nexus devices, you've probably heard the term Color/Gamma Control thrown around a bit. A once *very* device dependent feature now made available for the following chipsets:
    8x10
    8974 v1.0
    8x26 v1.0
    8x26 v2.0, 8926 v1.0
    8926 v2.0
    8974 v2.0
    8974 v3.0 (Pro)
    8084 v1.0
    8084 v1.1
    8994 v1.0
    8916 v1.0
    8939 v1.0
    8092 v1.0

    Color calibration allows you to use an app (or root shell) to manipulate the following post-processing features of the Qualcomm MDSS:
    RGB Multipliers (Polynomial Color Correction)
    Display Color Inversion (Inverse Gamma Correction)
    Hue/Saturation/Value/Contrast Manipulation (Picture Adjustment)

    Too confusing? Here's a video demonstration by @Andromjb:

    Sysfs paths/variables:
    /sys/devices/platform/kcal_ctrl.0/kcal - (0-256 0-256 0-256) - Controls R/G/B Multipliers
    /sys/devices/platform/kcal_ctrl.0/kcal_min - (0-256) - Controls minimum RGB Multiplier value
    /sys/devices/platform/kcal_ctrl.0/kcal_enable - (0-1) - Enables/Disables RGB Multiplier Control
    /sys/devices/platform/kcal_ctrl.0/kcal_invert - (0-1) - Enables/Disables Display Inversion Mode
    /sys/devices/platform/kcal_ctrl.0/kcal_sat - (224-383 or 128) - Controls saturation intensity - use 128 for grayscale mode
    /sys/devices/platform/kcal_ctrl.0/kcal_hue - (0-1536) - Controls display hue - may have issues with msm8x26 in the higher values
    /sys/devices/platform/kcal_ctrl.0/kcal_val - (128-383) - Controls display value
    /sys/devices/platform/kcal_ctrl.0/kcal_cont - (128-383) - Controls display contrast

    Link your favorite kernel developer back to this thread and ask them to add support!

    KCAL for MDP5
    https://github.com/savoca/kcal/commits/mdp5

    KCAL for MDP3 (Only supports RGB multipliers):
    https://github.com/savoca/kcal/commits/mdp3

    And finally, an app to control your display - available for free here:
    http://downloads.codefi.re/savoca/kcal

    Thank you to LG for the display inversion control and code reference, also thank you to @faux123 for insight/reference with MDP3 RGB multipliers and @eng.stk for testing on APQ8084
    26
    Looks great to me. I'll give it a whirl on Shamu. Thanks!
    18
    Sweet. I'll try it on HTC m8 and Nexus 6 this week.
    12
    To devs: New update keeps all KCAL code within one file, and touches absolutely zero lines of Qualcomm code. So if you're just now finding out about KCAL, you can just grab the source file on github, and add the Kconfig/Makefile entries and you're good to go. :good:

    https://github.com/savoca/kernel-msm/commit/6e5d7e7f669373d7879dbd61eca4c1df593aafa6
    11
    pa_v2 support added (APQ8084 - Nexus 6) thank you @eng.stk for testing and dealing with my endless requests :)

    Also, if you haven't yet, I recommend you move to PCC for RGB calibration, various Sony devices had issues with PGC/ARGC RGB multipliers.

    All necessary changes here: https://github.com/savoca/kernel-msm/commits/mdp5

    Shameless bugging of n6 devs: @franciscofranco @neobuddy89 @flar2