Commit aa603389 authored by Stanimir Varbanov's avatar Stanimir Varbanov Committed by Mauro Carvalho Chehab
Browse files

media: venus: Create hfi platform and move vpp/vsp there



Introduce a new hfi platform to cover differences between hfi
versions. As a start move vpp/vsp freq data in that hfi
platform, more platform data will come later.

Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent c7f50ce5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@

venus-core-objs += core.o helpers.o firmware.o \
		   hfi_venus.o hfi_msgs.o hfi_cmds.o hfi.o \
		   hfi_parser.o pm_helpers.o dbgfs.o
		   hfi_parser.o pm_helpers.o dbgfs.o \
		   hfi_platform.o hfi_platform_v4.o \

venus-dec-objs += vdec.o vdec_ctrls.o
venus-enc-objs += venc.o venc_ctrls.o
+0 −17
Original line number Diff line number Diff line
@@ -486,17 +486,6 @@ static const struct freq_tbl sdm845_freq_table[] = {
	{  244800, 100000000 },	/* 1920x1080@30 */
};

static const struct codec_freq_data sdm845_codec_freq_data[] =  {
	{ V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675, 10 },
	{ V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675, 10 },
	{ V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675, 10 },
	{ V4L2_PIX_FMT_MPEG2, VIDC_SESSION_TYPE_DEC, 200, 10 },
	{ V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_DEC, 200, 10 },
	{ V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_DEC, 200, 10 },
	{ V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_DEC, 200, 10 },
	{ V4L2_PIX_FMT_VP9, VIDC_SESSION_TYPE_DEC, 200, 10 },
};

static const struct bw_tbl sdm845_bw_table_enc[] = {
	{ 1944000, 1612000, 0, 2416000, 0 },	/* 3840x2160@60 */
	{  972000,  951000, 0, 1434000, 0 },	/* 3840x2160@30 */
@@ -518,8 +507,6 @@ static const struct venus_resources sdm845_res = {
	.bw_tbl_enc_size = ARRAY_SIZE(sdm845_bw_table_enc),
	.bw_tbl_dec = sdm845_bw_table_dec,
	.bw_tbl_dec_size = ARRAY_SIZE(sdm845_bw_table_dec),
	.codec_freq_data = sdm845_codec_freq_data,
	.codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data),
	.clks = {"core", "iface", "bus" },
	.clks_num = 3,
	.vcodec0_clks = { "core", "bus" },
@@ -541,8 +528,6 @@ static const struct venus_resources sdm845_res_v2 = {
	.bw_tbl_enc_size = ARRAY_SIZE(sdm845_bw_table_enc),
	.bw_tbl_dec = sdm845_bw_table_dec,
	.bw_tbl_dec_size = ARRAY_SIZE(sdm845_bw_table_dec),
	.codec_freq_data = sdm845_codec_freq_data,
	.codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data),
	.clks = {"core", "iface", "bus" },
	.clks_num = 3,
	.vcodec0_clks = { "vcodec0_core", "vcodec0_bus" },
@@ -592,8 +577,6 @@ static const struct venus_resources sc7180_res = {
	.bw_tbl_enc_size = ARRAY_SIZE(sc7180_bw_table_enc),
	.bw_tbl_dec = sc7180_bw_table_dec,
	.bw_tbl_dec_size = ARRAY_SIZE(sc7180_bw_table_dec),
	.codec_freq_data = sdm845_codec_freq_data,
	.codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data),
	.clks = {"core", "iface", "bus" },
	.clks_num = 3,
	.vcodec0_clks = { "vcodec0_core", "vcodec0_bus" },
+2 −10
Original line number Diff line number Diff line
@@ -36,13 +36,6 @@ struct reg_val {
	u32 value;
};

struct codec_freq_data {
	u32 pixfmt;
	u32 session_type;
	unsigned long vpp_freq;
	unsigned long vsp_freq;
};

struct bw_tbl {
	u32 mbs_per_sec;
	u32 avg;
@@ -61,8 +54,6 @@ struct venus_resources {
	unsigned int bw_tbl_dec_size;
	const struct reg_val *reg_tbl;
	unsigned int reg_tbl_size;
	const struct codec_freq_data *codec_freq_data;
	unsigned int codec_freq_data_size;
	const char * const clks[VIDC_CLKS_NUM_MAX];
	unsigned int clks_num;
	const char * const vcodec0_clks[VIDC_VCODEC_CLKS_NUM_MAX];
@@ -266,7 +257,8 @@ struct venus_buffer {
struct clock_data {
	u32 core_id;
	unsigned long freq;
	const struct codec_freq_data *codec_freq_data;
	unsigned long vpp_freq;
	unsigned long vsp_freq;
};

#define to_venus_buffer(ptr)	container_of(ptr, struct venus_buffer, vb)
+24 −30
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "helpers.h"
#include "hfi_helper.h"
#include "pm_helpers.h"
#include "hfi_platform.h"

struct intbuf {
	struct list_head list;
@@ -1042,36 +1043,6 @@ int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode)
}
EXPORT_SYMBOL_GPL(venus_helper_set_work_mode);

int venus_helper_init_codec_freq_data(struct venus_inst *inst)
{
	const struct codec_freq_data *data;
	unsigned int i, data_size;
	u32 pixfmt;
	int ret = 0;

	if (!IS_V4(inst->core))
		return 0;

	data = inst->core->res->codec_freq_data;
	data_size = inst->core->res->codec_freq_data_size;
	pixfmt = inst->session_type == VIDC_SESSION_TYPE_DEC ?
			inst->fmt_out->pixfmt : inst->fmt_cap->pixfmt;

	for (i = 0; i < data_size; i++) {
		if (data[i].pixfmt == pixfmt &&
		    data[i].session_type == inst->session_type) {
			inst->clk_data.codec_freq_data = &data[i];
			break;
		}
	}

	if (!inst->clk_data.codec_freq_data)
		ret = -EINVAL;

	return ret;
}
EXPORT_SYMBOL_GPL(venus_helper_init_codec_freq_data);

int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
			      unsigned int output_bufs,
			      unsigned int output2_bufs)
@@ -1527,6 +1498,29 @@ void venus_helper_m2m_job_abort(void *priv)
}
EXPORT_SYMBOL_GPL(venus_helper_m2m_job_abort);

int venus_helper_session_init(struct venus_inst *inst)
{
	enum hfi_version version = inst->core->res->hfi_version;
	u32 session_type = inst->session_type;
	u32 codec;
	int ret;

	codec = inst->session_type == VIDC_SESSION_TYPE_DEC ?
			inst->fmt_out->pixfmt : inst->fmt_cap->pixfmt;

	ret = hfi_session_init(inst, codec);
	if (ret)
		return ret;

	inst->clk_data.vpp_freq = hfi_platform_get_codec_vpp_freq(version, codec,
								  session_type);
	inst->clk_data.vsp_freq = hfi_platform_get_codec_vsp_freq(version, codec,
								  session_type);

	return 0;
}
EXPORT_SYMBOL_GPL(venus_helper_session_init);

void venus_helper_init_instance(struct venus_inst *inst)
{
	if (inst->session_type == VIDC_SESSION_TYPE_DEC) {
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ int venus_helper_set_output_resolution(struct venus_inst *inst,
				       unsigned int width, unsigned int height,
				       u32 buftype);
int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode);
int venus_helper_init_codec_freq_data(struct venus_inst *inst);
int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
			      unsigned int output_bufs,
			      unsigned int output2_bufs);
@@ -48,6 +47,7 @@ unsigned int venus_helper_get_opb_size(struct venus_inst *inst);
void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf);
void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx);
void venus_helper_init_instance(struct venus_inst *inst);
int venus_helper_session_init(struct venus_inst *inst);
int venus_helper_get_out_fmts(struct venus_inst *inst, u32 fmt, u32 *out_fmt,
			      u32 *out2_fmt, bool ubwc);
int venus_helper_alloc_dpb_bufs(struct venus_inst *inst);
Loading