diff --git a/system/camerad/cameras/tici.h b/system/camerad/cameras/hw.h similarity index 92% rename from system/camerad/cameras/tici.h rename to system/camerad/cameras/hw.h index d0b2aece6d..f9ebc07052 100644 --- a/system/camerad/cameras/tici.h +++ b/system/camerad/cameras/hw.h @@ -16,6 +16,7 @@ struct CameraConfig { cereal::FrameData::Builder (cereal::Event::Builder::*init_camera_state)(); bool enabled; uint32_t phy; + bool vignetting_correction; }; // NOTE: to be able to disable road and wide road, we still have to configure the sensor over i2c @@ -28,6 +29,7 @@ const CameraConfig WIDE_ROAD_CAMERA_CONFIG = { .init_camera_state = &cereal::Event::Builder::initWideRoadCameraState, .enabled = !getenv("DISABLE_WIDE_ROAD"), .phy = CAM_ISP_IFE_IN_RES_PHY_0, + .vignetting_correction = false, }; const CameraConfig ROAD_CAMERA_CONFIG = { @@ -38,6 +40,7 @@ const CameraConfig ROAD_CAMERA_CONFIG = { .init_camera_state = &cereal::Event::Builder::initRoadCameraState, .enabled = !getenv("DISABLE_ROAD"), .phy = CAM_ISP_IFE_IN_RES_PHY_1, + .vignetting_correction = true, }; const CameraConfig DRIVER_CAMERA_CONFIG = { @@ -48,4 +51,5 @@ const CameraConfig DRIVER_CAMERA_CONFIG = { .init_camera_state = &cereal::Event::Builder::initDriverCameraState, .enabled = !getenv("DISABLE_DRIVER"), .phy = CAM_ISP_IFE_IN_RES_PHY_2, + .vignetting_correction = false, }; diff --git a/system/camerad/cameras/ife.h b/system/camerad/cameras/ife.h index a0ffcfa1b5..5dd1efa479 100644 --- a/system/camerad/cameras/ife.h +++ b/system/camerad/cameras/ife.h @@ -2,13 +2,14 @@ #include "cdm.h" -#include "system/camerad/cameras/tici.h" +#include "system/camerad/cameras/hw.h" #include "system/camerad/sensors/sensor.h" -int build_update(uint8_t *dst, const SensorInfo *s, std::vector &patches, int camera_num) { +int build_update(uint8_t *dst, const CameraConfig cam, const SensorInfo *s, std::vector &patches) { uint8_t *start = dst; + // init sequence dst += write_random(dst, { 0x2c, 0xffffffff, 0x30, 0xffffffff, @@ -17,6 +18,7 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector &patch 0x3c, 0xffffffff, }); + // demux cfg dst += write_cont(dst, 0x560, { 0x00000001, 0x04440444, @@ -35,38 +37,31 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector &patch 0x00000000, }); + // module config/enables (e.g. enable debayer, white balance, etc.) dst += write_cont(dst, 0x40, { - 0x00000c06 | ((uint32_t)(camera_num == 1) << 8), + 0x00000c06 | ((uint32_t)(cam.vignetting_correction) << 8), + }); + dst += write_cont(dst, 0x44, { + 0x00000000, }); - dst += write_cont(dst, 0x48, { (1 << 3) | (1 << 1), }); - dst += write_cont(dst, 0x4c, { 0x00000019, }); + dst += write_cont(dst, 0xf00, { + 0x00000000, + }); + // cropping dst += write_cont(dst, 0xe0c, { 0x00000e00, }); - dst += write_cont(dst, 0xe2c, { 0x00000e00, }); - dst += write_cont(dst, 0x44, { - 0x00000000, - }); - - dst += write_cont(dst, 0xaac, { - 0x00000000, - }); - - dst += write_cont(dst, 0xf00, { - 0x00000000, - }); - // black level scale + offset dst += write_cont(dst, 0x6b0, { ((uint32_t)(1 << 11) << 0xf) | (s->black_level << (14 - s->bits_per_pixel)), @@ -78,11 +73,11 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector &patch } -int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector &patches, int camera_num) { +int build_initial_config(uint8_t *dst, const CameraConfig cam, const SensorInfo *s, std::vector &patches) { uint8_t *start = dst; // start with the every frame config - dst += build_update(dst, s, patches, camera_num); + dst += build_update(dst, cam, s, patches); uint64_t addr; @@ -115,15 +110,6 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vectorlinearization_lut.size()*sizeof(uint32_t), 0xc24, 9); patches.push_back(addr - (uint64_t)start); - /* TODO - cdm_dmi_cmd_t 248 - .length = 287 - .reserved = 33 - .cmd = 11 - .addr = 0 - .DMIAddr = 3108 - .DMISel = 9 - */ // vignetting correction dst += write_cont(dst, 0x6bc, { @@ -180,7 +166,7 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vectorframe_width - 1) << 16) | (s->frame_width - 1), diff --git a/system/camerad/cameras/spectra.cc b/system/camerad/cameras/spectra.cc index 2b3767c105..16acabce00 100644 --- a/system/camerad/cameras/spectra.cc +++ b/system/camerad/cameras/spectra.cc @@ -715,9 +715,9 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) { bool is_raw = output_type != ISP_IFE_PROCESSED; if (!is_raw) { if (init) { - buf_desc[0].length = build_initial_config((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches, cc.camera_num); + buf_desc[0].length = build_initial_config((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, cc, sensor.get(), patches); } else { - buf_desc[0].length = build_update((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches, cc.camera_num); + buf_desc[0].length = build_update((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, cc, sensor.get(), patches); } } diff --git a/system/camerad/cameras/spectra.h b/system/camerad/cameras/spectra.h index 7759f60798..fd739a160c 100644 --- a/system/camerad/cameras/spectra.h +++ b/system/camerad/cameras/spectra.h @@ -9,7 +9,7 @@ #include "media/cam_req_mgr.h" #include "common/util.h" -#include "system/camerad/cameras/tici.h" +#include "system/camerad/cameras/hw.h" #include "system/camerad/cameras/camera_common.h" #include "system/camerad/sensors/sensor.h"