video: driver: add scaling checks for encode session

Encoder supports downscale with scaling ratio upto 1/8 of width
and 1/8 of height. So added necessary scaling checks at streamon.

Change-Id: I3a29b43c79cf4e693ba2c0d9f98ec24410d50fbd
Signed-off-by: Govindaraj Rajagopal <grajagop@codeaurora.org>
This commit is contained in:
Govindaraj Rajagopal
2021-05-31 15:49:12 +05:30
parent 65636fd2ad
commit a33041f799
7 changed files with 42 additions and 24 deletions

View File

@@ -205,10 +205,7 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
{OPERATING_RATE, ENC|DEC, CODECS_ALL,
1, INT_MAX, 1, (DEFAULT_FPS << 16)},
{SCALE_X, ENC, H264|HEVC, 8192, 65536, 1, 8192},
{SCALE_X, DEC, H264|HEVC|VP9, 65536, 65536, 1, 65536},
{SCALE_Y, ENC, H264|HEVC, 8192, 65536, 1, 8192},
{SCALE_Y, DEC, H264|HEVC|VP9, 65536, 65536, 1, 65536},
{SCALE_FACTOR, ENC, H264|HEVC, 1, 8, 1, 8},
{MB_CYCLES_VSP, ENC, CODECS_ALL, 25, 25, 1, 25},
{MB_CYCLES_VSP, DEC, CODECS_ALL, 25, 25, 1, 25},

View File

@@ -455,8 +455,7 @@ static u32 msm_vidc_encoder_vpss_size_iris2(struct msm_vidc_inst* inst)
msm_vidc_v4l2_to_hfi_enum(inst, ROTATION, &rotation_val);
f = &inst->fmts[OUTPUT_PORT];
if (inst->capabilities->cap[ROTATION].value == 90 ||
inst->capabilities->cap[ROTATION].value == 270) {
if (is_rotation_90_or_270(inst)) {
/*
* output width and height are rotated,
* so unrotate them to use as arguments to

View File

@@ -73,6 +73,12 @@ static inline is_scaling_enabled(struct msm_vidc_inst *inst)
inst->crop.height != inst->compose.height;
}
static inline is_rotation_90_or_270(struct msm_vidc_inst *inst)
{
return inst->capabilities->cap[ROTATION].value == 90 ||
inst->capabilities->cap[ROTATION].value == 270;
}
static inline is_internal_buffer(enum msm_vidc_buffer_type buffer_type)
{
return buffer_type == MSM_VIDC_BUF_BIN ||

View File

@@ -347,8 +347,7 @@ enum msm_vidc_inst_capability_type {
POWER_SAVE_MBPS,
FRAME_RATE,
OPERATING_RATE,
SCALE_X,
SCALE_Y,
SCALE_FACTOR,
MB_CYCLES_VSP,
MB_CYCLES_VPP,
MB_CYCLES_LP,

View File

@@ -1397,10 +1397,6 @@ int msm_vdec_streamon_input(struct msm_vidc_inst *inst)
if (rc)
goto error;
rc = msm_vidc_check_scaling_supported(inst);
if (rc)
goto error;
rc = msm_vdec_set_input_properties(inst);
if (rc)
goto error;

View File

@@ -247,8 +247,7 @@ static int msm_venc_set_crop_offsets(struct msm_vidc_inst *inst,
width = inst->compose.width;
height = inst->compose.height;
if (inst->capabilities->cap[ROTATION].value == 90 ||
inst->capabilities->cap[ROTATION].value == 270) {
if (is_rotation_90_or_270(inst)) {
width = inst->compose.height;
height = inst->compose.width;
}
@@ -1051,8 +1050,7 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
/* use rotated width height if rotation is enabled */
width = inst->compose.width;
height = inst->compose.height;
if (inst->capabilities->cap[ROTATION].value == 90 ||
inst->capabilities->cap[ROTATION].value == 270) {
if (is_rotation_90_or_270(inst)) {
width = inst->compose.height;
height = inst->compose.width;
}
@@ -1424,10 +1422,7 @@ int msm_venc_s_selection(struct msm_vidc_inst* inst, struct v4l2_selection* s)
inst->compose.width = s->r.width;
inst->compose.height= s->r.height;
if (inst->crop.left != inst->compose.left ||
inst->crop.top != inst->compose.top ||
inst->crop.width != inst->compose.width ||
inst->crop.height != inst->compose.height) {
if (is_scaling_enabled(inst)) {
i_vpr_h(inst,
"%s: scaling enabled, crop: l %d t %d w %d h %d compose: l %d t %d w %d h %d\n",
__func__, inst->crop.left, inst->crop.top,

View File

@@ -67,8 +67,7 @@ static const struct msm_vidc_cap_name cap_name_arr[] = {
{POWER_SAVE_MBPS, "POWER_SAVE_MBPS" },
{FRAME_RATE, "FRAME_RATE" },
{OPERATING_RATE, "OPERATING_RATE" },
{SCALE_X, "SCALE_X" },
{SCALE_Y, "SCALE_Y" },
{SCALE_FACTOR, "SCALE_FACTOR" },
{MB_CYCLES_VSP, "MB_CYCLES_VSP" },
{MB_CYCLES_VPP, "MB_CYCLES_VPP" },
{MB_CYCLES_LP, "MB_CYCLES_LP" },
@@ -5377,7 +5376,9 @@ exit:
int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
{
if (!inst) {
u32 iwidth, owidth, iheight, oheight, ds_factor;
if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
@@ -5387,7 +5388,32 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
return 0;
}
/* todo: add scaling check for encode session */
if (!is_scaling_enabled(inst)) {
i_vpr_h(inst, "%s: Scaling not enabled. skip scaling check\n", __func__);
return 0;
}
iwidth = inst->crop.width;
iheight = inst->crop.height;
owidth = inst->compose.width;
oheight = inst->compose.height;
ds_factor = inst->capabilities->cap[SCALE_FACTOR].value;
/* upscaling: encoder doesnot support upscaling */
if (owidth > iwidth || oheight > iheight) {
i_vpr_e(inst, "%s: upscale not supported: input [%u x %u], output [%u x %u]\n",
__func__, iwidth, iheight, owidth, oheight);
return -EINVAL;
}
/* downscaling: only supported upto 1/8 of width & 1/8 of height */
if (iwidth > owidth * ds_factor || iheight > oheight * ds_factor) {
i_vpr_e(inst,
"%s: unsupported ratio: input [%u x %u], output [%u x %u], ratio %u\n",
__func__, iwidth, iheight, owidth, oheight, ds_factor);
return -EINVAL;
}
return 0;
}