[KMS/DRM] Replace indent tabs with spaces, as intended.

This commit is contained in:
Manuel Alfayate Corchete 2021-02-06 14:03:53 +01:00
parent 59cd46c24a
commit 6ee53258cd
5 changed files with 133 additions and 132 deletions

View File

@ -93,8 +93,8 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display)
/* Destroy the curso GBM BO. */ /* Destroy the curso GBM BO. */
if (dispdata->cursor_bo) { if (dispdata->cursor_bo) {
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
dispdata->cursor_bo = NULL; dispdata->cursor_bo = NULL;
} }
} }
@ -109,33 +109,33 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) {
SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata;
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev,
GBM_FORMAT_ARGB8888, GBM_FORMAT_ARGB8888,
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
{ {
SDL_SetError("Unsupported pixel format for cursor"); SDL_SetError("Unsupported pixel format for cursor");
return; return;
} }
if (KMSDRM_drmGetCap(viddata->drm_fd, if (KMSDRM_drmGetCap(viddata->drm_fd,
DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) || DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) ||
KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT,
&dispdata->cursor_h)) &dispdata->cursor_h))
{ {
SDL_SetError("Could not get the recommended GBM cursor size"); SDL_SetError("Could not get the recommended GBM cursor size");
return; return;
} }
if (dispdata->cursor_w == 0 || dispdata->cursor_h == 0) { if (dispdata->cursor_w == 0 || dispdata->cursor_h == 0) {
SDL_SetError("Could not get an usable GBM cursor size"); SDL_SetError("Could not get an usable GBM cursor size");
return; return;
} }
dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev,
dispdata->cursor_w, dispdata->cursor_h, dispdata->cursor_w, dispdata->cursor_h,
GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR); GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR);
if (!dispdata->cursor_bo) { if (!dispdata->cursor_bo) {
SDL_SetError("Could not create GBM cursor BO"); SDL_SetError("Could not create GBM cursor BO");
return; return;
} }
} }
@ -150,10 +150,10 @@ KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata); SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata);
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, ret = KMSDRM_drmModeSetCursor(viddata->drm_fd,
dispdata->crtc->crtc_id, 0, 0, 0); dispdata->crtc->crtc_id, 0, 0, 0);
if (ret) { if (ret) {
ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor()."); ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
} }
return ret; return ret;
@ -327,15 +327,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
cleanup: cleanup:
if (ret == NULL) { if (ret == NULL) {
if (curdata) { if (curdata) {
if (curdata->buffer) { if (curdata->buffer) {
SDL_free(curdata->buffer); SDL_free(curdata->buffer);
} }
SDL_free(curdata); SDL_free(curdata);
} }
if (cursor) { if (cursor) {
SDL_free(cursor); SDL_free(cursor);
} }
} }
return ret; return ret;
@ -381,37 +381,37 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
if (!window || !cursor) { if (!window || !cursor) {
/* If no window is focused by mouse or cursor is NULL, /* If no window is focused by mouse or cursor is NULL,
since we have no window (no mouse->focus) and hence since we have no window (no mouse->focus) and hence
we have no display, we simply hide mouse on all displays. we have no display, we simply hide mouse on all displays.
This happens on video quit, where we get here after This happens on video quit, where we get here after
the mouse focus has been unset, yet SDL wants to the mouse focus has been unset, yet SDL wants to
restore the system default cursor (makes no sense here). */ restore the system default cursor (makes no sense here). */
num_displays = SDL_GetNumVideoDisplays(); num_displays = SDL_GetNumVideoDisplays();
/* Iterate on the displays hidding the cursor. */ /* Iterate on the displays hidding the cursor. */
for (i = 0; i < num_displays; i++) { for (i = 0; i < num_displays; i++) {
display = SDL_GetDisplay(i); display = SDL_GetDisplay(i);
ret = KMSDRM_RemoveCursorFromBO(display); ret = KMSDRM_RemoveCursorFromBO(display);
} }
} else { } else {
display = SDL_GetDisplayForWindow(window); display = SDL_GetDisplayForWindow(window);
if (display) { if (display) {
if (cursor) { if (cursor) {
/* Dump the cursor to the display DRM cursor BO so it becomes visible /* Dump the cursor to the display DRM cursor BO so it becomes visible
on that display. */ on that display. */
ret = KMSDRM_DumpCursorToBO(display, cursor); ret = KMSDRM_DumpCursorToBO(display, cursor);
} else { } else {
/* Hide the cursor on that display. */ /* Hide the cursor on that display. */
ret = KMSDRM_RemoveCursorFromBO(display); ret = KMSDRM_RemoveCursorFromBO(display);
} }
} }
} }
return ret; return ret;
@ -441,21 +441,22 @@ KMSDRM_WarpMouseGlobal(int x, int y)
/* And now update the cursor graphic position on screen. */ /* And now update the cursor graphic position on screen. */
if (dispdata->cursor_bo) { if (dispdata->cursor_bo) {
int drm_fd; int drm_fd;
int ret = 0; int ret = 0;
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo)); drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y); ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y);
if (ret) { if (ret) {
SDL_SetError("drmModeMoveCursor() failed."); SDL_SetError("drmModeMoveCursor() failed.");
} }
return ret; return ret;
} else { } else {
return SDL_SetError("Cursor not initialized properly."); return SDL_SetError("Cursor not initialized properly.");
} }
} else { } else {
return SDL_SetError("No mouse or current cursor."); return SDL_SetError("No mouse or current cursor.");
} }

View File

@ -173,12 +173,12 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
} }
ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id, ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,
fb_info->fb_id, flip_flags, &windata->waiting_for_flip); fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
if (ret == 0) { if (ret == 0) {
windata->waiting_for_flip = SDL_TRUE; windata->waiting_for_flip = SDL_TRUE;
} else { } else {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret); SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
} }
/* Wait immediately for vsync (as if we only had two buffers). /* Wait immediately for vsync (as if we only had two buffers).
@ -191,10 +191,10 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>" Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>"
to enable this. */ to enable this. */
if (windata->double_buffer) { if (windata->double_buffer) {
if (!KMSDRM_WaitPageflip(_this, windata)) { if (!KMSDRM_WaitPageflip(_this, windata)) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed"); SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed");
return 0; return 0;
} }
} }
return 1; return 1;

View File

@ -85,11 +85,11 @@ SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr)
SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr))
SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr))
SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id, SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id,
uint32_t fb_id, uint32_t flags, uint32_t fb_id, uint32_t flags,
int32_t crtc_x, int32_t crtc_y, int32_t crtc_x, int32_t crtc_y,
uint32_t crtc_w, uint32_t crtc_h, uint32_t crtc_w, uint32_t crtc_h,
uint32_t src_x, uint32_t src_y, uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h)) uint32_t src_w, uint32_t src_h))
/* Planes stuff ends. */ /* Planes stuff ends. */
SDL_KMSDRM_MODULE(GBM) SDL_KMSDRM_MODULE(GBM)

View File

@ -471,17 +471,17 @@ void KMSDRM_DeinitDisplays (_THIS) {
/* Get the driverdata for this display */ /* Get the driverdata for this display */
dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i);
/* Free connector */ /* Free connector */
if (dispdata && dispdata->connector) { if (dispdata && dispdata->connector) {
KMSDRM_drmModeFreeConnector(dispdata->connector); KMSDRM_drmModeFreeConnector(dispdata->connector);
dispdata->connector = NULL; dispdata->connector = NULL;
} }
/* Free CRTC */ /* Free CRTC */
if (dispdata && dispdata->crtc) { if (dispdata && dispdata->crtc) {
KMSDRM_drmModeFreeCrtc(dispdata->crtc); KMSDRM_drmModeFreeCrtc(dispdata->crtc);
dispdata->crtc = NULL; dispdata->crtc = NULL;
} }
} }
} }
@ -1025,9 +1025,9 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
for (i = 0; i < viddata->num_windows; i++) { for (i = 0; i < viddata->num_windows; i++) {
SDL_Window *window = viddata->windows[i]; SDL_Window *window = viddata->windows[i];
if (KMSDRM_CreateSurfaces(_this, window)) { if (KMSDRM_CreateSurfaces(_this, window)) {
return -1; return -1;
} }
/* Tell app about the window resize */ /* Tell app about the window resize */
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h);
@ -1132,42 +1132,42 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */ if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */
if (!(dispdata->gbm_init)) { if (!(dispdata->gbm_init)) {
/* In order for the GL_CreateRenderer() and GL_LoadFunctions() calls /* In order for the GL_CreateRenderer() and GL_LoadFunctions() calls
in SDL_CreateWindow succeed (no doing so causes a windo re-creation), in SDL_CreateWindow succeed (no doing so causes a windo re-creation),
At the end of this block, we must have: At the end of this block, we must have:
-Marked the window as being OPENGL -Marked the window as being OPENGL
-Loaded the GL library (which can't be loaded until the GBM -Loaded the GL library (which can't be loaded until the GBM
device has been created) because SDL_EGL_Library() function uses it. device has been created) because SDL_EGL_Library() function uses it.
*/ */
/* Maybe you didn't ask for an OPENGL window, but that's what you will get. /* Maybe you didn't ask for an OPENGL window, but that's what you will get.
See previous comment on why. */ See previous comment on why. */
window->flags |= SDL_WINDOW_OPENGL; window->flags |= SDL_WINDOW_OPENGL;
/* Reopen FD, create gbm dev, setup display plane, etc,. /* Reopen FD, create gbm dev, setup display plane, etc,.
but only when we come here for the first time, but only when we come here for the first time,
and only if it's not a VK window. */ and only if it's not a VK window. */
if ((ret = KMSDRM_GBMInit(_this, dispdata))) { if ((ret = KMSDRM_GBMInit(_this, dispdata))) {
goto cleanup; goto cleanup;
} }
/* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already /* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
been called by SDL_CreateWindow() but we don't do anything there, been called by SDL_CreateWindow() but we don't do anything there,
precisely to be able to load it here. precisely to be able to load it here.
If we let SDL_CreateWindow() load the lib, it will be loaded If we let SDL_CreateWindow() load the lib, it will be loaded
before we call KMSDRM_GBMInit(), causing GLES programs to fail. */ before we call KMSDRM_GBMInit(), causing GLES programs to fail. */
if (!_this->egl_data) { if (!_this->egl_data) {
egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev; egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) { if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
goto cleanup; goto cleanup;
} }
if (SDL_GL_LoadLibrary(NULL) < 0) { if (SDL_GL_LoadLibrary(NULL) < 0) {
goto cleanup; goto cleanup;
} }
} }
/* Create the cursor BO for the display of this window, /* Create the cursor BO for the display of this window,
now that we know this is not a VK window. */ now that we know this is not a VK window. */
@ -1175,15 +1175,15 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
/* Create and set the default cursor now that we know /* Create and set the default cursor now that we know
this is not a VK window. */ this is not a VK window. */
KMSDRM_InitMouse(_this, display); KMSDRM_InitMouse(_this, display);
/* When we destroy a window, we remove the cursor buffer from /* When we destroy a window, we remove the cursor buffer from
the cursor plane and destroy the cursor GBM BO, but SDL expects the cursor plane and destroy the cursor GBM BO, but SDL expects
that we keep showing the visible cursors bewteen window that we keep showing the visible cursors bewteen window
destruction/creation cycles. So we must manually re-show the destruction/creation cycles. So we must manually re-show the
visible cursors, if necessary, when we create a window. */ visible cursors, if necessary, when we create a window. */
KMSDRM_InitCursor(); KMSDRM_InitCursor();
} }
/* The FULLSCREEN flags are cut out from window->flags at this point, /* The FULLSCREEN flags are cut out from window->flags at this point,
so we can't know if a window is fullscreen or not, hence all windows so we can't know if a window is fullscreen or not, hence all windows
@ -1205,7 +1205,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
} }
/* Take note to do the modesettng on the CRTC in SwapWindow. */ /* Take note to do the modesettng on the CRTC in SwapWindow. */
dispdata->modeset_pending = SDL_TRUE; dispdata->modeset_pending = SDL_TRUE;
/* Create the window surfaces with the size we have just chosen. /* Create the window surfaces with the size we have just chosen.
Needs the window diverdata in place. */ Needs the window diverdata in place. */
@ -1286,24 +1286,24 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
refresh_rate = (uint32_t)window->fullscreen_mode.refresh_rate; refresh_rate = (uint32_t)window->fullscreen_mode.refresh_rate;
} }
/* Try to find a valid video mode matching the size of the window. */ /* Try to find a valid video mode matching the size of the window. */
mode = KMSDRM_GetClosestDisplayMode(display, mode = KMSDRM_GetClosestDisplayMode(display,
window->windowed.w, window->windowed.h, refresh_rate ); window->windowed.w, window->windowed.h, refresh_rate );
if (mode) { if (mode) {
/* If matching mode found, recreate the GBM surface with the size /* If matching mode found, recreate the GBM surface with the size
of that mode and configure it on the CRTC. */ of that mode and configure it on the CRTC. */
windata->surface_w = mode->hdisplay; windata->surface_w = mode->hdisplay;
windata->surface_h = mode->vdisplay; windata->surface_h = mode->vdisplay;
dispdata->mode = *mode; dispdata->mode = *mode;
} else { } else {
/* If not matching mode found, recreate the GBM surfaces with the /* If not matching mode found, recreate the GBM surfaces with the
size of the mode that was originally configured on the CRTC, size of the mode that was originally configured on the CRTC,
and setup that mode on the CRTC. */ and setup that mode on the CRTC. */
windata->surface_w = dispdata->original_mode.hdisplay; windata->surface_w = dispdata->original_mode.hdisplay;
windata->surface_h = dispdata->original_mode.vdisplay; windata->surface_h = dispdata->original_mode.vdisplay;
dispdata->mode = dispdata->original_mode; dispdata->mode = dispdata->original_mode;
} }
/* Tell app about the size we have determined for the window, /* Tell app about the size we have determined for the window,
so SDL pre-scales to that size for us. */ so SDL pre-scales to that size for us. */

View File

@ -361,22 +361,22 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
new_mode_parameters.visibleRegion.width = window->w; new_mode_parameters.visibleRegion.width = window->w;
new_mode_parameters.visibleRegion.height = window->h; new_mode_parameters.visibleRegion.height = window->h;
new_mode_parameters.refreshRate = 60000; /* Always use 60Hz for now. */ new_mode_parameters.refreshRate = 60000; /* Always use 60Hz for now. */
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR; display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
display_mode_create_info.parameters = new_mode_parameters; display_mode_create_info.parameters = new_mode_parameters;
result = vkCreateDisplayModeKHR(gpu, result = vkCreateDisplayModeKHR(gpu,
displays_props[display_index].display, displays_props[display_index].display,
&display_mode_create_info, &display_mode_create_info,
NULL, display_mode); NULL, display_mode);
if (result != VK_SUCCESS) { if (result != VK_SUCCESS) {
SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode."); SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
goto clean; goto clean;
} }
} }
/* Just in case we get here without a display_mode. */ /* Just in case we get here without a display_mode. */
if (!display_mode) { if (!display_mode) {
SDL_SetError("Vulkan couldn't get a display mode."); SDL_SetError("Vulkan couldn't get a display mode.");
goto clean; goto clean;
} }
/********************************************/ /********************************************/