Skip to content

Commit

Permalink
fill and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ZwX1616 committed Oct 22, 2024
1 parent 9c2296f commit b586e27
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 68 deletions.
59 changes: 0 additions & 59 deletions system/camerad/cameras/ife.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,6 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t

dst += write_cont(dst, 0x760, s->color_correct_matrix);

dst += write_cont(dst, 0x794, {
0x00000000,
});
/* TODO
cdm_dmi_cmd_t 568
.length = 511
.reserved = 33
.cmd = 11
.addr = 0
.DMIAddr = 3108
.DMISel = 24
*/

// gamma
dst += write_cont(dst, 0x798, {
0x00000000,
Expand Down Expand Up @@ -498,52 +485,6 @@ int build_first_update(uint8_t *dst) {
0x08000066,
});

dst += write_cont(dst, 0x794, {
0x00000001,
});
/* TODO
cdm_dmi_cmd_t 432
.length = 511
.reserved = 33
.cmd = 11
.addr = 832
.DMIAddr = 3108
.DMISel = 25
*/

/*
dst += write_cont(dst, 0x798, {
0x00000007,
});
*/
/* TODO
cdm_dmi_cmd_t 444
.length = 255
.reserved = 33
.cmd = 10
.addr = 5344
.DMIAddr = 3108
.DMISel = 27
*/
/* TODO
cdm_dmi_cmd_t 444
.length = 255
.reserved = 33
.cmd = 10
.addr = 5344
.DMIAddr = 3108
.DMISel = 29
*/
/* TODO
cdm_dmi_cmd_t 444
.length = 255
.reserved = 33
.cmd = 10
.addr = 5344
.DMIAddr = 3108
.DMISel = 31
*/

dst += write_cont(dst, 0xd84, {
0x000004b7,
0x00000787,
Expand Down
6 changes: 3 additions & 3 deletions system/camerad/cameras/spectra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,9 @@ void SpectraCamera::configISP() {
ife_dmi.init(m, 64*sizeof(uint32_t), 0x20,
CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE,
m->device_iommu, m->cdm_iommu, 3); // 3 for RGB
memcpy(ife_dmi.ptr + ife_dmi.size*0, sensor->gamma_lut_r.data(), ife_dmi.size);
memcpy(ife_dmi.ptr + ife_dmi.size*1, sensor->gamma_lut_g.data(), ife_dmi.size);
memcpy(ife_dmi.ptr + ife_dmi.size*2, sensor->gamma_lut_b.data(), ife_dmi.size);
for (int i = 0; i < 3; i++) {
memcpy(ife_dmi.ptr + ife_dmi.size*i, sensor->gamma_lut_rgb.data(), ife_dmi.size);
}

config_ife(0, 1, true);
}
Expand Down
12 changes: 12 additions & 0 deletions system/camerad/sensors/ar0231.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ AR0231::AR0231() {
0x00000fbc, 0x000000bb, 0x00000009,
0x00000fb6, 0x00000fe0, 0x000000ea,
};
for (int i = 0; i < 64; i++) {
float fx = i / 63.0;
const float gamma_k = 0.75;
const float gamma_b = 0.125;
const float mp = 0.01; // ideally midpoint should be adaptive
const float rk = 9 - 100*mp;
// poly approximation for s curve
fx = (fx > mp) ?
((rk * (fx-mp) * (1-(gamma_k*mp+gamma_b)) * (1+1/(rk*(1-mp))) / (1+rk*(fx-mp))) + gamma_k*mp + gamma_b) :
((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));
}
}

void AR0231::processRegisters(uint8_t *cur_buf, cereal::FrameData::Builder &framed) const {
Expand Down
4 changes: 4 additions & 0 deletions system/camerad/sensors/os04c10.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ OS04C10::OS04C10() {
0x00000fa7, 0x000000d9, 0x00001000,
0x00000fca, 0x00000fef, 0x000000c7,
};
for (int i = 0; i < 64; i++) {
float fx = i / 63.0;
gamma_lut_rgb.push_back((uint32_t)(pow(fx, 0.7)*1023.0 + 0.5));
}
}

std::vector<i2c_random_wr_payload> OS04C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const {
Expand Down
6 changes: 3 additions & 3 deletions system/camerad/sensors/ox03c10.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ OX03C10::OX03C10() {
0x00000fc2, 0x00000ff6, 0x000000c9,
};
for (int i = 0; i < 64; i++) {
gamma_lut_r.push_back(0xaa);
gamma_lut_g.push_back(0xaa);
gamma_lut_b.push_back(0xaa);
float fx = i / 63.0;
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));
}
}

Expand Down
4 changes: 1 addition & 3 deletions system/camerad/sensors/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ class SensorInfo {
// ISP image processing params
uint32_t black_level;
std::vector<uint32_t> color_correct_matrix; // 3x3
std::vector<uint32_t> gamma_lut_r; // gamma LUTs are length 64 * sizeof(uint32_t)
std::vector<uint32_t> gamma_lut_g;
std::vector<uint32_t> gamma_lut_b;
std::vector<uint32_t> gamma_lut_rgb; // gamma LUTs are length 64 * sizeof(uint32_t); same for r/g/b here
};

class AR0231 : public SensorInfo {
Expand Down

0 comments on commit b586e27

Please sign in to comment.