src/video/kmsdrm/SDL_kmsdrmsym.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 02 Aug 2017 10:22:48 -0700
changeset 11175 cbc6a8a5b701
child 11811 5d94cb6b24d3
permissions -rw-r--r--
Fixed bug 3690 - SDL2 KMS/DRM render context support

Manuel

The attached patch adds support for KMS/DRM context graphics.

It builds with no problem on X86_64 GNU/Linux systems, provided the needed libraries are present, and on ARM GNU/Linux systems that have KMS/DRM support and a GLES2 implementation.
Tested on Raspberry Pi: KMS/DRM is what the Raspberry Pi will use as default in the near future, once the propietary DispmanX API by Broadcom is overtaken by open graphics stack, it's possible to boot current Raspbian system in KMS mode by adding "dtoverlay=vc4-kms-v3d" to config.txt on Raspbian's boot partition.
X86 systems use KMS right away in every current GNU/Linux system.

Simple build instructions:

$./autogen.sh
$./configure --enable-video-kmsdrm
$make
slouken@11175
     1
/*
slouken@11175
     2
  Simple DirectMedia Layer
slouken@11175
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
slouken@11175
     4
slouken@11175
     5
  This software is provided 'as-is', without any express or implied
slouken@11175
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@11175
     7
  arising from the use of this software.
slouken@11175
     8
slouken@11175
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@11175
    10
  including commercial applications, and to alter it and redistribute it
slouken@11175
    11
  freely, subject to the following restrictions:
slouken@11175
    12
slouken@11175
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@11175
    14
     claim that you wrote the original software. If you use this software
slouken@11175
    15
     in a product, an acknowledgment in the product documentation would be
slouken@11175
    16
     appreciated but is not required.
slouken@11175
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@11175
    18
     misrepresented as being the original software.
slouken@11175
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@11175
    20
*/
slouken@11175
    21
slouken@11175
    22
/* *INDENT-OFF* */
slouken@11175
    23
slouken@11175
    24
#ifndef SDL_KMSDRM_MODULE
slouken@11175
    25
#define SDL_KMSDRM_MODULE(modname)
slouken@11175
    26
#endif
slouken@11175
    27
slouken@11175
    28
#ifndef SDL_KMSDRM_SYM
slouken@11175
    29
#define SDL_KMSDRM_SYM(rc,fn,params)
slouken@11175
    30
#endif
slouken@11175
    31
slouken@11175
    32
#ifndef SDL_KMSDRM_SYM_CONST
slouken@11175
    33
#define SDL_KMSDRM_SYM_CONST(type, name)
slouken@11175
    34
#endif
slouken@11175
    35
slouken@11175
    36
slouken@11175
    37
SDL_KMSDRM_MODULE(LIBDRM)
slouken@11175
    38
SDL_KMSDRM_SYM(void,drmModeFreeResources,(drmModeResPtr ptr))
slouken@11175
    39
SDL_KMSDRM_SYM(void,drmModeFreeFB,(drmModeFBPtr ptr))
slouken@11175
    40
SDL_KMSDRM_SYM(void,drmModeFreeCrtc,(drmModeCrtcPtr ptr))
slouken@11175
    41
SDL_KMSDRM_SYM(void,drmModeFreeConnector,(drmModeConnectorPtr ptr))
slouken@11175
    42
SDL_KMSDRM_SYM(void,drmModeFreeEncoder,(drmModeEncoderPtr ptr))
slouken@11175
    43
SDL_KMSDRM_SYM(drmModeResPtr,drmModeGetResources,(int fd))
slouken@11175
    44
SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_t depth,
slouken@11175
    45
                                 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
slouken@11175
    46
                                 uint32_t *buf_id))
slouken@11175
    47
SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId))
slouken@11175
    48
SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf))
slouken@11175
    49
SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId))
slouken@11175
    50
SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId,
slouken@11175
    51
                                   uint32_t x, uint32_t y, uint32_t *connectors, int count,
slouken@11175
    52
                                   drmModeModeInfoPtr mode))
slouken@11175
    53
SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle,
slouken@11175
    54
                                     uint32_t width, uint32_t height))
slouken@11175
    55
SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle,
slouken@11175
    56
                                      uint32_t width, uint32_t height,
slouken@11175
    57
                                      int32_t hot_x, int32_t hot_y))
slouken@11175
    58
SDL_KMSDRM_SYM(int,drmModeMoveCursor,(int fd, uint32_t crtcId, int x, int y))
slouken@11175
    59
SDL_KMSDRM_SYM(drmModeEncoderPtr,drmModeGetEncoder,(int fd, uint32_t encoder_id))
slouken@11175
    60
SDL_KMSDRM_SYM(drmModeConnectorPtr,drmModeGetConnector,(int fd, uint32_t connector_id))
slouken@11175
    61
SDL_KMSDRM_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx))
slouken@11175
    62
SDL_KMSDRM_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id,
slouken@11175
    63
                                    uint32_t flags, void *user_data))
slouken@11175
    64
slouken@11175
    65
slouken@11175
    66
SDL_KMSDRM_MODULE(GBM)
slouken@11175
    67
SDL_KMSDRM_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm))
slouken@11175
    68
SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm,
slouken@11175
    69
                                                   uint32_t format, uint32_t usage))
slouken@11175
    70
SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm))
slouken@11175
    71
SDL_KMSDRM_SYM(struct gbm_device *,gbm_create_device,(int fd))
slouken@11175
    72
SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_width,(struct gbm_bo *bo))
slouken@11175
    73
SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_height,(struct gbm_bo *bo))
slouken@11175
    74
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride,(struct gbm_bo *bo))
slouken@11175
    75
SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle,(struct gbm_bo *bo))
slouken@11175
    76
SDL_KMSDRM_SYM(int,gbm_bo_write,(struct gbm_bo *bo, const void *buf, size_t count))
slouken@11175
    77
SDL_KMSDRM_SYM(struct gbm_device *,gbm_bo_get_device,(struct gbm_bo *bo))
slouken@11175
    78
SDL_KMSDRM_SYM(void,gbm_bo_set_user_data,(struct gbm_bo *bo, void *data,
slouken@11175
    79
                                          void (*destroy_user_data)(struct gbm_bo *, void *)))
slouken@11175
    80
SDL_KMSDRM_SYM(void *,gbm_bo_get_user_data,(struct gbm_bo *bo))
slouken@11175
    81
SDL_KMSDRM_SYM(void,gbm_bo_destroy,(struct gbm_bo *bo))
slouken@11175
    82
SDL_KMSDRM_SYM(struct gbm_bo *,gbm_bo_create,(struct gbm_device *gbm,
slouken@11175
    83
                                              uint32_t width, uint32_t height,
slouken@11175
    84
                                              uint32_t format, uint32_t usage))
slouken@11175
    85
SDL_KMSDRM_SYM(struct gbm_surface *,gbm_surface_create,(struct gbm_device *gbm,
slouken@11175
    86
                                                        uint32_t width, uint32_t height,
slouken@11175
    87
                                                        uint32_t format, uint32_t flags))
slouken@11175
    88
SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf))
slouken@11175
    89
SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf))
slouken@11175
    90
SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo))
slouken@11175
    91
slouken@11175
    92
slouken@11175
    93
#undef SDL_KMSDRM_MODULE
slouken@11175
    94
#undef SDL_KMSDRM_SYM
slouken@11175
    95
#undef SDL_KMSDRM_SYM_CONST
slouken@11175
    96
slouken@11175
    97
/* *INDENT-ON* */
slouken@11175
    98
slouken@11175
    99
/* vi: set ts=4 sw=4 expandtab: */