forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
....@@ -1,20 +1,13 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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.
124 */
135
146 #ifndef MTK_DRM_DDP_COMP_H
157 #define MTK_DRM_DDP_COMP_H
168
179 #include <linux/io.h>
10
+#include <linux/soc/mediatek/mtk-mmsys.h>
1811
1912 struct device;
2013 struct device_node;
....@@ -25,9 +18,12 @@
2518
2619 enum mtk_ddp_comp_type {
2720 MTK_DISP_OVL,
21
+ MTK_DISP_OVL_2L,
2822 MTK_DISP_RDMA,
2923 MTK_DISP_WDMA,
3024 MTK_DISP_COLOR,
25
+ MTK_DISP_CCORR,
26
+ MTK_DISP_DITHER,
3127 MTK_DISP_AAL,
3228 MTK_DISP_GAMMA,
3329 MTK_DISP_UFOE,
....@@ -40,51 +36,30 @@
4036 MTK_DDP_COMP_TYPE_MAX,
4137 };
4238
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
-
7239 struct mtk_ddp_comp;
73
-
40
+struct cmdq_pkt;
7441 struct mtk_ddp_comp_funcs {
7542 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);
7745 void (*start)(struct mtk_ddp_comp *comp);
7846 void (*stop)(struct mtk_ddp_comp *comp);
7947 void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc);
8048 void (*disable_vblank)(struct mtk_ddp_comp *comp);
49
+ unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp);
8150 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);
8454 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);
8657 void (*gamma_set)(struct mtk_ddp_comp *comp,
8758 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);
8863 };
8964
9065 struct mtk_ddp_comp {
....@@ -94,14 +69,17 @@
9469 struct device *larb_dev;
9570 enum mtk_ddp_comp_id id;
9671 const struct mtk_ddp_comp_funcs *funcs;
72
+ resource_size_t regs_pa;
73
+ u8 subsys;
9774 };
9875
9976 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
10077 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)
10280 {
10381 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);
10583 }
10684
10785 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
....@@ -129,6 +107,15 @@
129107 comp->funcs->disable_vblank(comp);
130108 }
131109
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
+
132119 static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
133120 {
134121 if (comp->funcs && comp->funcs->layer_nr)
....@@ -137,26 +124,22 @@
137124 return 0;
138125 }
139126
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)
142130 {
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;
152134 }
153135
154136 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
155137 unsigned int idx,
156
- struct mtk_plane_state *state)
138
+ struct mtk_plane_state *state,
139
+ struct cmdq_pkt *cmdq_pkt)
157140 {
158141 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);
160143 }
161144
162145 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
....@@ -166,14 +149,42 @@
166149 comp->funcs->gamma_set(comp, state);
167150 }
168151
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
+
169171 int mtk_ddp_comp_get_id(struct device_node *node,
170172 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);
171175 int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
172176 struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
173177 const struct mtk_ddp_comp_funcs *funcs);
174178 int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp);
175179 void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp);
176180 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);
179190 #endif /* MTK_DRM_DDP_COMP_H */