Auto Exposure not reaching Minimum Gain Value in Jetson Nano

We have a custom board with imx335 and a Jetson Nano
Our sensor has 0dB to 72dB gain value, we have tested the camera in various lighting conditions with auto exposure enabled, we are getting a value of ~0.99dB not 0dB

Our requirement is to get the minimum gain of 0dB, even though we have given the minimum gain value as 0dB as mentioned in the camera device tree

                                        gain_factor = "100";
                                        min_gain_val = "0";     /*0dB*/
                                        max_gain_val = "7200";  /*72dB*/
                                        step_gain_val = "3";    /*0.3*/
                                        default_gain = "0";

We are able to set the value of gain to 0dB from v4l2 application when autoexposure is disabled in the gstreamer pipeline with command,

v4l2-ctl --set-ctrl=gain=0

Could you please let us known whether auto exposure algorithm is limiting the value of gain before reaching its minimum gain value as mentioned in the camera device tree, otherwise give some inputs to solve the issue?
Any help would be appreciated

hello krishnaprasad.k,

may I know what’s the real use-case to configure gain as 0dB?
since you’ve AE free running, is the environment bright enough for the algorithm to configure the gain value as low as possible?

Hi @JerryChang

may I know what’s the real use-case to configure gain as 0dB?
since you’ve AE free running, is the environment bright enough for the algorithm to configure the gain value as low as possible?

We have tested our camera with AE enabled and camera facing a bright light source. The minimum gain value we are achieving is ~0.9dB and after that point, exposure time is starting to decrease. Our usage is purely outdoor environment and higher gain is not needed in most conditions. Can you please help to debug this?

One more point to be added @JerryChang
Actually, we are developing the camera driver and the tuning is done by one of the preferred partners of Nvidia, during conformance test they are facing issues with camera driver, so they have shared the error log, we want to solve that error then only they can further proceed. We can’t figure out what is the root cause of the problem is by checking the logs they shared.
Can you support us on this issue if we share the error logs in here?

hello krishnaprasad.k,

conformance test should be passed to ensure camera driver sanity.
so… what’s the failure looks like?

@JerryChang Thanks for the reply

conformance test should be passed to ensure camera driver sanity.
so… what’s the failure looks like?

We have shared the summary of all Error logs from the conformance test

Accumulated ERROR messages from test run:
2021-12-10 14:49:37.493442         gain: ERROR: ConformanceGainTest::runTest: SensorGains value of 1.0000 is not correct in the raw header Diff should be less than 10.0000 percent. Applied value was 0.0000
2021-12-10 14:49:51.895396         makernote: ERROR: makernote_test_Gn_and_ET: Gain from 1st capture is not equal/close to input of 6.0, with a tolerance of +/-6.300000000000001. Actual Gain is 43.86
2021-12-10 14:49:51.895503         makernote: ERROR: makernote_test_Gn_and_ET: Gain from 2nd capture is not equal/close to input of 8.0, with a tolerance of +/-6.300000000000001. Actual Gain is 43.626

As this is critical for us could you please give some inputs from the above logs to sort out the issue?, if you need the full logs from the conformance test we can share here the same too.

@JerryChang Any update on this?

hello krishnaprasad.k,

please refer to developer guide for Device Properties section. here’s formula for gain, for example, dB = 20 × log(analog gain).
could you please add some debug prints to examine the analog gain sensor has applied is 1.0?

@JerryChang Thanks for the input

could you please add some debug prints to examine the analog gain sensor has applied is 1.0

We have set use_decibel_gain_property to default(false) in our camera device tree, camera debug logs and camera driver logs are shared below,

Camera debug logs -
debug_log_argus_without_use_decibel_gain_property.log (7.6 MB)

Camera driver logs 
[  332.567519] imx335 6-001a: imx335_set_gain: gain reg = 3, val 99
[  332.597704] imx335 6-001a: imx335_set_gain: gain reg = 3, val 99

And 2nd one
use_decibel_gain_property to true in the camera device tree
Camera debug logs -
debug_argus_output_with_use_decibal_gain_property.log (15.9 MB)

Camera driver logs 
[  311.042045] imx335 6-001a: imx335_set_gain: gain reg = 0, val 0
[  335.214505] imx335 6-001a: imx335_set_gain: gain reg = 0, val 0

Note : These tests are conducted in brighter conditions

Could you please support us to solve the conformance test issue by looking into these logs shared with changes in gain properties of camera device tree as this is very critical to us @JerryChang?

Can you specify which camera framework do we need to give db scale or linear ration scale in camera device tree and why?

@JerryChang Any update on this?

hello krishnaprasad.k,

TBH, we don’t have such 0dB camera sensor for validation.
I’ve already put this into internal discussion, it may take some times to have conclusions.

@JerryChang Thanks for the reply

TBH, we don’t have such 0dB camera sensor for validation.
I’ve already put this into internal discussion, it may take some times to have conclusions.

Noted

One more point @JerryChang
By looking into the conformance test log that we have shared earlier. Can you confirm the issue is actually the analog gain sensor value is not set to 1.0 or something else?

according to this error log.
SensorGains value of 1.0000: this is shown gain value returns the sensor gain value from the raw file metadata.
Applied value was 0.0000: this is shown the apply value, which looks correct as your minimum gain.

besides,
there’s a similar problem can be observed with the makernote test,
makernote: ERROR: makernote_test_Gn_and_ET: Gain from 1st capture is not equal/close to input of 6.0, with a tolerance of +/-6.300000000000001. Actual Gain is 43.86
where the actual gain value (43.86) does not match the input value (6.0).

as you’ve examine camera driver logs to check it’s actually configure 0-gain.
[ 311.042045] imx335 6-001a: imx335_set_gain: gain reg = 0, val 0
[ 335.214505] imx335 6-001a: imx335_set_gain: gain reg = 0, val 0

could you please double check the gain calculation for your IMX335 sensor driver?
otherwise,
this is more like an internal camera software bug with 0dB camera sensor. let me arrange resources for investigation.
in the meanwhile, could you please avoid this issue by setting min_gain_val in device tree as 1dB as temporary solution?

@JerryChang Thanks for the input

as you’ve examine camera driver logs to check it’s actually configure 0-gain.
[ 311.042045] imx335 6-001a: imx335_set_gain: gain reg = 0, val 0
[ 335.214505] imx335 6-001a: imx335_set_gain: gain reg = 0, val 0

After setting the use_decibel_gain_property to true in the camera device tree, then only the gain val becomes 0dB also conformance test is not conducted on this image as we have no clear idea whether the real issue is sensor gain value not set to 0dB. Can you confirm if we set use_decibel_gain_property set to true in camera device tree will solve the issue when conformance test is conducted,
Can you specify what is the need of use_decibel_gain_property in camera device tree?

could you please double check the gain calculation for your IMX335 sensor driver?

As we have given sensor gain calculation as per imx335 datasheet, as we have given

                            gain_factor = "100";
                            min_gain_val = "0";     /*0dB*/
                            max_gain_val = "7200";  /*72dB*/
                            step_gain_val = "3";    /*0.3*/
                            default_gain = "0";

and in camera driver gain control

        gain = val / 30;
         dev_dbg(dev, "%s: gain reg %d, val %lld\n",  __func__, gain, val);

We have scaled the dB value of gain as per imx335 datasheet.

in the meanwhile, could you please avoid this issue by setting min_gain_val in device tree as 1dB as temporary solution?

Can you clarify a bit more why we need to give min_gain_val as 1dB, as this limit the gain value from not reaching 0db also will it solve the conformance test issue?

Expecting a reply from @JerryChang for these queries as this is very critical to us

hello krishnaprasad.k,

since this is related to conformance test, which isn’t a public testing tool.
may I also know the sensor vendor you’ve approaching to. is it one of the Jetson Camera Partners? if yes, please ask them to file bug ticket to track this issue internally.

let me have double confirmation, did you meant you could pass conformance test by setting use_decibel_gain = "true";?

FYI, when you setting use_decibel_gain = "true";, it’ll convert Gain to unit of dB (decibel) before passing to kernel driver.
and… in the low-level side, 0 dB = 1.0f analog gain.

Hi @JerryChang

let me have double confirmation, did you meant you could pass conformance test by setting use_decibel_gain = "true";?

Correct, minimum gain value is reaching 0dB by doing so
But we could not achieve the maximum gain value of 72dB till now as we have mentioned in the camera device tree as well
Note :Only sanity test is success by enabling the dB scale in camera device tree

On more point to be added @JerryChang
We are facing yet another issue in conformance test as gain linearity test is failed, we have observed that after 48dB sensor response is not linear.
Shared the summary of error log from the conformance test

INFO: =================================================================
Accumulated ERROR messages from test run:
2021-12-10 15:24:34.939345         linearity: ERROR: Gain Linearity Test failed.
2021-12-10 15:25:58.352147         linearity: ERROR: Linearity Test [GAIN] in range of [1.000000 ~ 3981.070800] : FAILED

As per our sensor vendor, they said analog gain 30dBrange the sensor response shows like linear and in digital gain range in the sensor response shows like exponent.
In imx335 as per datasheet,
0 dB to 30dB : Analog Gain 30dB
30.3 dB to 72dB : Analog Gain 30dB + Digital Gain 0.3 to 42dB

As we don’t see any option to mention analog and digital gain in dB scale separately in the camera device tree
Since this is critical for us, can you please help us how to solve the sensor gain linearity issue?

it’s the test for checking the linear response of sensor exposure and gain.
you may try using --segment commands to limit the gain range for testing.

anyways,
as mentioned in comment #16 please contact with sensor vendor to check conformance test issues internally.

@JerryChang Thanks for the reply

it’s the test for checking the linear response of sensor exposure and gain.
you may try using --segment commands to limit the gain range for testing.

Will the tool in which conformance test is conducted support --segment commands, if yes these commands can be used outside the tool also?
So we have to limit the gain range using --segment commands in the tool in which conformance test is conducted, in order to pass the sensor gain linearity test is that what you are trying to say? But it may look like a temporary fix only, right

as mentioned in comment #16 please contact with sensor vendor to check conformance test issues internally.
as mentioned in comment #16 please contact with sensor vendor to check conformance test issues internally.

As per your suggestions, our tuning partner has raised a NvBug with Nvidia, and they said it will take time to get a response from Nvidia.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.