1 #ifndef _TDM_NEXELL_TYPES_H_
2 #define _TDM_NEXELL_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>
31 #define C(b, m) (((b) >> (m)) & 0xFF)
32 #define B(c, s) ((((unsigned int)(c)) & 0xff) << (s))
33 #define FOURCC(a, b, c, d) (B(d, 24) | B(c, 16) | B(b, 8) | B(a, 0))
34 #define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24)
36 #define IS_RGB(format) (format == TBM_FORMAT_XRGB8888 || format == TBM_FORMAT_ARGB8888 || \
37 format == TBM_FORMAT_XBGR8888 || format == TBM_FORMAT_ABGR8888)
39 #define CLEAR(x) memset(&(x), 0, sizeof(x))
40 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
41 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
42 #define SWAP(a, b) ({int t; t = a; a = b; b = t; })
43 #define ROUNDUP(x) (ceil(floor((float)(height) / 4)))
45 #define ALIGN_TO_16B(x) ((((x) + (1 << 4) - 1) >> 4) << 4)
46 #define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
47 #define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
48 #define ALIGN_TO_2KB(x) ((((x) + (1 << 11) - 1) >> 11) << 11)
49 #define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
50 #define ALIGN_TO_64KB(x) ((((x) + (1 << 16) - 1) >> 16) << 16)
52 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
54 #define CURSOR_MIN_W 192
55 #define CURSOR_MIN_H 192
56 #define CURSOR_MAX_W 192
57 #define CURSOR_MAX_H 192
62 #define NUM_UI_LAYERS 2
64 #define ZPOS_CURSOR 2 // cursor
65 #define ZPOS_2 2 // ui
66 #define ZPOS_1 1 // ui, primary layer
67 #define ZPOS_0 0 // video
68 #define ZPOS_VIDEO1 0 // video
69 #define ZPOS_NONE -999
71 #define RETURN_VAL_IF_FAIL(cond, val) {\
73 TDM_ERR("'%s' failed", #cond);\
78 #define RETURN_IF_FAIL(cond) {\
80 TDM_ERR("'%s' failed", #cond);\
85 #define GOTO_IF_FAIL(cond, val) {\
87 TDM_ERR("'%s' failed", #cond);\
92 typedef struct _tdm_nexell_data tdm_nexell_data;
93 typedef struct _tdm_nexell_output_data tdm_nexell_output_data;
94 typedef struct _tdm_nexell_layer_data tdm_nexell_layer_data;
95 typedef struct _tdm_nexell_hwc_data tdm_nexell_hwc_data;
96 typedef struct _tdm_nexell_hwc_window_data tdm_nexell_hwc_window_data;
97 typedef struct _tdm_nexell_event_data tdm_nexell_event_data;
98 typedef struct _tdm_nexell_display_buffer tdm_nexell_display_buffer;
101 TDM_NEXELL_EVENT_TYPE_WAIT,
102 TDM_NEXELL_EVENT_TYPE_COMMIT,
103 TDM_NEXELL_EVENT_TYPE_PAGEFLIP,
104 } tdm_nexell_event_type;
106 struct _tdm_nexell_data
113 #if LIBDRM_MAJOR_VERSION >= 2 && LIBDRM_MINOR_VERSION >= 4 && LIBDRM_MICRO_VERSION >= 47
114 int has_universal_plane;
118 struct udev_monitor *uevent_monitor;
119 tdm_event_loop_source *uevent_source;
122 drmModeResPtr mode_res;
123 drmModePlaneResPtr plane_res;
127 struct list_head output_list;
128 struct list_head buffer_list;
131 struct _tdm_nexell_display_buffer {
132 struct list_head link;
135 tbm_surface_h buffer;
139 unsigned int handles[4];
141 unsigned int pitches[4];
142 unsigned int offsets[4];
147 struct _tdm_nexell_event_data {
148 tdm_nexell_event_type type;
149 tdm_nexell_output_data *output_data;
153 struct _tdm_nexell_output_data {
154 struct list_head link;
156 /* data which are fixed at initializing */
157 tdm_nexell_data *nexell_data;
158 uint32_t connector_id;
162 uint32_t dpms_prop_id;
164 drmModeModeInfoPtr drm_modes;
165 tdm_output_mode *output_modes;
166 tdm_output_type connector_type;
167 unsigned int connector_type_id;
168 struct list_head layer_list;
169 tdm_nexell_layer_data *primary_layer;
171 /* not fixed data below */
172 tdm_output_vblank_handler vblank_func;
173 tdm_output_commit_handler commit_func;
175 tdm_output_conn_status status;
176 tdm_output_status_handler status_func;
177 void *status_user_data;
180 const tdm_output_mode *current_mode;
182 tbm_surface_h crtc_buffer;
184 unsigned int crtc_fb_id;
188 tdm_nexell_hwc_data *hwc_data;
191 struct _tdm_nexell_layer_data {
192 struct list_head link;
194 /* data which are fixed at initializing */
195 tdm_nexell_data *nexell_data;
196 tdm_nexell_output_data *output_data;
198 tdm_layer_capability capabilities;
201 /* not fixed data below */
205 tdm_nexell_display_buffer *display_buffer;
206 int display_buffer_changed;
209 struct _tdm_nexell_hwc_data {
210 tdm_nexell_hwc_window_data *target_hwc_window;
213 int need_target_window;
216 int target_window_zpos;
218 tdm_nexell_output_data *output_data;
219 struct list_head hwc_window_list;
221 tbm_surface_h cursor_tsurface;
223 /* UI buffer_queue list for the reserved scanout memory */
225 tbm_surface_queue_h tqueue;
227 } ui_buffer_queue[NUM_LAYERS];
229 tdm_hwc_commit_handler commit_func;
232 struct _tdm_nexell_hwc_window_data {
233 struct list_head link;
235 tdm_nexell_hwc_data *hwc_data;
237 tdm_hwc_window_info info;
238 tbm_surface_h surface;
239 tdm_hwc_window_composition client_type;
240 tdm_hwc_window_composition validated_type;
244 char name[TDM_NAME_LEN];
251 int cursor_img_surface;
252 int cursor_img_refresh;
255 tbm_surface_queue_h tqueue;
258 #endif /* _TDM_NEXELL_TYPES_H_ */