xref: /linux/drivers/media/platform/qcom/iris/iris_vpu2.c (revision 6dfafbd0299a60bfb5d5e277fdf100037c7ded07)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4  */
5 
6 #include <linux/bits.h>
7 #include <linux/iopoll.h>
8 #include <linux/reset.h>
9 
10 #include "iris_instance.h"
11 #include "iris_vpu_common.h"
12 
13 #include "iris_vpu_register_defines.h"
14 
15 static u64 iris_vpu2_calc_freq(struct iris_inst *inst, size_t data_size)
16 {
17 	struct platform_inst_caps *caps = inst->core->iris_platform_data->inst_caps;
18 	struct v4l2_format *inp_f = inst->fmt_src;
19 	u32 mbs_per_second, mbpf, height, width;
20 	unsigned long vpp_freq, vsp_freq;
21 	u32 fps = DEFAULT_FPS;
22 
23 	width = max(inp_f->fmt.pix_mp.width, inst->crop.width);
24 	height = max(inp_f->fmt.pix_mp.height, inst->crop.height);
25 
26 	mbpf = NUM_MBS_PER_FRAME(height, width);
27 	mbs_per_second = mbpf * fps;
28 
29 	vpp_freq = mbs_per_second * caps->mb_cycles_vpp;
30 
31 	/* 21 / 20 is overhead factor */
32 	vpp_freq += vpp_freq / 20;
33 	vsp_freq = mbs_per_second * caps->mb_cycles_vsp;
34 
35 	/* 10 / 7 is overhead factor */
36 	vsp_freq += ((fps * data_size * 8) * 10) / 7;
37 
38 	return max(vpp_freq, vsp_freq);
39 }
40 
41 const struct vpu_ops iris_vpu2_ops = {
42 	.power_off_hw = iris_vpu_power_off_hw,
43 	.power_on_hw = iris_vpu_power_on_hw,
44 	.power_off_controller = iris_vpu_power_off_controller,
45 	.power_on_controller = iris_vpu_power_on_controller,
46 	.calc_freq = iris_vpu2_calc_freq,
47 };
48