2 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
3 * Author:Mark Yao <mark.yao@rock-chips.com>
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #ifndef _ROCKCHIP_DRM_VOP_H
16 #define _ROCKCHIP_DRM_VOP_H
19 * major: IP major version, used for IP structure
20 * minor: big feature change under same structure
22 #define VOP_VERSION(major, minor) ((major) << 8 | (minor))
23 #define VOP_MAJOR(version) ((version) >> 8)
24 #define VOP_MINOR(version) ((version) & 0xff)
26 #define NUM_YUV2YUV_COEFFICIENTS 12
28 enum vop_data_format
{
46 struct vop_reg htotal_pw
;
47 struct vop_reg hact_st_end
;
48 struct vop_reg hpost_st_end
;
49 struct vop_reg vtotal_pw
;
50 struct vop_reg vact_st_end
;
51 struct vop_reg vpost_st_end
;
55 struct vop_reg pin_pol
;
56 struct vop_reg dp_pin_pol
;
57 struct vop_reg edp_pin_pol
;
58 struct vop_reg hdmi_pin_pol
;
59 struct vop_reg mipi_pin_pol
;
60 struct vop_reg rgb_pin_pol
;
62 struct vop_reg edp_en
;
63 struct vop_reg hdmi_en
;
64 struct vop_reg mipi_en
;
65 struct vop_reg mipi_dual_channel_en
;
66 struct vop_reg rgb_en
;
70 struct vop_reg cfg_done
;
71 struct vop_reg dsp_blank
;
72 struct vop_reg data_blank
;
73 struct vop_reg pre_dither_down
;
74 struct vop_reg dither_down
;
75 struct vop_reg dither_up
;
76 struct vop_reg gate_en
;
77 struct vop_reg mmu_en
;
78 struct vop_reg out_mode
;
79 struct vop_reg standby
;
83 struct vop_reg global_regdone_en
;
90 struct vop_reg line_flag_num
[2];
91 struct vop_reg enable
;
93 struct vop_reg status
;
96 struct vop_scl_extension
{
97 struct vop_reg cbcr_vsd_mode
;
98 struct vop_reg cbcr_vsu_mode
;
99 struct vop_reg cbcr_hsd_mode
;
100 struct vop_reg cbcr_ver_scl_mode
;
101 struct vop_reg cbcr_hor_scl_mode
;
102 struct vop_reg yrgb_vsd_mode
;
103 struct vop_reg yrgb_vsu_mode
;
104 struct vop_reg yrgb_hsd_mode
;
105 struct vop_reg yrgb_ver_scl_mode
;
106 struct vop_reg yrgb_hor_scl_mode
;
107 struct vop_reg line_load_mode
;
108 struct vop_reg cbcr_axi_gather_num
;
109 struct vop_reg yrgb_axi_gather_num
;
110 struct vop_reg vsd_cbcr_gt2
;
111 struct vop_reg vsd_cbcr_gt4
;
112 struct vop_reg vsd_yrgb_gt2
;
113 struct vop_reg vsd_yrgb_gt4
;
114 struct vop_reg bic_coe_sel
;
115 struct vop_reg cbcr_axi_gather_en
;
116 struct vop_reg yrgb_axi_gather_en
;
117 struct vop_reg lb_mode
;
120 struct vop_scl_regs
{
121 const struct vop_scl_extension
*ext
;
123 struct vop_reg scale_yrgb_x
;
124 struct vop_reg scale_yrgb_y
;
125 struct vop_reg scale_cbcr_x
;
126 struct vop_reg scale_cbcr_y
;
129 struct vop_yuv2yuv_phy
{
130 struct vop_reg y2r_coefficients
[NUM_YUV2YUV_COEFFICIENTS
];
134 const struct vop_scl_regs
*scl
;
135 const uint32_t *data_formats
;
138 struct vop_reg enable
;
140 struct vop_reg format
;
141 struct vop_reg rb_swap
;
142 struct vop_reg act_info
;
143 struct vop_reg dsp_info
;
144 struct vop_reg dsp_st
;
145 struct vop_reg yrgb_mst
;
146 struct vop_reg uv_mst
;
147 struct vop_reg yrgb_vir
;
148 struct vop_reg uv_vir
;
149 struct vop_reg y_mir_en
;
150 struct vop_reg x_mir_en
;
152 struct vop_reg dst_alpha_ctl
;
153 struct vop_reg src_alpha_ctl
;
154 struct vop_reg channel
;
157 struct vop_win_yuv2yuv_data
{
159 const struct vop_yuv2yuv_phy
*phy
;
160 struct vop_reg y2r_en
;
163 struct vop_win_data
{
165 const struct vop_win_phy
*phy
;
166 enum drm_plane_type type
;
171 const struct vop_intr
*intr
;
172 const struct vop_common
*common
;
173 const struct vop_misc
*misc
;
174 const struct vop_modeset
*modeset
;
175 const struct vop_output
*output
;
176 const struct vop_win_yuv2yuv_data
*win_yuv2yuv
;
177 const struct vop_win_data
*win
;
178 unsigned int win_size
;
180 #define VOP_FEATURE_OUTPUT_RGB10 BIT(0)
181 #define VOP_FEATURE_INTERNAL_RGB BIT(1)
185 /* interrupt define */
186 #define DSP_HOLD_VALID_INTR (1 << 0)
187 #define FS_INTR (1 << 1)
188 #define LINE_FLAG_INTR (1 << 2)
189 #define BUS_ERROR_INTR (1 << 3)
191 #define INTR_MASK (DSP_HOLD_VALID_INTR | FS_INTR | \
192 LINE_FLAG_INTR | BUS_ERROR_INTR)
194 #define DSP_HOLD_VALID_INTR_EN(x) ((x) << 4)
195 #define FS_INTR_EN(x) ((x) << 5)
196 #define LINE_FLAG_INTR_EN(x) ((x) << 6)
197 #define BUS_ERROR_INTR_EN(x) ((x) << 7)
198 #define DSP_HOLD_VALID_INTR_MASK (1 << 4)
199 #define FS_INTR_MASK (1 << 5)
200 #define LINE_FLAG_INTR_MASK (1 << 6)
201 #define BUS_ERROR_INTR_MASK (1 << 7)
203 #define INTR_CLR_SHIFT 8
204 #define DSP_HOLD_VALID_INTR_CLR (1 << (INTR_CLR_SHIFT + 0))
205 #define FS_INTR_CLR (1 << (INTR_CLR_SHIFT + 1))
206 #define LINE_FLAG_INTR_CLR (1 << (INTR_CLR_SHIFT + 2))
207 #define BUS_ERROR_INTR_CLR (1 << (INTR_CLR_SHIFT + 3))
209 #define DSP_LINE_NUM(x) (((x) & 0x1fff) << 12)
210 #define DSP_LINE_NUM_MASK (0x1fff << 12)
212 /* src alpha ctrl define */
213 #define SRC_FADING_VALUE(x) (((x) & 0xff) << 24)
214 #define SRC_GLOBAL_ALPHA(x) (((x) & 0xff) << 16)
215 #define SRC_FACTOR_M0(x) (((x) & 0x7) << 6)
216 #define SRC_ALPHA_CAL_M0(x) (((x) & 0x1) << 5)
217 #define SRC_BLEND_M0(x) (((x) & 0x3) << 3)
218 #define SRC_ALPHA_M0(x) (((x) & 0x1) << 2)
219 #define SRC_COLOR_M0(x) (((x) & 0x1) << 1)
220 #define SRC_ALPHA_EN(x) (((x) & 0x1) << 0)
221 /* dst alpha ctrl define */
222 #define DST_FACTOR_M0(x) (((x) & 0x7) << 6)
225 * display output interface supported by rockchip lcdc
227 #define ROCKCHIP_OUT_MODE_P888 0
228 #define ROCKCHIP_OUT_MODE_P666 1
229 #define ROCKCHIP_OUT_MODE_P565 2
230 /* for use special outface */
231 #define ROCKCHIP_OUT_MODE_AAAA 15
234 #define ROCKCHIP_OUTPUT_DSI_DUAL BIT(0)
241 enum global_blend_mode
{
244 ALPHA_PER_PIX_GLOBAL
,
247 enum alpha_cal_mode
{
254 ALPHA_SRC_NO_PRE_MUL
,
285 enum scale_down_mode
{
286 SCALE_DOWN_BIL
= 0x0,
297 #define FRAC_16_16(mult, div) (((mult) << 16) / (div))
298 #define SCL_FT_DEFAULT_FIXPOINT_SHIFT 12
299 #define SCL_MAX_VSKIPLINES 4
300 #define MIN_SCL_FT_AFTER_VSKIP 1
302 static inline uint16_t scl_cal_scale(int src
, int dst
, int shift
)
304 return ((src
* 2 - 3) << (shift
- 1)) / (dst
- 1);
307 static inline uint16_t scl_cal_scale2(int src
, int dst
)
309 return ((src
- 1) << 12) / (dst
- 1);
312 #define GET_SCL_FT_BILI_DN(src, dst) scl_cal_scale(src, dst, 12)
313 #define GET_SCL_FT_BILI_UP(src, dst) scl_cal_scale(src, dst, 16)
314 #define GET_SCL_FT_BIC(src, dst) scl_cal_scale(src, dst, 16)
316 static inline uint16_t scl_get_bili_dn_vskip(int src_h
, int dst_h
,
321 act_height
= (src_h
+ vskiplines
- 1) / vskiplines
;
323 if (act_height
== dst_h
)
324 return GET_SCL_FT_BILI_DN(src_h
, dst_h
) / vskiplines
;
326 return GET_SCL_FT_BILI_DN(act_height
, dst_h
);
329 static inline enum scale_mode
scl_get_scl_mode(int src
, int dst
)
339 static inline int scl_get_vskiplines(uint32_t srch
, uint32_t dsth
)
343 for (vskiplines
= SCL_MAX_VSKIPLINES
; vskiplines
> 1; vskiplines
/= 2)
344 if (srch
>= vskiplines
* dsth
* MIN_SCL_FT_AFTER_VSKIP
)
350 static inline int scl_vop_cal_lb_mode(int width
, bool is_yuv
)
356 lb_mode
= LB_YUV_3840X5
;
358 lb_mode
= LB_YUV_2560X8
;
361 lb_mode
= LB_RGB_3840X2
;
362 else if (width
> 1920)
363 lb_mode
= LB_RGB_2560X4
;
365 lb_mode
= LB_RGB_1920X5
;
371 extern const struct component_ops vop_component_ops
;
372 #endif /* _ROCKCHIP_DRM_VOP_H */