src/video/kmsdrm/SDL_kmsdrmvideo.h
changeset 11175 cbc6a8a5b701
child 11181 951807bdae20
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h	Wed Aug 02 10:22:48 2017 -0700
     1.3 @@ -0,0 +1,119 @@
     1.4 +/*
     1.5 +  Simple DirectMedia Layer
     1.6 +  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
     1.7 +
     1.8 +  This software is provided 'as-is', without any express or implied
     1.9 +  warranty.  In no event will the authors be held liable for any damages
    1.10 +  arising from the use of this software.
    1.11 +
    1.12 +  Permission is granted to anyone to use this software for any purpose,
    1.13 +  including commercial applications, and to alter it and redistribute it
    1.14 +  freely, subject to the following restrictions:
    1.15 +
    1.16 +  1. The origin of this software must not be misrepresented; you must not
    1.17 +     claim that you wrote the original software. If you use this software
    1.18 +     in a product, an acknowledgment in the product documentation would be
    1.19 +     appreciated but is not required.
    1.20 +  2. Altered source versions must be plainly marked as such, and must not be
    1.21 +     misrepresented as being the original software.
    1.22 +  3. This notice may not be removed or altered from any source distribution.
    1.23 +*/
    1.24 +
    1.25 +#ifndef __SDL_KMSDRMVIDEO_H__
    1.26 +#define __SDL_KMSDRMVIDEO_H__
    1.27 +
    1.28 +#include "../../SDL_internal.h"
    1.29 +#include "../SDL_sysvideo.h"
    1.30 +
    1.31 +#include <fcntl.h>
    1.32 +#include <unistd.h>
    1.33 +#include <poll.h>
    1.34 +#include <xf86drm.h>
    1.35 +#include <xf86drmMode.h>
    1.36 +#include <gbm.h>
    1.37 +#if SDL_VIDEO_OPENGL_EGL
    1.38 +#include <EGL/egl.h>
    1.39 +#endif
    1.40 +
    1.41 +typedef struct SDL_VideoData
    1.42 +{
    1.43 +    int devindex;               /* device index that was passed on creation */
    1.44 +    int drm_fd;                 /* DRM file desc */
    1.45 +    struct gbm_device *gbm;
    1.46 +    drmEventContext drm_evctx;  /* DRM event context */
    1.47 +    struct pollfd drm_pollfd;   /* pollfd containing DRM file desc */
    1.48 +    drmModeCrtc *saved_crtc;    /* Saved CRTC to restore on quit */
    1.49 +    uint32_t saved_conn_id;     /* Saved DRM connector ID */
    1.50 +} SDL_VideoData;
    1.51 +
    1.52 +
    1.53 +typedef struct SDL_DisplayData
    1.54 +{
    1.55 +    uint32_t encoder_id;
    1.56 +    uint32_t crtc_id;
    1.57 +    drmModeModeInfo cur_mode;
    1.58 +} SDL_DisplayData;
    1.59 +
    1.60 +
    1.61 +typedef struct SDL_WindowData
    1.62 +{
    1.63 +    struct gbm_surface *gs;
    1.64 +    struct gbm_bo *locked_bo;
    1.65 +    SDL_bool waiting_for_flip;
    1.66 +#if SDL_VIDEO_OPENGL_EGL
    1.67 +    EGLSurface egl_surface;
    1.68 +#endif
    1.69 +} SDL_WindowData;
    1.70 +
    1.71 +typedef struct KMSDRM_FBInfo
    1.72 +{
    1.73 +    int drm_fd;         /* DRM file desc */
    1.74 +    uint32_t fb_id;     /* DRM framebuffer ID */
    1.75 +} KMSDRM_FBInfo;
    1.76 +
    1.77 +/* Helper functions */
    1.78 +KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo);
    1.79 +SDL_bool KMSDRM_WaitPageFlip(_THIS, SDL_WindowData *wdata, int timeout);
    1.80 +
    1.81 +/****************************************************************************/
    1.82 +/* SDL_VideoDevice functions declaration                                    */
    1.83 +/****************************************************************************/
    1.84 +
    1.85 +/* Display and window functions */
    1.86 +int KMSDRM_VideoInit(_THIS);
    1.87 +void KMSDRM_VideoQuit(_THIS);
    1.88 +void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
    1.89 +int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    1.90 +int KMSDRM_CreateWindow(_THIS, SDL_Window * window);
    1.91 +int KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
    1.92 +void KMSDRM_SetWindowTitle(_THIS, SDL_Window * window);
    1.93 +void KMSDRM_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
    1.94 +void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window);
    1.95 +void KMSDRM_SetWindowSize(_THIS, SDL_Window * window);
    1.96 +void KMSDRM_ShowWindow(_THIS, SDL_Window * window);
    1.97 +void KMSDRM_HideWindow(_THIS, SDL_Window * window);
    1.98 +void KMSDRM_RaiseWindow(_THIS, SDL_Window * window);
    1.99 +void KMSDRM_MaximizeWindow(_THIS, SDL_Window * window);
   1.100 +void KMSDRM_MinimizeWindow(_THIS, SDL_Window * window);
   1.101 +void KMSDRM_RestoreWindow(_THIS, SDL_Window * window);
   1.102 +void KMSDRM_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
   1.103 +void KMSDRM_DestroyWindow(_THIS, SDL_Window * window);
   1.104 +
   1.105 +/* Window manager function */
   1.106 +SDL_bool KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window,
   1.107 +                             struct SDL_SysWMinfo *info);
   1.108 +
   1.109 +/* OpenGL/OpenGL ES functions */
   1.110 +int KMSDRM_GLES_LoadLibrary(_THIS, const char *path);
   1.111 +void *KMSDRM_GLES_GetProcAddress(_THIS, const char *proc);
   1.112 +void KMSDRM_GLES_UnloadLibrary(_THIS);
   1.113 +SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window * window);
   1.114 +int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
   1.115 +int KMSDRM_GLES_SetSwapInterval(_THIS, int interval);
   1.116 +int KMSDRM_GLES_GetSwapInterval(_THIS);
   1.117 +int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window);
   1.118 +void KMSDRM_GLES_DeleteContext(_THIS, SDL_GLContext context);
   1.119 +
   1.120 +#endif /* __SDL_KMSDRMVIDEO_H__ */
   1.121 +
   1.122 +/* vi: set ts=4 sw=4 expandtab: */