mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-20 00:32:11 +08:00
camerad: use single instance of MemoryManager for all cameras (#34654)
use single instance of MemoryManager for all cameras
This commit is contained in:
@@ -230,6 +230,8 @@ void SpectraMaster::init() {
|
||||
sub.id = V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS;
|
||||
ret = HANDLE_EINTR(ioctl(video0_fd, VIDIOC_SUBSCRIBE_EVENT, &sub));
|
||||
LOGD("req mgr subscribe: %d", ret);
|
||||
|
||||
mem_mgr.init(video0_fd);
|
||||
}
|
||||
|
||||
// *** SpectraCamera ***
|
||||
@@ -239,8 +241,6 @@ SpectraCamera::SpectraCamera(SpectraMaster *master, const CameraConfig &config,
|
||||
enabled(config.enabled),
|
||||
cc(config),
|
||||
output_type(out) {
|
||||
mm.init(m->video0_fd);
|
||||
|
||||
ife_buf_depth = (out == ISP_RAW_OUTPUT) ? 4 : VIPC_BUFFER_COUNT;
|
||||
assert(ife_buf_depth < MAX_IFE_BUFS);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ void SpectraCamera::sensors_start() {
|
||||
void SpectraCamera::sensors_poke(int request_id) {
|
||||
uint32_t cam_packet_handle = 0;
|
||||
int size = sizeof(struct cam_packet);
|
||||
auto pkt = mm.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
auto pkt = m->mem_mgr.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
pkt->num_cmd_buf = 0;
|
||||
pkt->kmd_cmd_buf_index = -1;
|
||||
pkt->header.size = size;
|
||||
@@ -345,7 +345,7 @@ void SpectraCamera::sensors_i2c(const struct i2c_random_wr_payload* dat, int len
|
||||
// LOGD("sensors_i2c: %d", len);
|
||||
uint32_t cam_packet_handle = 0;
|
||||
int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*1;
|
||||
auto pkt = mm.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
auto pkt = m->mem_mgr.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
pkt->num_cmd_buf = 1;
|
||||
pkt->kmd_cmd_buf_index = -1;
|
||||
pkt->header.size = size;
|
||||
@@ -355,7 +355,7 @@ void SpectraCamera::sensors_i2c(const struct i2c_random_wr_payload* dat, int len
|
||||
buf_desc[0].size = buf_desc[0].length = sizeof(struct i2c_rdwr_header) + len*sizeof(struct i2c_random_wr_payload);
|
||||
buf_desc[0].type = CAM_CMD_BUF_I2C;
|
||||
|
||||
auto i2c_random_wr = mm.alloc<struct cam_cmd_i2c_random_wr>(buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle);
|
||||
auto i2c_random_wr = m->mem_mgr.alloc<struct cam_cmd_i2c_random_wr>(buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle);
|
||||
i2c_random_wr->header.count = len;
|
||||
i2c_random_wr->header.op_code = 1;
|
||||
i2c_random_wr->header.cmd_type = CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR;
|
||||
@@ -374,7 +374,7 @@ void SpectraCamera::sensors_i2c(const struct i2c_random_wr_payload* dat, int len
|
||||
int SpectraCamera::sensors_init() {
|
||||
uint32_t cam_packet_handle = 0;
|
||||
int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*2;
|
||||
auto pkt = mm.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
auto pkt = m->mem_mgr.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
pkt->num_cmd_buf = 2;
|
||||
pkt->kmd_cmd_buf_index = -1;
|
||||
pkt->header.op_code = CSLDeviceTypeImageSensor | CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE;
|
||||
@@ -383,7 +383,7 @@ int SpectraCamera::sensors_init() {
|
||||
|
||||
buf_desc[0].size = buf_desc[0].length = sizeof(struct cam_cmd_i2c_info) + sizeof(struct cam_cmd_probe);
|
||||
buf_desc[0].type = CAM_CMD_BUF_LEGACY;
|
||||
auto i2c_info = mm.alloc<struct cam_cmd_i2c_info>(buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle);
|
||||
auto i2c_info = m->mem_mgr.alloc<struct cam_cmd_i2c_info>(buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle);
|
||||
auto probe = (struct cam_cmd_probe *)(i2c_info.get() + 1);
|
||||
|
||||
probe->camera_id = cc.camera_num;
|
||||
@@ -404,7 +404,7 @@ int SpectraCamera::sensors_init() {
|
||||
//buf_desc[1].size = buf_desc[1].length = 148;
|
||||
buf_desc[1].size = buf_desc[1].length = 196;
|
||||
buf_desc[1].type = CAM_CMD_BUF_I2C;
|
||||
auto power_settings = mm.alloc<struct cam_cmd_power>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
|
||||
auto power_settings = m->mem_mgr.alloc<struct cam_cmd_power>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
|
||||
|
||||
// power on
|
||||
struct cam_cmd_power *power = power_settings.get();
|
||||
@@ -486,7 +486,7 @@ void SpectraCamera::config_bps(int idx, int request_id) {
|
||||
size += sizeof(struct cam_patch_desc)*9;
|
||||
|
||||
uint32_t cam_packet_handle = 0;
|
||||
auto pkt = mm.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
auto pkt = m->mem_mgr.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
|
||||
pkt->header.op_code = CSLDeviceTypeBPS | CAM_ICP_OPCODE_BPS_UPDATE;
|
||||
pkt->header.request_id = request_id;
|
||||
@@ -622,7 +622,7 @@ void SpectraCamera::config_bps(int idx, int request_id) {
|
||||
buf_desc[1].length = buf_desc[1].size - buf_desc[1].offset;
|
||||
buf_desc[1].type = CAM_CMD_BUF_GENERIC;
|
||||
buf_desc[1].meta_data = CAM_ICP_CMD_META_GENERIC_BLOB;
|
||||
auto buf2 = mm.alloc<uint32_t>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
|
||||
auto buf2 = m->mem_mgr.alloc<uint32_t>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
|
||||
memcpy(buf2.get(), &tmp, sizeof(tmp));
|
||||
}
|
||||
|
||||
@@ -718,7 +718,7 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) {
|
||||
}
|
||||
|
||||
uint32_t cam_packet_handle = 0;
|
||||
auto pkt = mm.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
auto pkt = m->mem_mgr.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
|
||||
if (!init) {
|
||||
pkt->header.op_code = CSLDeviceTypeIFE | OpcodesIFEUpdate; // 0xf000001
|
||||
@@ -822,7 +822,7 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) {
|
||||
buf_desc[1].length = buf_desc[1].size - buf_desc[1].offset;
|
||||
buf_desc[1].type = CAM_CMD_BUF_GENERIC;
|
||||
buf_desc[1].meta_data = CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON;
|
||||
auto buf2 = mm.alloc<uint32_t>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
|
||||
auto buf2 = m->mem_mgr.alloc<uint32_t>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
|
||||
memcpy(buf2.get(), &tmp, sizeof(tmp));
|
||||
}
|
||||
|
||||
@@ -1247,7 +1247,7 @@ void SpectraCamera::configCSIPHY() {
|
||||
{
|
||||
uint32_t cam_packet_handle = 0;
|
||||
int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*1;
|
||||
auto pkt = mm.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
auto pkt = m->mem_mgr.alloc<struct cam_packet>(size, &cam_packet_handle);
|
||||
pkt->num_cmd_buf = 1;
|
||||
pkt->kmd_cmd_buf_index = -1;
|
||||
pkt->header.size = size;
|
||||
@@ -1256,7 +1256,7 @@ void SpectraCamera::configCSIPHY() {
|
||||
buf_desc[0].size = buf_desc[0].length = sizeof(struct cam_csiphy_info);
|
||||
buf_desc[0].type = CAM_CMD_BUF_GENERIC;
|
||||
|
||||
auto csiphy_info = mm.alloc<struct cam_csiphy_info>(buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle);
|
||||
auto csiphy_info = m->mem_mgr.alloc<struct cam_csiphy_info>(buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle);
|
||||
csiphy_info->lane_mask = 0x1f;
|
||||
csiphy_info->lane_assign = 0x3210;// skip clk. How is this 16 bit for 5 channels??
|
||||
csiphy_info->csiphy_3phase = 0x0; // no 3 phase, only 2 conductors per lane
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
int device_iommu = -1;
|
||||
int cdm_iommu = -1;
|
||||
int icp_device_iommu = -1;
|
||||
MemoryManager mem_mgr;
|
||||
};
|
||||
|
||||
class SpectraBuf {
|
||||
@@ -196,7 +197,6 @@ public:
|
||||
SpectraOutputType output_type;
|
||||
|
||||
CameraBuf buf;
|
||||
MemoryManager mm;
|
||||
SpectraMaster *m;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user