kmsdrm: less excessive error checkhing
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
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 7364968..0ead2e6 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -258,29 +258,22 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
/**********************************/
if (!cursor) {
/* Hide CURRENT cursor, a cursor that is already on screen
- and SDL stores in mouse->cur_cursor. */
+ 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. */
- if (drm_atomic_set_plane_props(&info)) {
- return SDL_SetError("Failed to set CURSOR PLANE props 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.");
}
- 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.");
}
/************************************************/
/* If cursor != NULL, DO show cursor on display */
/************************************************/
-
if (!display) {
return SDL_SetError("Could not get display for mouse.");
}
@@ -313,14 +306,11 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
info.crtc_w = curdata->w;
info.crtc_h = curdata->h;
- if (drm_atomic_set_plane_props(&info)) {
- return SDL_SetError("Failed to set CURSOR PLANE props in KMSDRM_ShowCursor.");
- }
+ 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;
}
@@ -338,22 +328,24 @@ static void
KMSDRM_FreeCursor(SDL_Cursor * cursor)
{
KMSDRM_CursorData *curdata = NULL;
- SDL_VideoDevice *video = NULL;
+ SDL_VideoDevice *video_device = SDL_GetVideoDevice();
KMSDRM_PlaneInfo info = {0};
-
if (cursor) {
curdata = (KMSDRM_CursorData *) cursor->driverdata;
- if (video && curdata->bo && curdata->plane) {
+ if (video_device && curdata->bo && curdata->plane) {
info.plane = curdata->plane; /* The other members are zeroed. */
drm_atomic_set_plane_props(&info);
/* Wait until the cursor is unset from the cursor plane before destroying it's BO. */
- drm_atomic_commit(video, SDL_TRUE);
+ 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;
-
- SDL_free(cursor->driverdata);
- SDL_free(cursor);
}
+
+ /* Even if the cursor is not ours, free it. */
+ SDL_free(cursor->driverdata);
+ SDL_free(cursor);
}
}
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 12bd354..bbc11b7 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -175,9 +175,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
info.crtc_h = windata->output_h;
info.crtc_x = windata->output_x;
- if (drm_atomic_set_plane_props(&info)) {
- return SDL_SetError("Failed to request prop changes for setting plane buffer and CRTC");
- }
+ drm_atomic_set_plane_props(&info);
/*****************************************************************/
/* Tell the display (KMS) that it will have to wait on the fence */
@@ -198,12 +196,10 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
/*****************************************************************/
if (dispdata->kms_in_fence_fd != -1)
{
- if (add_plane_property(dispdata->atomic_req, dispdata->display_plane,
- "IN_FENCE_FD", dispdata->kms_in_fence_fd) < 0)
- return SDL_SetError("Failed to set plane IN_FENCE_FD prop");
- if (add_crtc_property(dispdata->atomic_req, dispdata->crtc,
- "OUT_FENCE_PTR", VOID2U64(&dispdata->kms_out_fence_fd)) < 0)
- return SDL_SetError("Failed to set CRTC OUT_FENCE_PTR prop");
+ 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,
+ "OUT_FENCE_PTR", VOID2U64(&dispdata->kms_out_fence_fd));
}
/* Do we have a pending modesetting? If so, set the necessary
@@ -212,14 +208,10 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
uint32_t blob_id;
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
- if (add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id) < 0)
- return -1;
- if (KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id) != 0)
- return -1;
- if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id) < 0)
- return -1;
- if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1) < 0)
- return -1;
+ 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);
dispdata->modeset_pending = SDL_FALSE;
}
@@ -310,9 +302,7 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
info.crtc_h = windata->output_h;
info.crtc_x = windata->output_x;
- if (drm_atomic_set_plane_props(&info)) {
- return SDL_SetError("Failed to request prop changes for setting plane buffer and CRTC");
- }
+ drm_atomic_set_plane_props(&info);
/* Do we have a pending modesetting? If so, set the necessary
props so it's included in the incoming atomic commit. */
@@ -320,14 +310,10 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
uint32_t blob_id;
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
- if (add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id) < 0)
- return -1;
- if (KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id) != 0)
- return -1;
- if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id) < 0)
- return -1;
- if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1) < 0)
- return -1;
+ 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);
dispdata->modeset_pending = SDL_FALSE;
}
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 00113b6..a3efa51 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -606,7 +606,7 @@ free_plane(struct plane **plane)
/* first, move the plane away from those buffers and ONLY THEN destroy the */
/* buffers and/or the GBM surface containig them. */
/**********************************************************************************/
-int
+void
drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info)
{
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
@@ -615,28 +615,16 @@ drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info)
if (!dispdata->atomic_req)
dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc();
- if (add_plane_property(dispdata->atomic_req, info->plane, "FB_ID", info->fb_id) < 0)
- return SDL_SetError("Failed to set plane FB_ID prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "CRTC_ID", info->crtc_id) < 0)
- return SDL_SetError("Failed to set plane CRTC_ID prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "SRC_W", info->src_w << 16) < 0)
- return SDL_SetError("Failed to set plane SRC_W prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "SRC_H", info->src_h << 16) < 0)
- return SDL_SetError("Failed to set plane SRC_H prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "SRC_X", info->src_x) < 0)
- return SDL_SetError("Failed to set plane SRC_X prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "SRC_Y", info->src_y) < 0)
- return SDL_SetError("Failed to set plane SRC_Y prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "CRTC_W", info->crtc_w) < 0)
- return SDL_SetError("Failed to set plane CRTC_W prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "CRTC_H", info->crtc_h) < 0)
- return SDL_SetError("Failed to set plane CRTC_H prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "CRTC_X", info->crtc_x) < 0)
- return SDL_SetError("Failed to set plane CRTC_X prop");
- if (add_plane_property(dispdata->atomic_req, info->plane, "CRTC_Y", info->crtc_y) < 0)
- return SDL_SetError("Failed to set plane CRTC_Y prop");
-
- return 0;
+ add_plane_property(dispdata->atomic_req, info->plane, "FB_ID", info->fb_id);
+ add_plane_property(dispdata->atomic_req, info->plane, "CRTC_ID", info->crtc_id);
+ add_plane_property(dispdata->atomic_req, info->plane, "SRC_W", info->src_w << 16);
+ add_plane_property(dispdata->atomic_req, info->plane, "SRC_H", info->src_h << 16);
+ add_plane_property(dispdata->atomic_req, info->plane, "SRC_X", info->src_x);
+ add_plane_property(dispdata->atomic_req, info->plane, "SRC_Y", info->src_y);
+ add_plane_property(dispdata->atomic_req, info->plane, "CRTC_W", info->crtc_w);
+ add_plane_property(dispdata->atomic_req, info->plane, "CRTC_H", info->crtc_h);
+ add_plane_property(dispdata->atomic_req, info->plane, "CRTC_X", info->crtc_x);
+ add_plane_property(dispdata->atomic_req, info->plane, "CRTC_Y", info->crtc_y);
}
int drm_atomic_commit(_THIS, SDL_bool blocking)
@@ -655,7 +643,7 @@ int drm_atomic_commit(_THIS, SDL_bool blocking)
if (ret) {
SDL_SetError("Atomic commit failed, returned %d.", ret);
/* Uncomment this for fast-debugging */
- //printf("ATOMIC COMMIT FAILED: %d.\n", ret);
+ // printf("ATOMIC COMMIT FAILED: %d.\n", ret);
goto out;
}
@@ -919,7 +907,7 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
/* Issue blocking atomic commit. */
if (drm_atomic_commit(_this, SDL_TRUE)) {
- SDL_SetError("Failed to issue atomic commit on DestroyWindow().");
+ SDL_SetError("Failed to issue atomic commit on window destruction.");
}
/****************************************************************************/
@@ -1428,11 +1416,8 @@ KMSDRM_VideoQuit(_THIS)
#else
- if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID", 0) < 0)
- SDL_SetError("Failed to set CONNECTOR prop CRTC_ID to zero before buffer destruction");
-
- if (add_crtc_property(dispdata->atomic_req, dispdata->crtc , "ACTIVE", 0) < 0)
- SDL_SetError("Failed to set CRTC prop ACTIVE to zero before buffer destruction");
+ add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID", 0);
+ add_crtc_property(dispdata->atomic_req, dispdata->crtc , "ACTIVE", 0);
/* Since we initialize plane_info to all zeros, ALL PRIMARY PLANE props are set to 0 with this,
including FB_ID and CRTC_ID. Not all drivers like FB_ID and CRTC_ID to 0 yet. */
@@ -1451,7 +1436,7 @@ KMSDRM_VideoQuit(_THIS)
/* Issue blocking atomic commit. */
if (drm_atomic_commit(_this, SDL_TRUE)) {
- SDL_SetError("Failed to issue atomic commit on DestroyWindow().");
+ SDL_SetError("Failed to issue atomic commit on video quitting.");
}
/* Destroy the DUMB buffer if it exists, now that it's not being
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index bb197fd..0a85367 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -203,7 +203,7 @@ int KMSDRM_CreateEGLSurface(_THIS, SDL_Window * window);
KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo);
/* Atomic functions that are used from SDL_kmsdrmopengles.c and SDL_kmsdrmmouse.c */
-int drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info);
+void drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info);
void drm_atomic_waitpending(_THIS);
int drm_atomic_commit(_THIS, SDL_bool blocking);