Skip to content

Commit

Permalink
12bit only (commaai#23953)
Browse files Browse the repository at this point in the history
Co-authored-by: Comma Device <device@comma.ai>
  • Loading branch information
geohot and Comma Device authored Mar 14, 2022
1 parent 5c3f3e4 commit a9b7f3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
13 changes: 6 additions & 7 deletions selfdrive/camerad/cameras/camera_qcom2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern ExitHandler do_exit;

const size_t FRAME_WIDTH = 1928;
const size_t FRAME_HEIGHT = 1208;
const size_t FRAME_STRIDE = 2416; // for 10 bit output
const size_t FRAME_STRIDE = 2896; // for 12 bit output. 1928 * 12 / 8 + 4 (alignment)

const int MIPI_SETTLE_CNT = 33; // Calculated by camera_freqs.py

Expand Down Expand Up @@ -471,10 +471,10 @@ void CameraState::config_isp(int io_mem_handle, int fence, int request_id, int b
.h_init = 0x0,
.v_init = 0x0,
};
io_cfg[0].format = CAM_FORMAT_MIPI_RAW_10; // CAM_FORMAT_UBWC_TP10 for YUV
io_cfg[0].format = CAM_FORMAT_MIPI_RAW_12; // CAM_FORMAT_UBWC_TP10 for YUV
io_cfg[0].color_space = CAM_COLOR_SPACE_BASE; // CAM_COLOR_SPACE_BT601_FULL for YUV
io_cfg[0].color_pattern = 0x5; // 0x0 for YUV
io_cfg[0].bpp = 0xa;
io_cfg[0].bpp = 0xc;
io_cfg[0].resource_type = CAM_ISP_IFE_OUT_RES_RDI_0; // CAM_ISP_IFE_OUT_RES_FULL for YUV
io_cfg[0].fence = fence;
io_cfg[0].direction = CAM_BUF_OUTPUT;
Expand Down Expand Up @@ -615,9 +615,8 @@ void CameraState::camera_open() {
.lane_cfg = 0x3210,

.vc = 0x0,
// .dt = 0x2C; //CSI_RAW12
.dt = 0x2B, //CSI_RAW10
.format = CAM_FORMAT_MIPI_RAW_10,
.dt = 0x2C, // CSI_RAW12
.format = CAM_FORMAT_MIPI_RAW_12,

.test_pattern = 0x2, // 0x3?
.usage_type = 0x0,
Expand All @@ -643,7 +642,7 @@ void CameraState::camera_open() {
.num_out_res = 0x1,
.data[0] = (struct cam_isp_out_port_info){
.res_type = CAM_ISP_IFE_OUT_RES_RDI_0,
.format = CAM_FORMAT_MIPI_RAW_10,
.format = CAM_FORMAT_MIPI_RAW_12,
.width = FRAME_WIDTH,
.height = FRAME_HEIGHT,
.comp_grp_id = 0x0, .split_point = 0x0, .secure_mode = 0x0,
Expand Down
12 changes: 6 additions & 6 deletions selfdrive/camerad/cameras/real_debayer.cl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ half3 color_correct(half3 rgb) {
}

half val_from_10(const uchar * source, int gx, int gy) {
// parse 10bit
int start = gy * FRAME_STRIDE + (5 * (gx / 4));
int offset = gx % 4;
uint major = (uint)source[start + offset] << 2;
uint minor = (source[start + 4] >> (2 * offset)) & 3;
half pv = (half)(major + minor);
// parse 12bit
int start = gy * FRAME_STRIDE + (3 * (gx / 2));
int offset = gx % 2;
uint major = (uint)source[start + offset] << 4;
uint minor = (source[start + 2] >> (4 * offset)) & 0xf;
half pv = (half)((major + minor)/4);

// normalize
pv = max(0.0h, pv - black_level);
Expand Down
12 changes: 6 additions & 6 deletions selfdrive/camerad/cameras/sensor2_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct i2c_random_wr_payload init_array_ar0231[] = {
{0x302C, 0x0001}, // VT_SYS_CLK_DIV
{0x302E, 0x0002}, // PRE_PLL_CLK_DIV
{0x3030, 0x0032}, // PLL_MULTIPLIER
{0x3036, 0x000A}, // OP_WORD_CLK_DIV
{0x3036, 0x000C}, // OP_WORD_CLK_DIV
{0x3038, 0x0001}, // OP_SYS_CLK_DIV

// FORMAT
Expand Down Expand Up @@ -46,11 +46,11 @@ struct i2c_random_wr_payload init_array_ar0231[] = {

// Readout Settings
{0x31AE, 0x0204}, // SERIAL_FORMAT, 4-lane MIPI
{0x31AC, 0x0C0A}, // DATA_FORMAT_BITS, 12 -> 10
{0x3342, 0x122B}, // MIPI_F1_PDT_EDT
{0x3346, 0x122B}, // MIPI_F2_PDT_EDT
{0x334A, 0x122B}, // MIPI_F3_PDT_EDT
{0x334E, 0x122B}, // MIPI_F4_PDT_EDT
{0x31AC, 0x0C0C}, // DATA_FORMAT_BITS, 12 -> 12
{0x3342, 0x122C}, // MIPI_F1_PDT_EDT
{0x3346, 0x122C}, // MIPI_F2_PDT_EDT
{0x334A, 0x122C}, // MIPI_F3_PDT_EDT
{0x334E, 0x122C}, // MIPI_F4_PDT_EDT
{0x3344, 0x0011}, // MIPI_F1_VDT_VC
{0x3348, 0x0111}, // MIPI_F2_VDT_VC
{0x334C, 0x0211}, // MIPI_F3_VDT_VC
Expand Down

0 comments on commit a9b7f3b

Please sign in to comment.