diff --git a/system/camerad/cameras/ife.h b/system/camerad/cameras/ife.h index 44c4bb58ef726c..380a6ae1346ae2 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, + 0x00000c04, // (1<<8) to enable vignetting correction }); dst += write_cont(dst, 0x48, { @@ -165,24 +165,10 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vectordst_buf_hdl = dst_hdl; + p->src_buf_hdl = src_hdl; + p->dst_offset = dst_offset; + p->src_offset = src_offset; +}; + void SpectraCamera::config_ife(int idx, int request_id, bool init) { /* Handles initial + per-frame IFE config. * IFE = Image Front End */ int size = sizeof(struct cam_packet) + sizeof(struct cam_cmd_buf_desc)*2; - size += sizeof(struct cam_patch_desc)*4; + size += sizeof(struct cam_patch_desc)*10; if (!init) { size += sizeof(struct cam_buf_io_cfg); } @@ -632,23 +640,24 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) { // *** patches *** // sets up the kernel driver to do address translation for the IFE { + // order here corresponds to the one in build_initial_config + assert(patches.size() == 6 || patches.size() == 0); + pkt->num_patches = patches.size(); pkt->patch_offset = sizeof(struct cam_cmd_buf_desc)*pkt->num_cmd_buf + sizeof(struct cam_buf_io_cfg)*pkt->num_io_configs; if (pkt->num_patches > 0) { + void *p = (char*)&pkt->payload + pkt->patch_offset; + // linearization LUT - struct cam_patch_desc *patch = (struct cam_patch_desc *)((char*)&pkt->payload + pkt->patch_offset); - patch->dst_buf_hdl = ife_cmd.handle; - patch->src_buf_hdl = ife_linearization_lut.handle; - patch->dst_offset = patches[0]; - patch->src_offset = 0; + add_patch(p, 0, ife_cmd.handle, patches[0], ife_linearization_lut.handle, 0); + + // vignetting correction LUTs + add_patch(p, 1, ife_cmd.handle, patches[1], ife_vignetting_lut.handle, 0); + add_patch(p, 2, ife_cmd.handle, patches[2], ife_vignetting_lut.handle, ife_vignetting_lut.size); - // gamma LUT + // gamma LUTs for (int i = 0; i < 3; i++) { - patch = (struct cam_patch_desc *)((char*)&pkt->payload + pkt->patch_offset + sizeof(cam_patch_desc)*(i+1)); - patch->dst_buf_hdl = ife_cmd.handle; - patch->src_buf_hdl = ife_gamma_lut.handle; - patch->dst_offset = patches[i+1]; - patch->src_offset = ife_gamma_lut.size*i; + add_patch(p, i+3, ife_cmd.handle, patches[i+3], ife_gamma_lut.handle, ife_gamma_lut.size*i); } } } @@ -873,6 +882,10 @@ void SpectraCamera::configISP() { 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); memcpy(ife_linearization_lut.ptr, sensor->linearization_lut.data(), ife_linearization_lut.size); + ife_vignetting_lut.init(m, sensor->vignetting_lut.size(), 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, 2); + memcpy(ife_vignetting_lut.ptr, sensor->vignetting_lut.data(), ife_vignetting_lut.size*2); } config_ife(0, 1, true); diff --git a/system/camerad/cameras/spectra.h b/system/camerad/cameras/spectra.h index 9da66a0900697a..ea5c5631670065 100644 --- a/system/camerad/cameras/spectra.h +++ b/system/camerad/cameras/spectra.h @@ -142,6 +142,7 @@ class SpectraCamera { SpectraBuf ife_cmd; SpectraBuf ife_gamma_lut; SpectraBuf ife_linearization_lut; + SpectraBuf ife_vignetting_lut; SpectraBuf bps_cmd; SpectraBuf bps_cdm_buffer; diff --git a/system/camerad/sensors/ox03c10.cc b/system/camerad/sensors/ox03c10.cc index b2e90c4e1d8bc3..edfb47f43903a5 100644 --- a/system/camerad/sensors/ox03c10.cc +++ b/system/camerad/sensors/ox03c10.cc @@ -78,6 +78,9 @@ OX03C10::OX03C10() { for (int i = 0; i < 288; i++) { linearization_lut.push_back(0xff); } + for (int i = 0; i < 884*2; i++) { + vignetting_lut.push_back(0xff); + } } std::vector OX03C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const { diff --git a/system/camerad/sensors/sensor.h b/system/camerad/sensors/sensor.h index b4c4303b6608f3..4fba4ff5941069 100644 --- a/system/camerad/sensors/sensor.h +++ b/system/camerad/sensors/sensor.h @@ -73,6 +73,7 @@ class SensorInfo { 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 vignetting_lut; // 2x length 884 }; class AR0231 : public SensorInfo {