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

Commit f962e1c5 authored by Vaibhav Deshu Venkatesh's avatar Vaibhav Deshu Venkatesh Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Update profile/level capabilities



Profile/level capabilities are being received as part of
HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED during sys init.
These capabilities weren't being used. Store them so that
they can be used later.

CRs-Fixed: 2086655
Change-Id: Ib0e4c9bf032152a03c088144dc4ab8de4b4a56c9
Signed-off-by: default avatarVaibhav Deshu Venkatesh <vdeshuve@codeaurora.org>
parent 1996ec83
Loading
Loading
Loading
Loading
+51 −23
Original line number Diff line number Diff line
@@ -775,6 +775,47 @@ static int hfi_fill_codec_info(u8 *data_ptr,
	return size;
}

static int copy_profile_caps_to_sessions(struct hfi_profile_level *prof,
		u32 profile_count, struct msm_vidc_capability *capabilities,
		u32 num_sessions, u32 codecs, u32 domain)
{
	u32 i = 0, j = 0;
	struct msm_vidc_capability *capability;
	u32 sess_codec;
	u32 sess_domain;

	/*
	 * iterate over num_sessions and copy all the profile capabilities
	 * to matching sessions.
	 */
	for (i = 0; i < num_sessions; i++) {
		sess_codec = 0;
		sess_domain = 0;
		capability = &capabilities[i];

		if (capability->codec)
			sess_codec =
				vidc_get_hfi_codec(capability->codec);
		if (capability->domain)
			sess_domain =
				vidc_get_hfi_domain(capability->domain);

		if (!(sess_codec & codecs && sess_domain & domain))
			continue;

		capability->profile_level.profile_count = profile_count;
		for (j = 0; j < profile_count; j++) {
			/* HFI and HAL follow same enums, hence no conversion */
			capability->profile_level.profile_level[j].profile =
				prof[j].profile;
			capability->profile_level.profile_level[j].level =
				prof[j].level;
		}
	}

	return 0;
}

static int copy_caps_to_sessions(struct hfi_capability_supported *cap,
		u32 num_caps, struct msm_vidc_capability *capabilities,
		u32 num_sessions, u32 codecs, u32 domain)
@@ -914,38 +955,25 @@ static enum vidc_status hfi_parse_init_done_properties(
		}
		case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED:
		{
			struct msm_vidc_capability capability;
			char *ptr = NULL;
			u32 count = 0;
			u32 prof_count = 0;
			struct hfi_profile_level *prof_level;
			struct hfi_profile_level_supported *prop =
				(struct hfi_profile_level_supported *)
				(data_ptr + next_offset);

			ptr = (char *) &prop->rg_profile_level[0];
			prof_count = prop->profile_count;
			next_offset += sizeof(u32);
			next_offset += sizeof(u32) +
				prop->profile_count *
				sizeof(struct hfi_profile_level);

			if (prof_count > MAX_PROFILE_COUNT) {
				prof_count = MAX_PROFILE_COUNT;
			if (prop->profile_count > MAX_PROFILE_COUNT) {
				prop->profile_count = MAX_PROFILE_COUNT;
				dprintk(VIDC_WARN,
					"prop count exceeds max profile count\n");
				break;
			}
			while (prof_count) {
				prof_level = (struct hfi_profile_level *)ptr;
				capability.
				profile_level.profile_level[count].profile
					= prof_level->profile;
				capability.
				profile_level.profile_level[count].level
					= prof_level->level;
				prof_count--;
				count++;
				ptr += sizeof(struct hfi_profile_level);
				next_offset += sizeof(struct hfi_profile_level);
			}

			copy_profile_caps_to_sessions(
					&prop->rg_profile_level[0],
					prop->profile_count, capabilities,
					num_sessions, codecs, domain);
			num_properties--;
			break;
		}
+39 −1
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ static void msm_vidc_ctrl_get_range(struct v4l2_queryctrl *ctrl,
int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl)
{
	struct msm_vidc_inst *inst = instance;
	int rc = 0;
	struct hal_profile_level_supported *prof_level_supported;
	int rc = 0, i = 0, profile_mask = 0, v4l2_prof_value = 0, max_level = 0;

	if (!inst || !ctrl)
		return -EINVAL;
@@ -178,6 +179,43 @@ int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl)
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES:
		msm_vidc_ctrl_get_range(ctrl, &inst->capability.slice_bytes);
		break;
	case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE:
	case V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_PROFILE:
	{
		prof_level_supported = &inst->capability.profile_level;
		for (i = 0; i < prof_level_supported->profile_count; i++) {
			v4l2_prof_value = msm_comm_hal_to_v4l2(ctrl->id,
				prof_level_supported->profile_level[i].profile);
			if (v4l2_prof_value == -EINVAL) {
				dprintk(VIDC_WARN, "Invalid profile");
				rc = -EINVAL;
			}
			profile_mask |= (1 << v4l2_prof_value);
		}
		ctrl->flags = profile_mask;
		break;
	}
	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_LEVEL:
	{
		prof_level_supported = &inst->capability.profile_level;
		for (i = 0; i < prof_level_supported->profile_count; i++) {
			if (max_level < prof_level_supported->
				profile_level[i].level) {
				max_level = prof_level_supported->
					profile_level[i].level;
			}
		}
		ctrl->maximum = msm_comm_hal_to_v4l2(ctrl->id, max_level);
		if (ctrl->maximum == -EINVAL) {
			dprintk(VIDC_WARN, "Invalid max level");
			rc = -EINVAL;
		}
		break;
	}
	default:
		rc = -EINVAL;
	}
+9 −0
Original line number Diff line number Diff line
@@ -1427,6 +1427,15 @@ static void handle_session_init_done(enum hal_command_response cmd, void *data)
	print_cap("max_work_modes", &inst->capability.max_work_modes);
	print_cap("ubwc_cr_stats", &inst->capability.ubwc_cr_stats);

	dprintk(VIDC_DBG, "profile count : %u",
		inst->capability.profile_level.profile_count);
	for (i = 0; i < inst->capability.profile_level.profile_count; i++) {
		dprintk(VIDC_DBG, "profile : %u ", inst->capability.
			profile_level.profile_level[i].profile);
		dprintk(VIDC_DBG, "level   : %u ", inst->capability.
			profile_level.profile_level[i].level);
	}

	signal_session_msg_receipt(cmd, inst);

	/*