From 85e8adf78d3b0bae0f7690822b8213de75958949 Mon Sep 17 00:00:00 2001 From: Manuel Alfayate Corchete Date: Mon, 11 Jan 2021 22:28:27 +0100 Subject: [PATCH] [KMS/DRM] Unused code cleaning. --- src/video/kmsdrm/SDL_kmsdrmopengles.c | 62 ++------------- src/video/kmsdrm/SDL_kmsdrmvideo.c | 109 -------------------------- 2 files changed, 8 insertions(+), 163 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 4b2562044..a20a49449 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -72,7 +72,12 @@ SDL_EGL_CreateContext_impl(KMSDRM) int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) { - /* + /* Issuing a new pageflip before the previous has completed + causes drmModePageFlip() to return EBUSY errors. + So just set egl_swapinterval to 1 to prevent that. */ + +#if 0 + if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); } @@ -81,23 +86,14 @@ int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) { _this->egl_data->egl_swapinterval = interval; } else { return SDL_SetError("Only swap intervals of 0 or 1 are supported"); - }*/ + } +#endif - /* Issuing a new pageflip before the previous has completed - causes drmModePageFlip() to return EBUSY errors. Don't do it. */ _this->egl_data->egl_swapinterval = 1; return 0; } -/* Check if we need to re-create the GBM and EGL surfaces and setup a new mode on the CRTC - matching the new GBM surface size so the buffers from these surfaces can be displayed - on the CRTC (remember we need the CRTC mode and the buffer size to match). */ -/*KMSDRM_CheckKMSDRM (_THIS, window) { - - -}*/ - int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata); @@ -147,47 +143,6 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { return 0; } -#if 0 - /* Get an actual usable fb (of the specified dimensions) form the BO, - so we can pass it to the CRTC. */ - fb_info = KMSDRM_FBFromBO2(_this, windata->next_bo, window->w, window->h); - if (!fb_info) { - return 0; - } -#endif - -#if 0 - /* If the window size does not match the current videomode configured on the CRTC, - update the current video mode and configure the new mode on the CRTC. */ - if (dispdata->mode.hdisplay != window->w || dispdata->mode.vdisplay != window->h) { - for (int i = 0; i < dispdata->connector->count_modes; i++) { - drmModeModeInfo mode = dispdata->connector->modes[i] ; - if (mode.hdisplay == window->w && mode.vdisplay == window->h) { - dispdata->mode = mode; - ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, - dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0, - &dispdata->connector->connector_id, 1, &dispdata->mode); - - if (ret) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set mode on CRTC."); - printf("********Could not set mode on CRTC.\n"); - } - return 0; - } - } - return 0; - } -#endif - -#if 0 - /* Get an actual usable fb for the next front buffer. */ - fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); - if (!fb_info) { - return 0; - } -#endif - -#if 1 /* Do we have a modeset pending? If so, configure the new mode on the CRTC. Has to be done before the upcoming pageflip issue, so the buffer with the new size is big enough so the CRTC doesn't read out of bounds. */ @@ -205,7 +160,6 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { return 0; } -#endif /* Issue pageflip on the next front buffer. The pageflip will be done during the next vblank. */ diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index f860815b0..081790676 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -332,115 +332,6 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) return fb_info; } -#if 0 -/* Get an actual usable fb from a BO, specifying the size of the desired fb. */ -KMSDRM_FBInfo * -KMSDRM_FBFromBO2(_THIS, struct gbm_bo *bo, int width, int height) -{ - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - int ret; - Uint32 stride, handle; - - uint32_t format, strides[4] = {0}, handles[4] = {0}, offsets[4] = {0}; - - /* Check for an existing framebuffer */ - KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo); - - if (fb_info) { - /* TODO We used to simply return the old fb_info if there was one here. - Now free it AND the actual buffer IF the sizes have changed (maybe - add them to fb_info? to avoid leaking.)*/ - SDL_free(fb_info); - } - - /* Create a structure that contains enough info to remove the framebuffer - when the backing buffer is destroyed */ - fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); - - if (!fb_info) { - SDL_OutOfMemory(); - return NULL; - } - - fb_info->drm_fd = viddata->drm_fd; - -#if 0 - /* Create framebuffer object for the buffer */ - stride = KMSDRM_gbm_bo_get_stride(bo); - handle = KMSDRM_gbm_bo_get_handle(bo).u32; - ret = KMSDRM_drmModeAddFB(viddata->drm_fd, width, height, 24, 32, stride, handle, - &fb_info->fb_id); -#endif - - handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32; - strides[0] = KMSDRM_gbm_bo_get_stride(bo); - offsets[0] = KMSDRM_gbm_bo_get_offset(bo, 0); - format = KMSDRM_gbm_bo_get_format(bo); - - ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, width, height, format, - handles, strides, offsets, &fb_info->fb_id, 0); - - - if (ret) { - SDL_free(fb_info); - return NULL; - } - - /* Associate our DRM framebuffer with this buffer object */ - KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback); - - return fb_info; -} -#endif - -#if 0 -/* Get an actual usable fb from a BO, specifying the size of the desired fb. */ -KMSDRM_FBInfo * -KMSDRM_FBFromBO2(_THIS, struct gbm_bo *bo, int width, int height) -{ - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - int ret; - Uint32 stride, handle; - - /* Check for an existing framebuffer */ - KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo); - - if (fb_info) { - /* TODO We used to simply return the old fb_info if there was one here. - Now free it AND the actual buffer IF the sizes have changed (maybe - add them to fb_info? to avoid leaking.)*/ - SDL_free(fb_info); - } - - /* Create a structure that contains enough info to remove the framebuffer - when the backing buffer is destroyed */ - fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); - - if (!fb_info) { - SDL_OutOfMemory(); - return NULL; - } - - fb_info->drm_fd = viddata->drm_fd; - - /* Create framebuffer object for the buffer */ - stride = KMSDRM_gbm_bo_get_stride(bo); - handle = KMSDRM_gbm_bo_get_handle(bo).u32; - ret = KMSDRM_drmModeAddFB(viddata->drm_fd, width, height, 24, 32, stride, handle, - &fb_info->fb_id); - - if (ret) { - SDL_free(fb_info); - return NULL; - } - - /* Associate our DRM framebuffer with this buffer object */ - KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback); - - return fb_info; -} -#endif - static void KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) {