Hi,
I am using OS08a20 as the example for porting a new sensor.
For exposure gain, sensor usually has min/max analog and digital gain. This is set in the vvcam_mode_info_s.ae_info.
My question is when ISP is calling set_gain(sensor, total_gain), how do I convert total_gain to sensor's analog and digital gain?
I also check OV2755 and IMX219 VVCAM as examples, but they all have different calculation on converting total gain to analog and digital gain.
attached a snippet of the vvcam
Hello,
The digital gain is realized by ISP (image signal processing), not directly adjusting the built-in register of the chip. Under normal circumstances, the default digital gain is close to 1.0, unless there are the following three situations.
Regards
Thanks for the clarification. I am still a little confused about the gain value.
When I look at the set_gain(...) which is called by ISP. It seems this function needs to convert "gain" to sensor's analog and digital gain.
But what is the equation or guideline for this conversion?
I already trace the function call, it seems the "gain" pass-in parameter is rather large and it is not floating point.
Hi Jimmy,
I must admit, that in my case, I do not allow the ISP to set the gain because I am not using AEC functionality.
Nevertheless I will tell you what I know.
The *_set_gain() function you are showing is controlled by either the AEC (auto exposure control) or the manual exposure control of the ISP. This is done via ISP's VVSENSORIOC_S_GAIN IOCTL. According to the "ISP tuning Tool User Guide" (ISPTTUG.pdf) which I highly recommend to read the max value is 32.0:
This means the gain range is between 0 and 32. This gain is to be mapped to your sensor gain. Your sensor might have analog and digital gain or both depending on the sensor. Each sensor is different.
I would recommend to e.g only use analog gain. You are not obliged to set both analog and digital gain.
Also your sensor gain range is sensor dependant. It may be from 0 to 1000 for example.
This means the formula to map ISP gain will map (0 to 32) range to (0 to 1000).
This is why the formulas are different from sensor to sensor.
If the gain is too high, the AEC algorithm will go ahead and set lower gain, etc.
Also the sensors register are mostly 16bit and spread over two registers. Therefore you see code like this:
ret |= os08a20_write_reg(sensor, 0x3508, (again >>
ret |= os08a20_write_reg(sensor, 0x3509, again & 0xff);
I hope this is useful.