Compare commits
No commits in common. "7d7bad60d3c7cb226ed389ada48e3c3b87455712" and "712fc2f18b09b5205a282eaa3e23e3e1f115e12e" have entirely different histories.
7d7bad60d3
...
712fc2f18b
18
README.md
18
README.md
|
@ -102,7 +102,23 @@ The AE controls realays in the feedback provided by the Driver's camera sensor t
|
|||
and the custom DTSIs with the sensor parameters definitions.
|
||||
As the AE has interdependency with the digital gain. This gain it's and operation on the Driver, and follows this setup:
|
||||
|
||||
MT9M021 sensor datasheet:
|
||||
```bash
|
||||
/*
|
||||
* Digital gain equation:
|
||||
*
|
||||
* RANGE: 1x, 7.97x
|
||||
* STEPS: 1/32
|
||||
*
|
||||
* SCALE FACTOR = 3
|
||||
*
|
||||
* min_gain_val = 102
|
||||
* max_gain_val = 160
|
||||
* gain_factor = 3
|
||||
*
|
||||
* gain accepts mapping to range 32 - 53
|
||||
*/
|
||||
```
|
||||
MT9M021 sensor datasheet:
|
||||
|
||||
* <a href="https://files.niemo.de/aptina_pdfs/MT9M021-M031_Developer_Guide.pdf">MT9M021 Developer Guide</a>
|
||||
|
||||
|
|
|
@ -93,18 +93,18 @@ i2c8 = "/i2c@31e0000";
|
|||
csi_pixel_bit_depth = "12";
|
||||
mode_type = "bayer";
|
||||
pixel_phase = "rggb";
|
||||
readout_orientation = "0";
|
||||
readout_orientation = "0";
|
||||
line_length = "1650";
|
||||
inherent_gain = "1";
|
||||
pix_clk_hz = "74250000";
|
||||
|
||||
gain_factor = "3125";
|
||||
gain_factor = "3";
|
||||
framerate_factor = "1000000";
|
||||
exposure_factor = "1000000";
|
||||
min_gain_val = "100000"; /* 1x */
|
||||
max_gain_val = "796875"; /* 7.97x */
|
||||
min_gain_val = "102";
|
||||
max_gain_val = "160";
|
||||
step_gain_val = "1";
|
||||
default_gain = "100000"; /* 1x */
|
||||
default_gain = "102";
|
||||
min_hdr_ratio = "1";
|
||||
max_hdr_ratio = "1";
|
||||
|
||||
|
@ -132,18 +132,18 @@ i2c8 = "/i2c@31e0000";
|
|||
csi_pixel_bit_depth = "12";
|
||||
mode_type = "bayer";
|
||||
pixel_phase = "rggb";
|
||||
readout_orientation = "0";
|
||||
readout_orientation = "0";
|
||||
line_length = "1650";
|
||||
inherent_gain = "1";
|
||||
pix_clk_hz = "74250000";
|
||||
|
||||
gain_factor = "3125";
|
||||
gain_factor = "3";
|
||||
framerate_factor = "1000000";
|
||||
exposure_factor = "1000000";
|
||||
min_gain_val = "100000"; /* 1x */
|
||||
max_gain_val = "796875"; /* 7.97x */
|
||||
min_gain_val = "102";
|
||||
max_gain_val = "160";
|
||||
step_gain_val = "1";
|
||||
default_gain = "100000"; /* 1x */
|
||||
default_gain = "102";
|
||||
min_hdr_ratio = "1";
|
||||
max_hdr_ratio = "1";
|
||||
|
||||
|
@ -220,18 +220,18 @@ i2c8 = "/i2c@31e0000";
|
|||
csi_pixel_bit_depth = "12";
|
||||
mode_type = "bayer";
|
||||
pixel_phase = "rggb";
|
||||
readout_orientation = "0";
|
||||
readout_orientation = "0";
|
||||
line_length = "1650";
|
||||
inherent_gain = "1";
|
||||
pix_clk_hz = "74250000";
|
||||
|
||||
gain_factor = "3125";
|
||||
gain_factor = "3";
|
||||
framerate_factor = "1000000";
|
||||
exposure_factor = "1000000";
|
||||
min_gain_val = "100000"; /* 1x */
|
||||
max_gain_val = "796875"; /* 7.97x */
|
||||
min_gain_val = "102";
|
||||
max_gain_val = "160" ;
|
||||
step_gain_val = "1";
|
||||
default_gain = "100000"; /* 1x */
|
||||
default_gain = "102";
|
||||
min_hdr_ratio = "1";
|
||||
max_hdr_ratio = "1";
|
||||
|
||||
|
@ -259,18 +259,18 @@ i2c8 = "/i2c@31e0000";
|
|||
csi_pixel_bit_depth = "12";
|
||||
mode_type = "bayer";
|
||||
pixel_phase = "rggb";
|
||||
readout_orientation = "0";
|
||||
readout_orientation = "0";
|
||||
line_length = "1650";
|
||||
inherent_gain = "1";
|
||||
pix_clk_hz = "74250000";
|
||||
|
||||
gain_factor = "3125";
|
||||
gain_factor = "3";
|
||||
framerate_factor = "1000000";
|
||||
exposure_factor = "1000000";
|
||||
min_gain_val = "100000"; /* 1x */
|
||||
max_gain_val = "796875"; /* 7.97x */
|
||||
min_gain_val = "102";
|
||||
max_gain_val = "160";
|
||||
step_gain_val = "1";
|
||||
default_gain = "100000"; /* 1x */
|
||||
default_gain = "102";
|
||||
min_hdr_ratio = "1";
|
||||
max_hdr_ratio = "1";
|
||||
|
||||
|
|
|
@ -397,26 +397,49 @@ static int mt9m021_set_gain(struct tegracam_device *tc_dev, s64 val)
|
|||
struct camera_common_data *s_data = tc_dev->s_data;
|
||||
struct device *dev = tc_dev->dev;
|
||||
int err = 0;
|
||||
u16 gain_mul;
|
||||
u16 reg16 = 0;
|
||||
u64 gain = 0;
|
||||
|
||||
dev_dbg(dev, "Setting Gain to: %lld", val);
|
||||
|
||||
if (val >= MT9M021_GAIN_8X_FIXED) {
|
||||
gain_mul = MT9M021_GAIN_8X;
|
||||
} else if (val >= MT9M021_GAIN_4X_FIXED) {
|
||||
gain_mul = MT9M021_GAIN_4X;
|
||||
} else if (val >= MT9M021_GAIN_2X_FIXED) {
|
||||
gain_mul = MT9M021_GAIN_2X;
|
||||
} else {
|
||||
gain_mul = MT9M021_GAIN_1X;
|
||||
}
|
||||
|
||||
/*
|
||||
* Digital gain equation:
|
||||
*
|
||||
* RANGE: 1x, 7.97x
|
||||
* STEPS: 1/32
|
||||
*
|
||||
* gain accepts mapping from range 32 - 255
|
||||
*
|
||||
* SCALE FACTOR = 3
|
||||
*
|
||||
* min_gain_val = 96
|
||||
* max_gain_val = 765
|
||||
* min_gain_val = 102
|
||||
* max_gain_val = 160
|
||||
* gain_factor = 3
|
||||
*
|
||||
* gain accepts mapping to range 32 - 53
|
||||
*/
|
||||
gain = val / 3125;
|
||||
gain = val / 3;
|
||||
|
||||
/* Update analog gain multiplier */
|
||||
err = mt9m021_read_reg16(s_data, MT9M021_DIGITAL_TEST, ®16);
|
||||
if (err)
|
||||
goto exit;
|
||||
reg16 =
|
||||
(reg16 & ~MT9M021_ANALOG_GAIN_MASK) |
|
||||
((gain_mul << MT9M021_ANALOG_GAIN_SHIFT) &
|
||||
MT9M021_ANALOG_GAIN_MASK);
|
||||
err = mt9m021_write_reg16(s_data, MT9M021_DIGITAL_TEST, reg16);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Update global gain */
|
||||
err = mt9m021_write_reg16(s_data, MT9M021_GLOBAL_GAIN, gain);
|
||||
|
|
|
@ -5,7 +5,7 @@ initial_exposure_time=0
|
|||
|
||||
while true; do sleep 0.5;
|
||||
# Read center camera controls
|
||||
echo `v4l2-ctl -d /dev/video0 --get-ctrl=gain --get-ctrl=exposure` > controls
|
||||
echo `v4l2-ctl -d /dev/video1 --get-ctrl=gain --get-ctrl=exposure` > controls
|
||||
awk '{print $2}' controls > get_control
|
||||
actual_gain=`cat get_control`
|
||||
awk '{print $4}' controls > get_control
|
||||
|
@ -18,10 +18,10 @@ while true; do sleep 0.5;
|
|||
rm controls get_control
|
||||
# Set R/L camera controls manually
|
||||
if [ $actual_gain -ne $initial_gain ]; then
|
||||
v4l2-ctl -d /dev/video1 --set-ctrl=gain=$actual_gain
|
||||
v4l2-ctl -d /dev/video0 --set-ctrl=gain=$actual_gain
|
||||
fi
|
||||
if [ $actual_exposure_time -ne $initial_exposure_time ]; then
|
||||
v4l2-ctl -d /dev/video1 --set-ctrl=exposure=$actual_exposure_time
|
||||
v4l2-ctl -d /dev/video0 --set-ctrl=exposure=$actual_exposure_time
|
||||
fi
|
||||
# Define new initial value
|
||||
initial_gain=$actual_gain
|
||||
|
|
Loading…
Reference in New Issue