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
23 struct mtk_plane_state
;
24 struct drm_crtc_state
;
26 enum mtk_ddp_comp_type
{
40 MTK_DDP_COMP_TYPE_MAX
,
43 enum mtk_ddp_comp_id
{
68 struct mtk_ddp_comp_funcs
{
69 void (*config
)(struct mtk_ddp_comp
*comp
, unsigned int w
,
70 unsigned int h
, unsigned int vrefresh
, unsigned int bpc
);
71 void (*start
)(struct mtk_ddp_comp
*comp
);
72 void (*stop
)(struct mtk_ddp_comp
*comp
);
73 void (*enable_vblank
)(struct mtk_ddp_comp
*comp
, struct drm_crtc
*crtc
);
74 void (*disable_vblank
)(struct mtk_ddp_comp
*comp
);
75 void (*layer_on
)(struct mtk_ddp_comp
*comp
, unsigned int idx
);
76 void (*layer_off
)(struct mtk_ddp_comp
*comp
, unsigned int idx
);
77 void (*layer_config
)(struct mtk_ddp_comp
*comp
, unsigned int idx
,
78 struct mtk_plane_state
*state
);
79 void (*gamma_set
)(struct mtk_ddp_comp
*comp
,
80 struct drm_crtc_state
*state
);
87 struct device
*larb_dev
;
88 enum mtk_ddp_comp_id id
;
89 const struct mtk_ddp_comp_funcs
*funcs
;
92 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp
*comp
,
93 unsigned int w
, unsigned int h
,
94 unsigned int vrefresh
, unsigned int bpc
)
96 if (comp
->funcs
&& comp
->funcs
->config
)
97 comp
->funcs
->config(comp
, w
, h
, vrefresh
, bpc
);
100 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp
*comp
)
102 if (comp
->funcs
&& comp
->funcs
->start
)
103 comp
->funcs
->start(comp
);
106 static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp
*comp
)
108 if (comp
->funcs
&& comp
->funcs
->stop
)
109 comp
->funcs
->stop(comp
);
112 static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp
*comp
,
113 struct drm_crtc
*crtc
)
115 if (comp
->funcs
&& comp
->funcs
->enable_vblank
)
116 comp
->funcs
->enable_vblank(comp
, crtc
);
119 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp
*comp
)
121 if (comp
->funcs
&& comp
->funcs
->disable_vblank
)
122 comp
->funcs
->disable_vblank(comp
);
125 static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp
*comp
,
128 if (comp
->funcs
&& comp
->funcs
->layer_on
)
129 comp
->funcs
->layer_on(comp
, idx
);
132 static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp
*comp
,
135 if (comp
->funcs
&& comp
->funcs
->layer_off
)
136 comp
->funcs
->layer_off(comp
, idx
);
139 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp
*comp
,
141 struct mtk_plane_state
*state
)
143 if (comp
->funcs
&& comp
->funcs
->layer_config
)
144 comp
->funcs
->layer_config(comp
, idx
, state
);
147 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp
*comp
,
148 struct drm_crtc_state
*state
)
150 if (comp
->funcs
&& comp
->funcs
->gamma_set
)
151 comp
->funcs
->gamma_set(comp
, state
);
154 int mtk_ddp_comp_get_id(struct device_node
*node
,
155 enum mtk_ddp_comp_type comp_type
);
156 int mtk_ddp_comp_init(struct device
*dev
, struct device_node
*comp_node
,
157 struct mtk_ddp_comp
*comp
, enum mtk_ddp_comp_id comp_id
,
158 const struct mtk_ddp_comp_funcs
*funcs
);
159 int mtk_ddp_comp_register(struct drm_device
*drm
, struct mtk_ddp_comp
*comp
);
160 void mtk_ddp_comp_unregister(struct drm_device
*drm
, struct mtk_ddp_comp
*comp
);
161 void mtk_dither_set(struct mtk_ddp_comp
*comp
, unsigned int bpc
,
164 #endif /* MTK_DRM_DDP_COMP_H */