video: driver: handle invalid format in s_fmt

Handle invalid format 0xfffff by invoking try_fmt in
s_fmt. It is expected from driver to return EINVAL for only
unsupported buf type and if color format is unsupported,
driver should fill the fmt structure with valid values.

Partially Fixes: v4l2-compliance:
			TestSetFormat(VIDIOC_S_FMT)

Change-Id: I27e82866e8ad4a13661431f2a38a66ac3ef7dd80
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
This commit is contained in:
Dikshita Agarwal
2022-02-01 13:13:22 +05:30
parent 0c0981b43c
commit 4d8dedc066
2 changed files with 26 additions and 25 deletions

View File

@@ -2410,27 +2410,25 @@ int msm_vdec_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
if (f->type == INPUT_MPLANE) {
pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
if (!pix_fmt) {
i_vpr_h(inst, "%s: unsupported codec, set default params\n", __func__);
f->fmt.pix_mp.width = DEFAULT_WIDTH;
f->fmt.pix_mp.height = DEFAULT_HEIGHT;
f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264;
i_vpr_e(inst, "%s: unsupported codec, set current params\n", __func__);
f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
f->fmt.pix_mp.pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
}
} else if (f->type == OUTPUT_MPLANE) {
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
if (!pix_fmt) {
i_vpr_e(inst, "%s: unsupported format, set current params\n", __func__);
f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
}
if (inst->bufq[INPUT_PORT].vb2q->streaming) {
f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
}
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
if (!pix_fmt) {
i_vpr_h(inst, "%s: unsupported format, set default params\n", __func__);
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);
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
}
} else {
i_vpr_e(inst, "%s: invalid type %d\n", __func__, f->type);
return -EINVAL;
@@ -2474,6 +2472,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
return -EINVAL;
}
core = inst->core;
msm_vdec_try_fmt(inst, f);
if (f->type == INPUT_MPLANE) {
if (inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat !=

View File

@@ -1060,21 +1060,20 @@ int msm_venc_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
if (f->type == INPUT_MPLANE) {
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
if (!pix_fmt) {
i_vpr_h(inst, "%s: unsupported format, set default params\n", __func__);
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);
i_vpr_e(inst, "%s: unsupported format, set current params\n", __func__);
f->fmt.pix_mp.pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
}
} else if (f->type == OUTPUT_MPLANE) {
pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
if (!pix_fmt) {
i_vpr_h(inst, "%s: unsupported codec, set default params\n", __func__);
f->fmt.pix_mp.width = DEFAULT_WIDTH;
f->fmt.pix_mp.height = DEFAULT_HEIGHT;
f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264;
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
i_vpr_e(inst, "%s: unsupported codec, set current params\n", __func__);
f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
}
} else {
i_vpr_e(inst, "%s: invalid type %d\n", __func__, f->type);
@@ -1101,6 +1100,7 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
return -EINVAL;
}
core = inst->core;
msm_venc_try_fmt(inst, f);
fmt = &inst->fmts[OUTPUT_PORT];
if (fmt->fmt.pix_mp.pixelformat != f->fmt.pix_mp.pixelformat) {
@@ -1222,6 +1222,8 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
return -EINVAL;
}
core = inst->core;
msm_venc_try_fmt(inst, f);
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
msm_vidc_update_cap_value(inst, PIX_FMTS, pix_fmt, __func__);