Skip to content

Commit

Permalink
set buf use buf
Browse files Browse the repository at this point in the history
  • Loading branch information
ZwX1616 committed Dec 13, 2024
1 parent cab1b11 commit 32b184f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
3 changes: 0 additions & 3 deletions system/camerad/cameras/camera_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ void CameraBuf::init(cl_device_id device_id, cl_context context, SpectraCamera *
LOGD("allocated %d CL buffers", frame_buf_count);
}

out_img_width = sensor->frame_width / sensor->out_scale;
out_img_height = (sensor->hdr_offset > 0 ? (sensor->frame_height - sensor->hdr_offset) / 2 : sensor->frame_height) / sensor->out_scale;

// the encoder HW tells us the size it wants after setting it up.
// TODO: VENUS_BUFFER_SIZE should give the size, but it's too small. dependent on encoder settings?
size_t nv12_size = (out_img_width <= 1344 ? 2900 : 2346)*cam->stride;
Expand Down
18 changes: 9 additions & 9 deletions system/camerad/cameras/ife.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patch
}


int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches) {
int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches, int out_width, int out_height) {
uint8_t *start = dst;

// start with the every frame config
Expand Down Expand Up @@ -184,25 +184,25 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t
// TODO: remove this
dst += write_cont(dst, 0xa3c, {
0x00000003,
((s->frame_width / s->out_scale - 1) << 16) | (s->frame_width - 1),
((out_width - 1) << 16) | (s->frame_width - 1),
0x30036666,
0x00000000,
0x00000000,
s->frame_width - 1,
((s->frame_height / s->out_scale - 1) << 16) | (s->frame_height - 1),
((out_height - 1) << 16) | (s->frame_height - 1),
0x30036666,
0x00000000,
0x00000000,
s->frame_height - 1,
});
dst += write_cont(dst, 0xa68, {
0x00000003,
((s->frame_width / s->out_scale / 2 - 1) << 16) | (s->frame_width - 1),
((out_width / 2 - 1) << 16) | (s->frame_width - 1),
0x3006cccc,
0x00000000,
0x00000000,
s->frame_width - 1,
((s->frame_height / s->out_scale / 2 - 1) << 16) | (s->frame_height - 1),
((out_height / 2 - 1) << 16) | (s->frame_height - 1),
0x3006cccc,
0x00000000,
0x00000000,
Expand All @@ -211,12 +211,12 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t

// cropping
dst += write_cont(dst, 0xe10, {
s->frame_height / s->out_scale - 1,
s->frame_width / s->out_scale - 1,
out_height - 1,
out_width - 1,
});
dst += write_cont(dst, 0xe30, {
s->frame_height / s->out_scale / 2 - 1,
s->frame_width / s->out_scale - 1,
out_height / 2 - 1,
out_width - 1,
});
dst += write_cont(dst, 0xe18, {
0x0ff00000,
Expand Down
29 changes: 16 additions & 13 deletions system/camerad/cameras/spectra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,21 @@ void SpectraCamera::camera_open(VisionIpcServer *v, cl_device_id device_id, cl_c

if (!enabled) return;

buf.out_img_width = sensor->frame_width / sensor->out_scale;
buf.out_img_height = (sensor->hdr_offset > 0 ? (sensor->frame_height - sensor->hdr_offset) / 2 : sensor->frame_height) / sensor->out_scale;

// size is driven by all the HW that handles frames,
// the video encoder has certain alignment requirements in this case
stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, sensor->frame_width / sensor->out_scale);
y_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, sensor->frame_height / sensor->out_scale);
uv_height = VENUS_UV_SCANLINES(COLOR_FMT_NV12, sensor->frame_height / sensor->out_scale);
stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, buf.out_img_width);
y_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, buf.out_img_height);
uv_height = VENUS_UV_SCANLINES(COLOR_FMT_NV12, buf.out_img_height);
uv_offset = stride*y_height;
yuv_size = uv_offset + stride*uv_height;
if (!is_raw) {
uv_offset = ALIGNED_SIZE(uv_offset, 0x1000);
yuv_size = uv_offset + ALIGNED_SIZE(stride*uv_height, 0x1000);
}
assert(stride == VENUS_UV_STRIDE(COLOR_FMT_NV12, sensor->frame_width / sensor->out_scale));
assert(stride == VENUS_UV_STRIDE(COLOR_FMT_NV12, buf.out_img_width));
assert(y_height/2 == uv_height);

open = true;
Expand Down Expand Up @@ -509,7 +512,7 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) {
// stream of IFE register writes
if (!is_raw) {
if (init) {
buf_desc[0].length = build_initial_config((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches);
buf_desc[0].length = build_initial_config((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches, buf.out_img_width, buf.out_img_height);
} else {
buf_desc[0].length = build_update((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches);
}
Expand Down Expand Up @@ -617,14 +620,14 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) {
io_cfg[0].mem_handle[0] = buf_handle_yuv[idx];
io_cfg[0].mem_handle[1] = buf_handle_yuv[idx];
io_cfg[0].planes[0] = (struct cam_plane_cfg){
.width = sensor->frame_width / sensor->out_scale,
.height = sensor->frame_height / sensor->out_scale,
.width = buf.out_img_width,
.height = buf.out_img_height,
.plane_stride = stride,
.slice_height = y_height,
};
io_cfg[0].planes[1] = (struct cam_plane_cfg){
.width = sensor->frame_width / sensor->out_scale,
.height = sensor->frame_height / sensor->out_scale / 2,
.width = buf.out_img_width,
.height = buf.out_img_height / 2,
.plane_stride = stride,
.slice_height = uv_height,
};
Expand Down Expand Up @@ -847,8 +850,8 @@ void SpectraCamera::configISP() {
.data[0] = (struct cam_isp_out_port_info){
.res_type = CAM_ISP_IFE_OUT_RES_FULL,
.format = CAM_FORMAT_NV12,
.width = sensor->frame_width / sensor->out_scale,
.height = sensor->frame_height / sensor->out_scale + sensor->extra_height,
.width = buf.out_img_width,
.height = buf.out_img_height + sensor->extra_height,
.comp_grp_id = 0x0, .split_point = 0x0, .secure_mode = 0x0,
},
};
Expand Down Expand Up @@ -920,8 +923,8 @@ void SpectraCamera::configICP() {
},
.out_res[0] = (struct cam_icp_res_info){
.format = 0x3, // YUV420NV12
.width = sensor->frame_width / sensor->out_scale,
.height = sensor->frame_height / sensor->out_scale,
.width = buf.out_img_width,
.height = buf.out_img_height,
.fps = 20,
},
};
Expand Down

0 comments on commit 32b184f

Please sign in to comment.