xref: /linux/drivers/gpu/drm/rockchip/rockchip_drm_vop.h (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
19c92ab61SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
22048e328SMark Yao /*
32048e328SMark Yao  * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
42048e328SMark Yao  * Author:Mark Yao <mark.yao@rock-chips.com>
52048e328SMark Yao  */
62048e328SMark Yao 
72048e328SMark Yao #ifndef _ROCKCHIP_DRM_VOP_H
82048e328SMark Yao #define _ROCKCHIP_DRM_VOP_H
92048e328SMark Yao 
10eb5cb6aaSMark yao /*
11eb5cb6aaSMark yao  * major: IP major version, used for IP structure
12eb5cb6aaSMark yao  * minor: big feature change under same structure
13eb5cb6aaSMark yao  */
14eb5cb6aaSMark yao #define VOP_VERSION(major, minor)	((major) << 8 | (minor))
15eb5cb6aaSMark yao #define VOP_MAJOR(version)		((version) >> 8)
16eb5cb6aaSMark yao #define VOP_MINOR(version)		((version) & 0xff)
17eb5cb6aaSMark yao 
181c21aa8fSDaniele Castagna #define NUM_YUV2YUV_COEFFICIENTS 12
191c21aa8fSDaniele Castagna 
205f94e357SAlyssa Rosenzweig /* AFBC supports a number of configurable modes. Relevant to us is block size
215f94e357SAlyssa Rosenzweig  * (16x16 or 32x8), storage modifiers (SPARSE, SPLIT), and the YUV-like
225f94e357SAlyssa Rosenzweig  * colourspace transform (YTR). 16x16 SPARSE mode is always used. SPLIT mode
235f94e357SAlyssa Rosenzweig  * could be enabled via the hreg_block_split register, but is not currently
245f94e357SAlyssa Rosenzweig  * handled. The colourspace transform is implicitly always assumed by the
255f94e357SAlyssa Rosenzweig  * decoder, so consumers must use this transform as well.
265f94e357SAlyssa Rosenzweig  *
275f94e357SAlyssa Rosenzweig  * Failure to match modifiers will cause errors displaying AFBC buffers
285f94e357SAlyssa Rosenzweig  * produced by conformant AFBC producers, including Mesa.
295f94e357SAlyssa Rosenzweig  */
307707f722SAndrzej Pietrasiewicz #define ROCKCHIP_AFBC_MOD \
317707f722SAndrzej Pietrasiewicz 	DRM_FORMAT_MOD_ARM_AFBC( \
327707f722SAndrzej Pietrasiewicz 		AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE \
335f94e357SAlyssa Rosenzweig 			| AFBC_FORMAT_MOD_YTR \
347707f722SAndrzej Pietrasiewicz 	)
357707f722SAndrzej Pietrasiewicz 
36a67719d1SMark Yao enum vop_data_format {
37a67719d1SMark Yao 	VOP_FMT_ARGB8888 = 0,
38a67719d1SMark Yao 	VOP_FMT_RGB888,
39a67719d1SMark Yao 	VOP_FMT_RGB565,
40a67719d1SMark Yao 	VOP_FMT_YUV420SP = 4,
41a67719d1SMark Yao 	VOP_FMT_YUV422SP,
42a67719d1SMark Yao 	VOP_FMT_YUV444SP,
43a67719d1SMark Yao };
44a67719d1SMark Yao 
458e140cb6SSascha Hauer struct vop_rect {
468e140cb6SSascha Hauer 	int width;
478e140cb6SSascha Hauer 	int height;
488e140cb6SSascha Hauer };
498e140cb6SSascha Hauer 
50a67719d1SMark Yao struct vop_reg {
51a67719d1SMark Yao 	uint32_t mask;
529a61c54bSMark yao 	uint16_t offset;
539a61c54bSMark yao 	uint8_t shift;
54d49463ecSMark Yao 	bool write_mask;
559548e1b4SMark yao 	bool relaxed;
56a67719d1SMark Yao };
57a67719d1SMark Yao 
587707f722SAndrzej Pietrasiewicz struct vop_afbc {
597707f722SAndrzej Pietrasiewicz 	struct vop_reg enable;
607707f722SAndrzej Pietrasiewicz 	struct vop_reg win_sel;
617707f722SAndrzej Pietrasiewicz 	struct vop_reg format;
62604be855SAndy Yan 	struct vop_reg rb_swap;
63604be855SAndy Yan 	struct vop_reg uv_swap;
64604be855SAndy Yan 	struct vop_reg auto_gating_en;
65604be855SAndy Yan 	struct vop_reg block_split_en;
66604be855SAndy Yan 	struct vop_reg pic_vir_width;
67604be855SAndy Yan 	struct vop_reg tile_num;
687707f722SAndrzej Pietrasiewicz 	struct vop_reg hreg_block_split;
69604be855SAndy Yan 	struct vop_reg pic_offset;
707707f722SAndrzej Pietrasiewicz 	struct vop_reg pic_size;
71604be855SAndy Yan 	struct vop_reg dsp_offset;
72604be855SAndy Yan 	struct vop_reg transform_offset;
737707f722SAndrzej Pietrasiewicz 	struct vop_reg hdr_ptr;
74604be855SAndy Yan 	struct vop_reg half_block_en;
75604be855SAndy Yan 	struct vop_reg xmirror;
76604be855SAndy Yan 	struct vop_reg ymirror;
77604be855SAndy Yan 	struct vop_reg rotate_270;
78604be855SAndy Yan 	struct vop_reg rotate_90;
797707f722SAndrzej Pietrasiewicz 	struct vop_reg rstn;
807707f722SAndrzej Pietrasiewicz };
817707f722SAndrzej Pietrasiewicz 
829a61c54bSMark yao struct vop_modeset {
839a61c54bSMark yao 	struct vop_reg htotal_pw;
849a61c54bSMark yao 	struct vop_reg hact_st_end;
859a61c54bSMark yao 	struct vop_reg hpost_st_end;
869a61c54bSMark yao 	struct vop_reg vtotal_pw;
879a61c54bSMark yao 	struct vop_reg vact_st_end;
889a61c54bSMark yao 	struct vop_reg vpost_st_end;
899a61c54bSMark yao };
909a61c54bSMark yao 
919a61c54bSMark yao struct vop_output {
929a61c54bSMark yao 	struct vop_reg pin_pol;
939a61c54bSMark yao 	struct vop_reg dp_pin_pol;
941f6c62caSNickey Yang 	struct vop_reg dp_dclk_pol;
959a61c54bSMark yao 	struct vop_reg edp_pin_pol;
961f6c62caSNickey Yang 	struct vop_reg edp_dclk_pol;
979a61c54bSMark yao 	struct vop_reg hdmi_pin_pol;
981f6c62caSNickey Yang 	struct vop_reg hdmi_dclk_pol;
999a61c54bSMark yao 	struct vop_reg mipi_pin_pol;
1001f6c62caSNickey Yang 	struct vop_reg mipi_dclk_pol;
1019a61c54bSMark yao 	struct vop_reg rgb_pin_pol;
1021f6c62caSNickey Yang 	struct vop_reg rgb_dclk_pol;
1039a61c54bSMark yao 	struct vop_reg dp_en;
104a67719d1SMark Yao 	struct vop_reg edp_en;
105a67719d1SMark Yao 	struct vop_reg hdmi_en;
106a67719d1SMark Yao 	struct vop_reg mipi_en;
107cf6d100dSHeiko Stuebner 	struct vop_reg mipi_dual_channel_en;
1089a61c54bSMark yao 	struct vop_reg rgb_en;
1099a61c54bSMark yao };
1109a61c54bSMark yao 
1119a61c54bSMark yao struct vop_common {
1129a61c54bSMark yao 	struct vop_reg cfg_done;
11360b7ae7fSMark yao 	struct vop_reg dsp_blank;
1149a61c54bSMark yao 	struct vop_reg data_blank;
1156bda8112SMark Yao 	struct vop_reg pre_dither_down;
116a5c0fa44SUrja Rannikko 	struct vop_reg dither_down_sel;
117a5c0fa44SUrja Rannikko 	struct vop_reg dither_down_mode;
118a5c0fa44SUrja Rannikko 	struct vop_reg dither_down_en;
119a67719d1SMark Yao 	struct vop_reg dither_up;
120b23ab6acSEzequiel Garcia 	struct vop_reg dsp_lut_en;
1213ba000d6SHugh Cole-Baker 	struct vop_reg update_gamma_lut;
1223ba000d6SHugh Cole-Baker 	struct vop_reg lut_buffer_index;
1239a61c54bSMark yao 	struct vop_reg gate_en;
1249a61c54bSMark yao 	struct vop_reg mmu_en;
125*6b44aa55SVal Packett 	struct vop_reg dma_stop;
1269a61c54bSMark yao 	struct vop_reg out_mode;
1279a61c54bSMark yao 	struct vop_reg standby;
1289a61c54bSMark yao };
129a67719d1SMark Yao 
1309a61c54bSMark yao struct vop_misc {
13160b7ae7fSMark yao 	struct vop_reg global_regdone_en;
132a67719d1SMark Yao };
133a67719d1SMark Yao 
134a67719d1SMark Yao struct vop_intr {
135a67719d1SMark Yao 	const int *intrs;
136a67719d1SMark Yao 	uint32_t nintrs;
137ac6560dfSMark yao 
138ac6560dfSMark yao 	struct vop_reg line_flag_num[2];
139a67719d1SMark Yao 	struct vop_reg enable;
140a67719d1SMark Yao 	struct vop_reg clear;
141a67719d1SMark Yao 	struct vop_reg status;
142a67719d1SMark Yao };
1431194fffbSMark Yao 
1441194fffbSMark Yao struct vop_scl_extension {
145a67719d1SMark Yao 	struct vop_reg cbcr_vsd_mode;
146a67719d1SMark Yao 	struct vop_reg cbcr_vsu_mode;
147a67719d1SMark Yao 	struct vop_reg cbcr_hsd_mode;
148a67719d1SMark Yao 	struct vop_reg cbcr_ver_scl_mode;
149a67719d1SMark Yao 	struct vop_reg cbcr_hor_scl_mode;
150a67719d1SMark Yao 	struct vop_reg yrgb_vsd_mode;
151a67719d1SMark Yao 	struct vop_reg yrgb_vsu_mode;
152a67719d1SMark Yao 	struct vop_reg yrgb_hsd_mode;
153a67719d1SMark Yao 	struct vop_reg yrgb_ver_scl_mode;
154a67719d1SMark Yao 	struct vop_reg yrgb_hor_scl_mode;
155a67719d1SMark Yao 	struct vop_reg line_load_mode;
156a67719d1SMark Yao 	struct vop_reg cbcr_axi_gather_num;
157a67719d1SMark Yao 	struct vop_reg yrgb_axi_gather_num;
158a67719d1SMark Yao 	struct vop_reg vsd_cbcr_gt2;
159a67719d1SMark Yao 	struct vop_reg vsd_cbcr_gt4;
160a67719d1SMark Yao 	struct vop_reg vsd_yrgb_gt2;
161a67719d1SMark Yao 	struct vop_reg vsd_yrgb_gt4;
162a67719d1SMark Yao 	struct vop_reg bic_coe_sel;
163a67719d1SMark Yao 	struct vop_reg cbcr_axi_gather_en;
164a67719d1SMark Yao 	struct vop_reg yrgb_axi_gather_en;
165a67719d1SMark Yao 	struct vop_reg lb_mode;
1661194fffbSMark Yao };
1671194fffbSMark Yao 
1681194fffbSMark Yao struct vop_scl_regs {
1691194fffbSMark Yao 	const struct vop_scl_extension *ext;
1701194fffbSMark Yao 
171a67719d1SMark Yao 	struct vop_reg scale_yrgb_x;
172a67719d1SMark Yao 	struct vop_reg scale_yrgb_y;
173a67719d1SMark Yao 	struct vop_reg scale_cbcr_x;
174a67719d1SMark Yao 	struct vop_reg scale_cbcr_y;
175a67719d1SMark Yao };
176a67719d1SMark Yao 
1771c21aa8fSDaniele Castagna struct vop_yuv2yuv_phy {
1781c21aa8fSDaniele Castagna 	struct vop_reg y2r_coefficients[NUM_YUV2YUV_COEFFICIENTS];
1791c21aa8fSDaniele Castagna };
1801c21aa8fSDaniele Castagna 
181a67719d1SMark Yao struct vop_win_phy {
182a67719d1SMark Yao 	const struct vop_scl_regs *scl;
183a67719d1SMark Yao 	const uint32_t *data_formats;
184a67719d1SMark Yao 	uint32_t nformats;
1857707f722SAndrzej Pietrasiewicz 	const uint64_t *format_modifiers;
186a67719d1SMark Yao 
187a67719d1SMark Yao 	struct vop_reg enable;
18860b7ae7fSMark yao 	struct vop_reg gate;
189a67719d1SMark Yao 	struct vop_reg format;
190d4b38422SJonas Karlman 	struct vop_reg fmt_10;
191a67719d1SMark Yao 	struct vop_reg rb_swap;
1923fa50896SChen-Yu Tsai 	struct vop_reg uv_swap;
193a67719d1SMark Yao 	struct vop_reg act_info;
194a67719d1SMark Yao 	struct vop_reg dsp_info;
195a67719d1SMark Yao 	struct vop_reg dsp_st;
196a67719d1SMark Yao 	struct vop_reg yrgb_mst;
197a67719d1SMark Yao 	struct vop_reg uv_mst;
198a67719d1SMark Yao 	struct vop_reg yrgb_vir;
199a67719d1SMark Yao 	struct vop_reg uv_vir;
200677e8bbcSDaniele Castagna 	struct vop_reg y_mir_en;
201677e8bbcSDaniele Castagna 	struct vop_reg x_mir_en;
202a67719d1SMark Yao 
203a67719d1SMark Yao 	struct vop_reg dst_alpha_ctl;
204a67719d1SMark Yao 	struct vop_reg src_alpha_ctl;
2052aae8ed1SPaul Kocialkowski 	struct vop_reg alpha_pre_mul;
2062aae8ed1SPaul Kocialkowski 	struct vop_reg alpha_mode;
2072aae8ed1SPaul Kocialkowski 	struct vop_reg alpha_en;
2089dd2aca4SMark yao 	struct vop_reg channel;
209a67719d1SMark Yao };
210a67719d1SMark Yao 
2111c21aa8fSDaniele Castagna struct vop_win_yuv2yuv_data {
2121c21aa8fSDaniele Castagna 	uint32_t base;
2131c21aa8fSDaniele Castagna 	const struct vop_yuv2yuv_phy *phy;
2141c21aa8fSDaniele Castagna 	struct vop_reg y2r_en;
2151c21aa8fSDaniele Castagna };
2161c21aa8fSDaniele Castagna 
217a67719d1SMark Yao struct vop_win_data {
218a67719d1SMark Yao 	uint32_t base;
219a67719d1SMark Yao 	const struct vop_win_phy *phy;
220a67719d1SMark Yao 	enum drm_plane_type type;
221a67719d1SMark Yao };
222a67719d1SMark Yao 
223a67719d1SMark Yao struct vop_data {
224eb5cb6aaSMark yao 	uint32_t version;
225a67719d1SMark Yao 	const struct vop_intr *intr;
2269a61c54bSMark yao 	const struct vop_common *common;
2279a61c54bSMark yao 	const struct vop_misc *misc;
2289a61c54bSMark yao 	const struct vop_modeset *modeset;
2299a61c54bSMark yao 	const struct vop_output *output;
2307707f722SAndrzej Pietrasiewicz 	const struct vop_afbc *afbc;
2311c21aa8fSDaniele Castagna 	const struct vop_win_yuv2yuv_data *win_yuv2yuv;
232a67719d1SMark Yao 	const struct vop_win_data *win;
233a67719d1SMark Yao 	unsigned int win_size;
234b23ab6acSEzequiel Garcia 	unsigned int lut_size;
2358e140cb6SSascha Hauer 	struct vop_rect max_output;
236efd11cc8SMark yao 
237efd11cc8SMark yao #define VOP_FEATURE_OUTPUT_RGB10	BIT(0)
2381f0f0151SSandy Huang #define VOP_FEATURE_INTERNAL_RGB	BIT(1)
239efd11cc8SMark yao 	u64 feature;
240a67719d1SMark Yao };
2412048e328SMark Yao 
2422048e328SMark Yao /* interrupt define */
2432048e328SMark Yao #define DSP_HOLD_VALID_INTR		(1 << 0)
2442048e328SMark Yao #define FS_INTR				(1 << 1)
2452048e328SMark Yao #define LINE_FLAG_INTR			(1 << 2)
2462048e328SMark Yao #define BUS_ERROR_INTR			(1 << 3)
2472048e328SMark Yao 
2482048e328SMark Yao #define INTR_MASK			(DSP_HOLD_VALID_INTR | FS_INTR | \
2492048e328SMark Yao 					 LINE_FLAG_INTR | BUS_ERROR_INTR)
2502048e328SMark Yao 
2512048e328SMark Yao #define DSP_HOLD_VALID_INTR_EN(x)	((x) << 4)
2522048e328SMark Yao #define FS_INTR_EN(x)			((x) << 5)
2532048e328SMark Yao #define LINE_FLAG_INTR_EN(x)		((x) << 6)
2542048e328SMark Yao #define BUS_ERROR_INTR_EN(x)		((x) << 7)
2552048e328SMark Yao #define DSP_HOLD_VALID_INTR_MASK	(1 << 4)
2562048e328SMark Yao #define FS_INTR_MASK			(1 << 5)
2572048e328SMark Yao #define LINE_FLAG_INTR_MASK		(1 << 6)
2582048e328SMark Yao #define BUS_ERROR_INTR_MASK		(1 << 7)
2592048e328SMark Yao 
2602048e328SMark Yao #define INTR_CLR_SHIFT			8
2612048e328SMark Yao #define DSP_HOLD_VALID_INTR_CLR		(1 << (INTR_CLR_SHIFT + 0))
2622048e328SMark Yao #define FS_INTR_CLR			(1 << (INTR_CLR_SHIFT + 1))
2632048e328SMark Yao #define LINE_FLAG_INTR_CLR		(1 << (INTR_CLR_SHIFT + 2))
2642048e328SMark Yao #define BUS_ERROR_INTR_CLR		(1 << (INTR_CLR_SHIFT + 3))
2652048e328SMark Yao 
2662048e328SMark Yao #define DSP_LINE_NUM(x)			(((x) & 0x1fff) << 12)
2672048e328SMark Yao #define DSP_LINE_NUM_MASK		(0x1fff << 12)
2682048e328SMark Yao 
2692048e328SMark Yao /* src alpha ctrl define */
2702048e328SMark Yao #define SRC_FADING_VALUE(x)		(((x) & 0xff) << 24)
2712048e328SMark Yao #define SRC_GLOBAL_ALPHA(x)		(((x) & 0xff) << 16)
2722048e328SMark Yao #define SRC_FACTOR_M0(x)		(((x) & 0x7) << 6)
2732048e328SMark Yao #define SRC_ALPHA_CAL_M0(x)		(((x) & 0x1) << 5)
2742048e328SMark Yao #define SRC_BLEND_M0(x)			(((x) & 0x3) << 3)
2752048e328SMark Yao #define SRC_ALPHA_M0(x)			(((x) & 0x1) << 2)
2762048e328SMark Yao #define SRC_COLOR_M0(x)			(((x) & 0x1) << 1)
2772048e328SMark Yao #define SRC_ALPHA_EN(x)			(((x) & 0x1) << 0)
2782048e328SMark Yao /* dst alpha ctrl define */
2792048e328SMark Yao #define DST_FACTOR_M0(x)		(((x) & 0x7) << 6)
2802048e328SMark Yao 
2812048e328SMark Yao enum alpha_mode {
2822048e328SMark Yao 	ALPHA_STRAIGHT,
2832048e328SMark Yao 	ALPHA_INVERSE,
2842048e328SMark Yao };
2852048e328SMark Yao 
2862048e328SMark Yao enum global_blend_mode {
2872048e328SMark Yao 	ALPHA_GLOBAL,
2882048e328SMark Yao 	ALPHA_PER_PIX,
2892048e328SMark Yao 	ALPHA_PER_PIX_GLOBAL,
2902048e328SMark Yao };
2912048e328SMark Yao 
2922048e328SMark Yao enum alpha_cal_mode {
2932048e328SMark Yao 	ALPHA_SATURATION,
2942048e328SMark Yao 	ALPHA_NO_SATURATION,
2952048e328SMark Yao };
2962048e328SMark Yao 
2972048e328SMark Yao enum color_mode {
2982048e328SMark Yao 	ALPHA_SRC_PRE_MUL,
2992048e328SMark Yao 	ALPHA_SRC_NO_PRE_MUL,
3002048e328SMark Yao };
3012048e328SMark Yao 
3022048e328SMark Yao enum factor_mode {
3032048e328SMark Yao 	ALPHA_ZERO,
3042048e328SMark Yao 	ALPHA_ONE,
3052048e328SMark Yao 	ALPHA_SRC,
3062048e328SMark Yao 	ALPHA_SRC_INVERSE,
3072048e328SMark Yao 	ALPHA_SRC_GLOBAL,
3082048e328SMark Yao };
3092048e328SMark Yao 
3104c156c21SMark Yao enum scale_mode {
3114c156c21SMark Yao 	SCALE_NONE = 0x0,
3124c156c21SMark Yao 	SCALE_UP   = 0x1,
3134c156c21SMark Yao 	SCALE_DOWN = 0x2
3144c156c21SMark Yao };
3154c156c21SMark Yao 
3164c156c21SMark Yao enum lb_mode {
3174c156c21SMark Yao 	LB_YUV_3840X5 = 0x0,
3184c156c21SMark Yao 	LB_YUV_2560X8 = 0x1,
3194c156c21SMark Yao 	LB_RGB_3840X2 = 0x2,
3204c156c21SMark Yao 	LB_RGB_2560X4 = 0x3,
3214c156c21SMark Yao 	LB_RGB_1920X5 = 0x4,
3224c156c21SMark Yao 	LB_RGB_1280X8 = 0x5
3234c156c21SMark Yao };
3244c156c21SMark Yao 
3254c156c21SMark Yao enum sacle_up_mode {
3264c156c21SMark Yao 	SCALE_UP_BIL = 0x0,
3274c156c21SMark Yao 	SCALE_UP_BIC = 0x1
3284c156c21SMark Yao };
3294c156c21SMark Yao 
3304c156c21SMark Yao enum scale_down_mode {
3314c156c21SMark Yao 	SCALE_DOWN_BIL = 0x0,
3324c156c21SMark Yao 	SCALE_DOWN_AVG = 0x1
3334c156c21SMark Yao };
3344c156c21SMark Yao 
335a5c0fa44SUrja Rannikko enum dither_down_mode {
336a5c0fa44SUrja Rannikko 	RGB888_TO_RGB565 = 0x0,
337a5c0fa44SUrja Rannikko 	RGB888_TO_RGB666 = 0x1
338a5c0fa44SUrja Rannikko };
339a5c0fa44SUrja Rannikko 
340a5c0fa44SUrja Rannikko enum dither_down_mode_sel {
341a5c0fa44SUrja Rannikko 	DITHER_DOWN_ALLEGRO = 0x0,
342a5c0fa44SUrja Rannikko 	DITHER_DOWN_FRC = 0x1
343a5c0fa44SUrja Rannikko };
344a5c0fa44SUrja Rannikko 
3451a0f7ed3SChris Zhong enum vop_pol {
3461a0f7ed3SChris Zhong 	HSYNC_POSITIVE = 0,
3471a0f7ed3SChris Zhong 	VSYNC_POSITIVE = 1,
3481f6c62caSNickey Yang 	DEN_NEGATIVE   = 2
3491a0f7ed3SChris Zhong };
3501a0f7ed3SChris Zhong 
3514c156c21SMark Yao #define FRAC_16_16(mult, div)    (((mult) << 16) / (div))
3524c156c21SMark Yao #define SCL_FT_DEFAULT_FIXPOINT_SHIFT	12
3534c156c21SMark Yao #define SCL_MAX_VSKIPLINES		4
3544c156c21SMark Yao #define MIN_SCL_FT_AFTER_VSKIP		1
3554c156c21SMark Yao 
scl_cal_scale(int src,int dst,int shift)3564c156c21SMark Yao static inline uint16_t scl_cal_scale(int src, int dst, int shift)
3574c156c21SMark Yao {
3584c156c21SMark Yao 	return ((src * 2 - 3) << (shift - 1)) / (dst - 1);
3594c156c21SMark Yao }
3604c156c21SMark Yao 
scl_cal_scale2(int src,int dst)3611194fffbSMark Yao static inline uint16_t scl_cal_scale2(int src, int dst)
3621194fffbSMark Yao {
3631194fffbSMark Yao 	return ((src - 1) << 12) / (dst - 1);
3641194fffbSMark Yao }
3651194fffbSMark Yao 
3664c156c21SMark Yao #define GET_SCL_FT_BILI_DN(src, dst)	scl_cal_scale(src, dst, 12)
3674c156c21SMark Yao #define GET_SCL_FT_BILI_UP(src, dst)	scl_cal_scale(src, dst, 16)
3684c156c21SMark Yao #define GET_SCL_FT_BIC(src, dst)	scl_cal_scale(src, dst, 16)
3694c156c21SMark Yao 
scl_get_bili_dn_vskip(int src_h,int dst_h,int vskiplines)3704c156c21SMark Yao static inline uint16_t scl_get_bili_dn_vskip(int src_h, int dst_h,
3714c156c21SMark Yao 					     int vskiplines)
3724c156c21SMark Yao {
3734c156c21SMark Yao 	int act_height;
3744c156c21SMark Yao 
37553c902b9SWambui Karuga 	act_height = DIV_ROUND_UP(src_h, vskiplines);
3764c156c21SMark Yao 
3770b12e9c0SMark yao 	if (act_height == dst_h)
3780b12e9c0SMark yao 		return GET_SCL_FT_BILI_DN(src_h, dst_h) / vskiplines;
3790b12e9c0SMark yao 
3804c156c21SMark Yao 	return GET_SCL_FT_BILI_DN(act_height, dst_h);
3814c156c21SMark Yao }
3824c156c21SMark Yao 
scl_get_scl_mode(int src,int dst)3834c156c21SMark Yao static inline enum scale_mode scl_get_scl_mode(int src, int dst)
3844c156c21SMark Yao {
3854c156c21SMark Yao 	if (src < dst)
3864c156c21SMark Yao 		return SCALE_UP;
3874c156c21SMark Yao 	else if (src > dst)
3884c156c21SMark Yao 		return SCALE_DOWN;
3894c156c21SMark Yao 
3904c156c21SMark Yao 	return SCALE_NONE;
3914c156c21SMark Yao }
3924c156c21SMark Yao 
scl_get_vskiplines(uint32_t srch,uint32_t dsth)3934c156c21SMark Yao static inline int scl_get_vskiplines(uint32_t srch, uint32_t dsth)
3944c156c21SMark Yao {
3954c156c21SMark Yao 	uint32_t vskiplines;
3964c156c21SMark Yao 
3974c156c21SMark Yao 	for (vskiplines = SCL_MAX_VSKIPLINES; vskiplines > 1; vskiplines /= 2)
3984c156c21SMark Yao 		if (srch >= vskiplines * dsth * MIN_SCL_FT_AFTER_VSKIP)
3994c156c21SMark Yao 			break;
4004c156c21SMark Yao 
4014c156c21SMark Yao 	return vskiplines;
4024c156c21SMark Yao }
4034c156c21SMark Yao 
scl_vop_cal_lb_mode(int width,bool is_yuv)4044c156c21SMark Yao static inline int scl_vop_cal_lb_mode(int width, bool is_yuv)
4054c156c21SMark Yao {
4064c156c21SMark Yao 	int lb_mode;
4074c156c21SMark Yao 
40810635917SSandy Huang 	if (is_yuv) {
40910635917SSandy Huang 		if (width > 1280)
41010635917SSandy Huang 			lb_mode = LB_YUV_3840X5;
41110635917SSandy Huang 		else
41210635917SSandy Huang 			lb_mode = LB_YUV_2560X8;
41310635917SSandy Huang 	} else {
4144c156c21SMark Yao 		if (width > 2560)
4154c156c21SMark Yao 			lb_mode = LB_RGB_3840X2;
4164c156c21SMark Yao 		else if (width > 1920)
4174c156c21SMark Yao 			lb_mode = LB_RGB_2560X4;
4184c156c21SMark Yao 		else
41910635917SSandy Huang 			lb_mode = LB_RGB_1920X5;
42010635917SSandy Huang 	}
4214c156c21SMark Yao 
4224c156c21SMark Yao 	return lb_mode;
4234c156c21SMark Yao }
4244c156c21SMark Yao 
425a67719d1SMark Yao extern const struct component_ops vop_component_ops;
4262048e328SMark Yao #endif /* _ROCKCHIP_DRM_VOP_H */
427