Skip to content

Commit

Permalink
camerad: IFE config definitions (#33624)
Browse files Browse the repository at this point in the history
* camerad: more definitions for IFE config

* comment
  • Loading branch information
adeebshihadeh authored Sep 22, 2024
1 parent d5039bc commit 62d044c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
18 changes: 11 additions & 7 deletions system/camerad/cameras/spectra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ int SpectraCamera::sensors_init() {
auto pkt = mm.alloc<struct cam_packet>(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;

Expand Down Expand Up @@ -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);
Expand All @@ -401,10 +405,10 @@ void SpectraCamera::config_isp(int io_mem_handle, int fence, int request_id, int
auto pkt = mm.alloc<struct cam_packet>(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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 9 additions & 2 deletions system/camerad/cameras/spectra.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t> 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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 62d044c

Please sign in to comment.