"Gain Control class inconsistent" and "Gain" control

Hello Nvidia,

nvcamera-daemon seemed to have problems with my 'Gain" implementation. It issued this error message : “Gain Control class inconsistent”. I now have changed it to use TEGRA_CAMERA_CID_GAIN instead of V4L2_CID_GAIN, added use_decibel_gain = “true”; to my sensor DT, but now nvcamera-daemon sets a not default value for gain at startup, and never recover from that : images stay white.

I have seen in the docs to description of TEGRA_CAMERA_CID_GAIN :

use_decibel_gain

Use this option for sensors that use decibels to represent the analog gain.
When set to true, the analog gain value received by the driver is expressed
in decibels (dB), based on the following conversion in the user mode library:
dB = 20 * log(Analog Gain)
TEGRA_CAMERA_CID_GAIN

32 Bit (deprecated)

Specifies the gain values from the user mode library. It uses 24.8 format (24 Bit integer, 8 Bit fraction) as default.
To change this format, adjust the min/max gain range in the driver.
Use the minimum gain value to determine how many bits of a fraction to use.

64 Bit

Specifies the gain values from the user mode library.
It uses 42.22 format (42 Bit integer, 22 Bit fraction). *
See imx185_set_gain function in imx185.c file

My sensor uses tenth of dB as gain unit and offers gain from 0 x 0,1 dB to 480 x 0,1 dB.
Which values must I expect to receive for 0 dB and 48 dB ?

hello phdm,

please notice that if you enable use_decibel_gain,
you should specify the gain range as dBs in the sensor device tree.

Which values must I expect to receive for 0 dB and 48 dB ?
according to the formula, you could expect the Analog Gain is 1 to result 0-dB, and 251 for 48-dB

please also have a look into imx185_set_gain() functions.
you should pass the analog gain down to sensor register by the formula.
thanks

Sorry for the bad wording of my question.

At the moment I don’t really want to control the gain myself, but only do the right thing when nvcamerasrc or nvcamera-daemon tries to set it. How must I decode the value given by nvcamera ?

Do I need to use TEGRA_CAMERA_CID_GAIN, or V4L2_CID_GAIN ?
How will the desired gain value in decibel be coded by nvcamera ?

hello phdm,

the user-space just passing the gain values down to kernel driver, given the use_decibel_gain property to let the camera driver know what’s the corresponding setting should write into the register.
for the CID controls, please use TEGRA_CAMERA_CID_GAIN, you should also refer to our reference camera driver to have implementation.
thanks