I have implemented the gain control as a INTEGER64 type - similar as it is in the reference imx185.c code. Note that, the min/max/default are no longer valid for int64 controls and your programmers are not aware of that.
So now I have this control:
gain (int64) : min=0 max=0 step=0 default=0 value=4194304 flags=slider
NOTE: the version of v4l2-ctl in Ubuntu is too old, and for int64 controls only the value shall be printed.
But it does not work.
Reading through the Sensor programming guide, I have found out that the camera framework can work either in dB scale or in linear ratio scale. This is controlled by the DTB settings:
use_decibel_gain = "true";
min_gain_val = "0"; /* dB */
max_gain_val = "27.046"; /* dB */
use_decibel_gain = "false";
min_gain_val = "1"; /* :1 */
max_gain_val = "22.505"; /* :1 */
In dB scale: the argus_camera will not change the gain at all. Probably the bug when the range starts with 0? But we really need a +0.0 dB unity gain!
In LINEAR: when running the argus_camera tool always the the maximal gain is applied (value found in DT), no matter what limits do we set with:
argus_camera --ispdigitalgainrange=1,1 --gainrange=1,5
The user interface show the proper range, but the call in kernel shows only the initial and then the maximal one:
[ 79.118028] [imx377:2] control[10100747:Gain] = 4194722 ~ 1.000099
[ 79.124224] [imx377:2] gain req:4194722 -> out:4194304 err:-418 idx:0 -> +0.000 dB ~ 1.000
[ 79.132564] [imx377:2] control[10100753:A gain] new VALUE is 0
[ 79.138410] [imx377:2] control[10100753:A gain] = 0
[ 79.380495] [imx377:2] control[10100747:Gain] = 94394885 ~ 22.505494
[ 79.386963] [imx377:2] gain req:94394885 -> out:94394885 err:0 idx:1957 -> +27.045 dB ~ 22.505
[ 79.395765] [imx377:2] control[10100753:A gain] new VALUE is 1957
[ 79.401996] [imx377:2] control[10100753:A gain] = 1957
This uses a helper function that translates the linear or dB gain request value into the sensor register setting (made through the ‘A gain’ custom control). I had to list all the 1958 settings in a lookup table which is searched for the minimal difference.
AE of course does not work at all now. With the old style INTEGER control, some functionality could be observed, but the system get into flickering by the gain being not the same scale as expected.