Commit 6ee53258cd1984da0f96cafbf8fd8293dcb046d0

Manuel Alfayate Corchete 2021-02-06T14:03:53

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 6a0e09e..2fd44fe 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -93,8 +93,8 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display)
    
     /* Destroy the curso GBM BO. */
     if (dispdata->cursor_bo) {
-	KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
-	dispdata->cursor_bo = NULL;
+        KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
+        dispdata->cursor_bo = NULL;
     }
 }
 
@@ -109,33 +109,33 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) {
     SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata;
 
     if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev,
-	  GBM_FORMAT_ARGB8888,
-	  GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
+          GBM_FORMAT_ARGB8888,
+          GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
     {
-	SDL_SetError("Unsupported pixel format for cursor");
+        SDL_SetError("Unsupported pixel format for cursor");
         return;
     }
 
     if (KMSDRM_drmGetCap(viddata->drm_fd,
-	  DRM_CAP_CURSOR_WIDTH,  &dispdata->cursor_w) ||
-	  KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT,
-	  &dispdata->cursor_h))
+          DRM_CAP_CURSOR_WIDTH,  &dispdata->cursor_w) ||
+          KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT,
+          &dispdata->cursor_h))
     {
-	SDL_SetError("Could not get the recommended GBM cursor size");
+        SDL_SetError("Could not get the recommended GBM cursor size");
         return;
     }
 
     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;
     }
 
     dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev,
-	dispdata->cursor_w, dispdata->cursor_h,
-	GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR);
+        dispdata->cursor_w, dispdata->cursor_h,
+        GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR);
 
     if (!dispdata->cursor_bo) {
-	SDL_SetError("Could not create GBM cursor BO");
+        SDL_SetError("Could not create GBM cursor BO");
         return;
     }
 } 
@@ -150,10 +150,10 @@ KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
     SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata);
 
     ret = KMSDRM_drmModeSetCursor(viddata->drm_fd,
-	dispdata->crtc->crtc_id, 0, 0, 0);
+        dispdata->crtc->crtc_id, 0, 0, 0);
 
     if (ret) {
-	ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
+        ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
     }
 
     return ret;
@@ -327,15 +327,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
 
 cleanup:
     if (ret == NULL) {
-	if (curdata) {
-	    if (curdata->buffer) {
-		SDL_free(curdata->buffer);
-	    }
-	    SDL_free(curdata);
-	}
-	if (cursor) {
-	    SDL_free(cursor);
-	}
+        if (curdata) {
+            if (curdata->buffer) {
+                SDL_free(curdata->buffer);
+            }
+            SDL_free(curdata);
+        }
+        if (cursor) {
+            SDL_free(cursor);
+        }
     }
 
     return ret;
@@ -381,37 +381,37 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
 
     if (!window || !cursor) {
 
-	    /* If no window is focused by mouse or cursor is NULL,
-	       since we have no window (no mouse->focus) and hence
-	       we have no display, we simply hide mouse on all displays.
-	       This happens on video quit, where we get here after
-	       the mouse focus has been unset, yet SDL wants to
-	       restore the system default cursor (makes no sense here). */
+            /* If no window is focused by mouse or cursor is NULL,
+               since we have no window (no mouse->focus) and hence
+               we have no display, we simply hide mouse on all displays.
+               This happens on video quit, where we get here after
+               the mouse focus has been unset, yet SDL wants to
+               restore the system default cursor (makes no sense here). */
 
-	    num_displays = SDL_GetNumVideoDisplays();
+            num_displays = SDL_GetNumVideoDisplays();
 
             /* 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);
                 ret = KMSDRM_RemoveCursorFromBO(display);
-	    }
+            }
 
     } else {
 
-	display = SDL_GetDisplayForWindow(window);
+        display = SDL_GetDisplayForWindow(window);
 
-	if (display) {
+        if (display) {
 
-	    if (cursor) {
-		/* Dump the cursor to the display DRM cursor BO so it becomes visible
-		   on that display. */
+            if (cursor) {
+                /* Dump the cursor to the display DRM cursor BO so it becomes visible
+                   on that display. */
                 ret = KMSDRM_DumpCursorToBO(display, cursor);
 
-	    } else {
-		/* Hide the cursor on that display. */
+            } else {
+                /* Hide the cursor on that display. */
                 ret = KMSDRM_RemoveCursorFromBO(display);
-	    }
-	}
+            }
+         }
     }
 
     return ret;
@@ -441,21 +441,22 @@ KMSDRM_WarpMouseGlobal(int x, int y)
 
         /* And now update the cursor graphic position on screen. */
         if (dispdata->cursor_bo) {
-	    int drm_fd;
+            int drm_fd;
             int ret = 0;
 
-	    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);
+            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);
 
-	    if (ret) {
-		SDL_SetError("drmModeMoveCursor() failed.");
-	    }
+            if (ret) {
+                SDL_SetError("drmModeMoveCursor() failed.");
+            }
 
-	    return ret;
+            return ret;
 
         } else {
             return SDL_SetError("Cursor not initialized properly.");
         }
+
     } else {
         return SDL_SetError("No mouse or current cursor.");
     }
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 0053e52..340b1ab 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -173,12 +173,12 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
     }
 
     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) {
-	windata->waiting_for_flip = SDL_TRUE;
+        windata->waiting_for_flip = SDL_TRUE;
     } 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).
@@ -191,10 +191,10 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
        Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>"
        to enable this. */
     if (windata->double_buffer) {
-	if (!KMSDRM_WaitPageflip(_this, windata)) {
-	    SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed");
-	    return 0;
-	}
+        if (!KMSDRM_WaitPageflip(_this, windata)) {
+            SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed");
+            return 0;
+        }
     }
 
     return 1;
diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h
index b706445..0460d4f 100644
--- a/src/video/kmsdrm/SDL_kmsdrmsym.h
+++ b/src/video/kmsdrm/SDL_kmsdrmsym.h
@@ -85,11 +85,11 @@ SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr)
 SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr))
 SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr))
 SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id,
-			   uint32_t fb_id, uint32_t flags,
-			   int32_t crtc_x, int32_t crtc_y,
-			   uint32_t crtc_w, uint32_t crtc_h,
-			   uint32_t src_x, uint32_t src_y,
-			   uint32_t src_w, uint32_t src_h))
+                                    uint32_t fb_id, uint32_t flags,
+                                    int32_t crtc_x, int32_t crtc_y,
+                                    uint32_t crtc_w, uint32_t crtc_h,
+                                    uint32_t src_x, uint32_t src_y,
+                                    uint32_t src_w, uint32_t src_h))
 /* Planes stuff ends. */
 
 SDL_KMSDRM_MODULE(GBM)
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index a41e076..cbbe7b0 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -471,17 +471,17 @@ void KMSDRM_DeinitDisplays (_THIS) {
         /* Get the driverdata for this display */   
         dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i);
 
-	/* Free connector */
-	if (dispdata && dispdata->connector) {
-	    KMSDRM_drmModeFreeConnector(dispdata->connector);
-	    dispdata->connector = NULL;
-	}
-
-	/* Free CRTC */
-	if (dispdata && dispdata->crtc) {
-	    KMSDRM_drmModeFreeCrtc(dispdata->crtc);
-	    dispdata->crtc = NULL;
-	}
+        /* Free connector */
+        if (dispdata && dispdata->connector) {
+            KMSDRM_drmModeFreeConnector(dispdata->connector);
+            dispdata->connector = NULL;
+        }
+
+        /* Free CRTC */
+        if (dispdata && dispdata->crtc) {
+            KMSDRM_drmModeFreeCrtc(dispdata->crtc);
+            dispdata->crtc = NULL;
+        }
     }
 }
 
@@ -1025,9 +1025,9 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
     for (i = 0; i < viddata->num_windows; i++) {
         SDL_Window *window = viddata->windows[i];
 
-	if (KMSDRM_CreateSurfaces(_this, window)) {
-	    return -1;
-	}
+        if (KMSDRM_CreateSurfaces(_this, window)) {
+            return -1;
+        }
 
         /* Tell app about the window resize */
         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 (!(dispdata->gbm_init)) {
+    if (!(dispdata->gbm_init)) {
 
             /* In order for the GL_CreateRenderer() and GL_LoadFunctions() calls
                in SDL_CreateWindow succeed (no doing so causes a windo re-creation),
                At the end of this block, we must have: 
                -Marked the window as being OPENGL
                -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.
-	       See previous comment on why. */
-	    window->flags |= SDL_WINDOW_OPENGL;
-
-	    /* Reopen FD, create gbm dev, setup display plane, etc,.
-		but only when we come here for the first time,
-		and only if it's not a VK window. */
-	    if ((ret = KMSDRM_GBMInit(_this, dispdata))) {
-		     goto cleanup;
-	    }
-
-	    /* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
-	       been called by SDL_CreateWindow() but we don't do anything there,
-	       precisely to be able to load it here.
-	       If we let SDL_CreateWindow() load the lib, it will be loaded
-	       before we call KMSDRM_GBMInit(), causing GLES programs to fail. */
-	    if (!_this->egl_data) {
-		egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
-		if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
-		    goto cleanup;
-		}
-
-		if (SDL_GL_LoadLibrary(NULL) < 0) {
-		    goto cleanup;
-		}
-	    }
+            /* Maybe you didn't ask for an OPENGL window, but that's what you will get.
+               See previous comment on why. */
+            window->flags |= SDL_WINDOW_OPENGL;
+
+            /* Reopen FD, create gbm dev, setup display plane, etc,.
+               but only when we come here for the first time,
+               and only if it's not a VK window. */
+            if ((ret = KMSDRM_GBMInit(_this, dispdata))) {
+                goto cleanup;
+            }
+
+            /* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
+               been called by SDL_CreateWindow() but we don't do anything there,
+               precisely to be able to load it here.
+               If we let SDL_CreateWindow() load the lib, it will be loaded
+               before we call KMSDRM_GBMInit(), causing GLES programs to fail. */
+            if (!_this->egl_data) {
+                egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
+                if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
+                    goto cleanup;
+                }
+
+                if (SDL_GL_LoadLibrary(NULL) < 0) {
+                    goto cleanup;
+                }
+            }
 
             /* Create the cursor BO for the display of this 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
                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
                that we keep showing the visible cursors bewteen window
                destruction/creation cycles. So we must manually re-show the
                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,
            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. */
-	dispdata->modeset_pending = SDL_TRUE;
+        dispdata->modeset_pending = SDL_TRUE;
 
         /* Create the window surfaces with the size we have just chosen.
            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;
         }
 
-	/* Try to find a valid video mode matching the size of the window. */
-	mode = KMSDRM_GetClosestDisplayMode(display,
+        /* Try to find a valid video mode matching the size of the window. */
+        mode = KMSDRM_GetClosestDisplayMode(display,
           window->windowed.w, window->windowed.h, refresh_rate );
 
-	if (mode) {
-	    /* If matching mode found, recreate the GBM surface with the size
-	       of that mode and configure it on the CRTC. */
-	    windata->surface_w = mode->hdisplay;
-	    windata->surface_h = mode->vdisplay;
-	    dispdata->mode = *mode;
-	} else {
-	    /* If not matching mode found, recreate the GBM surfaces with the
-	       size of the mode that was originally configured on the CRTC,
-	       and setup that mode on the CRTC. */
-	    windata->surface_w = dispdata->original_mode.hdisplay;
-	    windata->surface_h = dispdata->original_mode.vdisplay;
-	    dispdata->mode = dispdata->original_mode;
-	}
+        if (mode) {
+            /* If matching mode found, recreate the GBM surface with the size
+               of that mode and configure it on the CRTC. */
+            windata->surface_w = mode->hdisplay;
+            windata->surface_h = mode->vdisplay;
+            dispdata->mode = *mode;
+        } else {
+            /* If not matching mode found, recreate the GBM surfaces with the
+               size of the mode that was originally configured on the CRTC,
+               and setup that mode on the CRTC. */
+            windata->surface_w = dispdata->original_mode.hdisplay;
+            windata->surface_h = dispdata->original_mode.vdisplay;
+            dispdata->mode = dispdata->original_mode;
+        }
 
         /* Tell app about the size we have determined for the window,
            so SDL pre-scales to that size for us. */
diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c
index ab4fdac..a429f42 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c
@@ -361,22 +361,22 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
         new_mode_parameters.visibleRegion.width = window->w;
         new_mode_parameters.visibleRegion.height = window->h;
         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.parameters = new_mode_parameters;
-	result = vkCreateDisplayModeKHR(gpu,
-				  displays_props[display_index].display,
-				  &display_mode_create_info,
-				  NULL, display_mode);
-	if (result != VK_SUCCESS) {
-	    SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
-	    goto clean;
-	}
+        display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
+        display_mode_create_info.parameters = new_mode_parameters;
+        result = vkCreateDisplayModeKHR(gpu,
+                                        displays_props[display_index].display,
+                                        &display_mode_create_info,
+                                        NULL, display_mode);
+        if (result != VK_SUCCESS) {
+            SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
+            goto clean;
+         }
     }
 
     /* Just in case we get here without a display_mode. */
     if (!display_mode) {
-	    SDL_SetError("Vulkan couldn't get a display mode.");
-	    goto clean;
+            SDL_SetError("Vulkan couldn't get a display mode.");
+            goto clean;
     }
 
     /********************************************/