1 #ifndef _TDM_DRM_TYPES_H_
2 #define _TDM_DRM_TYPES_H_
11 #include <sys/types.h>
13 #include <sys/ioctl.h>
18 #include <xf86drmMode.h>
19 #include <tbm_surface.h>
20 #include <tbm_surface_internal.h>
21 #include <tdm_backend.h>
24 #include <drm_fourcc.h>
25 #include <tdm_helper.h>
33 /* drm module internal macros, structures, functions */
34 #define NEVER_GET_HERE() TDM_ERR("** NEVER GET HERE **")
36 #define C(b, m) (((b) >> (m)) & 0xFF)
37 #define B(c, s) ((((unsigned int)(c)) & 0xff) << (s))
38 #define FOURCC(a, b, c, d) (B(d, 24) | B(c, 16) | B(b, 8) | B(a, 0))
39 #define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24)
41 #define IS_RGB(format) (format == TBM_FORMAT_XRGB8888 || format == TBM_FORMAT_ARGB8888 || \
42 format == TBM_FORMAT_XBGR8888 || format == TBM_FORMAT_ABGR8888)
44 #define CLEAR(x) memset(&(x), 0, sizeof(x))
45 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
46 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
47 #define SWAP(a, b) ({int t; t = a; a = b; b = t; })
48 #define ROUNDUP(x) (ceil(floor((float)(height) / 4)))
50 #define ALIGN_TO_16B(x) ((((x) + (1 << 4) - 1) >> 4) << 4)
51 #define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
52 #define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
53 #define ALIGN_TO_2KB(x) ((((x) + (1 << 11) - 1) >> 11) << 11)
54 #define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
55 #define ALIGN_TO_64KB(x) ((((x) + (1 << 16) - 1) >> 16) << 16)
57 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
59 #define CURSOR_MIN_W 192
60 #define CURSOR_MIN_H 192
61 #define CURSOR_MAX_W 192
62 #define CURSOR_MAX_H 192
64 #define RETURN_VAL_IF_FAIL(cond, val) {\
66 TDM_ERR("'%s' failed", #cond);\
71 #define RETURN_IF_FAIL(cond) {\
73 TDM_ERR("'%s' failed", #cond);\
78 #define GOTO_IF_FAIL(cond, val) {\
80 TDM_ERR("'%s' failed", #cond);\
85 typedef struct _tdm_drm_data tdm_drm_data;
86 typedef struct _tdm_drm_output_data tdm_drm_output_data;
87 typedef struct _tdm_drm_layer_data tdm_drm_layer_data;
88 typedef struct _tdm_drm_hwc_data tdm_drm_hwc_data;
89 typedef struct _tdm_drm_hwc_window_data tdm_drm_hwc_window_data;
90 typedef struct _tdm_drm_event_data tdm_drm_event_data;
91 typedef struct _tdm_drm_display_buffer tdm_drm_display_buffer;
94 TDM_DRM_EVENT_TYPE_WAIT,
95 TDM_DRM_EVENT_TYPE_COMMIT,
96 TDM_DRM_EVENT_TYPE_PAGEFLIP,
99 struct _tdm_drm_data {
104 #if LIBDRM_MAJOR_VERSION >= 2 && LIBDRM_MINOR_VERSION >= 4 && LIBDRM_MICRO_VERSION >= 47
105 int has_universal_plane;
109 struct udev_monitor *uevent_monitor;
110 tdm_event_loop_source *uevent_source;
113 drmModeResPtr mode_res;
114 drmModePlaneResPtr plane_res;
118 struct list_head output_list;
119 struct list_head buffer_list;
122 struct _tdm_drm_display_buffer {
123 struct list_head link;
126 tbm_surface_h buffer;
130 unsigned int handles[4];
132 unsigned int pitches[4];
133 unsigned int offsets[4];
138 struct _tdm_drm_event_data {
139 tdm_drm_event_type type;
140 tdm_drm_output_data *output_data;
144 struct _tdm_drm_output_data {
145 struct list_head link;
147 /* data which are fixed at initializing */
148 tdm_drm_data *drm_data;
149 uint32_t connector_id;
153 uint32_t dpms_prop_id;
155 drmModeModeInfoPtr drm_modes;
156 tdm_output_mode *output_modes;
157 tdm_output_type connector_type;
158 unsigned int connector_type_id;
159 struct list_head layer_list;
160 tdm_drm_layer_data *primary_layer;
162 /* not fixed data below */
163 tdm_output_vblank_handler vblank_func;
164 tdm_output_commit_handler commit_func;
166 tdm_output_conn_status status;
167 tdm_output_status_handler status_func;
168 void *status_user_data;
171 const tdm_output_mode *current_mode;
175 tdm_drm_hwc_data *hwc_data;
178 tdm_output_dpms current_dpms;
181 struct _tdm_drm_layer_data {
182 struct list_head link;
184 /* data which are fixed at initializing */
185 tdm_drm_data *drm_data;
186 tdm_drm_output_data *output_data;
188 tdm_layer_capability capabilities;
191 /* not fixed data below */
195 tdm_drm_display_buffer *display_buffer;
196 int display_buffer_changed;
199 struct _tdm_drm_hwc_data {
200 tdm_drm_hwc_window_data *target_hwc_window;
203 int need_target_window;
206 int target_window_zpos;
208 tdm_drm_output_data *output_data;
209 struct list_head hwc_window_list;
211 tbm_surface_h cursor_tsurface;
213 tdm_hwc_commit_handler commit_func;
216 struct _tdm_drm_hwc_window_data {
217 struct list_head link;
219 tdm_drm_hwc_data *hwc_data;
221 tdm_hwc_window_info info;
222 tbm_surface_h surface;
223 tdm_hwc_window_composition client_type;
224 tdm_hwc_window_composition validated_type;
227 char name[TDM_NAME_LEN];
234 int cursor_img_surface;
235 int cursor_img_refresh;
238 #endif /* _TDM_DRM_TYPES_H_ */