Commit | Line | Data |
---|---|---|
119f5173 CH |
1 | /* |
2 | * 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 | */ | |
13 | ||
14 | #ifndef MTK_DRM_DDP_COMP_H | |
15 | #define MTK_DRM_DDP_COMP_H | |
16 | ||
17 | #include <linux/io.h> | |
18 | ||
19 | struct device; | |
20 | struct device_node; | |
21 | struct drm_crtc; | |
22 | struct drm_device; | |
23 | struct mtk_plane_state; | |
24 | ||
25 | enum mtk_ddp_comp_type { | |
26 | MTK_DISP_OVL, | |
27 | MTK_DISP_RDMA, | |
28 | MTK_DISP_WDMA, | |
29 | MTK_DISP_COLOR, | |
30 | MTK_DISP_AAL, | |
31 | MTK_DISP_GAMMA, | |
32 | MTK_DISP_UFOE, | |
33 | MTK_DSI, | |
34 | MTK_DPI, | |
35 | MTK_DISP_PWM, | |
36 | MTK_DISP_MUTEX, | |
37 | MTK_DISP_OD, | |
38 | MTK_DDP_COMP_TYPE_MAX, | |
39 | }; | |
40 | ||
41 | enum mtk_ddp_comp_id { | |
42 | DDP_COMPONENT_AAL, | |
43 | DDP_COMPONENT_COLOR0, | |
44 | DDP_COMPONENT_COLOR1, | |
45 | DDP_COMPONENT_DPI0, | |
46 | DDP_COMPONENT_DSI0, | |
47 | DDP_COMPONENT_DSI1, | |
48 | DDP_COMPONENT_GAMMA, | |
49 | DDP_COMPONENT_OD, | |
50 | DDP_COMPONENT_OVL0, | |
51 | DDP_COMPONENT_OVL1, | |
52 | DDP_COMPONENT_PWM0, | |
53 | DDP_COMPONENT_PWM1, | |
54 | DDP_COMPONENT_RDMA0, | |
55 | DDP_COMPONENT_RDMA1, | |
56 | DDP_COMPONENT_RDMA2, | |
57 | DDP_COMPONENT_UFOE, | |
58 | DDP_COMPONENT_WDMA0, | |
59 | DDP_COMPONENT_WDMA1, | |
60 | DDP_COMPONENT_ID_MAX, | |
61 | }; | |
62 | ||
63 | struct mtk_ddp_comp; | |
64 | ||
65 | struct mtk_ddp_comp_funcs { | |
66 | void (*config)(struct mtk_ddp_comp *comp, unsigned int w, | |
67 | unsigned int h, unsigned int vrefresh); | |
68 | void (*start)(struct mtk_ddp_comp *comp); | |
69 | void (*stop)(struct mtk_ddp_comp *comp); | |
70 | void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc); | |
71 | void (*disable_vblank)(struct mtk_ddp_comp *comp); | |
72 | void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx); | |
73 | void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx); | |
74 | void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx, | |
75 | struct mtk_plane_state *state); | |
76 | }; | |
77 | ||
78 | struct mtk_ddp_comp { | |
79 | struct clk *clk; | |
80 | void __iomem *regs; | |
81 | int irq; | |
82 | struct device *larb_dev; | |
83 | enum mtk_ddp_comp_id id; | |
84 | const struct mtk_ddp_comp_funcs *funcs; | |
85 | }; | |
86 | ||
87 | static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp, | |
88 | unsigned int w, unsigned int h, | |
89 | unsigned int vrefresh) | |
90 | { | |
91 | if (comp->funcs && comp->funcs->config) | |
92 | comp->funcs->config(comp, w, h, vrefresh); | |
93 | } | |
94 | ||
95 | static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp) | |
96 | { | |
97 | if (comp->funcs && comp->funcs->start) | |
98 | comp->funcs->start(comp); | |
99 | } | |
100 | ||
101 | static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp) | |
102 | { | |
103 | if (comp->funcs && comp->funcs->stop) | |
104 | comp->funcs->stop(comp); | |
105 | } | |
106 | ||
107 | static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp, | |
108 | struct drm_crtc *crtc) | |
109 | { | |
110 | if (comp->funcs && comp->funcs->enable_vblank) | |
111 | comp->funcs->enable_vblank(comp, crtc); | |
112 | } | |
113 | ||
114 | static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp) | |
115 | { | |
116 | if (comp->funcs && comp->funcs->disable_vblank) | |
117 | comp->funcs->disable_vblank(comp); | |
118 | } | |
119 | ||
120 | static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp *comp, | |
121 | unsigned int idx) | |
122 | { | |
123 | if (comp->funcs && comp->funcs->layer_on) | |
124 | comp->funcs->layer_on(comp, idx); | |
125 | } | |
126 | ||
127 | static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp, | |
128 | unsigned int idx) | |
129 | { | |
130 | if (comp->funcs && comp->funcs->layer_off) | |
131 | comp->funcs->layer_off(comp, idx); | |
132 | } | |
133 | ||
134 | static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp, | |
135 | unsigned int idx, | |
136 | struct mtk_plane_state *state) | |
137 | { | |
138 | if (comp->funcs && comp->funcs->layer_config) | |
139 | comp->funcs->layer_config(comp, idx, state); | |
140 | } | |
141 | ||
142 | int mtk_ddp_comp_get_id(struct device_node *node, | |
143 | enum mtk_ddp_comp_type comp_type); | |
144 | int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node, | |
145 | struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, | |
146 | const struct mtk_ddp_comp_funcs *funcs); | |
147 | int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp); | |
148 | void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp); | |
149 | ||
150 | #endif /* MTK_DRM_DDP_COMP_H */ |