diff --git a/system/camerad/cameras/spectra.cc b/system/camerad/cameras/spectra.cc index 6e855f08e86918..ef771a64b72467 100644 --- a/system/camerad/cameras/spectra.cc +++ b/system/camerad/cameras/spectra.cc @@ -302,7 +302,7 @@ int SpectraCamera::sensors_init() { auto pkt = mm.alloc(size, &cam_packet_handle); pkt->num_cmd_buf = 2; pkt->kmd_cmd_buf_index = -1; - pkt->header.op_code = 0x1000000 | CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE; + pkt->header.op_code = CSLDeviceTypeImageSensor | CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE; pkt->header.size = size; struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; @@ -391,7 +391,11 @@ int SpectraCamera::sensors_init() { return ret; } -void SpectraCamera::config_isp(int io_mem_handle, int fence, int request_id, int buf0_idx) { +void SpectraCamera::config_ife(int io_mem_handle, int fence, int request_id, int buf0_idx) { + /* + Handles initial + per-frame IFE config. + IFE = Image Front End + */ int size = sizeof(struct cam_packet) + sizeof(struct cam_cmd_buf_desc)*2; if (io_mem_handle != 0) { size += sizeof(struct cam_buf_io_cfg); @@ -401,10 +405,10 @@ void SpectraCamera::config_isp(int io_mem_handle, int fence, int request_id, int auto pkt = mm.alloc(size, &cam_packet_handle); if (io_mem_handle != 0) { - pkt->header.op_code = 0xf000001; + pkt->header.op_code = CSLDeviceTypeIFE | OpcodesIFEUpdate; // 0xf000001 pkt->header.request_id = request_id; } else { - pkt->header.op_code = 0xf000000; + pkt->header.op_code = CSLDeviceTypeIFE | OpcodesIFEInitialConfig; // 0xf000000 pkt->header.request_id = 1; } pkt->header.size = size; @@ -595,7 +599,7 @@ void SpectraCamera::enqueue_buffer(int i, bool dp) { sensors_poke(request_id); // submit request to the ife - config_isp(buf_handle[i], sync_objs[i], request_id, i); + config_ife(buf_handle[i], sync_objs[i], request_id, i); } void SpectraCamera::camera_map_bufs() { @@ -710,11 +714,11 @@ void SpectraCamera::configISP() { isp_dev_handle = *isp_dev_handle_; LOGD("acquire isp dev"); - // config ISP + // config IFE alloc_w_mmu_hdl(m->video0_fd, FRAME_BUF_COUNT*ALIGNED_SIZE(buf0_size, buf0_alignment), (uint32_t*)&buf0_handle, buf0_alignment, 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); - config_isp(0, 0, 1, 0); + config_ife(0, 0, 1, 0); } void SpectraCamera::configCSIPHY() { diff --git a/system/camerad/cameras/spectra.h b/system/camerad/cameras/spectra.h index e9e83ddb38638a..5796f47098f47e 100644 --- a/system/camerad/cameras/spectra.h +++ b/system/camerad/cameras/spectra.h @@ -16,10 +16,17 @@ const int MIPI_SETTLE_CNT = 33; // Calculated by camera_freqs.py -// For use with the Spectra 280 ISP in the SDM845 +// For use with the Titan 170 ISP in the SDM845 // https://github.com/commaai/agnos-kernel-sdm845 +// CSLDeviceType/CSLPacketOpcodesIFE from camx +// cam_packet_header.op_code = (device << 24) | (opcode); +#define CSLDeviceTypeImageSensor (0x1 << 24) +#define CSLDeviceTypeIFE (0xF << 24) +#define OpcodesIFEInitialConfig 0x0 +#define OpcodesIFEUpdate 0x1 + std::optional device_acquire(int fd, int32_t session_handle, void *data, uint32_t num_resources=1); int device_config(int fd, int32_t session_handle, int32_t dev_handle, uint64_t packet_handle); int device_control(int fd, int op_code, int session_handle, int dev_handle); @@ -69,7 +76,7 @@ class SpectraCamera { void handle_camera_event(const cam_req_mgr_message *event_data); void camera_close(); void camera_map_bufs(); - void config_isp(int io_mem_handle, int fence, int request_id, int buf0_idx); + void config_ife(int io_mem_handle, int fence, int request_id, int buf0_idx); int clear_req_queue(); void enqueue_buffer(int i, bool dp);