video: driver: update input, output and crop dimensions
Update input, output and crop resolution based in client provided resolution on input port as per the v4l2 compliance test expectation. Change-Id: I56f197d72cc132f38c00842b28b23b20c508cf23 Signed-off-by: Maheshwar Ajja <quic_majja@quicinc.com> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
This commit is contained in:

committed by
Dikshita Agarwal

父節點
2d2e07aee9
當前提交
db8a8959e2
@@ -159,8 +159,20 @@ static int msm_venc_set_stride_scanline(struct msm_vidc_inst *inst,
|
||||
return 0;
|
||||
}
|
||||
|
||||
stride_y = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
|
||||
scanline_y = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
|
||||
if (is_image_session(inst)) {
|
||||
stride_y = ALIGN(inst->fmts[INPUT_PORT].fmt.pix_mp.width, HEIC_GRID_DIMENSION);
|
||||
scanline_y = ALIGN(inst->fmts[INPUT_PORT].fmt.pix_mp.height, HEIC_GRID_DIMENSION);
|
||||
} else if (is_rgba_colorformat(color_format)) {
|
||||
stride_y = VIDEO_RGB_STRIDE_PIX(inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat,
|
||||
inst->fmts[INPUT_PORT].fmt.pix_mp.width);
|
||||
scanline_y = VIDEO_RGB_SCANLINES(inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat,
|
||||
inst->fmts[INPUT_PORT].fmt.pix_mp.height);
|
||||
} else {
|
||||
stride_y = VIDEO_Y_STRIDE_PIX(inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat,
|
||||
inst->fmts[INPUT_PORT].fmt.pix_mp.width);
|
||||
scanline_y = VIDEO_Y_SCANLINES(inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat,
|
||||
inst->fmts[INPUT_PORT].fmt.pix_mp.height);
|
||||
}
|
||||
if (color_format == MSM_VIDC_FMT_NV12 ||
|
||||
color_format == MSM_VIDC_FMT_P010 ||
|
||||
color_format == MSM_VIDC_FMT_NV21) {
|
||||
@@ -1156,7 +1168,6 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
}
|
||||
inst->buffers.output.size =
|
||||
fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
|
||||
memcpy(f, fmt, sizeof(struct v4l2_format));
|
||||
|
||||
/* reset metadata buffer size with updated resolution*/
|
||||
msm_vidc_update_meta_port_settings(inst);
|
||||
@@ -1169,6 +1180,8 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
inst->buffers.output.min_count,
|
||||
inst->buffers.output.extra_count);
|
||||
|
||||
/* finally update client format */
|
||||
memcpy(f, fmt, sizeof(struct v4l2_format));
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1220,8 +1233,7 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
||||
int rc = 0;
|
||||
struct v4l2_format *fmt, *output_fmt;
|
||||
struct msm_vidc_core *core;
|
||||
u32 pix_fmt, width, height, size, bytesperline,
|
||||
crop_width, crop_height;
|
||||
u32 pix_fmt, width, height, size, bytesperline;
|
||||
|
||||
if (!inst || !inst->core || !inst->capabilities) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
@@ -1233,25 +1245,21 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
||||
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
|
||||
msm_vidc_update_cap_value(inst, PIX_FMTS, pix_fmt, __func__);
|
||||
|
||||
if (is_rgba_colorformat(pix_fmt)) {
|
||||
width = VIDEO_RGB_STRIDE_PIX(f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.width);
|
||||
height = VIDEO_RGB_SCANLINES(f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.height);
|
||||
crop_width = VIDEO_RGB_STRIDE_PIX(f->fmt.pix_mp.pixelformat, inst->crop.width);
|
||||
crop_height = VIDEO_RGB_SCANLINES(f->fmt.pix_mp.pixelformat, inst->crop.height);
|
||||
bytesperline =
|
||||
VIDEO_RGB_STRIDE_BYTES(f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.width);
|
||||
} else if (is_image_session(inst)) {
|
||||
width = f->fmt.pix_mp.width;
|
||||
height = f->fmt.pix_mp.height;
|
||||
|
||||
if (is_image_session(inst)) {
|
||||
width = ALIGN(f->fmt.pix_mp.width, HEIC_GRID_DIMENSION);
|
||||
height = ALIGN(f->fmt.pix_mp.height, HEIC_GRID_DIMENSION);
|
||||
crop_width = ALIGN(inst->crop.width, HEIC_GRID_DIMENSION);
|
||||
crop_height = ALIGN(inst->crop.height, HEIC_GRID_DIMENSION);
|
||||
inst->crop.width = ALIGN(inst->crop.width, HEIC_GRID_DIMENSION);
|
||||
inst->crop.height = ALIGN(inst->crop.height, HEIC_GRID_DIMENSION);
|
||||
bytesperline = width * (is_10bit_colorformat(pix_fmt) ? 2 : 1);
|
||||
} else if (is_rgba_colorformat(pix_fmt)) {
|
||||
bytesperline = VIDEO_RGB_STRIDE_BYTES(f->fmt.pix_mp.pixelformat,
|
||||
f->fmt.pix_mp.width);
|
||||
} else {
|
||||
width = VIDEO_Y_STRIDE_PIX(f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.width);
|
||||
height = VIDEO_Y_SCANLINES(f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.height);
|
||||
crop_width = VIDEO_Y_STRIDE_PIX(f->fmt.pix_mp.pixelformat, inst->crop.width);
|
||||
crop_height = VIDEO_Y_SCANLINES(f->fmt.pix_mp.pixelformat, inst->crop.height);
|
||||
bytesperline = VIDEO_Y_STRIDE_BYTES(f->fmt.pix_mp.pixelformat, f->fmt.pix_mp.width);
|
||||
bytesperline = VIDEO_Y_STRIDE_BYTES(f->fmt.pix_mp.pixelformat,
|
||||
f->fmt.pix_mp.width);
|
||||
}
|
||||
|
||||
fmt = &inst->fmts[INPUT_PORT];
|
||||
@@ -1295,9 +1303,8 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
||||
}
|
||||
inst->buffers.input.size = size;
|
||||
|
||||
if (fmt->fmt.pix_mp.width != crop_width ||
|
||||
fmt->fmt.pix_mp.height != crop_height) {
|
||||
struct v4l2_format *output_fmt;
|
||||
if (f->fmt.pix_mp.width != inst->crop.width ||
|
||||
f->fmt.pix_mp.height != inst->crop.height) {
|
||||
|
||||
/* reset crop dimensions with updated resolution */
|
||||
inst->crop.top = inst->crop.left = 0;
|
||||
@@ -1309,12 +1316,11 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
||||
inst->compose.width = f->fmt.pix_mp.width;
|
||||
inst->compose.height = f->fmt.pix_mp.height;
|
||||
|
||||
output_fmt = &inst->fmts[OUTPUT_PORT];
|
||||
/* update output format */
|
||||
rc = msm_venc_s_fmt_output(inst, output_fmt);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
memcpy(f, fmt, sizeof(struct v4l2_format));
|
||||
|
||||
/* reset metadata buffer size with updated resolution*/
|
||||
msm_vidc_update_meta_port_settings(inst);
|
||||
@@ -1327,6 +1333,9 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
||||
inst->buffers.input.min_count,
|
||||
inst->buffers.input.extra_count);
|
||||
|
||||
/* finally update client format */
|
||||
memcpy(f, fmt, sizeof(struct v4l2_format));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1884,10 +1893,8 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
|
||||
f = &inst->fmts[INPUT_PORT];
|
||||
f->type = INPUT_MPLANE;
|
||||
f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_VIDC_NV12C;
|
||||
f->fmt.pix_mp.width = VIDEO_Y_STRIDE_PIX(f->fmt.pix_mp.pixelformat,
|
||||
DEFAULT_WIDTH);
|
||||
f->fmt.pix_mp.height = VIDEO_Y_SCANLINES(f->fmt.pix_mp.pixelformat,
|
||||
DEFAULT_HEIGHT);
|
||||
f->fmt.pix_mp.width = DEFAULT_WIDTH;
|
||||
f->fmt.pix_mp.height = DEFAULT_HEIGHT;
|
||||
f->fmt.pix_mp.num_planes = 1;
|
||||
f->fmt.pix_mp.plane_fmt[0].bytesperline =
|
||||
VIDEO_Y_STRIDE_BYTES(f->fmt.pix_mp.pixelformat,
|
||||
|
Reference in New Issue
Block a user