summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2/ecore_drm2_private.h
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2016-11-14 13:33:44 -0500
committerChris Michael <cp.michael@samsung.com>2016-11-15 08:42:07 -0500
commitb820ad367641cceef2071fd25619a0dc09a4681a (patch)
treea8e8027d47982a152a49cb7cd58b84a8b18c1845 /src/lib/ecore_drm2/ecore_drm2_private.h
parentfc81a998c871513bb2cd794b26ff307a0c153c7c (diff)
ecore-drm2: Add structure definitions and function symlinks for libdrm
As we are moving away from linking to libdrm during compile time, and instead dlsym to things we need at runtime, we need to include copies of the libdrm structures that we will be using along with function declarations that we symlink to. @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm2/ecore_drm2_private.h')
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_private.h486
1 files changed, 482 insertions, 4 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index e02018d2bc..3a26237212 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -18,10 +18,7 @@
18# include <ctype.h> 18# include <ctype.h>
19 19
20# include <sys/ioctl.h> 20# include <sys/ioctl.h>
21# include <xf86drm.h> 21# include <dlfcn.h>
22# include <xf86drmMode.h>
23# include <drm_mode.h>
24# include <drm_fourcc.h>
25 22
26extern int _ecore_drm2_log_dom; 23extern int _ecore_drm2_log_dom;
27extern Eina_Bool _ecore_drm2_use_atomic; 24extern Eina_Bool _ecore_drm2_use_atomic;
@@ -56,7 +53,446 @@ extern Eina_Bool _ecore_drm2_use_atomic;
56# endif 53# endif
57# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm2_log_dom, __VA_ARGS__) 54# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm2_log_dom, __VA_ARGS__)
58 55
56# define DRM_MODE_FEATURE_DIRTYFB 1 // drm.h
57
58// drm_mode.h
59# define DRM_MODE_TYPE_BUILTIN (1<<0)
60# define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
61# define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
62# define DRM_MODE_TYPE_PREFERRED (1<<3)
63# define DRM_MODE_TYPE_DEFAULT (1<<4)
64# define DRM_MODE_TYPE_USERDEF (1<<5)
65# define DRM_MODE_TYPE_DRIVER (1<<6)
66
67# define DRM_MODE_PROP_BLOB (1<<4)
68
69# define DRM_MODE_DPMS_ON 0
70# define DRM_MODE_DPMS_STANDBY 1
71# define DRM_MODE_DPMS_SUSPEND 2
72# define DRM_MODE_DPMS_OFF 3
73// end drm_mode.h
74
75// xf86drm.h
76typedef enum
77{
78 DRM_VBLANK_ABSOLUTE = 0x00000000,
79 DRM_VBLANK_RELATIVE = 0x00000001,
80 DRM_VBLANK_EVENT = 0x04000000,
81 DRM_VBLANK_FLIP = 0x08000000,
82 DRM_VBLANK_NEXTONMISS = 0x10000000,
83 DRM_VBLANK_SECONDARY = 0x20000000,
84 DRM_VBLANK_SIGNAL = 0x40000000
85} drmVBlankSeqType;
86
87typedef enum
88{
89 DRM_MODE_CONNECTED = 1,
90 DRM_MODE_DISCONNECTED = 2,
91 DRM_MODE_UNKNOWNCONNECTION = 3
92} drmModeConnection;
93
94typedef enum
95{
96 DRM_MODE_SUBPIXEL_UNKNOWN = 1,
97 DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
98 DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
99 DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4,
100 DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5,
101 DRM_MODE_SUBPIXEL_NONE = 6
102} drmModeSubPixel;
103
104// xf86drm.h
105typedef struct _drmVBlankReq
106{
107 drmVBlankSeqType type;
108 unsigned int sequence;
109 unsigned long signal;
110} drmVBlankReq;
111
112// xf86drm.h
113typedef struct _drmVBlankReply
114{
115 drmVBlankSeqType type;
116 unsigned int sequence;
117 long tval_sec;
118 long tval_usec;
119} drmVBlankReply;
120
121// xf86drm.h
122typedef union _drmVBlank
123{
124 drmVBlankReq request;
125 drmVBlankReply reply;
126} drmVBlank;
127
128// xf86drm.h
129# define DRM_EVENT_CONTEXT_VERSION 2
130
131// xf86drm.h
132typedef struct _drmEventContext
133{
134 int version;
135 void (*vblank_handler)(int fd,
136 unsigned int sequence,
137 unsigned int tv_sec,
138 unsigned int tv_usec,
139 void *user_data);
140 void (*page_flip_handler)(int fd,
141 unsigned int sequence,
142 unsigned int tv_sec,
143 unsigned int tv_usec,
144 void *user_data);
145} drmEventContext;
146
147// xf86drm.h
148typedef struct _drmVersionBroken
149{
150 int version_major;
151 int version_minor;
152 int version_patchlevel;
153 size_t name_len;
154 // WARNING! this does NOT match the system drm.h headers because
155 // literally drm.h is wrong. the below is correct. drm hapily
156 // broke its ABI at some point.
157 char *name;
158 size_t date_len;
159 char *date;
160 size_t desc_len;
161 char *desc;
162} drmVersionBroken;
163
164// xf86drm.h
165typedef struct _drmVersion
166{
167 int version_major;
168 int version_minor;
169 int version_patchlevel;
170 int name_len;
171 // WARNING! this does NOT match the system drm.h headers because
172 // literally drm.h is wrong. the below is correct. drm hapily
173 // broke its ABI at some point.
174 char *name;
175 int date_len;
176 char *date;
177 int desc_len;
178 char *desc;
179} drmVersion, *drmVersionPtr;
180
181// drm_mode.h
182# define DRM_DISPLAY_MODE_LEN 32
183
184# define DRM_MODE_FLAG_PHSYNC (1<<0)
185# define DRM_MODE_FLAG_NHSYNC (1<<1)
186# define DRM_MODE_FLAG_PVSYNC (1<<2)
187# define DRM_MODE_FLAG_NVSYNC (1<<3)
188# define DRM_MODE_FLAG_INTERLACE (1<<4)
189# define DRM_MODE_FLAG_DBLSCAN (1<<5)
190# define DRM_MODE_FLAG_CSYNC (1<<6)
191# define DRM_MODE_FLAG_PCSYNC (1<<7)
192# define DRM_MODE_FLAG_NCSYNC (1<<8)
193# define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
194# define DRM_MODE_FLAG_BCAST (1<<10)
195# define DRM_MODE_FLAG_PIXMUX (1<<11)
196# define DRM_MODE_FLAG_DBLCLK (1<<12)
197# define DRM_MODE_FLAG_CLKDIV2 (1<<13)
198# define DRM_MODE_FLAG_3D_MASK (0x1f<<14)
199# define DRM_MODE_FLAG_3D_NONE (0<<14)
200# define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
201# define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14)
202# define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14)
203# define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14)
204# define DRM_MODE_FLAG_3D_L_DEPTH (5<<14)
205# define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14)
206# define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14)
207# define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14)
208
209typedef struct _drmModePropertyBlob
210{
211 uint32_t id;
212 uint32_t length;
213 void *data;
214} drmModePropertyBlobRes, *drmModePropertyBlobPtr;
215
216typedef struct _drmModeModeInfo
217{
218 uint32_t clock;
219 uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
220 uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
221
222 uint32_t vrefresh;
223
224 uint32_t flags;
225 uint32_t type;
226 char name[DRM_DISPLAY_MODE_LEN];
227} drmModeModeInfo, *drmModeModeInfoPtr;
228
229typedef struct _drmModeCrtc
230{
231 uint32_t crtc_id;
232 uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */
233
234 uint32_t x, y; /**< Position on the framebuffer */
235 uint32_t width, height;
236 int mode_valid;
237 drmModeModeInfo mode;
238
239 int gamma_size; /**< Number of gamma stops */
240} drmModeCrtc, *drmModeCrtcPtr;
241
242// drm_mode.h
243# define DRM_PROP_NAME_LEN 32
244
245typedef struct _drm_mode_property_enum
246{
247 uint64_t value;
248 char name[DRM_PROP_NAME_LEN];
249} drm_mode_property_enum;
250
251// drm_mode.h
252typedef struct _drmModeProperty
253{
254 uint32_t prop_id;
255 uint32_t flags;
256 char name[DRM_PROP_NAME_LEN];
257 int count_values;
258 uint64_t *values; /* store the blob lengths */
259 int count_enums;
260 drm_mode_property_enum *enums;
261 int count_blobs;
262 uint32_t *blob_ids; /* store the blob IDs */
263} drmModePropertyRes, *drmModePropertyPtr;
264
265typedef struct _drmModeEncoder
266{
267 uint32_t encoder_id;
268 uint32_t encoder_type;
269 uint32_t crtc_id;
270 uint32_t possible_crtcs;
271 uint32_t possible_clones;
272} drmModeEncoder, *drmModeEncoderPtr;
273
274// drm_mode.h
275# define DRM_CONNECTOR_NAME_LEN 32
276
277// drm_mode.h
278# define DRM_MODE_CONNECTOR_Unknown 0
279# define DRM_MODE_CONNECTOR_VGA 1
280# define DRM_MODE_CONNECTOR_DVII 2
281# define DRM_MODE_CONNECTOR_DVID 3
282# define DRM_MODE_CONNECTOR_DVIA 4
283# define DRM_MODE_CONNECTOR_Composite 5
284# define DRM_MODE_CONNECTOR_SVIDEO 6
285# define DRM_MODE_CONNECTOR_LVDS 7
286# define DRM_MODE_CONNECTOR_Component 8
287# define DRM_MODE_CONNECTOR_9PinDIN 9
288# define DRM_MODE_CONNECTOR_DisplayPort 10
289# define DRM_MODE_CONNECTOR_HDMIA 11
290# define DRM_MODE_CONNECTOR_HDMIB 12
291# define DRM_MODE_CONNECTOR_TV 13
292# define DRM_MODE_CONNECTOR_eDP 14
293# define DRM_MODE_CONNECTOR_VIRTUAL 15
294# define DRM_MODE_CONNECTOR_DSI 16
295
296typedef struct _drmModeConnector
297{
298 uint32_t connector_id;
299 uint32_t encoder_id; /**< Encoder currently connected to */
300 uint32_t connector_type;
301 uint32_t connector_type_id;
302 drmModeConnection connection;
303 uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
304 drmModeSubPixel subpixel;
305
306 int count_modes;
307 drmModeModeInfoPtr modes;
308
309 int count_props;
310 uint32_t *props; /**< List of property ids */
311 uint64_t *prop_values; /**< List of property values */
312
313 int count_encoders;
314 uint32_t *encoders; /**< List of encoder ids */
315} drmModeConnector, *drmModeConnectorPtr;
316
317typedef struct _drmModeRes
318{
319 int count_fbs;
320 uint32_t *fbs;
321
322 int count_crtcs;
323 uint32_t *crtcs;
324
325 int count_connectors;
326 uint32_t *connectors;
327
328 int count_encoders;
329 uint32_t *encoders;
330
331 uint32_t min_width, max_width;
332 uint32_t min_height, max_height;
333} drmModeRes, *drmModeResPtr;
334
335// drm_mode.h
336typedef struct _drm_mode_fb_cmd2
337{
338 uint32_t fb_id;
339 uint32_t width;
340 uint32_t height;
341 uint32_t pixel_format; /* fourcc code from drm_fourcc.h */
342 uint32_t flags; /* see above flags */
343
344 /*
345 * In case of planar formats, this ioctl allows up to 4
346 * buffer objects with offsets and pitches per plane.
347 * The pitch and offset order is dictated by the fourcc,
348 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
349 *
350 * YUV 4:2:0 image with a plane of 8 bit Y samples
351 * followed by an interleaved U/V plane containing
352 * 8 bit 2x2 subsampled colour difference samples.
353 *
354 * So it would consist of Y as offsets[0] and UV as
355 * offsets[1]. Note that offsets[0] will generally
356 * be 0 (but this is not required).
357 *
358 * To accommodate tiled, compressed, etc formats, a per-plane
359 * modifier can be specified. The default value of zero
360 * indicates "native" format as specified by the fourcc.
361 * Vendor specific modifier token. This allows, for example,
362 * different tiling/swizzling pattern on different planes.
363 * See discussion above of DRM_FORMAT_MOD_xxx.
364 */
365 uint32_t handles[4];
366 uint32_t pitches[4]; /* pitch for each plane */
367 uint32_t offsets[4]; /* offset of each plane */
368 uint64_t modifier[4]; /* ie, tiling, compressed (per plane) */
369} drm_mode_fb_cmd2;
370
371# define DRM_IOCTL_BASE 'd'
372# define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)
373# define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, drm_mode_fb_cmd2)
374
375# define DRM_CLIENT_CAP_STEREO_3D 1
376# define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
377# define DRM_CLIENT_CAP_ATOMIC 3
378# define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
379
380# define DRM_MODE_OBJECT_CRTC 0xcccccccc
381# define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
382# define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
383# define DRM_MODE_OBJECT_MODE 0xdededede
384# define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
385# define DRM_MODE_OBJECT_FB 0xfbfbfbfb
386# define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
387# define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
388# define DRM_MODE_OBJECT_ANY 0
389
390# define DRM_PLANE_TYPE_OVERLAY 0
391# define DRM_PLANE_TYPE_PRIMARY 1
392# define DRM_PLANE_TYPE_CURSOR 2
393
394# define DRM_MODE_PAGE_FLIP_EVENT 0x01
395# define DRM_MODE_PAGE_FLIP_ASYNC 0x02
396# define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT|DRM_MODE_PAGE_FLIP_ASYNC)
397
398typedef struct _drm_mode_create_dumb
399{
400 uint32_t height;
401 uint32_t width;
402 uint32_t bpp;
403 uint32_t flags;
404 /* handle, pitch, size will be returned */
405 uint32_t handle;
406 uint32_t pitch;
407 uint64_t size;
408} drm_mode_create_dumb;
409
410typedef struct _drm_mode_map_dumb
411{
412 /** Handle for the object being mapped. */
413 uint32_t handle;
414 uint32_t pad;
415 /**
416 * Fake offset to use for subsequent mmap call
417 *
418 * This is a fixed-size type for 32/64 compatibility.
419 */
420 uint64_t offset;
421} drm_mode_map_dumb;
422
423typedef struct _drm_mode_destroy_dumb
424{
425 uint32_t handle;
426} drm_mode_destroy_dumb;
427
428# define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, drm_mode_create_dumb)
429# define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, drm_mode_map_dumb)
430# define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, drm_mode_destroy_dumb)
431
432# define DRM_MODE_PROP_NAME_LEN 32
433
434typedef struct _drmModeObjectProperties
435{
436 uint32_t count_props;
437 uint32_t *props;
438 uint64_t *prop_values;
439} drmModeObjectProperties, *drmModeObjectPropertiesPtr;
440
441typedef struct _drmModePlane
442{
443 uint32_t count_formats;
444 uint32_t *formats;
445 uint32_t plane_id;
446
447 uint32_t crtc_id;
448 uint32_t fb_id;
449
450 uint32_t crtc_x, crtc_y;
451 uint32_t x, y;
452
453 uint32_t possible_crtcs;
454 uint32_t gamma_size;
455} drmModePlane, *drmModePlanePtr;
456
457typedef struct _drmModePlaneRes
458{
459 uint32_t count_planes;
460 uint32_t *planes;
461} drmModePlaneRes, *drmModePlaneResPtr;
462
463typedef struct _drmModeClip
464{
465 unsigned short x1, y1;
466 unsigned short x2, y2;
467} drmModeClip, *drmModeClipPtr;
468
59# ifdef HAVE_ATOMIC_DRM 469# ifdef HAVE_ATOMIC_DRM
470
471# define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
472# define DRM_MODE_ATOMIC_NONBLOCK 0x0200
473# define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
474
475# define DRM_MODE_ATOMIC_FLAGS \
476 (DRM_MODE_PAGE_FLIP_EVENT |\
477 DRM_MODE_PAGE_FLIP_ASYNC |\
478 DRM_MODE_ATOMIC_TEST_ONLY |\
479 DRM_MODE_ATOMIC_NONBLOCK |\
480 DRM_MODE_ATOMIC_ALLOW_MODESET)
481
482typedef struct _drmModeAtomicReqItem
483{
484 uint32_t object_id;
485 uint32_t property_id;
486 uint64_t value;
487} drmModeAtomicReqItem, *drmModeAtomicReqItemPtr;
488
489typedef struct _drmModeAtomicReq
490{
491 uint32_t cursor;
492 uint32_t size_items;
493 drmModeAtomicReqItemPtr items;
494} drmModeAtomicReq, *drmModeAtomicReqPtr;
495
60typedef struct _Ecore_Drm2_Atomic_State Ecore_Drm2_Atomic_State; 496typedef struct _Ecore_Drm2_Atomic_State Ecore_Drm2_Atomic_State;
61 497
62typedef struct _Ecore_Drm2_Atomic_Blob 498typedef struct _Ecore_Drm2_Atomic_Blob
@@ -259,4 +695,46 @@ struct _Ecore_Drm2_Device
259 Eina_List *outputs; 695 Eina_List *outputs;
260}; 696};
261 697
698/* extern int (*sym_drmClose)(int fd); */
699/* extern int (*sym_drmWaitVBlank)(int fd, drmVBlank *vbl); */
700extern int (*sym_drmHandleEvent)(int fd, drmEventContext *evctx);
701extern void *(*sym_drmGetVersion)(int fd);
702extern void (*sym_drmFreeVersion)(void *drmver);
703extern void *(*sym_drmModeGetProperty)(int fd, uint32_t propertyId);
704extern void (*sym_drmModeFreeProperty)(drmModePropertyPtr ptr);
705extern void *(*sym_drmModeGetPropertyBlob)(int fd, uint32_t blob_id);
706extern void (*sym_drmModeFreePropertyBlob)(drmModePropertyBlobPtr ptr);
707extern int (*sym_drmModeDestroyPropertyBlob)(int fd, uint32_t id);
708extern int (*sym_drmIoctl)(int fd, unsigned long request, void *arg);
709extern void *(*sym_drmModeObjectGetProperties)(int fd, uint32_t object_id, uint32_t object_type);
710extern void (*sym_drmModeFreeObjectProperties)(drmModeObjectPropertiesPtr ptr);
711extern int (*sym_drmModeCreatePropertyBlob)(int fd, const void *data, size_t size, uint32_t *id);
712# ifdef HAVE_ATOMIC_DRM
713extern void *(*sym_drmModeAtomicAlloc)(void);
714extern void (*sym_drmModeAtomicFree)(drmModeAtomicReqPtr req);
715extern int (*sym_drmModeAtomicAddProperty)(drmModeAtomicReqPtr req, uint32_t object_id, uint32_t property_id, uint64_t value);
716extern int (*sym_drmModeAtomicCommit)(int fd, drmModeAtomicReqPtr req, uint32_t flags, void *user_data);
717extern void (*sym_drmModeAtomicSetCursor)(drmModeAtomicReqPtr req, int cursor);
718# endif
719extern void *(*sym_drmModeGetEncoder)(int fd, uint32_t encoder_id);
720extern void (*sym_drmModeFreeEncoder)(drmModeEncoderPtr ptr);
721extern void *(*sym_drmModeGetCrtc)(int fd, uint32_t crtcId);
722extern void (*sym_drmModeFreeCrtc)(drmModeCrtcPtr ptr);
723extern int (*sym_drmModeSetCrtc)(int fd, uint32_t crtcId, uint32_t bufferId, uint32_t x, uint32_t y, uint32_t *connectors, int count, drmModeModeInfoPtr mode);
724extern void *(*sym_drmModeGetResources)(int fd);
725extern void (*sym_drmModeFreeResources)(drmModeResPtr ptr);
726extern void *(*sym_drmModeGetConnector)(int fd, uint32_t connectorId);
727extern void (*sym_drmModeFreeConnector)(drmModeConnectorPtr ptr);
728extern int (*sym_drmModeConnectorSetProperty)(int fd, uint32_t connector_id, uint32_t property_id, uint64_t value);
729extern int (*sym_drmGetCap)(int fd, uint64_t capability, uint64_t *value);
730extern int (*sym_drmSetClientCap)(int fd, uint64_t capability, uint64_t value);
731extern void *(*sym_drmModeGetPlaneResources)(int fd);
732extern void (*sym_drmModeFreePlaneResources)(drmModePlaneResPtr ptr);
733extern void *(*sym_drmModeGetPlane)(int fd, uint32_t plane_id);
734extern void (*sym_drmModeFreePlane)(drmModePlanePtr ptr);
735extern int (*sym_drmModeAddFB)(int fd, uint32_t width, uint32_t height, uint8_t depth, uint8_t bpp, uint32_t pitch, uint32_t bo_handle, uint32_t *buf_id);
736extern int (*sym_drmModeRmFB)(int fd, uint32_t bufferId);
737extern int (*sym_drmModePageFlip)(int fd, uint32_t crtc_id, uint32_t fb_id, uint32_t flags, void *user_data);
738extern int (*sym_drmModeDirtyFB)(int fd, uint32_t bufferId, drmModeClipPtr clips, uint32_t num_clips);
739
262#endif 740#endif