Linux 4.9.243
[linux/fpc-iii.git] / drivers / gpu / drm / mediatek / mtk_drm_ddp_comp.h
blob22a33ee451c4d96ef3f409c08c9f215a75ece97e
1 /*
2 * Copyright (c) 2015 MediaTek Inc.
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.
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.
14 #ifndef MTK_DRM_DDP_COMP_H
15 #define MTK_DRM_DDP_COMP_H
17 #include <linux/io.h>
19 struct device;
20 struct device_node;
21 struct drm_crtc;
22 struct drm_device;
23 struct mtk_plane_state;
24 struct drm_crtc_state;
26 enum mtk_ddp_comp_type {
27 MTK_DISP_OVL,
28 MTK_DISP_RDMA,
29 MTK_DISP_WDMA,
30 MTK_DISP_COLOR,
31 MTK_DISP_AAL,
32 MTK_DISP_GAMMA,
33 MTK_DISP_UFOE,
34 MTK_DSI,
35 MTK_DPI,
36 MTK_DISP_PWM,
37 MTK_DISP_MUTEX,
38 MTK_DISP_OD,
39 MTK_DDP_COMP_TYPE_MAX,
42 enum mtk_ddp_comp_id {
43 DDP_COMPONENT_AAL,
44 DDP_COMPONENT_COLOR0,
45 DDP_COMPONENT_COLOR1,
46 DDP_COMPONENT_DPI0,
47 DDP_COMPONENT_DSI0,
48 DDP_COMPONENT_DSI1,
49 DDP_COMPONENT_GAMMA,
50 DDP_COMPONENT_OD,
51 DDP_COMPONENT_OVL0,
52 DDP_COMPONENT_OVL1,
53 DDP_COMPONENT_PWM0,
54 DDP_COMPONENT_PWM1,
55 DDP_COMPONENT_RDMA0,
56 DDP_COMPONENT_RDMA1,
57 DDP_COMPONENT_RDMA2,
58 DDP_COMPONENT_UFOE,
59 DDP_COMPONENT_WDMA0,
60 DDP_COMPONENT_WDMA1,
61 DDP_COMPONENT_ID_MAX,
64 struct mtk_ddp_comp;
66 struct mtk_ddp_comp_funcs {
67 void (*config)(struct mtk_ddp_comp *comp, unsigned int w,
68 unsigned int h, unsigned int vrefresh, unsigned int bpc);
69 void (*start)(struct mtk_ddp_comp *comp);
70 void (*stop)(struct mtk_ddp_comp *comp);
71 void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc);
72 void (*disable_vblank)(struct mtk_ddp_comp *comp);
73 void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx);
74 void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx);
75 void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
76 struct mtk_plane_state *state);
77 void (*gamma_set)(struct mtk_ddp_comp *comp,
78 struct drm_crtc_state *state);
81 struct mtk_ddp_comp {
82 struct clk *clk;
83 void __iomem *regs;
84 int irq;
85 struct device *larb_dev;
86 enum mtk_ddp_comp_id id;
87 const struct mtk_ddp_comp_funcs *funcs;
90 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
91 unsigned int w, unsigned int h,
92 unsigned int vrefresh, unsigned int bpc)
94 if (comp->funcs && comp->funcs->config)
95 comp->funcs->config(comp, w, h, vrefresh, bpc);
98 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
100 if (comp->funcs && comp->funcs->start)
101 comp->funcs->start(comp);
104 static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp)
106 if (comp->funcs && comp->funcs->stop)
107 comp->funcs->stop(comp);
110 static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp,
111 struct drm_crtc *crtc)
113 if (comp->funcs && comp->funcs->enable_vblank)
114 comp->funcs->enable_vblank(comp, crtc);
117 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
119 if (comp->funcs && comp->funcs->disable_vblank)
120 comp->funcs->disable_vblank(comp);
123 static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp *comp,
124 unsigned int idx)
126 if (comp->funcs && comp->funcs->layer_on)
127 comp->funcs->layer_on(comp, idx);
130 static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp,
131 unsigned int idx)
133 if (comp->funcs && comp->funcs->layer_off)
134 comp->funcs->layer_off(comp, idx);
137 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
138 unsigned int idx,
139 struct mtk_plane_state *state)
141 if (comp->funcs && comp->funcs->layer_config)
142 comp->funcs->layer_config(comp, idx, state);
145 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
146 struct drm_crtc_state *state)
148 if (comp->funcs && comp->funcs->gamma_set)
149 comp->funcs->gamma_set(comp, state);
152 int mtk_ddp_comp_get_id(struct device_node *node,
153 enum mtk_ddp_comp_type comp_type);
154 int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
155 struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
156 const struct mtk_ddp_comp_funcs *funcs);
157 int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp);
158 void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp);
159 void mtk_dither_set(struct mtk_ddp_comp *comp, unsigned int bpc,
160 unsigned int CFG);
162 #endif /* MTK_DRM_DDP_COMP_H */