1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2015 MediaTek Inc.
6 #ifndef MTK_DRM_DDP_COMP_H
7 #define MTK_DRM_DDP_COMP_H
15 struct mtk_plane_state;
16 struct drm_crtc_state;
18 enum mtk_ddp_comp_type {
32 MTK_DDP_COMP_TYPE_MAX,
35 enum mtk_ddp_comp_id {
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 unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);
74 void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx);
75 void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx);
76 void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
77 struct mtk_plane_state *state);
78 void (*gamma_set)(struct mtk_ddp_comp *comp,
79 struct drm_crtc_state *state);
86 struct device *larb_dev;
87 enum mtk_ddp_comp_id id;
88 const struct mtk_ddp_comp_funcs *funcs;
91 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
92 unsigned int w, unsigned int h,
93 unsigned int vrefresh, unsigned int bpc)
95 if (comp->funcs && comp->funcs->config)
96 comp->funcs->config(comp, w, h, vrefresh, bpc);
99 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
101 if (comp->funcs && comp->funcs->start)
102 comp->funcs->start(comp);
105 static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp)
107 if (comp->funcs && comp->funcs->stop)
108 comp->funcs->stop(comp);
111 static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp,
112 struct drm_crtc *crtc)
114 if (comp->funcs && comp->funcs->enable_vblank)
115 comp->funcs->enable_vblank(comp, crtc);
118 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
120 if (comp->funcs && comp->funcs->disable_vblank)
121 comp->funcs->disable_vblank(comp);
124 static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
126 if (comp->funcs && comp->funcs->layer_nr)
127 return comp->funcs->layer_nr(comp);
132 static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp *comp,
135 if (comp->funcs && comp->funcs->layer_on)
136 comp->funcs->layer_on(comp, idx);
139 static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp,
142 if (comp->funcs && comp->funcs->layer_off)
143 comp->funcs->layer_off(comp, idx);
146 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
148 struct mtk_plane_state *state)
150 if (comp->funcs && comp->funcs->layer_config)
151 comp->funcs->layer_config(comp, idx, state);
154 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
155 struct drm_crtc_state *state)
157 if (comp->funcs && comp->funcs->gamma_set)
158 comp->funcs->gamma_set(comp, state);
161 int mtk_ddp_comp_get_id(struct device_node *node,
162 enum mtk_ddp_comp_type comp_type);
163 int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
164 struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
165 const struct mtk_ddp_comp_funcs *funcs);
166 int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp);
167 void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp);
168 void mtk_dither_set(struct mtk_ddp_comp *comp, unsigned int bpc,
171 #endif /* MTK_DRM_DDP_COMP_H */