i.MX8QXP gamma tuning

Document created by PengFushi Employee on Feb 27, 2020Last modified by PengFushi Employee on Feb 27, 2020
Version 2Show Document
  • View in full screen mode

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

 

1.Introduce gamma

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 15.9.2.4.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

 

Reference:

a>https://www.nxp.com/webapp/Download?colCode=IMX8DQXPRM

b>https://www.nxp.com/webapp/Download?colCode=L4.14.98_2.2.0_MX8QXP&appType=license

c> https://source.codeaurora.org/external/imx/libdrm-imx/

d> https://en.wikipedia.org/wiki/Gamma_correction

3 people found this helpful

Outcomes