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
18 enum vop_data_format {
40 struct vop_reg standby;
41 struct vop_reg data_blank;
42 struct vop_reg gate_en;
43 struct vop_reg mmu_en;
44 struct vop_reg rgb_en;
45 struct vop_reg edp_en;
46 struct vop_reg hdmi_en;
47 struct vop_reg mipi_en;
48 struct vop_reg out_mode;
49 struct vop_reg dsp_layer_sel;
50 struct vop_reg dither_down;
51 struct vop_reg dither_up;
52 struct vop_reg pin_pol;
53 struct vop_reg rgb_pin_pol;
54 struct vop_reg hdmi_pin_pol;
55 struct vop_reg edp_pin_pol;
56 struct vop_reg mipi_pin_pol;
58 struct vop_reg htotal_pw;
59 struct vop_reg hact_st_end;
60 struct vop_reg vtotal_pw;
61 struct vop_reg vact_st_end;
62 struct vop_reg hpost_st_end;
63 struct vop_reg vpost_st_end;
65 struct vop_reg cfg_done;
71 struct vop_reg enable;
73 struct vop_reg status;
76 struct vop_scl_extension {
77 struct vop_reg cbcr_vsd_mode;
78 struct vop_reg cbcr_vsu_mode;
79 struct vop_reg cbcr_hsd_mode;
80 struct vop_reg cbcr_ver_scl_mode;
81 struct vop_reg cbcr_hor_scl_mode;
82 struct vop_reg yrgb_vsd_mode;
83 struct vop_reg yrgb_vsu_mode;
84 struct vop_reg yrgb_hsd_mode;
85 struct vop_reg yrgb_ver_scl_mode;
86 struct vop_reg yrgb_hor_scl_mode;
87 struct vop_reg line_load_mode;
88 struct vop_reg cbcr_axi_gather_num;
89 struct vop_reg yrgb_axi_gather_num;
90 struct vop_reg vsd_cbcr_gt2;
91 struct vop_reg vsd_cbcr_gt4;
92 struct vop_reg vsd_yrgb_gt2;
93 struct vop_reg vsd_yrgb_gt4;
94 struct vop_reg bic_coe_sel;
95 struct vop_reg cbcr_axi_gather_en;
96 struct vop_reg yrgb_axi_gather_en;
97 struct vop_reg lb_mode;
100 struct vop_scl_regs {
101 const struct vop_scl_extension *ext;
103 struct vop_reg scale_yrgb_x;
104 struct vop_reg scale_yrgb_y;
105 struct vop_reg scale_cbcr_x;
106 struct vop_reg scale_cbcr_y;
110 const struct vop_scl_regs *scl;
111 const uint32_t *data_formats;
114 struct vop_reg enable;
115 struct vop_reg format;
116 struct vop_reg rb_swap;
117 struct vop_reg act_info;
118 struct vop_reg dsp_info;
119 struct vop_reg dsp_st;
120 struct vop_reg yrgb_mst;
121 struct vop_reg uv_mst;
122 struct vop_reg yrgb_vir;
123 struct vop_reg uv_vir;
125 struct vop_reg dst_alpha_ctl;
126 struct vop_reg src_alpha_ctl;
129 struct vop_win_data {
131 enum drm_plane_type type;
132 const struct vop_win_phy *phy;
133 const struct vop_win_phy **area;
134 unsigned int area_size;
138 const struct vop_reg_data *init_table;
139 unsigned int table_size;
140 const struct vop_ctrl *ctrl;
141 const struct vop_intr *intr;
142 const struct vop_win_data *win;
143 unsigned int win_size;
146 /* interrupt define */
147 #define DSP_HOLD_VALID_INTR (1 << 0)
148 #define FS_INTR (1 << 1)
149 #define LINE_FLAG_INTR (1 << 2)
150 #define BUS_ERROR_INTR (1 << 3)
152 #define INTR_MASK (DSP_HOLD_VALID_INTR | FS_INTR | \
153 LINE_FLAG_INTR | BUS_ERROR_INTR)
155 #define DSP_HOLD_VALID_INTR_EN(x) ((x) << 4)
156 #define FS_INTR_EN(x) ((x) << 5)
157 #define LINE_FLAG_INTR_EN(x) ((x) << 6)
158 #define BUS_ERROR_INTR_EN(x) ((x) << 7)
159 #define DSP_HOLD_VALID_INTR_MASK (1 << 4)
160 #define FS_INTR_MASK (1 << 5)
161 #define LINE_FLAG_INTR_MASK (1 << 6)
162 #define BUS_ERROR_INTR_MASK (1 << 7)
164 #define INTR_CLR_SHIFT 8
165 #define DSP_HOLD_VALID_INTR_CLR (1 << (INTR_CLR_SHIFT + 0))
166 #define FS_INTR_CLR (1 << (INTR_CLR_SHIFT + 1))
167 #define LINE_FLAG_INTR_CLR (1 << (INTR_CLR_SHIFT + 2))
168 #define BUS_ERROR_INTR_CLR (1 << (INTR_CLR_SHIFT + 3))
170 #define DSP_LINE_NUM(x) (((x) & 0x1fff) << 12)
171 #define DSP_LINE_NUM_MASK (0x1fff << 12)
173 /* src alpha ctrl define */
174 #define SRC_FADING_VALUE(x) (((x) & 0xff) << 24)
175 #define SRC_GLOBAL_ALPHA(x) (((x) & 0xff) << 16)
176 #define SRC_FACTOR_M0(x) (((x) & 0x7) << 6)
177 #define SRC_ALPHA_CAL_M0(x) (((x) & 0x1) << 5)
178 #define SRC_BLEND_M0(x) (((x) & 0x3) << 3)
179 #define SRC_ALPHA_M0(x) (((x) & 0x1) << 2)
180 #define SRC_COLOR_M0(x) (((x) & 0x1) << 1)
181 #define SRC_ALPHA_EN(x) (((x) & 0x1) << 0)
182 /* dst alpha ctrl define */
183 #define DST_FACTOR_M0(x) (((x) & 0x7) << 6)
186 * display output interface supported by rockchip lcdc
188 #define ROCKCHIP_OUT_MODE_P888 0
189 #define ROCKCHIP_OUT_MODE_P666 1
190 #define ROCKCHIP_OUT_MODE_P565 2
191 /* for use special outface */
192 #define ROCKCHIP_OUT_MODE_AAAA 15
194 #define ROCKCHIP_OUT_MODE_TYPE(x) ((x) >> 16)
195 #define ROCKCHIP_OUT_MODE(x) ((x) & 0xffff)
196 #define ROCKCHIP_DSP_MODE(type, mode) \
197 (DRM_MODE_CONNECTOR_##type << 16) | \
198 (ROCKCHIP_OUT_MODE_##mode & 0xffff)
205 enum global_blend_mode {
208 ALPHA_PER_PIX_GLOBAL,
211 enum alpha_cal_mode {
218 ALPHA_SRC_NO_PRE_MUL,
249 enum scale_down_mode {
250 SCALE_DOWN_BIL = 0x0,
254 #define FRAC_16_16(mult, div) (((mult) << 16) / (div))
255 #define SCL_FT_DEFAULT_FIXPOINT_SHIFT 12
256 #define SCL_MAX_VSKIPLINES 4
257 #define MIN_SCL_FT_AFTER_VSKIP 1
259 static inline uint16_t scl_cal_scale(int src, int dst, int shift)
261 return ((src * 2 - 3) << (shift - 1)) / (dst - 1);
264 static inline uint16_t scl_cal_scale2(int src, int dst)
266 return ((src - 1) << 12) / (dst - 1);
269 #define GET_SCL_FT_BILI_DN(src, dst) scl_cal_scale(src, dst, 12)
270 #define GET_SCL_FT_BILI_UP(src, dst) scl_cal_scale(src, dst, 16)
271 #define GET_SCL_FT_BIC(src, dst) scl_cal_scale(src, dst, 16)
273 static inline uint16_t scl_get_bili_dn_vskip(int src_h, int dst_h,
278 act_height = (src_h + vskiplines - 1) / vskiplines;
280 return GET_SCL_FT_BILI_DN(act_height, dst_h);
283 static inline enum scale_mode scl_get_scl_mode(int src, int dst)
293 static inline int scl_get_vskiplines(uint32_t srch, uint32_t dsth)
297 for (vskiplines = SCL_MAX_VSKIPLINES; vskiplines > 1; vskiplines /= 2)
298 if (srch >= vskiplines * dsth * MIN_SCL_FT_AFTER_VSKIP)
304 static inline int scl_vop_cal_lb_mode(int width, bool is_yuv)
309 lb_mode = LB_RGB_3840X2;
310 else if (width > 1920)
311 lb_mode = LB_RGB_2560X4;
313 lb_mode = LB_RGB_1920X5;
314 else if (width > 1280)
315 lb_mode = LB_YUV_3840X5;
317 lb_mode = LB_YUV_2560X8;
322 extern const struct component_ops vop_component_ops;
323 #endif /* _ROCKCHIP_DRM_VOP_H */