This doc show how to use i.MX8QXP Display Controller GammaCor unit to tune gamma.
HW: i.MX8QXP MEK board, HDMI monitor
SW: i.MX Linux 4.14.98_2.2.0 BSP release, patch in this doc
The gamma, gamma correction, gamma encoding, gamma compression , these words all related one kind operation , see wiki page of it:
The device used for image capture/print/display follow this power-law.
For example the camera captured image , to view this image on display device as good as original captured image : gamma encoding when camera saved sensor data to image file, and gamma decoding when that image file display on your PC LCD monitor.
That is :
2. i.MX8QXP Display Controller Gamma Correction Unit
The Gamma Correction unit position is located between Frame Gen unit and TCon unit.
More detail see below contents from i.MX8QXP RM:
So GammaCor unit could be used as adjust display gamma , or brightness or contrast.
To used it, need follow the steps at RM 126.96.36.199.4.8.3.
Something need to note:
You need program 33 sample point value into the register, these sample point value range is from 0 to 1023. Note, first write is start sample point value , then the other is delta value: current sample point minus previous sample point value.
You can use GammaCor unit on any channel of R/G/B.
If you use normalized function f(x), the following formula should be used to
clut[i = 0..32] = round( f(i * 32 / 1023) * 1023)
3. i.MX8QXP Linux device driver patch and test code
Apply attached patch 8qxp_dpu_gammacor_4.14.98_2.2.0.diff on Linux kernel.
In the kernel patch, function dpu_gammacor_update, I choose not calculate delta value between each sample pint , let user space application calculate delta value and passed to kernel.
Apply 8qxp-dpu-gammacor-modetst.diff on libdrm-imx, to get test application which is based on modetest. Test app will read one greyscale image file 720P.rgb, put it under same folder of test application , calculate sample point value by pow function , and calling drmModeCrtcSetGamma to pass related value to kernel, next loop will change sample point value, and will see that greyscale image will changed on HDMI monitor.
After system boot up, run below cmd to check result of test application
systemctl stop weston
./gamma_show_rgba.out -P 29@32:1280x720@AB24