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

Commit 66cc9a62 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: Remove support for k-k CVP usage"

parents fb49e0af 5a054656
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@ msm-vidc-objs := vidc/msm_v4l2_vidc.o \
                vidc/msm_vdec.o \
                vidc/msm_venc.o \
                vidc/msm_cvp_internal.o \
                vidc/msm_cvp_external.o \
                vidc/msm_smem.o \
                vidc/msm_vidc_debug.o \
                vidc/msm_vidc_res_parse.o \

msm/vidc/msm_cvp_external.c

deleted100644 → 0
+0 −1499

File deleted.

Preview size limit exceeded, changes collapsed.

msm/vidc/msm_cvp_external.h

deleted100644 → 0
+0 −202
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2019, The Linux Foundation. All rights reserved.
 */

#ifndef _MSM_CVP_EXTERNAL_H_
#define _MSM_CVP_EXTERNAL_H_

#include <media/msm_media_info.h>
#include <media/msm_cvp_private.h>
#include <media/msm_cvp_vidc.h>
#include "msm_vidc_internal.h"
#include "msm_vidc_debug.h"

#define CVP_DME                                 (24)

#define HFI_COMMON_BASE                         (0)
#define HFI_VIDEO_DOMAIN_CVP                    (HFI_COMMON_BASE + 0x8)
#define HFI_DOMAIN_BASE_COMMON                  (HFI_COMMON_BASE + 0)
#define HFI_DOMAIN_BASE_CVP                     (HFI_COMMON_BASE + 0x04000000)
#define HFI_ARCH_COMMON_OFFSET                  (0)
#define HFI_CMD_START_OFFSET                    (0x00010000)
#define HFI_CMD_SESSION_CVP_START \
		(HFI_DOMAIN_BASE_CVP + HFI_ARCH_COMMON_OFFSET +	\
		HFI_CMD_START_OFFSET + 0x1000)

#define HFI_CMD_SESSION_CVP_DME_FRAME \
		(HFI_CMD_SESSION_CVP_START + 0x03A)
#define HFI_CMD_SESSION_CVP_DME_BASIC_CONFIG \
		(HFI_CMD_SESSION_CVP_START + 0x03B)
#define HFI_CMD_SESSION_CVP_SET_PERSIST_BUFFERS \
		(HFI_CMD_SESSION_CVP_START + 0x04D)
#define HFI_CMD_SESSION_CVP_RELEASE_PERSIST_BUFFERS \
		(HFI_CMD_SESSION_CVP_START + 0x050)

#define HFI_DME_OUTPUT_BUFFER_SIZE              (256 * 4)
#define HFI_DME_INTERNAL_PERSIST_2_BUFFER_SIZE  (512 * 1024)
#define HFI_DME_FRAME_CONTEXT_BUFFER_SIZE       (64 * 1024)

#define CVP_KMD_HFI_VERSION_PROP_TYPE           (1)
#define CVP_KMD_HFI_VERSION_PROP_NUMBER	        (1)

#define CVP_FRAME_RATE_MAX                      (60)

static inline bool is_vidc_cvp_enabled(struct msm_vidc_inst *inst)
{
	return !!inst->cvp;
}

enum HFI_COLOR_PLANE_TYPE {
	HFI_COLOR_PLANE_METADATA,
	HFI_COLOR_PLANE_PICDATA,
	HFI_COLOR_PLANE_UV_META,
	HFI_COLOR_PLANE_UV,
	HFI_MAX_COLOR_PLANES
};

struct msm_cvp_color_plane_info {
	u32 stride[HFI_MAX_COLOR_PLANES];
	u32 buf_size[HFI_MAX_COLOR_PLANES];
};

struct msm_cvp_client_data {
	u32 transactionid;
	u32 client_data1;
	u32 client_data2;
	u32 kernel_data1;
	u32 kernel_data2;
	u32 reserved1;
	u32 reserved2;
};

struct msm_cvp_buffer_type {
	u32 buffer_addr;
	u32 size;
	u32 offset;
	u32 flags;
	u32 reserved1;
	u32 reserved2;
};

struct msm_cvp_session_release_persist_buffers_packet {
	u32 size;
	u32 packet_type;
	u32 sid;
	struct msm_cvp_client_data client_data;
	u32 cvp_op;
	struct msm_cvp_buffer_type persist1_buffer;
	struct msm_cvp_buffer_type persist2_buffer;
};

struct msm_cvp_session_set_persist_buffers_packet {
	u32 size;
	u32 packet_type;
	u32 sid;
	struct msm_cvp_client_data client_data;
	u32 cvp_op;
	struct msm_cvp_buffer_type persist1_buffer;
	struct msm_cvp_buffer_type persist2_buffer;
};

struct msm_cvp_dme_frame_packet {
	u32 size;
	u32 packet_type;
	u32 sid;
	struct msm_cvp_client_data client_data;
	u32 stream_idx;
	u32 skip_mv_calc;
	u32 min_fpx_threshold;
	u32 enable_descriptor_lpf;
	u32 enable_ncc_subpel;
	u32 descmatch_threshold;
	int ncc_robustness_threshold;
	u32 reserved[8];
	u32 buf_marker;
	struct msm_cvp_buffer_type fullres_srcbuffer;
	struct msm_cvp_buffer_type src_buffer;
	struct msm_cvp_buffer_type srcframe_contextbuffer;
	struct msm_cvp_buffer_type prsp_buffer;
	struct msm_cvp_buffer_type grid_buffer;
	struct msm_cvp_buffer_type ref_buffer;
	struct msm_cvp_buffer_type refframe_contextbuffer;
	struct msm_cvp_buffer_type videospatialtemporal_statsbuffer;
};

struct msm_cvp_dme_basic_config_packet {
	u32 size;
	u32 packet_type;
	u32 sid;
	struct msm_cvp_client_data client_data;
	u32 stream_idx;
	u32 srcbuffer_format;
	struct msm_cvp_color_plane_info srcbuffer_planeinfo;
	u32 src_width;
	u32 src_height;
	u32 fullres_width;
	u32 fullres_height;
	u32 fullresbuffer_format;
	struct msm_cvp_color_plane_info fullresbuffer_planeinfo;
	u32 ds_enable;
	u32 enable_lrme_robustness;
	u32 enable_inlier_tracking;
	u32 override_defaults;
	s32 inlier_step;
	s32 outlier_step;
	s32 follow_globalmotion_step;
	s32 nomv_conveyedinfo_step;
	s32 invalid_transform_step;
	s32 valid_transform_min_confidence_for_updates;
	u32 min_inlier_weight_threshold;
	u32 ncc_threshold;
	u32 min_allowed_tar_var;
	u32 meaningful_ncc_diff;
	u32 robustness_distmap[8];
	u32 ransac_threshold;
};

enum msm_vidc_cvp_buf_type {
	MSM_VIDC_CVP_INPUT_BUF = 1,
	MSM_VIDC_CVP_OUTPUT_BUF,
	MSM_VIDC_CVP_PERSIST_BUF,
	MSM_VIDC_CVP_CONTEXT_BUF
};

struct msm_cvp_buf {
	u32 index;
	u32 size;
	u32 offset;
	u32 buf_type;
	int fd;
	struct dma_buf *dbuf;
	void *kvaddr;
};

struct msm_cvp_external {
	void *priv;
	void *arg;
	u32 sid;
	u32 width;
	u32 height;
	u32 ds_width;
	u32 ds_height;
	u32 frame_rate;
	u32 operating_rate;
	bool downscale;
	u32 framecount;
	u32 buffer_idx;
	bool metadata_available;
	struct msm_cvp_buf fullres_buffer;
	struct msm_cvp_buf src_buffer;
	struct msm_cvp_buf ref_buffer;
	struct msm_cvp_buf output_buffer;
	struct msm_cvp_buf context_buffer;
	struct msm_cvp_buf refcontext_buffer;
	struct msm_cvp_buf persist2_buffer;
};

int msm_vidc_cvp_preprocess(struct msm_vidc_inst *inst,
		struct msm_vidc_buffer *mbuf);
int msm_vidc_cvp_prepare_preprocess(struct msm_vidc_inst *inst);
int msm_vidc_cvp_unprepare_preprocess(struct msm_vidc_inst *inst);
#endif
+24 −6
Original line number Diff line number Diff line
@@ -4349,11 +4349,25 @@ int msm_venc_set_extradata(struct msm_vidc_inst *inst)
		}
	}

	if(!msm_vidc_cvp_usage)
		inst->prop.extradata_ctrls &= ~EXTRADATA_ENC_INPUT_CVP;
	if (inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP) {
		struct v4l2_ctrl *max_layers = NULL;
		u32 value = 0x1;

	/* CVP extradata is common between user space and external CVP kernel to kernel.
	   Hence, skipping here and will be set after msm_vidc_prepare_preprocess in start_streaming*/
		max_layers = get_ctrl(inst,
			V4L2_CID_MPEG_VIDC_VIDEO_HEVC_MAX_HIER_CODING_LAYER);
		if (!msm_vidc_cvp_usage || max_layers->val > 1) {
			inst->prop.extradata_ctrls &= ~EXTRADATA_ENC_INPUT_CVP;
			value = 0x0;
		}
		s_vpr_h(inst->sid, "%s: CVP extradata %d\n", __func__, value);
		rc = msm_comm_set_extradata(inst,
			HFI_PROPERTY_PARAM_VENC_CVP_METADATA_EXTRADATA, value);
		if (rc)
			s_vpr_h(inst->sid,
				"%s: set CVP extradata failed\n", __func__);
	} else {
		s_vpr_h(inst->sid, "%s: CVP extradata not enabled\n", __func__);
	}

	return rc;
}
@@ -4391,7 +4405,8 @@ int msm_venc_set_cvp_skipratio(struct msm_vidc_inst *inst)
		d_vpr_e("%s: invalid params %pK\n", __func__, inst);
		return -EINVAL;
	}
	if (!msm_vidc_cvp_usage || !inst->core->resources.cvp_external)
	if (!msm_vidc_cvp_usage ||
		!(inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP))
		return 0;

	capture_rate_ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_CAPTURE_FRAME_RATE);
@@ -4662,6 +4677,9 @@ int msm_venc_set_properties(struct msm_vidc_inst *inst)
	if (rc)
		goto exit;
	rc = msm_venc_set_extradata(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_cvp_skipratio(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_operating_rate(inst);
+0 −178
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
#include "msm_vdec.h"
#include "msm_venc.h"
#include "msm_cvp_internal.h"
#include "msm_cvp_external.h"
#include "msm_vidc_common.h"
#include <linux/delay.h>
#include "vidc_hfi.h"
@@ -735,144 +734,6 @@ static int msm_vidc_set_properties(struct msm_vidc_inst *inst)
	return rc;
}

bool is_vidc_cvp_allowed(struct msm_vidc_inst *inst)
{
	bool allowed = false;
	struct msm_vidc_core *core;
	struct v4l2_ctrl *cvp_disable;
	struct v4l2_ctrl *superframe_enable;

	if (!inst || !inst->core) {
		d_vpr_e("%s: invalid params %pK\n", __func__, inst);
		goto exit;
	}
	core = inst->core;

	/*
	 * CVP enable if
	 * - platform support CVP external
	 * - client did not disable CVP forcefully
	 *      - client may disable forcefully to save power
	 * - client did not enable CVP extradata
	 *      - if enabled, client will give CVP extradata
	 * - rate control is not one of below modes
	 *      - RATE_CONTROL_OFF
	 *      - V4L2_MPEG_VIDEO_BITRATE_MODE_CQ
	 *      - V4L2_MPEG_VIDEO_BITRATE_MODE_CBR
	 * - not secure session
	 * - not superframe enabled
	 */
	cvp_disable = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VENC_CVP_DISABLE);
	superframe_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDC_SUPERFRAME);

	if (core->resources.cvp_external && !cvp_disable->val &&
		!(inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP) &&
		inst->rc_type != RATE_CONTROL_OFF &&
		inst->rc_type != V4L2_MPEG_VIDEO_BITRATE_MODE_CQ &&
		!inst->clk_data.is_legacy_cbr &&
		!superframe_enable->val) {
		s_vpr_h(inst->sid, "%s: cvp allowed\n", __func__);
		allowed = true;
	} else {
		s_vpr_h(inst->sid,
			"%s: cvp not allowed, cvp_external %d cvp_disable %d extradata %#x rc_type %d legacy_cbr %d secure %d superframe %d\n",
			__func__, core->resources.cvp_external,
			cvp_disable->val, inst->prop.extradata_ctrls,
			inst->rc_type, inst->clk_data.is_legacy_cbr,
			is_secure_session(inst), superframe_enable->val);
		allowed = false;
	}
	s_vpr_h(inst->sid, "%s: Hardcoded as cvp not allowed\n", __func__);
exit:
	return false;
}

static int msm_vidc_prepare_preprocess(struct msm_vidc_inst *inst)
{
	int rc = 0;

	if (!inst) {
		d_vpr_e("%s: invalid params\n", __func__);
		return -EINVAL;
	}

	if (!msm_vidc_cvp_usage) {
		s_vpr_h(inst->sid, "%s: cvp usage disabled\n", __func__);
		return 0;
	}

	if (!is_vidc_cvp_allowed(inst)) {
		s_vpr_h(inst->sid, "%s: cvp not allowed\n", __func__);
		return 0;
	}

	rc = msm_vidc_cvp_prepare_preprocess(inst);
	if (rc) {
		s_vpr_e(inst->sid, "%s: no cvp preprocessing\n", __func__);
		goto exit;
	}
	s_vpr_h(inst->sid, "%s: kernel to kernel cvp enabled\n", __func__);
	inst->prop.extradata_ctrls |= EXTRADATA_ENC_INPUT_KK_CVP;

exit:
	if (rc)
		msm_vidc_cvp_unprepare_preprocess(inst);
	return rc;
}

static bool msm_vidc_set_cvp_metadata(struct msm_vidc_inst *inst) {

	int rc = 0;
	u32 value = 0x0;

	if (!inst) {
		d_vpr_e("%s: invalid params\n", __func__);
		return false;
	}

	if ((inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP) ||
	    (inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_KK_CVP))
	    value = 0x1;

	s_vpr_h(inst->sid, "%s: CVP extradata %d\n", __func__, value);
	rc = msm_comm_set_extradata(inst,
		HFI_PROPERTY_PARAM_VENC_CVP_METADATA_EXTRADATA, value);
	if (rc) {
		s_vpr_e(inst->sid, "%s: set CVP extradata failed\n", __func__);
		return false;
	}

	if (inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_KK_CVP) {
		u32 cap_rate = 0;
		u32 cvp_rate = 0;
		u32 oprate = 0;
		u32 fps_max = CVP_FRAME_RATE_MAX << 16;

		if (inst->clk_data.operating_rate == INT_MAX)
			oprate = fps_max;
		else
			oprate = inst->clk_data.operating_rate;

		cap_rate = max(inst->clk_data.frame_rate, oprate);
		if (cap_rate > fps_max) {
			cap_rate = roundup(cap_rate, fps_max);
			cvp_rate = fps_max;
		}
		else
			cvp_rate = cap_rate;
		rc = msm_comm_set_cvp_skip_ratio(inst, cap_rate, cvp_rate);
	}
	else if(inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP)
		rc = msm_venc_set_cvp_skipratio(inst);

	if (rc) {
		s_vpr_e(inst->sid,
			"%s: set CVP skip ratio controls failed\n", __func__);
		return false;
	}
	return true;
}

static inline int start_streaming(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -889,17 +750,6 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
		goto fail_start;
	}

	if (is_encode_session(inst)) {
		rc = msm_vidc_prepare_preprocess(inst);
		if (rc) {
			s_vpr_e(inst->sid, "%s: no preprocessing\n", __func__);
			/* ignore error */
			rc = 0;
		}
		if (!(msm_vidc_set_cvp_metadata(inst)))
			goto fail_start;
	}

	b.buffer_type = HFI_BUFFER_OUTPUT;
	if (inst->session_type == MSM_VIDC_DECODER &&
		is_secondary_output_mode(inst))
@@ -1124,25 +974,6 @@ static int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count)
	return rc;
}

static int msm_vidc_unprepare_preprocess(struct msm_vidc_inst *inst)
{
	int rc = 0;

	if (!inst) {
		d_vpr_e("%s: invalid params\n", __func__);
		return -EINVAL;
	}

	if (!is_vidc_cvp_enabled(inst))
		return 0;

	rc = msm_vidc_cvp_unprepare_preprocess(inst);
	if (rc)
		s_vpr_e(inst->sid, "%s: failed rc %d\n", __func__, rc);

	return rc;
}

static inline int stop_streaming(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -1159,11 +990,6 @@ static inline int stop_streaming(struct msm_vidc_inst *inst)
				inst, MSM_VIDC_RELEASE_RESOURCES_DONE);

	if (is_encode_session(inst)) {
		rc = msm_vidc_unprepare_preprocess(inst);
		if (rc)
			s_vpr_e(inst->sid,
				"%s: failed to unprepare preprocess\n",
				__func__);
		inst->all_intra = false;
	}

@@ -1900,10 +1726,6 @@ int msm_vidc_close(void *instance)
	if (inst->session_type == MSM_VIDC_CVP)
		msm_cvp_inst_deinit(inst);

	/* clean up preprocess if not done already */
	if (is_encode_session(inst))
		msm_vidc_unprepare_preprocess(inst);

	msm_vidc_cleanup_instance(inst);

	rc = msm_comm_try_state(inst, MSM_VIDC_CORE_UNINIT);
Loading