SDL  2.0
SDL_kmsdrmvideo.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #include "../../SDL_internal.h"
23 
24 #if SDL_VIDEO_DRIVER_KMSDRM
25 
26 /* SDL internals */
27 #include "../SDL_sysvideo.h"
28 #include "SDL_syswm.h"
29 #include "SDL_log.h"
30 #include "../../events/SDL_mouse_c.h"
31 #include "../../events/SDL_keyboard_c.h"
32 
33 #ifdef SDL_INPUT_LINUXEV
34 #include "../../core/linux/SDL_evdev.h"
35 #endif
36 
37 /* KMS/DRM declarations */
38 #include "SDL_kmsdrmvideo.h"
39 #include "SDL_kmsdrmevents.h"
40 #include "SDL_kmsdrmopengles.h"
41 #include "SDL_kmsdrmmouse.h"
42 #include "SDL_kmsdrmdyn.h"
43 
44 #define KMSDRM_DRI_CARD_0 "/dev/dri/card0"
45 
46 static int
47 KMSDRM_Available(void)
48 {
49  int available = 0;
50 
51  int drm_fd = open(KMSDRM_DRI_CARD_0, O_RDWR | O_CLOEXEC);
52  if (drm_fd >= 0) {
53  if (SDL_KMSDRM_LoadSymbols()) {
54  drmModeRes *resources = KMSDRM_drmModeGetResources(drm_fd);
55  if (resources != NULL) {
56  available = 1;
57  KMSDRM_drmModeFreeResources(resources);
58  }
60  }
61  close(drm_fd);
62  }
63 
64  return available;
65 }
66 
67 static void
68 KMSDRM_Destroy(SDL_VideoDevice * device)
69 {
70  if (device->driverdata != NULL) {
71  SDL_free(device->driverdata);
72  device->driverdata = NULL;
73  }
74 
75  SDL_free(device);
77 }
78 
79 static SDL_VideoDevice *
80 KMSDRM_Create(int devindex)
81 {
83  SDL_VideoData *vdata;
84 
85  if (devindex < 0 || devindex > 99) {
86  SDL_SetError("devindex (%d) must be between 0 and 99.\n", devindex);
87  return NULL;
88  }
89 
90  if (!SDL_KMSDRM_LoadSymbols()) {
91  return NULL;
92  }
93 
94  /* Initialize SDL_VideoDevice structure */
95  device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
96  if (device == NULL) {
98  return NULL;
99  }
100 
101  /* Initialize internal data */
102  vdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
103  if (vdata == NULL) {
104  SDL_OutOfMemory();
105  goto cleanup;
106  }
107  vdata->devindex = devindex;
108  vdata->drm_fd = -1;
109 
110  device->driverdata = vdata;
111 
112  /* Setup amount of available displays and current display */
113  device->num_displays = 0;
114 
115  /* Set device free function */
116  device->free = KMSDRM_Destroy;
117 
118  /* Setup all functions which we can handle */
119  device->VideoInit = KMSDRM_VideoInit;
120  device->VideoQuit = KMSDRM_VideoQuit;
129  device->ShowWindow = KMSDRM_ShowWindow;
130  device->HideWindow = KMSDRM_HideWindow;
138 #if SDL_VIDEO_OPENGL_EGL
148 #endif
149 
150  device->PumpEvents = KMSDRM_PumpEvents;
151 
152  return device;
153 
154 cleanup:
155  if (device != NULL)
156  SDL_free(device);
157  if (vdata != NULL)
158  SDL_free(vdata);
159  return NULL;
160 }
161 
163  "KMSDRM",
164  "KMS/DRM Video Driver",
165  KMSDRM_Available,
166  KMSDRM_Create
167 };
168 
169 
170 static void
171 KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data)
172 {
173  KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)data;
174 
175  if (fb_info && fb_info->drm_fd > 0 && fb_info->fb_id != 0) {
176  KMSDRM_drmModeRmFB(fb_info->drm_fd, fb_info->fb_id);
177  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Delete DRM FB %u", fb_info->fb_id);
178  }
179 
180  free(fb_info);
181 }
182 
184 KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
185 {
186  uint32_t w, h, stride, handle;
187  int ret;
189  KMSDRM_FBInfo *fb_info;
190 
191  fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo);
192  if (fb_info != NULL) {
193  /* Have a previously used framebuffer, return it */
194  return fb_info;
195  }
196 
197  /* Here a new DRM FB must be created */
198  fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo));
199  if (fb_info == NULL) {
200  SDL_OutOfMemory();
201  return NULL;
202  }
203  fb_info->drm_fd = vdata->drm_fd;
204 
205  w = KMSDRM_gbm_bo_get_width(bo);
206  h = KMSDRM_gbm_bo_get_height(bo);
207  stride = KMSDRM_gbm_bo_get_stride(bo);
208  handle = KMSDRM_gbm_bo_get_handle(bo).u32;
209 
210  ret = KMSDRM_drmModeAddFB(vdata->drm_fd, w, h, 24, 32, stride, handle, &fb_info->fb_id);
211  if (ret < 0) {
212  free(fb_info);
213  return NULL;
214  }
215  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, stride %u from BO %p", fb_info->fb_id, w, h, stride, (void *)bo);
216 
217  /* Associate our DRM framebuffer with this buffer object */
218  KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback);
219  return fb_info;
220 }
221 
222 SDL_bool
225 
226  while (wdata->waiting_for_flip) {
227  vdata->drm_pollfd.revents = 0;
228  if (poll(&vdata->drm_pollfd, 1, timeout) < 0) {
229  SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll error");
230  return SDL_FALSE;
231  }
232 
233  if (vdata->drm_pollfd.revents & (POLLHUP | POLLERR)) {
234  SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll hup or error");
235  return SDL_FALSE;
236  }
237 
238  if (vdata->drm_pollfd.revents & POLLIN) {
239  /* Page flip? If so, drmHandleEvent will unset wdata->waiting_for_flip */
240  KMSDRM_drmHandleEvent(vdata->drm_fd, &vdata->drm_evctx);
241  } else {
242  /* Timed out and page flip didn't happen */
243  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Dropping frame while waiting_for_flip");
244  return SDL_FALSE;
245  }
246  }
247  return SDL_TRUE;
248 }
249 
250 static void
251 KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data)
252 {
253  *((SDL_bool *) data) = SDL_FALSE;
254 }
255 
256 
257 /*****************************************************************************/
258 /* SDL Video and Display initialization/handling functions */
259 /* _this is a SDL_VideoDevice * */
260 /*****************************************************************************/
261 int
263 {
264  int i;
265  int ret = 0;
266  char *devname;
268  drmModeRes *resources = NULL;
269  drmModeConnector *connector = NULL;
270  drmModeEncoder *encoder = NULL;
271  SDL_DisplayMode current_mode;
272  SDL_VideoDisplay display;
273 
274  /* Allocate display internal data */
276  if (data == NULL) {
277  return SDL_OutOfMemory();
278  }
279 
280  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()");
281 
282  /* Open /dev/dri/cardNN */
283  devname = (char *) SDL_calloc(1, 16);
284  if (devname == NULL) {
285  ret = SDL_OutOfMemory();
286  goto cleanup;
287  }
288  SDL_snprintf(devname, 16, "/dev/dri/card%d", vdata->devindex);
289  vdata->drm_fd = open(devname, O_RDWR | O_CLOEXEC);
290  SDL_free(devname);
291 
292  if (vdata->drm_fd < 0) {
293  ret = SDL_SetError("Could not open /dev/dri/card%d.", vdata->devindex);
294  goto cleanup;
295  }
296  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", vdata->drm_fd);
297 
298  vdata->gbm = KMSDRM_gbm_create_device(vdata->drm_fd);
299  if (vdata->gbm == NULL) {
300  ret = SDL_SetError("Couldn't create gbm device.");
301  goto cleanup;
302  }
303 
304  /* Find the first available connector with modes */
305  resources = KMSDRM_drmModeGetResources(vdata->drm_fd);
306  if (!resources) {
307  ret = SDL_SetError("drmModeGetResources(%d) failed", vdata->drm_fd);
308  goto cleanup;
309  }
310 
311  for (i = 0; i < resources->count_connectors; i++) {
312  connector = KMSDRM_drmModeGetConnector(vdata->drm_fd, resources->connectors[i]);
313  if (connector == NULL)
314  continue;
315 
316  if (connector->connection == DRM_MODE_CONNECTED &&
317  connector->count_modes > 0) {
318  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found connector %d with %d modes.",
319  connector->connector_id, connector->count_modes);
320  vdata->saved_conn_id = connector->connector_id;
321  break;
322  }
323 
324  KMSDRM_drmModeFreeConnector(connector);
325  connector = NULL;
326  }
327 
328  if (i == resources->count_connectors) {
329  ret = SDL_SetError("No currently active connector found.");
330  goto cleanup;
331  }
332 
333  for (i = 0; i < resources->count_encoders; i++) {
334  encoder = KMSDRM_drmModeGetEncoder(vdata->drm_fd, resources->encoders[i]);
335 
336  if (encoder == NULL)
337  continue;
338 
339  if (encoder->encoder_id == connector->encoder_id) {
340  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found encoder %d.", encoder->encoder_id);
341  data->encoder_id = encoder->encoder_id;
342  break;
343  }
344 
345  KMSDRM_drmModeFreeEncoder(encoder);
346  encoder = NULL;
347  }
348 
349  if (i == resources->count_encoders) {
350  ret = SDL_SetError("No connected encoder found.");
351  goto cleanup;
352  }
353 
354  vdata->saved_crtc = KMSDRM_drmModeGetCrtc(vdata->drm_fd, encoder->crtc_id);
355  if (vdata->saved_crtc == NULL) {
356  ret = SDL_SetError("No CRTC found.");
357  goto cleanup;
358  }
359  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Saved crtc_id %u, fb_id %u, (%u,%u), %ux%u",
360  vdata->saved_crtc->crtc_id, vdata->saved_crtc->buffer_id, vdata->saved_crtc->x,
361  vdata->saved_crtc->y, vdata->saved_crtc->width, vdata->saved_crtc->height);
362  data->crtc_id = encoder->crtc_id;
363  data->cur_mode = vdata->saved_crtc->mode;
364 
365  SDL_zero(current_mode);
366 
367  current_mode.w = vdata->saved_crtc->mode.hdisplay;
368  current_mode.h = vdata->saved_crtc->mode.vdisplay;
369  current_mode.refresh_rate = vdata->saved_crtc->mode.vrefresh;
370 
371  /* FIXME ?
372  drmModeFB *fb = drmModeGetFB(vdata->drm_fd, vdata->saved_crtc->buffer_id);
373  current_mode.format = drmToSDLPixelFormat(fb->bpp, fb->depth);
374  drmModeFreeFB(fb);
375  */
376  current_mode.format = SDL_PIXELFORMAT_ARGB8888;
377 
378  current_mode.driverdata = NULL;
379 
380  SDL_zero(display);
381  display.desktop_mode = current_mode;
382  display.current_mode = current_mode;
383 
384  display.driverdata = data;
385  /* SDL_VideoQuit will later SDL_free(display.driverdata) */
386  SDL_AddVideoDisplay(&display);
387 
388  /* Setup page flip handler */
389  vdata->drm_pollfd.fd = vdata->drm_fd;
390  vdata->drm_pollfd.events = POLLIN;
391  vdata->drm_evctx.version = DRM_EVENT_CONTEXT_VERSION;
392  vdata->drm_evctx.page_flip_handler = KMSDRM_FlipHandler;
393 
394 #ifdef SDL_INPUT_LINUXEV
395  SDL_EVDEV_Init();
396 #endif
397 
399 
400 cleanup:
401  if (encoder != NULL)
402  KMSDRM_drmModeFreeEncoder(encoder);
403  if (connector != NULL)
404  KMSDRM_drmModeFreeConnector(connector);
405  if (resources != NULL)
406  KMSDRM_drmModeFreeResources(resources);
407 
408  if (ret != 0) {
409  /* Error (complete) cleanup */
410  SDL_free(data);
411  if(vdata->saved_crtc != NULL) {
412  KMSDRM_drmModeFreeCrtc(vdata->saved_crtc);
413  vdata->saved_crtc = NULL;
414  }
415  if (vdata->gbm != NULL) {
416  KMSDRM_gbm_device_destroy(vdata->gbm);
417  vdata->gbm = NULL;
418  }
419  if (vdata->drm_fd >= 0) {
420  close(vdata->drm_fd);
421  vdata->drm_fd = -1;
422  }
423  }
424  return ret;
425 }
426 
427 void
429 {
431 
432  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoQuit()");
433 
436  }
437 
438  if(vdata->saved_crtc != NULL) {
439  if(vdata->drm_fd > 0 && vdata->saved_conn_id > 0) {
440  /* Restore saved CRTC settings */
441  drmModeCrtc *crtc = vdata->saved_crtc;
442  if(KMSDRM_drmModeSetCrtc(vdata->drm_fd, crtc->crtc_id, crtc->buffer_id,
443  crtc->x, crtc->y, &vdata->saved_conn_id, 1,
444  &crtc->mode) != 0) {
445  SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not restore original CRTC mode");
446  }
447  }
448  KMSDRM_drmModeFreeCrtc(vdata->saved_crtc);
449  vdata->saved_crtc = NULL;
450  }
451  if (vdata->gbm != NULL) {
452  KMSDRM_gbm_device_destroy(vdata->gbm);
453  vdata->gbm = NULL;
454  }
455  if (vdata->drm_fd >= 0) {
456  close(vdata->drm_fd);
457  SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Closed DRM FD %d", vdata->drm_fd);
458  vdata->drm_fd = -1;
459  }
460 #ifdef SDL_INPUT_LINUXEV
461  SDL_EVDEV_Quit();
462 #endif
463 }
464 
465 void
467 {
468  /* Only one display mode available, the current one */
469  SDL_AddDisplayMode(display, &display->current_mode);
470 }
471 
472 int
474 {
475  return 0;
476 }
477 
478 int
480 {
481  SDL_WindowData *wdata;
482  SDL_VideoDisplay *display;
484  Uint32 surface_fmt, surface_flags;
485 
486  /* Allocate window internal data */
487  wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
488  if (wdata == NULL) {
489  SDL_OutOfMemory();
490  goto error;
491  }
492 
493  wdata->waiting_for_flip = SDL_FALSE;
494  display = SDL_GetDisplayForWindow(window);
495 
496  /* Windows have one size for now */
497  window->w = display->desktop_mode.w;
498  window->h = display->desktop_mode.h;
499 
500  /* Maybe you didn't ask for a fullscreen OpenGL window, but that's what you get */
502 
503  surface_fmt = GBM_FORMAT_XRGB8888;
504  surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
505 
506  if (!KMSDRM_gbm_device_is_format_supported(vdata->gbm, surface_fmt, surface_flags)) {
507  SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "GBM surface format not supported. Trying anyway.");
508  }
509  wdata->gs = KMSDRM_gbm_surface_create(vdata->gbm, window->w, window->h, surface_fmt, surface_flags);
510 
511 #if SDL_VIDEO_OPENGL_EGL
512  if (!_this->egl_data) {
513  if (SDL_GL_LoadLibrary(NULL) < 0) {
514  goto error;
515  }
516  }
517  wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wdata->gs);
518 
519  if (wdata->egl_surface == EGL_NO_SURFACE) {
520  SDL_SetError("Could not create EGL window surface");
521  goto error;
522  }
523 #endif /* SDL_VIDEO_OPENGL_EGL */
524 
525  /* Window is created, but we have yet to set up CRTC to one of the GBM buffers if we want
526  drmModePageFlip to work, and we can't do it until EGL is completely setup, because we
527  need to do eglSwapBuffers so we can get a valid GBM buffer object to call
528  drmModeSetCrtc on it. */
529  wdata->crtc_ready = SDL_FALSE;
530 
531  /* Setup driver data for this window */
532  window->driverdata = wdata;
533 
534  /* One window, it always has focus */
535  SDL_SetMouseFocus(window);
536  SDL_SetKeyboardFocus(window);
537 
538  /* Window has been successfully created */
539  return 0;
540 
541 error:
542  if (wdata != NULL) {
543 #if SDL_VIDEO_OPENGL_EGL
544  if (wdata->egl_surface != EGL_NO_SURFACE)
545  SDL_EGL_DestroySurface(_this, wdata->egl_surface);
546 #endif /* SDL_VIDEO_OPENGL_EGL */
547  if (wdata->gs != NULL)
548  KMSDRM_gbm_surface_destroy(wdata->gs);
549  SDL_free(wdata);
550  }
551  return -1;
552 }
553 
554 void
556 {
557  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
558  if(data) {
559  /* Wait for any pending page flips and unlock buffer */
560  KMSDRM_WaitPageFlip(_this, data, -1);
561  if (data->next_bo != NULL) {
562  KMSDRM_gbm_surface_release_buffer(data->gs, data->next_bo);
563  data->next_bo = NULL;
564  }
565  if (data->current_bo != NULL) {
566  KMSDRM_gbm_surface_release_buffer(data->gs, data->current_bo);
567  data->current_bo = NULL;
568  }
569 #if SDL_VIDEO_OPENGL_EGL
570  SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT);
571  if (data->egl_surface != EGL_NO_SURFACE) {
572  SDL_EGL_DestroySurface(_this, data->egl_surface);
573  }
574 #endif /* SDL_VIDEO_OPENGL_EGL */
575  if (data->gs != NULL) {
576  KMSDRM_gbm_surface_destroy(data->gs);
577  data->gs = NULL;
578  }
579  SDL_free(data);
580  window->driverdata = NULL;
581  }
582 }
583 
584 int
585 KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
586 {
587  return -1;
588 }
589 
590 void
592 {
593 }
594 void
596 {
597 }
598 void
600 {
601 }
602 void
604 {
605 }
606 void
608 {
609 }
610 void
612 {
613 }
614 void
616 {
617 }
618 void
620 {
621 }
622 void
624 {
625 }
626 void
628 {
629 }
630 void
631 KMSDRM_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
632 {
633 
634 }
635 
636 /*****************************************************************************/
637 /* SDL Window Manager function */
638 /*****************************************************************************/
639 SDL_bool
640 KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
641 {
642  if (info->version.major <= SDL_MAJOR_VERSION) {
643  return SDL_TRUE;
644  } else {
645  SDL_SetError("application not compiled with SDL %d.%d\n",
647  return SDL_FALSE;
648  }
649 
650  /* Failed to get window manager information */
651  return SDL_FALSE;
652 }
653 
654 #endif /* SDL_VIDEO_DRIVER_KMSDRM */
655 
656 /* vi: set ts=4 sw=4 expandtab: */
int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
int KMSDRM_GLES_GetSwapInterval(_THIS)
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
GLsizei stride
void SDL_KMSDRM_UnloadSymbols(void)
drmModeModeInfo cur_mode
void KMSDRM_SetWindowSize(_THIS, SDL_Window *window)
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227
void * KMSDRM_GLES_GetProcAddress(_THIS, const char *proc)
SDL_bool waiting_for_flip
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:630
#define EGL_NO_SURFACE
Definition: egl.h:100
struct pollfd drm_pollfd
VideoBootStrap KMSDRM_bootstrap
struct gbm_bo * current_bo
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
void KMSDRM_InitMouse(_THIS)
void KMSDRM_MaximizeWindow(_THIS, SDL_Window *window)
static int available()
Definition: video.c:356
void(* free)(_THIS)
Definition: SDL_sysvideo.h:390
GLfloat GLfloat GLfloat GLfloat h
SDL_EventEntry * free
Definition: SDL_events.c:84
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:260
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:222
The structure that defines a display mode.
Definition: SDL_video.h:53
int KMSDRM_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
SDL_version version
Definition: SDL_syswm.h:196
Uint8 major
Definition: SDL_version.h:53
int SDL_KMSDRM_LoadSymbols(void)
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
int KMSDRM_GLES_SetSwapInterval(_THIS, int interval)
int KMSDRM_GLES_LoadLibrary(_THIS, const char *path)
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:151
uint32_t Uint32
Definition: SDL_stdinc.h:181
void KMSDRM_GLES_UnloadLibrary(_THIS)
#define SDL_GL_LoadLibrary
SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window *window)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:606
int KMSDRM_CreateWindow(_THIS, SDL_Window *window)
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:254
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:204
#define SDL_LogError
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
EGLNativeWindowType NativeWindowType
Definition: eglplatform.h:112
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223
static SDL_AudioDeviceID device
Definition: loopwave.c:37
#define SDL_GL_UnloadLibrary
void KMSDRM_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:224
#define SDL_LogDebug
#define EGL_NO_CONTEXT
Definition: egl.h:98
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:247
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:257
EGLImageKHR EGLint EGLint * handle
Definition: eglext.h:937
void KMSDRM_PumpEvents(_THIS)
int KMSDRM_VideoInit(_THIS)
#define _THIS
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:258
#define SDL_free
int frame
Definition: teststreaming.c:60
void * driverdata
Definition: SDL_video.h:59
int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
GLenum mode
GLubyte GLubyte GLubyte GLubyte w
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:234
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:213
drmEventContext drm_evctx
void KMSDRM_RestoreWindow(_THIS, SDL_Window *window)
SDL_bool crtc_ready
void KMSDRM_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void KMSDRM_HideWindow(_THIS, SDL_Window *window)
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:256
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
struct gbm_device * gbm
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:196
SDL_bool KMSDRM_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_bool KMSDRM_WaitPageFlip(_THIS, SDL_WindowData *wdata, int timeout)
#define NULL
Definition: begin_code.h:164
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:210
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_bool
Definition: SDL_stdinc.h:139
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
unsigned int uint32_t
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:166
void KMSDRM_SetWindowPosition(_THIS, SDL_Window *window)
#define SDL_SetError
#define SDL_calloc
void KMSDRM_RaiseWindow(_THIS, SDL_Window *window)
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1073
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
void KMSDRM_GLES_DeleteContext(_THIS, SDL_GLContext context)
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:262
struct gbm_surface * gs
The type used to identify a window.
Definition: SDL_sysvideo.h:73
GLbitfield GLuint64 timeout
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:226
void KMSDRM_MinimizeWindow(_THIS, SDL_Window *window)
void KMSDRM_SetWindowTitle(_THIS, SDL_Window *window)
void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:743
struct gbm_bo * next_bo
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:160
#define SDL_snprintf
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:211
struct SDL_VideoDevice::@34 gl_config
KMSDRM_FBInfo * KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
void * driverdata
Definition: SDL_sysvideo.h:111
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:263
Uint32 format
Definition: SDL_video.h:55
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:212
#define SDL_LogWarn
int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window)
void KMSDRM_ShowWindow(_THIS, SDL_Window *window)
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:261
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225
Uint32 flags
Definition: SDL_sysvideo.h:83
drmModeCrtc * saved_crtc
void KMSDRM_VideoQuit(_THIS)
static void cleanup(void)
Definition: testfile.c:44
uint32_t saved_conn_id
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
Definition: SDL_sysvideo.h:233
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:255
GLuint64 GLenum GLint fd
Definition: gl2ext.h:1508
EGLSurface egl_surface
void KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:280