kmsdrm: Always use spaces for indentation. Always use SDL_calloc() for calloc.
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 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 9204c9f..3a164f2 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -117,7 +117,9 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
SDL_assert(surface->pitch == surface->w * 4);
- if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
+ if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, GBM_FORMAT_ARGB8888,
+ GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
+ {
SDL_SetError("Unsupported pixel format for cursor");
return NULL;
}
@@ -136,14 +138,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
/* Find out what GBM cursor size is recommended by the driver. */
if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) ||
- KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h)) {
- SDL_SetError("Could not get the recommended GBM cursor size");
- goto cleanup;
+ KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h))
+ {
+ SDL_SetError("Could not get the recommended GBM cursor size");
+ goto cleanup;
}
if (usable_cursor_w == 0 || usable_cursor_h == 0) {
- SDL_SetError("Could not get an usable GBM cursor size");
- goto cleanup;
+ SDL_SetError("Could not get an usable GBM cursor size");
+ goto cleanup;
}
/* hox_x and hot_y are the coordinates of the "tip of the cursor" from it's base. */
@@ -152,8 +155,8 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
curdata->w = usable_cursor_w;
curdata->h = usable_cursor_h;
- curdata->bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, usable_cursor_w, usable_cursor_h, GBM_FORMAT_ARGB8888,
- GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
+ curdata->bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, usable_cursor_w, usable_cursor_h,
+ GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
if (!curdata->bo) {
SDL_SetError("Could not create GBM cursor BO");
@@ -169,15 +172,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
SDL surface, line by line, to a gbm BO with different pitch. */
buffer = (uint32_t*)SDL_malloc(bufsize);
if (!buffer) {
- SDL_OutOfMemory();
- goto cleanup;
+ SDL_OutOfMemory();
+ goto cleanup;
}
if (SDL_MUSTLOCK(surface)) {
- if (SDL_LockSurface(surface) < 0) {
- /* Could not lock surface */
- goto cleanup;
- }
+ if (SDL_LockSurface(surface) < 0) {
+ /* Could not lock surface */
+ goto cleanup;
+ }
}
/* Clean the whole temporary buffer. */
@@ -188,17 +191,17 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
for (j = 0; j < surface->w; j++) {
pixel = ((uint32_t*)surface->pixels)[i * surface->w + j];
alpha_premultiply_ARGB8888 (&pixel);
- SDL_memcpy(buffer + (i * curdata->w) + j, &pixel, 4);
+ SDL_memcpy(buffer + (i * curdata->w) + j, &pixel, 4);
}
}
if (SDL_MUSTLOCK(surface)) {
- SDL_UnlockSurface(surface);
+ SDL_UnlockSurface(surface);
}
if (KMSDRM_gbm_bo_write(curdata->bo, buffer, bufsize)) {
- SDL_SetError("Could not write to GBM cursor BO");
- goto cleanup;
+ SDL_SetError("Could not write to GBM cursor BO");
+ goto cleanup;
}
/* Free temporary buffer */
@@ -261,14 +264,14 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
/* Hide CURRENT cursor, a cursor that is already on screen
and SDL is stored in mouse->cur_cursor. */
if (mouse->cur_cursor && mouse->cur_cursor->driverdata) {
- if (dispdata && dispdata->cursor_plane) {
- info.plane = dispdata->cursor_plane; /* The rest of the members are zeroed. */
- drm_atomic_set_plane_props(&info);
- if (drm_atomic_commit(display->device, SDL_TRUE))
- return SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor.");
+ if (dispdata && dispdata->cursor_plane) {
+ info.plane = dispdata->cursor_plane; /* The rest of the members are zeroed. */
+ drm_atomic_set_plane_props(&info);
+ if (drm_atomic_commit(display->device, SDL_TRUE))
+ return SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor.");
}
return 0;
- }
+ }
return SDL_SetError("Couldn't find cursor to hide.");
}
@@ -335,18 +338,18 @@ KMSDRM_FreeCursor(SDL_Cursor * cursor)
curdata = (KMSDRM_CursorData *) cursor->driverdata;
if (video_device && curdata->bo && curdata->plane) {
info.plane = curdata->plane; /* The other members are zeroed. */
- drm_atomic_set_plane_props(&info);
+ drm_atomic_set_plane_props(&info);
/* Wait until the cursor is unset from the cursor plane before destroying it's BO. */
if (drm_atomic_commit(video_device, SDL_TRUE)) {
SDL_SetError("Failed atomic commit in KMSDRM_FreeCursor.");
}
- KMSDRM_gbm_bo_destroy(curdata->bo);
- curdata->bo = NULL;
+ KMSDRM_gbm_bo_destroy(curdata->bo);
+ curdata->bo = NULL;
}
- /* Even if the cursor is not ours, free it. */
- SDL_free(cursor->driverdata);
- SDL_free(cursor);
+ /* Even if the cursor is not ours, free it. */
+ SDL_free(cursor->driverdata);
+ SDL_free(cursor);
}
}
@@ -372,11 +375,9 @@ KMSDRM_WarpMouseGlobal(int x, int y)
/* And now update the cursor graphic position on screen. */
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
if (curdata->bo) {
-
- if (drm_atomic_movecursor(curdata, x, y)) {
- return SDL_SetError("drm_atomic_movecursor() failed.");
- }
-
+ if (drm_atomic_movecursor(curdata, x, y)) {
+ return SDL_SetError("drm_atomic_movecursor() failed.");
+ }
} else {
return SDL_SetError("Cursor not initialized properly.");
}
@@ -405,7 +406,7 @@ KMSDRM_InitMouse(_THIS)
/* Init cursor plane, if we haven't yet. */
if (!dispdata->cursor_plane) {
- setup_plane(_this, &(dispdata->cursor_plane), DRM_PLANE_TYPE_CURSOR);
+ setup_plane(_this, &(dispdata->cursor_plane), DRM_PLANE_TYPE_CURSOR);
}
SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor());
@@ -436,9 +437,9 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor)
cursor movement request, but it cripples the movement to 30FPS, so a future solution
is needed. SDLPoP "QUIT?" menu is an example of this situation. */
- if (drm_atomic_movecursor(curdata, mouse->x, mouse->y)) {
- SDL_SetError("drm_atomic_movecursor() failed.");
- }
+ if (drm_atomic_movecursor(curdata, mouse->x, mouse->y)) {
+ SDL_SetError("drm_atomic_movecursor() failed.");
+ }
}
}
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index bbc11b7..a7f9745 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -90,14 +90,15 @@ int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) {
static EGLSyncKHR create_fence(int fd, _THIS)
{
- EGLint attrib_list[] = {
- EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
- EGL_NONE,
- };
- EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR(_this->egl_data->egl_display,
- EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
- assert(fence);
- return fence;
+ EGLint attrib_list[] = {
+ EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
+ EGL_NONE,
+ };
+ EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR
+ (_this->egl_data->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
+
+ assert(fence);
+ return fence;
}
/***********************************************************************************/
@@ -132,6 +133,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
}
+
/******************************************************************/
/* EXPORT the GPU-side FENCE OBJECT to the fence INPUT FD, so we */
/* can pass it into the kernel. Atomic ioctl will pass the */
@@ -144,8 +146,8 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
/* in the CMDSTREAM to be lifted when the CMDSTREAM to this point */
/* is completed). */
/******************************************************************/
- dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID
- (_this->egl_data->egl_display, dispdata->gpu_fence);
+ dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID (_this->egl_data->egl_display,
+ dispdata->gpu_fence);
_this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->gpu_fence);
assert(dispdata->kms_in_fence_fd != -1);
@@ -157,11 +159,11 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
called after eglSwapBuffers(). */
windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs);
if (!windata->next_bo) {
- return SDL_SetError("Failed to lock frontbuffer");
+ return SDL_SetError("Failed to lock frontbuffer");
}
fb = KMSDRM_FBFromBO(_this, windata->next_bo);
if (!fb) {
- return SDL_SetError("Failed to get a new framebuffer from BO");
+ return SDL_SetError("Failed to get a new framebuffer from BO");
}
/* Add the pageflip to the request list. */
@@ -196,19 +198,20 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
/*****************************************************************/
if (dispdata->kms_in_fence_fd != -1)
{
- add_plane_property(dispdata->atomic_req, dispdata->display_plane,
+ add_plane_property(dispdata->atomic_req, dispdata->display_plane,
"IN_FENCE_FD", dispdata->kms_in_fence_fd);
- add_crtc_property(dispdata->atomic_req, dispdata->crtc,
+ add_crtc_property(dispdata->atomic_req, dispdata->crtc,
"OUT_FENCE_PTR", VOID2U64(&dispdata->kms_out_fence_fd));
}
/* Do we have a pending modesetting? If so, set the necessary
props so it's included in the incoming atomic commit. */
if (dispdata->modeset_pending) {
+ uint32_t blob_id;
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
- uint32_t blob_id;
+
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
- add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
+ add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1);
@@ -227,7 +230,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
/* Release the previous front buffer so EGL can chose it as back buffer
and render on it again. */
if (windata->bo) {
- KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
+ KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
}
/* Take note of the buffer about to become front buffer, so next
@@ -308,9 +311,9 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
props so it's included in the incoming atomic commit. */
if (dispdata->modeset_pending) {
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
- uint32_t blob_id;
+ uint32_t blob_id;
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
- add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
+ add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1);
@@ -325,7 +328,7 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
/* Release last front buffer so EGL can chose it as back buffer and render on it again. */
if (windata->bo) {
- KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
+ KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
}
/* Take note of current front buffer, so we can free it next time we come here. */
@@ -352,7 +355,8 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
if (windata->swap_window == NULL) {
/* We want the fenced version by default, but it needs extensions. */
if ( (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) ||
- (!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) ) {
+ (!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) )
+ {
windata->swap_window = KMSDRM_GLES_SwapWindowDoubleBuffered;
} else {
windata->swap_window = KMSDRM_GLES_SwapWindowFenced;
diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h
index bc1c41d..b75943b 100644
--- a/src/video/kmsdrm/SDL_kmsdrmsym.h
+++ b/src/video/kmsdrm/SDL_kmsdrmsym.h
@@ -49,15 +49,15 @@ SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_
uint32_t *buf_id))
SDL_KMSDRM_SYM(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height,
- uint32_t pixel_format, const uint32_t bo_handles[4],
- const uint32_t pitches[4], const uint32_t offsets[4],
- uint32_t *buf_id, uint32_t flags))
+ uint32_t pixel_format, const uint32_t bo_handles[4],
+ const uint32_t pitches[4], const uint32_t offsets[4],
+ uint32_t *buf_id, uint32_t flags))
SDL_KMSDRM_SYM(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width, uint32_t height,
- uint32_t pixel_format, const uint32_t bo_handles[4],
- const uint32_t pitches[4], const uint32_t offsets[4],
- const uint64_t modifier[4], uint32_t *buf_id,
- uint32_t flags))
+ uint32_t pixel_format, const uint32_t bo_handles[4],
+ const uint32_t pitches[4], const uint32_t offsets[4],
+ const uint64_t modifier[4], uint32_t *buf_id,
+ uint32_t flags))
SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId))
SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf))
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index c73a025..aad2a79 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -157,11 +157,16 @@ static dumb_buffer *KMSDRM_CreateDumbBuffer(_THIS)
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
- dumb_buffer *ret = calloc(1, sizeof(*ret));
struct drm_mode_create_dumb create;
struct drm_mode_map_dumb map;
struct drm_mode_destroy_dumb destroy;
+ dumb_buffer *ret = SDL_calloc(1, sizeof(*ret));
+ if (!ret)
+ SDL_OutOfMemory();
+ return NULL;
+ }
+
/*
* The create ioctl uses the combination of depth and bpp to infer
* a format; 24/32 refers to DRM_FORMAT_XRGB8888 as defined in
@@ -174,14 +179,14 @@ static dumb_buffer *KMSDRM_CreateDumbBuffer(_THIS)
* for us, also returning us the GEM handle.
*/
create = (struct drm_mode_create_dumb) {
- .width = dispdata->mode.hdisplay,
- .height = dispdata->mode.vdisplay,
- .bpp = 32,
+ .width = dispdata->mode.hdisplay,
+ .height = dispdata->mode.vdisplay,
+ .bpp = 32,
};
if (KMSDRM_drmIoctl(viddata->drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &create)) {
- SDL_SetError("failed to create dumb buffer\n");
- goto err;
+ SDL_SetError("failed to create dumb buffer\n");
+ goto err;
}
ret->gem_handles[0] = create.handle;
@@ -247,10 +252,10 @@ KMSDRM_FillDumbBuffer(dumb_buffer *buffer)
{
unsigned int x, y;
for (y = 0; y < buffer->height; y++) {
- uint32_t *pix = (uint32_t *) ((uint8_t *) buffer->dumb.mem + (y * buffer->pitches[0]));
- for (x = 0; x < buffer->width; x++) {
- *pix++ = (0x00000000);
- }
+ uint32_t *pix = (uint32_t *) ((uint8_t *) buffer->dumb.mem + (y * buffer->pitches[0]));
+ for (x = 0; x < buffer->width; x++) {
+ *pix++ = (0x00000000);
+ }
}
}
@@ -302,15 +307,15 @@ int add_connector_property(drmModeAtomicReq *req, struct connector *connector,
int prop_id = 0;
for (i = 0 ; i < connector->props->count_props ; i++) {
- if (strcmp(connector->props_info[i]->name, name) == 0) {
- prop_id = connector->props_info[i]->prop_id;
- break;
- }
+ if (strcmp(connector->props_info[i]->name, name) == 0) {
+ prop_id = connector->props_info[i]->prop_id;
+ break;
+ }
}
if (prop_id < 0) {
- SDL_SetError("no connector property: %s", name);
- return -EINVAL;
+ SDL_SetError("no connector property: %s", name);
+ return -EINVAL;
}
return KMSDRM_drmModeAtomicAddProperty(req, connector->connector->connector_id, prop_id, value);
@@ -323,15 +328,15 @@ int add_crtc_property(drmModeAtomicReq *req, struct crtc *crtc,
int prop_id = -1;
for (i = 0 ; i < crtc->props->count_props ; i++) {
- if (strcmp(crtc->props_info[i]->name, name) == 0) {
- prop_id = crtc->props_info[i]->prop_id;
- break;
- }
+ if (strcmp(crtc->props_info[i]->name, name) == 0) {
+ prop_id = crtc->props_info[i]->prop_id;
+ break;
+ }
}
if (prop_id < 0) {
- SDL_SetError("no crtc property: %s", name);
- return -EINVAL;
+ SDL_SetError("no crtc property: %s", name);
+ return -EINVAL;
}
return KMSDRM_drmModeAtomicAddProperty(req, crtc->crtc->crtc_id, prop_id, value);
@@ -345,8 +350,8 @@ int add_plane_property(drmModeAtomicReq *req, struct plane *plane,
for (i = 0 ; i < plane->props->count_props ; i++) {
if (strcmp(plane->props_info[i]->name, name) == 0) {
- prop_id = plane->props_info[i]->prop_id;
- break;
+ prop_id = plane->props_info[i]->prop_id;
+ break;
}
}
@@ -373,27 +378,27 @@ void print_plane_info(_THIS, drmModePlanePtr plane)
/* Search the plane props for the plane type. */
for (int j = 0; j < props->count_props; j++) {
- drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd, props->props[j]);
+ drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd, props->props[j]);
- if ((strcmp(p->name, "type") == 0)) {
- type = props->prop_values[j];
- }
+ if ((strcmp(p->name, "type") == 0)) {
+ type = props->prop_values[j];
+ }
- KMSDRM_drmModeFreeProperty(p);
+ KMSDRM_drmModeFreeProperty(p);
}
switch (type) {
case DRM_PLANE_TYPE_OVERLAY:
- plane_type = "overlay";
- break;
+ plane_type = "overlay";
+ break;
case DRM_PLANE_TYPE_PRIMARY:
- plane_type = "primary";
- break;
+ plane_type = "primary";
+ break;
case DRM_PLANE_TYPE_CURSOR:
- plane_type = "cursor";
- break;
+ plane_type = "cursor";
+ break;
}
@@ -408,11 +413,11 @@ void print_plane_info(_THIS, drmModePlanePtr plane)
printf("--PLANE ID: %d\nPLANE TYPE: %s\nCRTC READING THIS PLANE: %d\nCRTCS SUPPORTED BY THIS PLANE: ", plane->plane_id, plane_type, plane->crtc_id);
for (int i = 0; i < resources->count_crtcs; i++) {
- if (plane->possible_crtcs & (1 << i)) {
- uint32_t crtc_id = resources->crtcs[i];
+ if (plane->possible_crtcs & (1 << i)) {
+ uint32_t crtc_id = resources->crtcs[i];
printf ("%d", crtc_id);
- break;
- }
+ break;
+ }
}
printf ("\n\n");
@@ -428,8 +433,8 @@ void get_planes_info(_THIS)
plane_resources = KMSDRM_drmModeGetPlaneResources(viddata->drm_fd);
if (!plane_resources) {
- printf("drmModeGetPlaneResources failed: %s\n", strerror(errno));
- return;
+ printf("drmModeGetPlaneResources failed: %s\n", strerror(errno));
+ return;
}
printf("--Number of planes found: %d-- \n", plane_resources->count_planes);
@@ -440,11 +445,11 @@ void get_planes_info(_THIS)
uint32_t plane_id = plane_resources->planes[i];
- drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
- if (!plane) {
- printf("drmModeGetPlane(%u) failed: %s\n", plane_id, strerror(errno));
- continue;
- }
+ drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
+ if (!plane) {
+ printf("drmModeGetPlane(%u) failed: %s\n", plane_id, strerror(errno));
+ continue;
+ }
/* Print plane info. */
print_plane_info(_this, plane);
@@ -475,54 +480,53 @@ static int get_plane_id(_THIS, uint32_t plane_type)
/* Get the crtc_index for the current CRTC.
It's needed to find out if a plane supports the CRTC. */
for (i = 0; i < resources->count_crtcs; i++) {
- if (resources->crtcs[i] == dispdata->crtc->crtc->crtc_id) {
- crtc_index = i;
- break;
- }
+ if (resources->crtcs[i] == dispdata->crtc->crtc->crtc_id) {
+ crtc_index = i;
+ break;
+ }
}
plane_resources = KMSDRM_drmModeGetPlaneResources(viddata->drm_fd);
if (!plane_resources) {
- return SDL_SetError("drmModeGetPlaneResources failed.");
+ return SDL_SetError("drmModeGetPlaneResources failed.");
}
/* Iterate on all the available planes. */
for (i = 0; (i < plane_resources->count_planes) && !found; i++) {
- uint32_t plane_id = plane_resources->planes[i];
+ uint32_t plane_id = plane_resources->planes[i];
- drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
- if (!plane) {
- continue;
- }
+ drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
+ if (!plane) {
+ continue;
+ }
/* See if the current CRTC is available for this plane. */
- if (plane->possible_crtcs & (1 << crtc_index)) {
+ if (plane->possible_crtcs & (1 << crtc_index)) {
- drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
- plane_id, DRM_MODE_OBJECT_PLANE);
- ret = plane_id;
+ drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(
+ viddata->drm_fd, plane_id, DRM_MODE_OBJECT_PLANE);
+ ret = plane_id;
/* Iterate on the plane props to find the type of the plane,
to see if it's of the type we want. */
- for (j = 0; j < props->count_props; j++) {
+ for (j = 0; j < props->count_props; j++) {
- drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd,
- props->props[j]);
+ drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd,
+ props->props[j]);
- if ((strcmp(p->name, "type") == 0) &&
- (props->prop_values[j] == plane_type)) {
- /* found our plane, use that: */
- found = 1;
- }
+ if ((strcmp(p->name, "type") == 0) && (props->prop_values[j] == plane_type)) {
+ /* found our plane, use that: */
+ found = 1;
+ }
KMSDRM_drmModeFreeProperty(p);
- }
+ }
- KMSDRM_drmModeFreeObjectProperties(props);
- }
+ KMSDRM_drmModeFreeObjectProperties(props);
+ }
- KMSDRM_drmModeFreePlane(plane);
+ KMSDRM_drmModeFreePlane(plane);
}
KMSDRM_drmModeFreePlaneResources(plane_resources);
@@ -554,7 +558,7 @@ setup_plane(_THIS, struct plane **plane, uint32_t plane_type)
if ((*plane)->plane) {
unsigned int i;
(*plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
- (*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);
+ (*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);
(*plane)->props_info = SDL_calloc((*plane)->props->count_props,
sizeof(*(*plane)->props_info));
@@ -647,12 +651,12 @@ int drm_atomic_commit(_THIS, SDL_bool blocking)
SDL_SetError("Atomic commit failed, returned %d.", ret);
/* Uncomment this for fast-debugging */
// printf("ATOMIC COMMIT FAILED: %d.\n", ret);
- goto out;
+ goto out;
}
if (dispdata->kms_in_fence_fd != -1) {
- close(dispdata->kms_in_fence_fd);
- dispdata->kms_in_fence_fd = -1;
+ close(dispdata->kms_in_fence_fd);
+ dispdata->kms_in_fence_fd = -1;
}
out:
@@ -671,15 +675,15 @@ drm_atomic_waitpending(_THIS)
/* Will return immediately if we have already destroyed the fence, because we NULL-ify it just after.
Also, will return immediately in double-buffer mode, because kms_fence will alsawys be NULL. */
if (dispdata->kms_fence) {
- EGLint status;
+ EGLint status;
- do {
- status = _this->egl_data->eglClientWaitSyncKHR(_this->egl_data->egl_display,
- dispdata->kms_fence, 0, EGL_FOREVER_KHR);
- } while (status != EGL_CONDITION_SATISFIED_KHR);
+ do {
+ status = _this->egl_data->eglClientWaitSyncKHR(_this->egl_data->egl_display,
+ dispdata->kms_fence, 0, EGL_FOREVER_KHR);
+ } while (status != EGL_CONDITION_SATISFIED_KHR);
- _this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->kms_fence);
- dispdata->kms_fence = NULL;
+ _this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->kms_fence);
+ dispdata->kms_fence = NULL;
}
}
@@ -883,16 +887,16 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
format = KMSDRM_gbm_bo_get_format(bo);
for (i = 0; i < num_planes; i++) {
- strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
- handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
- offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
+ strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
+ handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
+ offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
}
/* Create framebuffer object for the buffer.
It's VERY important to note that fb_id is what we ise to set the FB_ID prop of a plane
when using the ATOMIC interface, and we get fb_id it here. */
ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, width, height, format,
- handles, strides, offsets, &fb_info->fb_id, 0);
+ handles, strides, offsets, &fb_info->fb_id, 0);
if (ret) {
SDL_free(fb_info);
@@ -960,8 +964,8 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
}
if (windata->next_bo) {
- KMSDRM_gbm_surface_release_buffer(windata->gs, windata->next_bo);
- windata->next_bo = NULL;
+ KMSDRM_gbm_surface_release_buffer(windata->gs, windata->next_bo);
+ windata->next_bo = NULL;
}
/* Destroy the EGL surface. */
@@ -985,8 +989,8 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
#endif
if (windata->gs) {
- KMSDRM_gbm_surface_destroy(windata->gs);
- windata->gs = NULL;
+ KMSDRM_gbm_surface_destroy(windata->gs);
+ windata->gs = NULL;
}
}
@@ -1114,7 +1118,7 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
}
if (KMSDRM_CreateSurfaces(_this, window)) {
- return -1;
+ return -1;
}
return 0;
@@ -1133,9 +1137,9 @@ KMSDRM_VideoInit(_THIS)
SDL_VideoDisplay display = {0};
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
- dispdata->display_plane = calloc(1, sizeof(*dispdata->display_plane));
- dispdata->crtc = calloc(1, sizeof(*dispdata->crtc));
- dispdata->connector = calloc(1, sizeof(*dispdata->connector));
+ dispdata->display_plane = SDL_calloc(1, sizeof(*dispdata->display_plane));
+ dispdata->crtc = SDL_calloc(1, sizeof(*dispdata->crtc));
+ dispdata->connector = SDL_calloc(1, sizeof(*dispdata->connector));
dispdata->atomic_flags = 0;
dispdata->atomic_req = NULL;
@@ -1333,7 +1337,7 @@ KMSDRM_VideoInit(_THIS)
sizeof(*dispdata->crtc->props_info));
for (i = 0; i < dispdata->crtc->props->count_props; i++) {
- dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
+ dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
dispdata->crtc->props->props[i]);
}
@@ -1345,7 +1349,7 @@ KMSDRM_VideoInit(_THIS)
sizeof(*dispdata->connector->props_info));
for (i = 0; i < dispdata->connector->props->count_props; i++) {
- dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
+ dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
dispdata->connector->props->props[i]);
}
@@ -1615,9 +1619,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);
@@ -1796,7 +1800,7 @@ KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
return SDL_TRUE;
} else {
SDL_SetError("application not compiled with SDL %d.%d\n",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index 0a85367..cba9729 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -60,8 +60,8 @@ typedef struct dumb_buffer {
/* Parameters for our memory-mapped image. */
struct {
- uint32_t *mem;
- unsigned int size;
+ uint32_t *mem;
+ unsigned int size;
} dumb;
unsigned int width;