mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Fixed bug 4980 - Build fails for SDL_kmsdrm*.c
Malte Kie?ling Since https://hg.libsdl.org/SDL/rev/f908bd722523 / bug 4966 i cannot build SDL anymore. The error i get is, essentially, caused by -Werror=declaration-after-statement in SDL_kmsdrmvideo.c and SDL_kmsdrmopengles.c
This commit is contained in:
parent
715f8d42a2
commit
35704c983e
@ -62,7 +62,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
|||||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
KMSDRM_FBInfo *fb_info;
|
KMSDRM_FBInfo *fb_info;
|
||||||
int ret;
|
int ret, timeout;
|
||||||
|
|
||||||
/* Recreate the GBM / EGL surfaces if the display mode has changed */
|
/* Recreate the GBM / EGL surfaces if the display mode has changed */
|
||||||
if (windata->egl_surface_dirty) {
|
if (windata->egl_surface_dirty) {
|
||||||
@ -71,7 +71,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
|||||||
|
|
||||||
/* Wait for confirmation that the next front buffer has been flipped, at which
|
/* Wait for confirmation that the next front buffer has been flipped, at which
|
||||||
point the previous front buffer can be released */
|
point the previous front buffer can be released */
|
||||||
int timeout = 0;
|
timeout = 0;
|
||||||
if (_this->egl_data->egl_swapinterval == 1) {
|
if (_this->egl_data->egl_swapinterval == 1) {
|
||||||
timeout = -1;
|
timeout = -1;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,9 @@ KMSDRM_FBInfo *
|
|||||||
KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||||
{
|
{
|
||||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
|
unsigned w,h;
|
||||||
|
int ret;
|
||||||
|
Uint32 stride, handle;
|
||||||
|
|
||||||
/* Check for an existing framebuffer */
|
/* Check for an existing framebuffer */
|
||||||
KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo);
|
KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo);
|
||||||
@ -278,11 +281,11 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
|||||||
fb_info->drm_fd = viddata->drm_fd;
|
fb_info->drm_fd = viddata->drm_fd;
|
||||||
|
|
||||||
/* Create framebuffer object for the buffer */
|
/* Create framebuffer object for the buffer */
|
||||||
unsigned w = KMSDRM_gbm_bo_get_width(bo);
|
w = KMSDRM_gbm_bo_get_width(bo);
|
||||||
unsigned h = KMSDRM_gbm_bo_get_height(bo);
|
h = KMSDRM_gbm_bo_get_height(bo);
|
||||||
Uint32 stride = KMSDRM_gbm_bo_get_stride(bo);
|
stride = KMSDRM_gbm_bo_get_stride(bo);
|
||||||
Uint32 handle = KMSDRM_gbm_bo_get_handle(bo).u32;
|
handle = KMSDRM_gbm_bo_get_handle(bo).u32;
|
||||||
int ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle,
|
ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle,
|
||||||
&fb_info->fb_id);
|
&fb_info->fb_id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
SDL_free(fb_info);
|
SDL_free(fb_info);
|
||||||
@ -307,12 +310,12 @@ KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int us
|
|||||||
SDL_bool
|
SDL_bool
|
||||||
KMSDRM_WaitPageFlip(_THIS, SDL_WindowData *windata, int timeout) {
|
KMSDRM_WaitPageFlip(_THIS, SDL_WindowData *windata, int timeout) {
|
||||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
|
|
||||||
drmEventContext ev = {0};
|
drmEventContext ev = {0};
|
||||||
|
struct pollfd pfd = {0};
|
||||||
|
|
||||||
ev.version = DRM_EVENT_CONTEXT_VERSION;
|
ev.version = DRM_EVENT_CONTEXT_VERSION;
|
||||||
ev.page_flip_handler = KMSDRM_FlipHandler;
|
ev.page_flip_handler = KMSDRM_FlipHandler;
|
||||||
|
|
||||||
struct pollfd pfd = {0};
|
|
||||||
pfd.fd = viddata->drm_fd;
|
pfd.fd = viddata->drm_fd;
|
||||||
pfd.events = POLLIN;
|
pfd.events = POLLIN;
|
||||||
|
|
||||||
@ -389,6 +392,7 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window)
|
|||||||
Uint32 height = dispdata->mode.vdisplay;
|
Uint32 height = dispdata->mode.vdisplay;
|
||||||
Uint32 surface_fmt = GBM_FORMAT_XRGB8888;
|
Uint32 surface_fmt = GBM_FORMAT_XRGB8888;
|
||||||
Uint32 surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
|
Uint32 surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
|
||||||
|
EGLContext egl_context;
|
||||||
|
|
||||||
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm, surface_fmt, surface_flags)) {
|
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm, surface_fmt, surface_flags)) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "GBM surface format not supported. Trying anyway.");
|
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "GBM surface format not supported. Trying anyway.");
|
||||||
@ -396,8 +400,7 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window)
|
|||||||
|
|
||||||
#if SDL_VIDEO_OPENGL_EGL
|
#if SDL_VIDEO_OPENGL_EGL
|
||||||
SDL_EGL_SetRequiredVisualId(_this, surface_fmt);
|
SDL_EGL_SetRequiredVisualId(_this, surface_fmt);
|
||||||
|
egl_context = (EGLContext)SDL_GL_GetCurrentContext();
|
||||||
EGLContext egl_context = (EGLContext)SDL_GL_GetCurrentContext();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KMSDRM_DestroySurfaces(_this, window);
|
KMSDRM_DestroySurfaces(_this, window);
|
||||||
@ -431,6 +434,8 @@ KMSDRM_VideoInit(_THIS)
|
|||||||
SDL_DisplayData *dispdata = NULL;
|
SDL_DisplayData *dispdata = NULL;
|
||||||
drmModeRes *resources = NULL;
|
drmModeRes *resources = NULL;
|
||||||
drmModeEncoder *encoder = NULL;
|
drmModeEncoder *encoder = NULL;
|
||||||
|
char devname[32];
|
||||||
|
SDL_VideoDisplay display = {0};
|
||||||
|
|
||||||
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
||||||
|
|
||||||
@ -441,7 +446,6 @@ KMSDRM_VideoInit(_THIS)
|
|||||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()");
|
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()");
|
||||||
|
|
||||||
/* Open /dev/dri/cardNN */
|
/* Open /dev/dri/cardNN */
|
||||||
char devname[32];
|
|
||||||
SDL_snprintf(devname, sizeof(devname), "/dev/dri/card%d", viddata->devindex);
|
SDL_snprintf(devname, sizeof(devname), "/dev/dri/card%d", viddata->devindex);
|
||||||
|
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", devname);
|
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", devname);
|
||||||
@ -575,7 +579,7 @@ KMSDRM_VideoInit(_THIS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the single display that's available */
|
/* Setup the single display that's available */
|
||||||
SDL_VideoDisplay display = {0};
|
|
||||||
display.desktop_mode.w = dispdata->mode.hdisplay;
|
display.desktop_mode.w = dispdata->mode.hdisplay;
|
||||||
display.desktop_mode.h = dispdata->mode.vdisplay;
|
display.desktop_mode.h = dispdata->mode.vdisplay;
|
||||||
display.desktop_mode.refresh_rate = dispdata->mode.vrefresh;
|
display.desktop_mode.refresh_rate = dispdata->mode.vrefresh;
|
||||||
@ -685,6 +689,7 @@ KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|||||||
{
|
{
|
||||||
SDL_DisplayData *dispdata = display->driverdata;
|
SDL_DisplayData *dispdata = display->driverdata;
|
||||||
drmModeConnector *conn = dispdata->conn;
|
drmModeConnector *conn = dispdata->conn;
|
||||||
|
SDL_DisplayMode mode;
|
||||||
|
|
||||||
for (int i = 0; i < conn->count_modes; i++) {
|
for (int i = 0; i < conn->count_modes; i++) {
|
||||||
SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||||
@ -693,7 +698,6 @@ KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|||||||
modedata->mode_index = i;
|
modedata->mode_index = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DisplayMode mode;
|
|
||||||
mode.w = conn->modes[i].hdisplay;
|
mode.w = conn->modes[i].hdisplay;
|
||||||
mode.h = conn->modes[i].vdisplay;
|
mode.h = conn->modes[i].vdisplay;
|
||||||
mode.refresh_rate = conn->modes[i].vrefresh;
|
mode.refresh_rate = conn->modes[i].vrefresh;
|
||||||
@ -712,12 +716,12 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
|
||||||
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
|
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
|
||||||
|
drmModeConnector *conn = dispdata->conn;
|
||||||
|
|
||||||
if (!modedata) {
|
if (!modedata) {
|
||||||
return SDL_SetError("Mode doesn't have an associated index");
|
return SDL_SetError("Mode doesn't have an associated index");
|
||||||
}
|
}
|
||||||
|
|
||||||
drmModeConnector *conn = dispdata->conn;
|
|
||||||
dispdata->mode = conn->modes[modedata->mode_index];
|
dispdata->mode = conn->modes[modedata->mode_index];
|
||||||
|
|
||||||
for (int i = 0; i < viddata->num_windows; i++) {
|
for (int i = 0; i < viddata->num_windows; i++) {
|
||||||
@ -745,6 +749,8 @@ int
|
|||||||
KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||||
|
SDL_WindowData *windata;
|
||||||
|
SDL_VideoDisplay *display;
|
||||||
|
|
||||||
#if SDL_VIDEO_OPENGL_EGL
|
#if SDL_VIDEO_OPENGL_EGL
|
||||||
if (!_this->egl_data) {
|
if (!_this->egl_data) {
|
||||||
@ -755,7 +761,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allocate window internal data */
|
/* Allocate window internal data */
|
||||||
SDL_WindowData *windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
||||||
|
|
||||||
if (!windata) {
|
if (!windata) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
@ -763,7 +769,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Windows have one size for now */
|
/* Windows have one size for now */
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
display = SDL_GetDisplayForWindow(window);
|
||||||
window->w = display->desktop_mode.w;
|
window->w = display->desktop_mode.w;
|
||||||
window->h = display->desktop_mode.h;
|
window->h = display->desktop_mode.h;
|
||||||
|
|
||||||
@ -815,13 +821,13 @@ void
|
|||||||
KMSDRM_DestroyWindow(_THIS, SDL_Window * window)
|
KMSDRM_DestroyWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||||
|
SDL_VideoData *viddata;
|
||||||
if (!windata) {
|
if (!windata) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove from the internal window list */
|
/* Remove from the internal window list */
|
||||||
SDL_VideoData *viddata = windata->viddata;
|
viddata = windata->viddata;
|
||||||
|
|
||||||
for (int i = 0; i < viddata->num_windows; i++) {
|
for (int i = 0; i < viddata->num_windows; i++) {
|
||||||
if (viddata->windows[i] == window) {
|
if (viddata->windows[i] == window) {
|
||||||
|
Loading…
Reference in New Issue
Block a user