diff --git a/Jenkinsfile b/Jenkinsfile index 64b2f05758..5afffad48f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -232,7 +232,6 @@ node { ["test pandad spi", "pytest selfdrive/pandad/tests/test_pandad_spi.py"], ["test pandad", "pytest selfdrive/pandad/tests/test_pandad.py", ["panda/", "selfdrive/pandad/"]], ["test amp", "pytest system/hardware/tici/tests/test_amplifier.py"], - ["test hw", "pytest system/hardware/tici/tests/test_hardware.py"], ["test qcomgpsd", "pytest system/qcomgpsd/tests/test_qcomgpsd.py"], ]) }, diff --git a/selfdrive/pandad/tests/test_pandad.py b/selfdrive/pandad/tests/test_pandad.py index 467c7f04c9..213678193f 100644 --- a/selfdrive/pandad/tests/test_pandad.py +++ b/selfdrive/pandad/tests/test_pandad.py @@ -103,9 +103,8 @@ class TestPandad: # 5s for USB (due to enumeration) # - 0.2s pandad -> pandad # - plus some buffer - assert 0.1 < (sum(ts)/len(ts)) < (0.5 if self.spi else 5.0) print("startup times", ts, sum(ts) / len(ts)) - + assert 0.1 < (sum(ts)/len(ts)) < (0.7 if self.spi else 5.0) def test_protocol_version_check(self): if not self.spi: diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index 714de01ca2..35338419de 100644 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -53,7 +53,7 @@ PROCS = { "selfdrive.locationd.calibrationd": 2.0, "selfdrive.locationd.torqued": 5.0, "selfdrive.locationd.locationd": 25.0, - "selfdrive.ui.soundd": 3.38, + "selfdrive.ui.soundd": 3.0, "selfdrive.monitoring.dmonitoringd": 4.0, "./proclogd": 1.54, "system.logmessaged": 0.2, diff --git a/system/camerad/cameras/ife.h b/system/camerad/cameras/ife.h index 380a6ae134..70a448dd1f 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 11e06de76a..a107a6e1b9 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 0ec891a4c0..08530989fe 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 edfb47f439..16ab0a65bc 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 4fba4ff594..d94cd57c8d 100644 --- a/system/camerad/sensors/sensor.h +++ b/system/camerad/sensors/sensor.h @@ -73,6 +73,7 @@ public: 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 }; diff --git a/system/hardware/tici/tests/test_hardware.py b/system/hardware/tici/tests/test_hardware.py deleted file mode 100644 index 75f53e7cdb..0000000000 --- a/system/hardware/tici/tests/test_hardware.py +++ /dev/null @@ -1,26 +0,0 @@ -import pytest -import time -import numpy as np - -from openpilot.system.hardware.tici.hardware import Tici - -HARDWARE = Tici() - - -@pytest.mark.tici -class TestHardware: - - def test_power_save_time(self): - ts = {True: [], False: []} - for _ in range(5): - for on in (True, False): - st = time.monotonic() - HARDWARE.set_power_save(on) - ts[on].append(time.monotonic() - st) - - # disabling power save is the main time-critical one - assert 0.1 < np.mean(ts[False]) < 0.15 - assert max(ts[False]) < 0.2 - - assert 0.1 < np.mean(ts[True]) < 0.35 - assert max(ts[True]) < 0.4