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

Commit 6fec6afc authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: Remove HAL translation for set properties"

parents be6924f0 d6c59e32
Loading
Loading
Loading
Loading
+7 −1275

File changed.

Preview size limit exceeded, changes collapsed.

+2 −5
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */
#ifndef __HFI_PACKETIZATION_H__
#define __HFI_PACKETIZATION_H__
@@ -76,13 +76,10 @@ struct hfi_packetization_ops {
		struct hal_session *session);
	int (*session_flush)(struct hfi_cmd_session_flush_packet *pkt,
		struct hal_session *session, enum hal_flush flush_mode);
	int (*session_get_property)(
		struct hfi_cmd_session_get_property_packet *pkt,
		struct hal_session *session, enum hal_property ptype);
	int (*session_set_property)(
		struct hfi_cmd_session_set_property_packet *pkt,
		struct hal_session *session,
		enum hal_property ptype, void *pdata);
		u32 ptype, void *pdata, u32 size);
	int (*session_sync_process)(
		struct hfi_cmd_session_sync_process_packet *pkt,
		struct hal_session *session);
+113 −72
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/slab.h>
@@ -8,6 +8,8 @@
#include "msm_vdec.h"
#include "msm_vidc_internal.h"
#include "msm_vidc_common.h"
#include "vidc_hfi.h"
#include "vidc_hfi_helper.h"
#include "vidc_hfi_api.h"
#include "msm_vidc_debug.h"
#include "msm_vidc_clocks.h"
@@ -938,7 +940,7 @@ int msm_vdec_set_frame_size(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct hal_frame_size frame_sz;
	struct hfi_frame_size frame_size;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -946,13 +948,13 @@ int msm_vdec_set_frame_size(struct msm_vidc_inst *inst)
	}
	hdev = inst->core->device;

	frame_sz.buffer_type = HAL_BUFFER_INPUT;
	frame_sz.width = inst->prop.width[OUTPUT_PORT];
	frame_sz.height = inst->prop.height[OUTPUT_PORT];
	frame_size.buffer_type = HFI_BUFFER_INPUT;
	frame_size.width = inst->prop.width[OUTPUT_PORT];
	frame_size.height = inst->prop.height[OUTPUT_PORT];
	dprintk(VIDC_DBG, "%s: input wxh %dx%d\n", __func__,
		frame_sz.width, frame_sz.height);
		frame_size.width, frame_size.height);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_FRAME_SIZE, &frame_sz);
		HFI_PROPERTY_PARAM_FRAME_SIZE, &frame_size, sizeof(frame_size));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1072,7 +1074,7 @@ int msm_vdec_set_profile_level(struct msm_vidc_inst *inst)
	struct hfi_device *hdev;
	struct v4l2_ctrl *profile;
	struct v4l2_ctrl *level;
	struct hal_profile_level profile_level;
	struct hfi_profile_level profile_level;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1094,10 +1096,17 @@ int msm_vdec_set_profile_level(struct msm_vidc_inst *inst)
	}
	profile_level.profile = profile->val;
	profile_level.level = level->val;
	if (profile_level.profile <= 0) {
		profile_level.profile = HFI_H264_PROFILE_HIGH;
		dprintk(VIDC_WARN,
			"Profile %d not supported, falling back to high\n",
			profile->val);
	}
	dprintk(VIDC_DBG, "%s: %#x %#x\n", __func__,
		profile_level.profile, profile_level.level);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_PROFILE_LEVEL_CURRENT, &profile_level);
		HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, &profile_level,
		sizeof(profile_level));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1135,12 +1144,13 @@ int msm_vdec_set_output_order(struct msm_vidc_inst *inst)
	}
	dprintk(VIDC_DBG, "%s: %d\n", __func__, ctrl->val);
	if (ctrl->val == V4L2_MPEG_MSM_VIDC_ENABLE)
		output_order = HAL_OUTPUT_ORDER_DECODE;
		output_order = HFI_OUTPUT_ORDER_DECODE;
	else
		output_order = HAL_OUTPUT_ORDER_DISPLAY;
		output_order = HFI_OUTPUT_ORDER_DISPLAY;

	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_OUTPUT_ORDER, &output_order);
		HFI_PROPERTY_PARAM_VDEC_OUTPUT_ORDER, &output_order,
		sizeof(u32));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1152,7 +1162,7 @@ int msm_vdec_set_picture_type(struct msm_vidc_inst *inst)
	int rc = 0;
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl;
	struct hal_enable_picture enable_picture;
	struct hfi_enable_picture enable_picture;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1171,7 +1181,8 @@ int msm_vdec_set_picture_type(struct msm_vidc_inst *inst)

	dprintk(VIDC_DBG, "%s: %#x\n", __func__, enable_picture.picture_type);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_PICTURE_TYPE_DECODE, &enable_picture);
		HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE, &enable_picture,
		sizeof(enable_picture));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1183,7 +1194,7 @@ int msm_vdec_set_sync_frame_mode(struct msm_vidc_inst *inst)
	int rc = 0;
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl;
	struct hal_enable hal_property;
	struct hfi_enable hfi_property;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1198,11 +1209,12 @@ int msm_vdec_set_sync_frame_mode(struct msm_vidc_inst *inst)
			"%s: failed to get sync_frame_mode ctrl\n", __func__);
		return -EINVAL;
	}
	hal_property.enable = (bool)ctrl->val;
	hfi_property.enable = (bool)ctrl->val;

	dprintk(VIDC_DBG, "%s: %#x\n", __func__, hal_property.enable);
	dprintk(VIDC_DBG, "%s: %#x\n", __func__, hfi_property.enable);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_SYNC_FRAME_DECODE, &hal_property);
		HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE, &hfi_property,
		sizeof(hfi_property));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1230,7 +1242,7 @@ int msm_vdec_set_secure_mode(struct msm_vidc_inst *inst)

	dprintk(VIDC_DBG, "%s: %#x\n", __func__, ctrl->val);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
				HAL_PARAM_SECURE, &ctrl->val);
		HFI_PROPERTY_PARAM_SECURE_SESSION, &ctrl->val, sizeof(u32));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1241,8 +1253,8 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct hal_multi_stream multi_stream;
	struct hal_frame_size frame_sz;
	struct hfi_multi_stream multi_stream;
	struct hfi_frame_size frame_sz;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1251,20 +1263,22 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst)
	hdev = inst->core->device;

	if (is_primary_output_mode(inst)) {
		multi_stream.buffer_type = HAL_BUFFER_OUTPUT;
		multi_stream.buffer_type = HFI_BUFFER_OUTPUT;
		multi_stream.enable = true;
		rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream);
			HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM, &multi_stream,
			sizeof(multi_stream));
		if (rc) {
			dprintk(VIDC_ERR,
				"%s: set prop multistream primary failed : %d\n",
				__func__, rc);
			return rc;
		}
		multi_stream.buffer_type = HAL_BUFFER_OUTPUT2;
		multi_stream.buffer_type = HFI_BUFFER_OUTPUT2;
		multi_stream.enable = false;
		rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream);
			HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM, &multi_stream,
			sizeof(multi_stream));
		if (rc) {
			dprintk(VIDC_ERR,
				"%s: set prop multistream primary2 failed : %d\n",
@@ -1277,34 +1291,37 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst)
		if (rc)
			return rc;

		multi_stream.buffer_type = HAL_BUFFER_OUTPUT2;
		multi_stream.buffer_type = HFI_BUFFER_OUTPUT2;
		multi_stream.enable = true;
		rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream);
			HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM, &multi_stream,
			sizeof(multi_stream));
		if (rc) {
			dprintk(VIDC_ERR,
				"%s: set prop multistream secondary failed : %d\n",
				__func__, rc);
			return rc;
		}
		multi_stream.buffer_type = HAL_BUFFER_OUTPUT;
		multi_stream.buffer_type = HFI_BUFFER_OUTPUT;
		multi_stream.enable = false;
		rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream);
			HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM, &multi_stream,
			sizeof(multi_stream));
		if (rc) {
			dprintk(VIDC_ERR,
				"%s: set prop multistream secondary2 failed : %d\n",
				__func__, rc);
			return rc;
		}
		frame_sz.buffer_type = HAL_BUFFER_OUTPUT2;
		frame_sz.buffer_type = HFI_BUFFER_OUTPUT2;
		frame_sz.width = inst->prop.width[CAPTURE_PORT];
		frame_sz.height = inst->prop.height[CAPTURE_PORT];
		dprintk(VIDC_DBG,
			"frame_size: hal buffer type %d, width %d, height %d\n",
			frame_sz.buffer_type, frame_sz.width, frame_sz.height);
		rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_FRAME_SIZE, &frame_sz);
			HFI_PROPERTY_PARAM_FRAME_SIZE, &frame_sz,
			sizeof(frame_sz));
		if (rc) {
			dprintk(VIDC_ERR,
				"%s: set prop frame_size failed\n",
@@ -1321,7 +1338,7 @@ int msm_vdec_set_priority(struct msm_vidc_inst *inst)
	int rc = 0;
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl;
	struct hal_enable hal_property;
	struct hfi_enable hfi_property;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1335,11 +1352,12 @@ int msm_vdec_set_priority(struct msm_vidc_inst *inst)
			"%s: failed to get output_order ctrl\n", __func__);
		return -EINVAL;
	}
	hal_property.enable = (bool)ctrl->val;
	hfi_property.enable = (bool)ctrl->val;

	dprintk(VIDC_DBG, "%s: %#x\n", __func__, hal_property.enable);
	dprintk(VIDC_DBG, "%s: %#x\n", __func__, hfi_property.enable);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_CONFIG_REALTIME, &hal_property);
		HFI_PROPERTY_CONFIG_REALTIME, &hfi_property,
		sizeof(hfi_property));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1351,7 +1369,7 @@ int msm_vdec_set_operating_rate(struct msm_vidc_inst *inst)
	int rc = 0;
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl;
	struct hal_operating_rate operating_rate;
	struct hfi_operating_rate operating_rate;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1374,7 +1392,8 @@ int msm_vdec_set_operating_rate(struct msm_vidc_inst *inst)
	dprintk(VIDC_DBG, "%s: %#x\n", __func__,
			operating_rate.operating_rate);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_CONFIG_OPERATING_RATE, &operating_rate);
		HFI_PROPERTY_CONFIG_OPERATING_RATE, &operating_rate,
		sizeof(operating_rate));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1387,7 +1406,7 @@ int msm_vdec_set_conceal_color(struct msm_vidc_inst *inst)
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl_8b;
	struct v4l2_ctrl *ctrl_10b;
	struct hal_conceal_color conceal_color;
	struct hfi_conceal_color conceal_color;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -1418,7 +1437,8 @@ int msm_vdec_set_conceal_color(struct msm_vidc_inst *inst)
		conceal_color.conceal_color_8bit,
		conceal_color.conceal_color_10bit);
	rc = call_hfi_op(hdev, session_set_property, inst->session,
			HAL_PARAM_VDEC_CONCEAL_COLOR, &conceal_color);
		HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR, &conceal_color,
		sizeof(conceal_color));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

@@ -1428,7 +1448,7 @@ int msm_vdec_set_conceal_color(struct msm_vidc_inst *inst)

int msm_vdec_set_extradata(struct msm_vidc_inst *inst)
{
	uint32_t display_info = HAL_EXTRADATA_VUI_DISPLAY_INFO;
	uint32_t display_info = HFI_PROPERTY_PARAM_VUI_DISPLAY_INFO_EXTRADATA;
	struct v4l2_ctrl *ctrl;

	ctrl = msm_vdec_get_ctrl(inst, V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA);
@@ -1441,75 +1461,96 @@ int msm_vdec_set_extradata(struct msm_vidc_inst *inst)
	switch (inst->fmts[OUTPUT_PORT].fourcc) {
	case V4L2_PIX_FMT_H264:
	case V4L2_PIX_FMT_HEVC:
		display_info = HAL_EXTRADATA_VUI_DISPLAY_INFO;
		display_info = HFI_PROPERTY_PARAM_VUI_DISPLAY_INFO_EXTRADATA;
		break;
	case V4L2_PIX_FMT_VP8:
	case V4L2_PIX_FMT_VP9:
		display_info = HAL_EXTRADATA_VPX_COLORSPACE;
		display_info =
			HFI_PROPERTY_PARAM_VDEC_VPX_COLORSPACE_EXTRADATA;
		break;
	case V4L2_PIX_FMT_MPEG2:
		display_info = HAL_EXTRADATA_MPEG2_SEQDISP;
		display_info = HFI_PROPERTY_PARAM_VDEC_MPEG2_SEQDISP_EXTRADATA;
		break;
	}

	if (ctrl->val == EXTRADATA_NONE) {
		// Disable all Extradata
		msm_comm_set_extradata(inst, HAL_EXTRADATA_OUTPUT_CROP, 0x0);
		msm_comm_set_index_extradata(inst,
			MSM_VIDC_EXTRADATA_OUTPUT_CROP, 0x0);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_INTERLACE_VIDEO, 0x0);
			HFI_PROPERTY_PARAM_VDEC_INTERLACE_VIDEO_EXTRADATA, 0x0);
		msm_comm_set_extradata(inst, display_info, 0x0);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_UBWC_CR_STATS_INFO, 0x0);
			HFI_PROPERTY_PARAM_VDEC_UBWC_CR_STAT_INFO_EXTRADATA,
			0x0);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_NUM_CONCEALED_MB, 0x0);
			HFI_PROPERTY_PARAM_VDEC_NUM_CONCEALED_MB, 0x0);
		if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_HEVC) {
			msm_comm_set_extradata(inst,
				HAL_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI,
			HFI_PROPERTY_PARAM_VDEC_MASTER_DISP_COL_SEI_EXTRADATA,
			0x0);
			msm_comm_set_extradata(inst,
				HAL_EXTRADATA_CONTENT_LIGHT_LEVEL_SEI, 0x0);
			HFI_PROPERTY_PARAM_VDEC_CLL_SEI_EXTRADATA,
			0x0);
		}
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_STREAM_USERDATA, 0x0);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_TIMESTAMP, 0x0);
			HFI_PROPERTY_PARAM_VDEC_STREAM_USERDATA_EXTRADATA,
			0x0);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_TIMESTAMP_EXTRADATA, 0x0);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_S3D_FRAME_PACKING, 0x0);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_FRAME_RATE, 0x0);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_PANSCAN_WINDOW, 0x0);
			HFI_PROPERTY_PARAM_S3D_FRAME_PACKING_EXTRADATA, 0x0);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_FRAME_RATE_EXTRADATA, 0x0);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_PANSCAN_WNDW_EXTRADATA, 0x0);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_RECOVERY_POINT_SEI_EXTRADATA,
			0x0);
		msm_comm_set_index_extradata(inst,
			MSM_VIDC_EXTRADATA_ASPECT_RATIO, 0x0);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_RECOVERY_POINT_SEI, 0x0);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_ASPECT_RATIO, 0x0);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_FRAME_QP, 0x0);
			HFI_PROPERTY_PARAM_VDEC_FRAME_QP_EXTRADATA, 0x0);
	}
	if (ctrl->val & EXTRADATA_DEFAULT) {
		// Enable Default Extradata
		msm_comm_set_extradata(inst, HAL_EXTRADATA_OUTPUT_CROP, 0x1);
		msm_comm_set_index_extradata(inst,
			MSM_VIDC_EXTRADATA_OUTPUT_CROP, 0x1);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_INTERLACE_VIDEO, 0x1);
			HFI_PROPERTY_PARAM_VDEC_INTERLACE_VIDEO_EXTRADATA,
			0x1);
		msm_comm_set_extradata(inst, display_info, 0x1);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_NUM_CONCEALED_MB, 0x1);
			HFI_PROPERTY_PARAM_VDEC_NUM_CONCEALED_MB, 0x1);
		if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_HEVC) {
			msm_comm_set_extradata(inst,
				HAL_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI,
			HFI_PROPERTY_PARAM_VDEC_MASTER_DISP_COL_SEI_EXTRADATA,
			0x1);
			msm_comm_set_extradata(inst,
				HAL_EXTRADATA_CONTENT_LIGHT_LEVEL_SEI, 0x1);
			HFI_PROPERTY_PARAM_VDEC_CLL_SEI_EXTRADATA,
			0x1);
		}
	}
	if (ctrl->val & EXTRADATA_ADVANCED) {
		// Enable Advanced Extradata
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_STREAM_USERDATA, 0x1);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_TIMESTAMP, 0x1);
			HFI_PROPERTY_PARAM_VDEC_STREAM_USERDATA_EXTRADATA,
			0x1);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_TIMESTAMP_EXTRADATA, 0x1);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_S3D_FRAME_PACKING, 0x1);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_FRAME_RATE, 0x1);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_PANSCAN_WINDOW, 0x1);
			HFI_PROPERTY_PARAM_S3D_FRAME_PACKING_EXTRADATA, 0x1);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_FRAME_RATE_EXTRADATA, 0x1);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_PANSCAN_WNDW_EXTRADATA, 0x1);
		msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VDEC_RECOVERY_POINT_SEI_EXTRADATA,
			0x1);
		msm_comm_set_index_extradata(inst,
			MSM_VIDC_EXTRADATA_ASPECT_RATIO, 0x1);
		msm_comm_set_extradata(inst,
			HAL_EXTRADATA_RECOVERY_POINT_SEI, 0x1);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_ASPECT_RATIO, 0x1);
		msm_comm_set_extradata(inst, HAL_EXTRADATA_FRAME_QP, 0x1);
			HFI_PROPERTY_PARAM_VDEC_FRAME_QP_EXTRADATA, 0x1);
	}

	return 0;
+250 −154

File changed.

Preview size limit exceeded, changes collapsed.

+48 −96
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/dma-direction.h>
@@ -14,6 +14,8 @@
#include "msm_cvp.h"
#include "msm_vidc_common.h"
#include <linux/delay.h>
#include "vidc_hfi.h"
#include "vidc_hfi_helper.h"
#include "vidc_hfi_api.h"
#include "msm_vidc_clocks.h"
#include <linux/dma-buf.h>
@@ -30,7 +32,7 @@ static int get_poll_flags(void *instance)
	struct vb2_queue *capq = &inst->bufq[CAPTURE_PORT].vb2_bufq;
	struct vb2_buffer *out_vb = NULL;
	struct vb2_buffer *cap_vb = NULL;
	unsigned long flags;
	unsigned long flags = 0;
	int rc = 0;

	if (v4l2_event_pending(&inst->event_handler))
@@ -168,7 +170,7 @@ int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl)
	{
		prof_lev_supp = &inst->capability.profile_level;
		for (i = 0; i < prof_lev_supp->profile_count; i++) {
			v4l2_prof_value = msm_comm_hal_to_v4l2(ctrl->id,
			v4l2_prof_value = msm_comm_hfi_to_v4l2(ctrl->id,
				prof_lev_supp->profile_level[i].profile);
			if (v4l2_prof_value == -EINVAL) {
				dprintk(VIDC_WARN, "Invalid profile");
@@ -195,7 +197,7 @@ int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl)
		if (ctrl->id == V4L2_CID_MPEG_VIDEO_HEVC_LEVEL)
			max_level &= ~(0xF << 28);

		ctrl->maximum = msm_comm_hal_to_v4l2(ctrl->id, max_level);
		ctrl->maximum = msm_comm_hfi_to_v4l2(ctrl->id, max_level);
		if (ctrl->maximum == -EINVAL) {
			dprintk(VIDC_WARN, "Invalid max level");
			rc = -EINVAL;
@@ -874,14 +876,11 @@ int msm_vidc_set_internal_config(struct msm_vidc_inst *inst)
{
	int rc = 0;
	u32 rc_mode = RATE_CONTROL_OFF;
	bool set_rc = false;
	struct hal_vbv_hdr_buf_size hrd_buf_size;
	struct hal_enable latency;
	struct hfi_vbv_hdr_buf_size hrd_buf_size;
	struct hfi_enable latency;
	struct hfi_device *hdev;
	struct hal_multi_slice_control multi_slice_control;
	u32 codec;
	u32 mbps, mb_per_frame, fps, bitrate;
	u32 slice_val, slice_mode, max_avg_slicesize;
	u32 mbps, fps;
	u32 output_width, output_height;

	if (!inst || !inst->core || !inst->core->device) {
@@ -898,21 +897,12 @@ int msm_vidc_set_internal_config(struct msm_vidc_inst *inst)
	latency.enable =  msm_comm_g_ctrl_for_id(inst,
			V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE);

	if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_MBR_VFR) {
	if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_MBR_VFR)
		rc_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_MBR;
		set_rc = true;
	} else if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR &&
	else if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR &&
			   latency.enable == V4L2_MPEG_MSM_VIDC_ENABLE &&
			   codec != V4L2_PIX_FMT_VP8) {
			   codec != V4L2_PIX_FMT_VP8)
		rc_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
		set_rc = true;
	}

	if (set_rc) {
		rc = call_hfi_op(hdev, session_set_property,
			(void *)inst->session, HAL_PARAM_VENC_RATE_CONTROL,
			(void *)&rc_mode);
	}

	output_height = inst->prop.height[CAPTURE_PORT];
	output_width = inst->prop.width[CAPTURE_PORT];
@@ -931,60 +921,12 @@ int msm_vidc_set_internal_config(struct msm_vidc_inst *inst)
		dprintk(VIDC_DBG, "Enable hdr_buf_size %d :\n",
				hrd_buf_size.vbv_hdr_buf_size);
		rc = call_hfi_op(hdev, session_set_property,
			(void *)inst->session, HAL_CONFIG_VENC_VBV_HRD_BUF_SIZE,
			(void *)&hrd_buf_size);
			(void *)inst->session,
			HFI_PROPERTY_CONFIG_VENC_VBV_HRD_BUF_SIZE,
			(void *)&hrd_buf_size, sizeof(hrd_buf_size));
		inst->clk_data.low_latency_mode = true;
	}

	/* Update Slice Config */
	slice_mode =  msm_comm_g_ctrl_for_id(inst,
		 V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE);

	if ((codec == V4L2_PIX_FMT_H264 || codec == V4L2_PIX_FMT_HEVC) &&
		slice_mode != V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE) {
		bitrate = inst->clk_data.bitrate;
		mb_per_frame = NUM_MBS_PER_FRAME(output_height, output_width);

		if (rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR &&
				rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) {
			slice_mode = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
			slice_val = 0;
		} else if (slice_mode ==
				    V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) {
			if (output_width > 3840 || output_height > 3840 ||
				mb_per_frame > NUM_MBS_PER_FRAME(3840, 2160) ||
				fps > 60) {
				slice_mode =
					V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
				slice_val = 0;
			} else {
				slice_val = msm_comm_g_ctrl_for_id(inst,
				   V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB);
				slice_val = max(slice_val, mb_per_frame / 10);
			}
		} else {
			if (output_width > 1920 || output_height > 1920 ||
				mb_per_frame > NUM_MBS_PER_FRAME(1920, 1088) ||
				 fps > 30) {
				slice_mode =
					V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
				slice_val = 0;
			} else {
				slice_val = msm_comm_g_ctrl_for_id(inst,
				   V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES);
				max_avg_slicesize = ((bitrate / fps) / 8) / 10;
				slice_val =
					max(slice_val, max_avg_slicesize);
			}
		}

		multi_slice_control.multi_slice = slice_mode;
		multi_slice_control.slice_size = slice_val;

		rc = call_hfi_op(hdev, session_set_property,
		 (void *)inst->session, HAL_PARAM_VENC_MULTI_SLICE_CONTROL,
		 (void *)&multi_slice_control);
	}
	return rc;
}

@@ -993,8 +935,8 @@ static int msm_vidc_set_rotation(struct msm_vidc_inst *inst)
	int rc = 0;
	int value = 0, hflip = 0, vflip = 0;
	struct hfi_device *hdev;
	struct hal_vpe_rotation vpe_rotation;
	struct hal_frame_size frame_sz;
	struct hfi_vpe_rotation_type vpe_rotation;
	struct hfi_frame_size frame_sz;

	hdev = inst->core->device;

@@ -1004,7 +946,14 @@ static int msm_vidc_set_rotation(struct msm_vidc_inst *inst)
		dprintk(VIDC_ERR, "Get control for rotation failed\n");
		return value;
	}
	vpe_rotation.rotate = value;

	vpe_rotation.rotation = HFI_ROTATE_NONE;
	if (value == 90)
		vpe_rotation.rotation = HFI_ROTATE_90;
	else if (value == 180)
		vpe_rotation.rotation = HFI_ROTATE_180;
	else if (value ==  270)
		vpe_rotation.rotation = HFI_ROTATE_270;

	hflip = msm_comm_g_ctrl_for_id(inst, V4L2_CID_HFLIP);
	if (hflip < 0) {
@@ -1017,35 +966,38 @@ static int msm_vidc_set_rotation(struct msm_vidc_inst *inst)
		dprintk(VIDC_ERR, "Get control for vflip failed\n");
		return value;
	}

	vpe_rotation.flip = HFI_FLIP_NONE;
	if ((hflip == V4L2_MPEG_MSM_VIDC_ENABLE) &&
		(vflip == V4L2_MPEG_MSM_VIDC_ENABLE))
		vpe_rotation.flip = HAL_FLIP_BOTH;
		vpe_rotation.flip = HFI_FLIP_HORIZONTAL | HFI_FLIP_VERTICAL;
	else if (hflip == V4L2_MPEG_MSM_VIDC_ENABLE)
		vpe_rotation.flip = HAL_FLIP_HORIZONTAL;
		vpe_rotation.flip = HFI_FLIP_HORIZONTAL;
	else if (vflip == V4L2_MPEG_MSM_VIDC_ENABLE)
		vpe_rotation.flip = HAL_FLIP_VERTICAL;
	else
		vpe_rotation.flip = HAL_FLIP_NONE;
		vpe_rotation.flip = HFI_FLIP_VERTICAL;

	dprintk(VIDC_DBG, "Set rotation = %d, flip = %d for capture port.\n",
			vpe_rotation.rotate, vpe_rotation.flip);
			vpe_rotation.rotation, vpe_rotation.flip);
	rc = call_hfi_op(hdev, session_set_property,
				(void *)inst->session,
				HAL_PARAM_VPE_ROTATION, &vpe_rotation);
				HFI_PROPERTY_PARAM_VPE_ROTATION,
				&vpe_rotation, sizeof(vpe_rotation));
	if (rc) {
		dprintk(VIDC_ERR, "Set rotation/flip at start stream failed\n");
		return rc;
	}

	/* flip the output resolution if required */
	if (vpe_rotation.rotate == 90 || vpe_rotation.rotate == 270) {
		frame_sz.buffer_type = HAL_BUFFER_OUTPUT;
	if (vpe_rotation.rotation == HFI_ROTATE_90 ||
		vpe_rotation.rotation == HFI_ROTATE_270) {
		frame_sz.buffer_type = HFI_BUFFER_OUTPUT;
		frame_sz.width = inst->prop.height[CAPTURE_PORT];
		frame_sz.height = inst->prop.width[CAPTURE_PORT];
		dprintk(VIDC_DBG, "CAPTURE port width = %d, height = %d\n",
			frame_sz.width, frame_sz.height);
		rc = call_hfi_op(hdev, session_set_property, (void *)
			inst->session, HAL_PARAM_FRAME_SIZE, &frame_sz);
			inst->session, HFI_PROPERTY_PARAM_FRAME_SIZE,
			&frame_sz, sizeof(frame_sz));
		if (rc) {
			dprintk(VIDC_ERR,
				"Failed to set framesize for CAPTURE port\n");
@@ -1071,7 +1023,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct hal_buffer_size_minimum b;
	struct hfi_buffer_size_minimum b;

	dprintk(VIDC_DBG, "%s: %x : inst %pK\n", __func__,
		hash32_ptr(inst->session), inst);
@@ -1084,7 +1036,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
		goto fail_start;
	}

	b.buffer_type = HAL_BUFFER_OUTPUT;
	b.buffer_type = HFI_BUFFER_OUTPUT;
	if (inst->session_type == MSM_VIDC_ENCODER) {
		rc = msm_vidc_set_rotation(inst);
		if (rc) {
@@ -1094,7 +1046,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
		}
	} else if ((inst->session_type == MSM_VIDC_DECODER) &&
			(is_secondary_output_mode(inst)))
		b.buffer_type = HAL_BUFFER_OUTPUT2;
		b.buffer_type = HFI_BUFFER_OUTPUT2;

	/* HEIC HW/FWK tiling encode is supported only for CQ RC mode */
	if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) {
@@ -1156,8 +1108,8 @@ static inline int start_streaming(struct msm_vidc_inst *inst)

	b.buffer_size = inst->bufq[CAPTURE_PORT].plane_sizes[0];
	rc = call_hfi_op(hdev, session_set_property,
			inst->session, HAL_PARAM_BUFFER_SIZE_MINIMUM,
			&b);
			inst->session, HFI_PROPERTY_PARAM_BUFFER_SIZE_MINIMUM,
			&b, sizeof(b));

	/* Verify if buffer counts are correct */
	rc = msm_vidc_verify_buffer_counts(inst);
@@ -1685,12 +1637,12 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst,
	switch (ctrl->id) {

	case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
		ctrl->val = msm_comm_hal_to_v4l2(
		ctrl->val = msm_comm_hfi_to_v4l2(
			V4L2_CID_MPEG_VIDEO_H264_PROFILE,
			inst->profile);
		break;
	case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE:
		ctrl->val = msm_comm_hal_to_v4l2(
		ctrl->val = msm_comm_hfi_to_v4l2(
			V4L2_CID_MPEG_VIDEO_HEVC_PROFILE,
			inst->profile);
		break;
@@ -1698,17 +1650,17 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst,
		ctrl->val = inst->grid_enable;
		break;
	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
		ctrl->val = msm_comm_hal_to_v4l2(
		ctrl->val = msm_comm_hfi_to_v4l2(
			V4L2_CID_MPEG_VIDEO_H264_LEVEL,
			inst->level);
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL:
		ctrl->val = msm_comm_hal_to_v4l2(
		ctrl->val = msm_comm_hfi_to_v4l2(
			V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL,
			inst->level);
		break;
	case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:
		ctrl->val = msm_comm_hal_to_v4l2(
		ctrl->val = msm_comm_hfi_to_v4l2(
			V4L2_CID_MPEG_VIDEO_HEVC_LEVEL,
			inst->level);
		break;
Loading