diff --git a/system/camerad/cameras/ife.h b/system/camerad/cameras/ife.h index 380a6ae1346ae2..70a448dd1fbd4b 100644 --- a/system/camerad/cameras/ife.h +++ b/system/camerad/cameras/ife.h @@ -34,7 +34,7 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector &patch }); dst += write_cont(dst, 0x40, { - 0x00000c04, // (1<<8) to enable vignetting correction + 0x00000c06, // (1<<8) to enable vignetting correction }); dst += write_cont(dst, 0x48, { @@ -67,7 +67,7 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector &patch // black level scale + offset dst += write_cont(dst, 0x6b0, { - (((uint32_t)(1 << s->bits_per_pixel) - 1) << 0xf) | (s->black_level << 0), + ((uint32_t)(1 << 11) << 0xf) | (s->black_level << 0), 0x0, 0x0, }); @@ -105,39 +105,11 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vectorlinearization_pts); + dst += write_cont(dst, 0x4f0, s->linearization_pts); + dst += write_cont(dst, 0x500, s->linearization_pts); + dst += write_cont(dst, 0x510, s->linearization_pts); // TODO: this is DMI64 in the dump, does that matter? dst += write_dmi(dst, &addr, 288, 0xc24, 9); patches.push_back(addr - (uint64_t)start); diff --git a/system/camerad/sensors/ar0231.cc b/system/camerad/sensors/ar0231.cc index 11e06de76ab589..a107a6e1b9e8a5 100644 --- a/system/camerad/sensors/ar0231.cc +++ b/system/camerad/sensors/ar0231.cc @@ -138,6 +138,21 @@ AR0231::AR0231() { ((rk * (fx-mp) * (gamma_k*mp+gamma_b) * (1+1/(rk*mp)) / (1-rk*(fx-mp))) + gamma_k*mp + gamma_b); gamma_lut_rgb.push_back((uint32_t)(fx*1023.0 + 0.5)); } + linearization_lut = { + 0x02000000, 0x02000000, 0x02000000, 0x02000000, + 0x020007ff, 0x020007ff, 0x020007ff, 0x020007ff, + 0x02000bff, 0x02000bff, 0x02000bff, 0x02000bff, + 0x020017ff, 0x020017ff, 0x020017ff, 0x020017ff, + 0x020006ff, 0x020006ff, 0x020006ff, 0x020006ff, + 0x02001bff, 0x02001bff, 0x02001bff, 0x02001bff, + 0x020023ff, 0x020023ff, 0x020023ff, 0x020023ff, + 0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff, + 0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff, + }; + for (int i = 0; i < 252; i++) { + linearization_lut.push_back(0x0); + } + linearization_pts = {0x07ff0bff, 0x17ff06ff, 0x1bff23ff, 0x3fff3fff}; } void AR0231::processRegisters(uint8_t *cur_buf, cereal::FrameData::Builder &framed) const { diff --git a/system/camerad/sensors/os04c10.cc b/system/camerad/sensors/os04c10.cc index 0ec891a4c0d5ab..08530989fe8d52 100644 --- a/system/camerad/sensors/os04c10.cc +++ b/system/camerad/sensors/os04c10.cc @@ -72,6 +72,21 @@ OS04C10::OS04C10() { float fx = i / 63.0; gamma_lut_rgb.push_back((uint32_t)(pow(fx, 0.7)*1023.0 + 0.5)); } + linearization_lut = { + 0x02000000, 0x02000000, 0x02000000, 0x02000000, + 0x020007ff, 0x020007ff, 0x020007ff, 0x020007ff, + 0x02000bff, 0x02000bff, 0x02000bff, 0x02000bff, + 0x020017ff, 0x020017ff, 0x020017ff, 0x020017ff, + 0x020006ff, 0x020006ff, 0x020006ff, 0x020006ff, + 0x02001bff, 0x02001bff, 0x02001bff, 0x02001bff, + 0x020023ff, 0x020023ff, 0x020023ff, 0x020023ff, + 0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff, + 0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff, + }; + for (int i = 0; i < 252; i++) { + linearization_lut.push_back(0x0); + } + linearization_pts = {0x07ff0bff, 0x17ff06ff, 0x1bff23ff, 0x3fff3fff}; } std::vector OS04C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const { diff --git a/system/camerad/sensors/ox03c10.cc b/system/camerad/sensors/ox03c10.cc index edfb47f43903a5..16ab0a65bc544d 100644 --- a/system/camerad/sensors/ox03c10.cc +++ b/system/camerad/sensors/ox03c10.cc @@ -64,7 +64,7 @@ OX03C10::OX03C10() { max_ev = exposure_time_max * dc_gain_factor * sensor_analog_gains[analog_gain_max_idx]; target_grey_factor = 0.01; - black_level = 64; + black_level = 0; color_correct_matrix = { 0x000000b6, 0x00000ff1, 0x00000fda, 0x00000fcc, 0x000000b9, 0x00000ffb, @@ -75,9 +75,21 @@ OX03C10::OX03C10() { fx = -0.507089*exp(-12.54124638*fx) + 0.9655*pow(fx, 0.5) - 0.472597*fx + 0.507089; gamma_lut_rgb.push_back((uint32_t)(fx*1023.0 + 0.5)); } - for (int i = 0; i < 288; i++) { - linearization_lut.push_back(0xff); + linearization_lut = { + 0x00200000, 0x00200000, 0x00200000, 0x00200000, + 0x00404080, 0x00404080, 0x00404080, 0x00404080, + 0x00804100, 0x00804100, 0x00804100, 0x00804100, + 0x006b8402, 0x006b8402, 0x006b8402, 0x006b8402, + 0x00b8c070, 0x00b8c070, 0x00b8c070, 0x00b8c070, + 0x06044804, 0x06044804, 0x06044804, 0x06044804, + 0x100ba015, 0x100ba015, 0x100ba015, 0x100ba015, + 0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff, + 0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff, + }; + for (int i = 0; i < 252; i++) { + linearization_lut.push_back(0x0); } + linearization_pts = {0x07ff0bff, 0x17ff06ff, 0x1bff23ff, 0x27ff3fff}; for (int i = 0; i < 884*2; i++) { vignetting_lut.push_back(0xff); } diff --git a/system/camerad/sensors/sensor.h b/system/camerad/sensors/sensor.h index 4fba4ff5941069..d94cd57c8dda8d 100644 --- a/system/camerad/sensors/sensor.h +++ b/system/camerad/sensors/sensor.h @@ -73,6 +73,7 @@ class SensorInfo { std::vector color_correct_matrix; // 3x3 std::vector gamma_lut_rgb; // gamma LUTs are length 64 * sizeof(uint32_t); same for r/g/b here std::vector linearization_lut; // length 288 + std::vector linearization_pts; // length 4 std::vector vignetting_lut; // 2x length 884 };