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

Commit c7154774 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: I137343d8d999c82fe211949016b19ec6722e9dd4
Signed-off-by: default avatarManikanta Kanamarlapudi <kmanikan@codeaurora.org>
Signed-off-by: default avatarParas Nagda <pnagda@codeaurora.org>
parent 1eccf98e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -1607,6 +1607,7 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
				V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL,
				V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL,
				temp_ctrl->val);
				temp_ctrl->val);
		pdata = &profile_level;
		pdata = &profile_level;
		inst->profile = profile_level.profile;
		break;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL:
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE);
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE);
+64 −0
Original line number Original line Diff line number Diff line
@@ -5646,6 +5646,65 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
	return 0;
	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)
int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
{
{
	struct msm_vidc_capability *capability;
	struct msm_vidc_capability *capability;
@@ -5691,6 +5750,11 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
		rc = -ENOTSUPP;
		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_height = ALIGN(inst->prop.height[CAPTURE_PORT], 16);
	output_width = ALIGN(inst->prop.width[CAPTURE_PORT], 16);
	output_width = ALIGN(inst->prop.width[CAPTURE_PORT], 16);


+12 −0
Original line number Original line Diff line number Diff line
@@ -231,6 +231,16 @@ struct msm_vidc_efuse_data {
	enum efuse_purpose purpose;
	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 {
enum vpu_version {
	VPU_VERSION_4 = 1,
	VPU_VERSION_4 = 1,
	VPU_VERSION_5,
	VPU_VERSION_5,
@@ -252,6 +262,8 @@ struct msm_vidc_platform_data {
	unsigned int efuse_data_length;
	unsigned int efuse_data_length;
	struct msm_vidc_ubwc_config *ubwc_config;
	struct msm_vidc_ubwc_config *ubwc_config;
	unsigned int ubwc_config_length;
	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;
	unsigned int sku_version;
	uint32_t vpu_ver;
	uint32_t vpu_ver;
};
};
+24 −0
Original line number Original line Diff line number Diff line
@@ -753,6 +753,14 @@ static struct msm_vidc_ubwc_config sdmshrike_ubwc_data[] = {
		HFI_PROPERTY_SYS_UBWC_CONFIG, 1, 0, 1, 0, 8, 0, 16, 0),
		HFI_PROPERTY_SYS_UBWC_CONFIG, 1, 0, 1, 0, 8, 0, 16, 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 = {
static struct msm_vidc_platform_data default_data = {
	.codec_data = default_codec_data,
	.codec_data = default_codec_data,
	.codec_data_length =  ARRAY_SIZE(default_codec_data),
	.codec_data_length =  ARRAY_SIZE(default_codec_data),
@@ -765,6 +773,8 @@ static struct msm_vidc_platform_data default_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_5,
	.vpu_ver = VPU_VERSION_5,
};
};
@@ -781,6 +791,8 @@ static struct msm_vidc_platform_data atoll_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
	.vpu_ver = VPU_VERSION_4,
};
};
@@ -797,6 +809,8 @@ static struct msm_vidc_platform_data sm6150_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.efuse_data_length = 0,
	.heic_image_capability = NULL,
	.hevc_image_capability = NULL,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
	.vpu_ver = VPU_VERSION_4,
};
};
@@ -813,6 +827,8 @@ static struct msm_vidc_platform_data trinket_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
	.vpu_ver = VPU_VERSION_4,
};
};
@@ -829,6 +845,8 @@ static struct msm_vidc_platform_data sm8150_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.efuse_data_length = 0,
	.heic_image_capability = &default_heic_image_capability,
	.hevc_image_capability = &default_hevc_image_capability,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_5,
	.vpu_ver = VPU_VERSION_5,
};
};
@@ -861,6 +879,8 @@ static struct msm_vidc_platform_data sdmmagpie_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = sdmmagpie_efuse_data,
	.efuse_data = sdmmagpie_efuse_data,
	.efuse_data_length = ARRAY_SIZE(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,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_5,
	.vpu_ver = VPU_VERSION_5,
};
};
@@ -877,6 +897,8 @@ static struct msm_vidc_platform_data sdm845_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = NULL,
	.efuse_data = NULL,
	.efuse_data_length = 0,
	.efuse_data_length = 0,
	.heic_image_capability = NULL,
	.hevc_image_capability = NULL,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
	.vpu_ver = VPU_VERSION_4,
};
};
@@ -893,6 +915,8 @@ static struct msm_vidc_platform_data sdm670_data = {
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
	.efuse_data = sdm670_efuse_data,
	.efuse_data = sdm670_efuse_data,
	.efuse_data_length = ARRAY_SIZE(sdm670_efuse_data),
	.efuse_data_length = ARRAY_SIZE(sdm670_efuse_data),
	.heic_image_capability = NULL,
	.hevc_image_capability = NULL,
	.sku_version = 0,
	.sku_version = 0,
	.vpu_ver = VPU_VERSION_4,
	.vpu_ver = VPU_VERSION_4,
};
};