Compare commits
4 Commits
712fc2f18b
...
7d7bad60d3
Author | SHA1 | Date |
---|---|---|
dchvs | 7d7bad60d3 | |
dchvs | 71bc9b31dd | |
dchvs | 6d982b1ebe | |
dchvs | bd9969166a |
16
README.md
16
README.md
|
@ -102,22 +102,6 @@ The AE controls realays in the feedback provided by the Driver's camera sensor t
|
||||||
and the custom DTSIs with the sensor parameters definitions.
|
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:
|
As the AE has interdependency with the digital gain. This gain it's and operation on the Driver, and follows this setup:
|
||||||
|
|
||||||
```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:
|
MT9M021 sensor datasheet:
|
||||||
|
|
||||||
* <a href="https://files.niemo.de/aptina_pdfs/MT9M021-M031_Developer_Guide.pdf">MT9M021 Developer Guide</a>
|
* <a href="https://files.niemo.de/aptina_pdfs/MT9M021-M031_Developer_Guide.pdf">MT9M021 Developer Guide</a>
|
||||||
|
|
|
@ -98,13 +98,13 @@ i2c8 = "/i2c@31e0000";
|
||||||
inherent_gain = "1";
|
inherent_gain = "1";
|
||||||
pix_clk_hz = "74250000";
|
pix_clk_hz = "74250000";
|
||||||
|
|
||||||
gain_factor = "3";
|
gain_factor = "3125";
|
||||||
framerate_factor = "1000000";
|
framerate_factor = "1000000";
|
||||||
exposure_factor = "1000000";
|
exposure_factor = "1000000";
|
||||||
min_gain_val = "102";
|
min_gain_val = "100000"; /* 1x */
|
||||||
max_gain_val = "160";
|
max_gain_val = "796875"; /* 7.97x */
|
||||||
step_gain_val = "1";
|
step_gain_val = "1";
|
||||||
default_gain = "102";
|
default_gain = "100000"; /* 1x */
|
||||||
min_hdr_ratio = "1";
|
min_hdr_ratio = "1";
|
||||||
max_hdr_ratio = "1";
|
max_hdr_ratio = "1";
|
||||||
|
|
||||||
|
@ -137,13 +137,13 @@ i2c8 = "/i2c@31e0000";
|
||||||
inherent_gain = "1";
|
inherent_gain = "1";
|
||||||
pix_clk_hz = "74250000";
|
pix_clk_hz = "74250000";
|
||||||
|
|
||||||
gain_factor = "3";
|
gain_factor = "3125";
|
||||||
framerate_factor = "1000000";
|
framerate_factor = "1000000";
|
||||||
exposure_factor = "1000000";
|
exposure_factor = "1000000";
|
||||||
min_gain_val = "102";
|
min_gain_val = "100000"; /* 1x */
|
||||||
max_gain_val = "160";
|
max_gain_val = "796875"; /* 7.97x */
|
||||||
step_gain_val = "1";
|
step_gain_val = "1";
|
||||||
default_gain = "102";
|
default_gain = "100000"; /* 1x */
|
||||||
min_hdr_ratio = "1";
|
min_hdr_ratio = "1";
|
||||||
max_hdr_ratio = "1";
|
max_hdr_ratio = "1";
|
||||||
|
|
||||||
|
@ -225,13 +225,13 @@ i2c8 = "/i2c@31e0000";
|
||||||
inherent_gain = "1";
|
inherent_gain = "1";
|
||||||
pix_clk_hz = "74250000";
|
pix_clk_hz = "74250000";
|
||||||
|
|
||||||
gain_factor = "3";
|
gain_factor = "3125";
|
||||||
framerate_factor = "1000000";
|
framerate_factor = "1000000";
|
||||||
exposure_factor = "1000000";
|
exposure_factor = "1000000";
|
||||||
min_gain_val = "102";
|
min_gain_val = "100000"; /* 1x */
|
||||||
max_gain_val = "160" ;
|
max_gain_val = "796875"; /* 7.97x */
|
||||||
step_gain_val = "1";
|
step_gain_val = "1";
|
||||||
default_gain = "102";
|
default_gain = "100000"; /* 1x */
|
||||||
min_hdr_ratio = "1";
|
min_hdr_ratio = "1";
|
||||||
max_hdr_ratio = "1";
|
max_hdr_ratio = "1";
|
||||||
|
|
||||||
|
@ -264,13 +264,13 @@ i2c8 = "/i2c@31e0000";
|
||||||
inherent_gain = "1";
|
inherent_gain = "1";
|
||||||
pix_clk_hz = "74250000";
|
pix_clk_hz = "74250000";
|
||||||
|
|
||||||
gain_factor = "3";
|
gain_factor = "3125";
|
||||||
framerate_factor = "1000000";
|
framerate_factor = "1000000";
|
||||||
exposure_factor = "1000000";
|
exposure_factor = "1000000";
|
||||||
min_gain_val = "102";
|
min_gain_val = "100000"; /* 1x */
|
||||||
max_gain_val = "160";
|
max_gain_val = "796875"; /* 7.97x */
|
||||||
step_gain_val = "1";
|
step_gain_val = "1";
|
||||||
default_gain = "102";
|
default_gain = "100000"; /* 1x */
|
||||||
min_hdr_ratio = "1";
|
min_hdr_ratio = "1";
|
||||||
max_hdr_ratio = "1";
|
max_hdr_ratio = "1";
|
||||||
|
|
||||||
|
|
|
@ -397,49 +397,26 @@ static int mt9m021_set_gain(struct tegracam_device *tc_dev, s64 val)
|
||||||
struct camera_common_data *s_data = tc_dev->s_data;
|
struct camera_common_data *s_data = tc_dev->s_data;
|
||||||
struct device *dev = tc_dev->dev;
|
struct device *dev = tc_dev->dev;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
u16 gain_mul;
|
|
||||||
u16 reg16 = 0;
|
|
||||||
u64 gain = 0;
|
u64 gain = 0;
|
||||||
|
|
||||||
dev_dbg(dev, "Setting Gain to: %lld", val);
|
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:
|
* Digital gain equation:
|
||||||
*
|
*
|
||||||
* RANGE: 1x, 7.97x
|
* RANGE: 1x, 7.97x
|
||||||
* STEPS: 1/32
|
* STEPS: 1/32
|
||||||
*
|
*
|
||||||
|
* gain accepts mapping from range 32 - 255
|
||||||
|
*
|
||||||
* SCALE FACTOR = 3
|
* SCALE FACTOR = 3
|
||||||
*
|
*
|
||||||
* min_gain_val = 102
|
* min_gain_val = 96
|
||||||
* max_gain_val = 160
|
* max_gain_val = 765
|
||||||
* gain_factor = 3
|
* gain_factor = 3
|
||||||
*
|
*
|
||||||
* gain accepts mapping to range 32 - 53
|
|
||||||
*/
|
*/
|
||||||
gain = val / 3;
|
gain = val / 3125;
|
||||||
|
|
||||||
/* 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 */
|
/* Update global gain */
|
||||||
err = mt9m021_write_reg16(s_data, MT9M021_GLOBAL_GAIN, 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;
|
while true; do sleep 0.5;
|
||||||
# Read center camera controls
|
# Read center camera controls
|
||||||
echo `v4l2-ctl -d /dev/video1 --get-ctrl=gain --get-ctrl=exposure` > controls
|
echo `v4l2-ctl -d /dev/video0 --get-ctrl=gain --get-ctrl=exposure` > controls
|
||||||
awk '{print $2}' controls > get_control
|
awk '{print $2}' controls > get_control
|
||||||
actual_gain=`cat get_control`
|
actual_gain=`cat get_control`
|
||||||
awk '{print $4}' controls > get_control
|
awk '{print $4}' controls > get_control
|
||||||
|
@ -18,10 +18,10 @@ while true; do sleep 0.5;
|
||||||
rm controls get_control
|
rm controls get_control
|
||||||
# Set R/L camera controls manually
|
# Set R/L camera controls manually
|
||||||
if [ $actual_gain -ne $initial_gain ]; then
|
if [ $actual_gain -ne $initial_gain ]; then
|
||||||
v4l2-ctl -d /dev/video0 --set-ctrl=gain=$actual_gain
|
v4l2-ctl -d /dev/video1 --set-ctrl=gain=$actual_gain
|
||||||
fi
|
fi
|
||||||
if [ $actual_exposure_time -ne $initial_exposure_time ]; then
|
if [ $actual_exposure_time -ne $initial_exposure_time ]; then
|
||||||
v4l2-ctl -d /dev/video0 --set-ctrl=exposure=$actual_exposure_time
|
v4l2-ctl -d /dev/video1 --set-ctrl=exposure=$actual_exposure_time
|
||||||
fi
|
fi
|
||||||
# Define new initial value
|
# Define new initial value
|
||||||
initial_gain=$actual_gain
|
initial_gain=$actual_gain
|
||||||
|
|
Loading…
Reference in New Issue