camerad: IFE register cleanup (#34550)

* start there

* lil more

* get camera num out of there

---------

Co-authored-by: Comma Device <device@comma.ai>
pull/34552/head
Adeeb Shihadeh 3 months ago committed by GitHub
parent 22591dc6f8
commit 1090af6e3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      system/camerad/cameras/hw.h
  2. 46
      system/camerad/cameras/ife.h
  3. 4
      system/camerad/cameras/spectra.cc
  4. 2
      system/camerad/cameras/spectra.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,
};

@ -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<uint32_t> &patches, int camera_num) {
int build_update(uint8_t *dst, const CameraConfig cam, const SensorInfo *s, std::vector<uint32_t> &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<uint32_t> &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<uint32_t> &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<uint32_t> &patch
}
int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches, int camera_num) {
int build_initial_config(uint8_t *dst, const CameraConfig cam, const SensorInfo *s, std::vector<uint32_t> &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::vector<uint32_t
// TODO: this is DMI64 in the dump, does that matter?
dst += write_dmi(dst, &addr, s->linearization_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::vector<uint32_t
0x03ff0000,
});
// TODO: remove this
// output size/scaling
dst += write_cont(dst, 0xa3c, {
0x00000003,
((s->frame_width - 1) << 16) | (s->frame_width - 1),

@ -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);
}
}

@ -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"

Loading…
Cancel
Save