.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2015 MediaTek Inc. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | 4 | */ |
---|
13 | 5 | |
---|
14 | 6 | #ifndef MTK_DRM_DDP_COMP_H |
---|
15 | 7 | #define MTK_DRM_DDP_COMP_H |
---|
16 | 8 | |
---|
17 | 9 | #include <linux/io.h> |
---|
| 10 | +#include <linux/soc/mediatek/mtk-mmsys.h> |
---|
18 | 11 | |
---|
19 | 12 | struct device; |
---|
20 | 13 | struct device_node; |
---|
.. | .. |
---|
25 | 18 | |
---|
26 | 19 | enum mtk_ddp_comp_type { |
---|
27 | 20 | MTK_DISP_OVL, |
---|
| 21 | + MTK_DISP_OVL_2L, |
---|
28 | 22 | MTK_DISP_RDMA, |
---|
29 | 23 | MTK_DISP_WDMA, |
---|
30 | 24 | MTK_DISP_COLOR, |
---|
| 25 | + MTK_DISP_CCORR, |
---|
| 26 | + MTK_DISP_DITHER, |
---|
31 | 27 | MTK_DISP_AAL, |
---|
32 | 28 | MTK_DISP_GAMMA, |
---|
33 | 29 | MTK_DISP_UFOE, |
---|
.. | .. |
---|
40 | 36 | MTK_DDP_COMP_TYPE_MAX, |
---|
41 | 37 | }; |
---|
42 | 38 | |
---|
43 | | -enum mtk_ddp_comp_id { |
---|
44 | | - DDP_COMPONENT_AAL0, |
---|
45 | | - DDP_COMPONENT_AAL1, |
---|
46 | | - DDP_COMPONENT_BLS, |
---|
47 | | - DDP_COMPONENT_COLOR0, |
---|
48 | | - DDP_COMPONENT_COLOR1, |
---|
49 | | - DDP_COMPONENT_DPI0, |
---|
50 | | - DDP_COMPONENT_DPI1, |
---|
51 | | - DDP_COMPONENT_DSI0, |
---|
52 | | - DDP_COMPONENT_DSI1, |
---|
53 | | - DDP_COMPONENT_DSI2, |
---|
54 | | - DDP_COMPONENT_DSI3, |
---|
55 | | - DDP_COMPONENT_GAMMA, |
---|
56 | | - DDP_COMPONENT_OD0, |
---|
57 | | - DDP_COMPONENT_OD1, |
---|
58 | | - DDP_COMPONENT_OVL0, |
---|
59 | | - DDP_COMPONENT_OVL1, |
---|
60 | | - DDP_COMPONENT_PWM0, |
---|
61 | | - DDP_COMPONENT_PWM1, |
---|
62 | | - DDP_COMPONENT_PWM2, |
---|
63 | | - DDP_COMPONENT_RDMA0, |
---|
64 | | - DDP_COMPONENT_RDMA1, |
---|
65 | | - DDP_COMPONENT_RDMA2, |
---|
66 | | - DDP_COMPONENT_UFOE, |
---|
67 | | - DDP_COMPONENT_WDMA0, |
---|
68 | | - DDP_COMPONENT_WDMA1, |
---|
69 | | - DDP_COMPONENT_ID_MAX, |
---|
70 | | -}; |
---|
71 | | - |
---|
72 | 39 | struct mtk_ddp_comp; |
---|
73 | | - |
---|
| 40 | +struct cmdq_pkt; |
---|
74 | 41 | struct mtk_ddp_comp_funcs { |
---|
75 | 42 | void (*config)(struct mtk_ddp_comp *comp, unsigned int w, |
---|
76 | | - unsigned int h, unsigned int vrefresh, unsigned int bpc); |
---|
| 43 | + unsigned int h, unsigned int vrefresh, |
---|
| 44 | + unsigned int bpc, struct cmdq_pkt *cmdq_pkt); |
---|
77 | 45 | void (*start)(struct mtk_ddp_comp *comp); |
---|
78 | 46 | void (*stop)(struct mtk_ddp_comp *comp); |
---|
79 | 47 | void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc); |
---|
80 | 48 | void (*disable_vblank)(struct mtk_ddp_comp *comp); |
---|
| 49 | + unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp); |
---|
81 | 50 | unsigned int (*layer_nr)(struct mtk_ddp_comp *comp); |
---|
82 | | - void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx); |
---|
83 | | - void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx); |
---|
| 51 | + int (*layer_check)(struct mtk_ddp_comp *comp, |
---|
| 52 | + unsigned int idx, |
---|
| 53 | + struct mtk_plane_state *state); |
---|
84 | 54 | void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx, |
---|
85 | | - struct mtk_plane_state *state); |
---|
| 55 | + struct mtk_plane_state *state, |
---|
| 56 | + struct cmdq_pkt *cmdq_pkt); |
---|
86 | 57 | void (*gamma_set)(struct mtk_ddp_comp *comp, |
---|
87 | 58 | struct drm_crtc_state *state); |
---|
| 59 | + void (*bgclr_in_on)(struct mtk_ddp_comp *comp); |
---|
| 60 | + void (*bgclr_in_off)(struct mtk_ddp_comp *comp); |
---|
| 61 | + void (*ctm_set)(struct mtk_ddp_comp *comp, |
---|
| 62 | + struct drm_crtc_state *state); |
---|
88 | 63 | }; |
---|
89 | 64 | |
---|
90 | 65 | struct mtk_ddp_comp { |
---|
.. | .. |
---|
94 | 69 | struct device *larb_dev; |
---|
95 | 70 | enum mtk_ddp_comp_id id; |
---|
96 | 71 | const struct mtk_ddp_comp_funcs *funcs; |
---|
| 72 | + resource_size_t regs_pa; |
---|
| 73 | + u8 subsys; |
---|
97 | 74 | }; |
---|
98 | 75 | |
---|
99 | 76 | static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp, |
---|
100 | 77 | unsigned int w, unsigned int h, |
---|
101 | | - unsigned int vrefresh, unsigned int bpc) |
---|
| 78 | + unsigned int vrefresh, unsigned int bpc, |
---|
| 79 | + struct cmdq_pkt *cmdq_pkt) |
---|
102 | 80 | { |
---|
103 | 81 | if (comp->funcs && comp->funcs->config) |
---|
104 | | - comp->funcs->config(comp, w, h, vrefresh, bpc); |
---|
| 82 | + comp->funcs->config(comp, w, h, vrefresh, bpc, cmdq_pkt); |
---|
105 | 83 | } |
---|
106 | 84 | |
---|
107 | 85 | static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp) |
---|
.. | .. |
---|
129 | 107 | comp->funcs->disable_vblank(comp); |
---|
130 | 108 | } |
---|
131 | 109 | |
---|
| 110 | +static inline |
---|
| 111 | +unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp) |
---|
| 112 | +{ |
---|
| 113 | + if (comp->funcs && comp->funcs->supported_rotations) |
---|
| 114 | + return comp->funcs->supported_rotations(comp); |
---|
| 115 | + |
---|
| 116 | + return 0; |
---|
| 117 | +} |
---|
| 118 | + |
---|
132 | 119 | static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp) |
---|
133 | 120 | { |
---|
134 | 121 | if (comp->funcs && comp->funcs->layer_nr) |
---|
.. | .. |
---|
137 | 124 | return 0; |
---|
138 | 125 | } |
---|
139 | 126 | |
---|
140 | | -static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp *comp, |
---|
141 | | - unsigned int idx) |
---|
| 127 | +static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp, |
---|
| 128 | + unsigned int idx, |
---|
| 129 | + struct mtk_plane_state *state) |
---|
142 | 130 | { |
---|
143 | | - if (comp->funcs && comp->funcs->layer_on) |
---|
144 | | - comp->funcs->layer_on(comp, idx); |
---|
145 | | -} |
---|
146 | | - |
---|
147 | | -static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp, |
---|
148 | | - unsigned int idx) |
---|
149 | | -{ |
---|
150 | | - if (comp->funcs && comp->funcs->layer_off) |
---|
151 | | - comp->funcs->layer_off(comp, idx); |
---|
| 131 | + if (comp->funcs && comp->funcs->layer_check) |
---|
| 132 | + return comp->funcs->layer_check(comp, idx, state); |
---|
| 133 | + return 0; |
---|
152 | 134 | } |
---|
153 | 135 | |
---|
154 | 136 | static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp, |
---|
155 | 137 | unsigned int idx, |
---|
156 | | - struct mtk_plane_state *state) |
---|
| 138 | + struct mtk_plane_state *state, |
---|
| 139 | + struct cmdq_pkt *cmdq_pkt) |
---|
157 | 140 | { |
---|
158 | 141 | if (comp->funcs && comp->funcs->layer_config) |
---|
159 | | - comp->funcs->layer_config(comp, idx, state); |
---|
| 142 | + comp->funcs->layer_config(comp, idx, state, cmdq_pkt); |
---|
160 | 143 | } |
---|
161 | 144 | |
---|
162 | 145 | static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp, |
---|
.. | .. |
---|
166 | 149 | comp->funcs->gamma_set(comp, state); |
---|
167 | 150 | } |
---|
168 | 151 | |
---|
| 152 | +static inline void mtk_ddp_comp_bgclr_in_on(struct mtk_ddp_comp *comp) |
---|
| 153 | +{ |
---|
| 154 | + if (comp->funcs && comp->funcs->bgclr_in_on) |
---|
| 155 | + comp->funcs->bgclr_in_on(comp); |
---|
| 156 | +} |
---|
| 157 | + |
---|
| 158 | +static inline void mtk_ddp_comp_bgclr_in_off(struct mtk_ddp_comp *comp) |
---|
| 159 | +{ |
---|
| 160 | + if (comp->funcs && comp->funcs->bgclr_in_off) |
---|
| 161 | + comp->funcs->bgclr_in_off(comp); |
---|
| 162 | +} |
---|
| 163 | + |
---|
| 164 | +static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp, |
---|
| 165 | + struct drm_crtc_state *state) |
---|
| 166 | +{ |
---|
| 167 | + if (comp->funcs && comp->funcs->ctm_set) |
---|
| 168 | + comp->funcs->ctm_set(comp, state); |
---|
| 169 | +} |
---|
| 170 | + |
---|
169 | 171 | int mtk_ddp_comp_get_id(struct device_node *node, |
---|
170 | 172 | enum mtk_ddp_comp_type comp_type); |
---|
| 173 | +unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, |
---|
| 174 | + struct mtk_ddp_comp ddp_comp); |
---|
171 | 175 | int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node, |
---|
172 | 176 | struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, |
---|
173 | 177 | const struct mtk_ddp_comp_funcs *funcs); |
---|
174 | 178 | int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp); |
---|
175 | 179 | void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp); |
---|
176 | 180 | void mtk_dither_set(struct mtk_ddp_comp *comp, unsigned int bpc, |
---|
177 | | - unsigned int CFG); |
---|
178 | | - |
---|
| 181 | + unsigned int CFG, struct cmdq_pkt *cmdq_pkt); |
---|
| 182 | +enum mtk_ddp_comp_type mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id); |
---|
| 183 | +void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value, |
---|
| 184 | + struct mtk_ddp_comp *comp, unsigned int offset); |
---|
| 185 | +void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value, |
---|
| 186 | + struct mtk_ddp_comp *comp, unsigned int offset); |
---|
| 187 | +void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value, |
---|
| 188 | + struct mtk_ddp_comp *comp, unsigned int offset, |
---|
| 189 | + unsigned int mask); |
---|
179 | 190 | #endif /* MTK_DRM_DDP_COMP_H */ |
---|