Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc5e68da authored by Manikanta Kanamarlapudi's avatar Manikanta Kanamarlapudi Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Check image encode capabilities



For heic/hevc image session, check respective
capabilities to allow and reject.

Change-Id: If3a296d984eb3e0f1f90faaa6f6b0be8a5f21f0d
Signed-off-by: default avatarManikanta Kanamarlapudi <kmanikan@codeaurora.org>
parent 02f478a7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1606,6 +1606,7 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
				V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL,
				temp_ctrl->val);
		pdata = &profile_level;
		inst->profile = profile_level.profile;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL:
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE);
+64 −0
Original line number Diff line number Diff line
@@ -5647,6 +5647,65 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
	return 0;
}

static bool is_image_session(struct msm_vidc_inst *inst)
{
	if (inst->session_type == MSM_VIDC_ENCODER &&
		get_hal_codec(inst->fmts[CAPTURE_PORT].fourcc) ==
			HAL_VIDEO_CODEC_HEVC)
		return (inst->profile == HAL_HEVC_PROFILE_MAIN_STILL_PIC ||
				inst->grid_enable);
	else
		return false;
}

static int msm_vidc_check_image_session_capabilities(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct msm_vidc_image_capability *capability = NULL;

	u32 output_height = ALIGN(inst->prop.height[CAPTURE_PORT], 512);
	u32 output_width = ALIGN(inst->prop.width[CAPTURE_PORT], 512);

	if (inst->grid_enable)
		capability = inst->core->platform_data->heic_image_capability;
	else
		capability = inst->core->platform_data->hevc_image_capability;

	if (!capability)
		return -EINVAL;

	if (output_width < capability->width.min ||
		output_height < capability->height.min) {
		dprintk(VIDC_ERR,
			"HEIC Unsupported WxH = (%u)x(%u), min supported is - (%u)x(%u)\n",
			output_width,
			output_height,
			capability->width.min,
			capability->height.min);
		rc = -ENOTSUPP;
	}
	if (!rc && (output_width > capability->width.max ||
		output_height > capability->height.max)) {
		dprintk(VIDC_ERR,
			"HEIC Unsupported WxH = (%u)x(%u), max supported is - (%u)x(%u)\n",
			output_width,
			output_height,
			capability->width.max,
			capability->height.max);
		rc = -ENOTSUPP;
	}
	if (!rc && output_height * output_width >
		capability->width.max * capability->height.max) {
		dprintk(VIDC_ERR,
		"HEIC Unsupported WxH = (%u)x(%u), max supported is - (%u)x(%u)\n",
		output_width, output_height,
		capability->width.max, capability->height.max);
		rc = -ENOTSUPP;
	}

	return rc;
}

int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
{
	struct msm_vidc_capability *capability;
@@ -5692,6 +5751,11 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
		rc = -ENOTSUPP;
	}

	if (is_image_session(inst)) {
		rc = msm_vidc_check_image_session_capabilities(inst);
		return rc;
	}

	output_height = ALIGN(inst->prop.height[CAPTURE_PORT], 16);
	output_width = ALIGN(inst->prop.width[CAPTURE_PORT], 16);

+12 −0
Original line number Diff line number Diff line
@@ -232,6 +232,16 @@ struct msm_vidc_efuse_data {
	enum efuse_purpose purpose;
};

struct msm_vidc_capability_range {
	u32 min;
	u32 max;
};

struct msm_vidc_image_capability {
	struct msm_vidc_capability_range width;
	struct msm_vidc_capability_range height;
};

enum vpu_version {
	VPU_VERSION_4 = 1,
	VPU_VERSION_5,
@@ -253,6 +263,8 @@ struct msm_vidc_platform_data {
	unsigned int efuse_data_length;
	struct msm_vidc_ubwc_config *ubwc_config;
	unsigned int ubwc_config_length;
	struct msm_vidc_image_capability *heic_image_capability;
	struct msm_vidc_image_capability *hevc_image_capability;
	unsigned int sku_version;
	uint32_t vpu_ver;
};
+22 −0
Original line number Diff line number Diff line
@@ -674,6 +674,14 @@ static struct msm_vidc_ubwc_config trinket_ubwc_data[] = {
	UBWC_CONFIG(0, 1, 0, 0, 0, 64, 0, 0),
};

static struct msm_vidc_image_capability default_heic_image_capability = {
	{512, 8192}, {512, 8192}
};

static struct msm_vidc_image_capability default_hevc_image_capability = {
	{512, 512}, {512, 512}
};

static struct msm_vidc_platform_data default_data = {
	.codec_data = default_codec_data,
	.codec_data_length =  ARRAY_SIZE(default_codec_data),
@@ -686,6 +694,8 @@ static struct msm_vidc_platform_data default_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_5,
};
@@ -702,6 +712,8 @@ static struct msm_vidc_platform_data sm6150_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.heic_image_capability = NULL,
	.hevc_image_capability = NULL,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
};
@@ -718,6 +730,8 @@ static struct msm_vidc_platform_data trinket_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
};
@@ -734,6 +748,8 @@ static struct msm_vidc_platform_data sm8150_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_5,
};
@@ -750,6 +766,8 @@ static struct msm_vidc_platform_data sdmmagpie_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = sdmmagpie_efuse_data,
	.efuse_data_length = ARRAY_SIZE(sdmmagpie_efuse_data),
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_5,
};
@@ -766,6 +784,8 @@ static struct msm_vidc_platform_data sdm845_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.heic_image_capability = NULL,
	.hevc_image_capability = NULL,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
};
@@ -782,6 +802,8 @@ static struct msm_vidc_platform_data sdm670_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = sdm670_efuse_data,
	.efuse_data_length = ARRAY_SIZE(sdm670_efuse_data),
	.heic_image_capability = NULL,
	.hevc_image_capability = NULL,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
};