kmsdrm: merge patches from Ozkan Sezer for removing c-99'isms and raising libgbm version reqeriments.
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
diff --git a/configure b/configure
index b7ae819..00bf5eb 100755
--- a/configure
+++ b/configure
@@ -21986,12 +21986,12 @@ if test -n "$LIBDRM_CFLAGS"; then
pkg_cv_LIBDRM_CFLAGS="$LIBDRM_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.46\""; } >&5
- ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.46") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.82\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.82") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 2.4.46" 2>/dev/null`
+ pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 2.4.82" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -22002,12 +22002,12 @@ if test -n "$LIBDRM_LIBS"; then
pkg_cv_LIBDRM_LIBS="$LIBDRM_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.46\""; } >&5
- ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.46") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.82\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.82") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 2.4.46" 2>/dev/null`
+ pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 2.4.82" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -22027,9 +22027,9 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libdrm >= 2.4.46" 2>&1`
+ LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libdrm >= 2.4.82" 2>&1`
else
- LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors "libdrm >= 2.4.46" 2>&1`
+ LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors "libdrm >= 2.4.82" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBDRM_PKG_ERRORS" >&5
@@ -22055,12 +22055,12 @@ if test -n "$LIBGBM_CFLAGS"; then
pkg_cv_LIBGBM_CFLAGS="$LIBGBM_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 9.0.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "gbm >= 9.0.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 17.1.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "gbm >= 17.1.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_LIBGBM_CFLAGS=`$PKG_CONFIG --cflags "gbm >= 9.0.0" 2>/dev/null`
+ pkg_cv_LIBGBM_CFLAGS=`$PKG_CONFIG --cflags "gbm >= 17.1.0" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -22071,12 +22071,12 @@ if test -n "$LIBGBM_LIBS"; then
pkg_cv_LIBGBM_LIBS="$LIBGBM_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 9.0.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "gbm >= 9.0.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 17.1.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "gbm >= 17.1.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_LIBGBM_LIBS=`$PKG_CONFIG --libs "gbm >= 9.0.0" 2>/dev/null`
+ pkg_cv_LIBGBM_LIBS=`$PKG_CONFIG --libs "gbm >= 17.1.0" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -22096,9 +22096,9 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- LIBGBM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gbm >= 9.0.0" 2>&1`
+ LIBGBM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gbm >= 17.1.0" 2>&1`
else
- LIBGBM_PKG_ERRORS=`$PKG_CONFIG --print-errors "gbm >= 9.0.0" 2>&1`
+ LIBGBM_PKG_ERRORS=`$PKG_CONFIG --print-errors "gbm >= 17.1.0" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBGBM_PKG_ERRORS" >&5
diff --git a/configure.ac b/configure.ac
index 5ba9d05..9b2b324 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2245,8 +2245,8 @@ AS_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [[default=no]]]
if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then
video_kmsdrm=no
- PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.46], libdrm_avail=yes, libdrm_avail=no)
- PKG_CHECK_MODULES([LIBGBM], [gbm >= 9.0.0], libgbm_avail=yes, libgbm_avail=no)
+ PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.82], libdrm_avail=yes, libdrm_avail=no)
+ PKG_CHECK_MODULES([LIBGBM], [gbm >= 17.1.0], libgbm_avail=yes, libgbm_avail=no)
if test x$libdrm_avail = xyes -a x$libgbm_avail = xyes; then
video_kmsdrm=yes
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 15ddf70..9204c9f 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -109,6 +109,7 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
uint32_t bo_stride, pixel;
uint32_t *buffer = NULL;
size_t bufsize;
+ unsigned int i, j;
/* All code below assumes ARGB8888 format for the cursor surface, like other backends do.
Also, the GBM BO pixels have to be alpha-premultiplied, but the SDL surface we receive has
@@ -183,8 +184,8 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
SDL_memset(buffer, 0x00, bo_stride * curdata->h);
/* Copy from SDL surface to buffer, pre-multiplying by alpha each pixel as we go. */
- for (int i = 0; i < surface->h; i++) {
- for (int j = 0; j < surface->w; j++) {
+ for (i = 0; i < surface->h; i++) {
+ 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);
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 2ce3cd4..ef25895 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -55,6 +55,7 @@ check_modesetting(int devindex)
{
SDL_bool available = SDL_FALSE;
char device[512];
+ unsigned int i;
int drm_fd;
SDL_snprintf(device, sizeof (device), "%scard%d", KMSDRM_DRI_PATH, devindex);
@@ -70,7 +71,7 @@ check_modesetting(int devindex)
resources->count_connectors, resources->count_encoders, resources->count_crtcs);
if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) {
- for (unsigned int i = 0; i < resources->count_connectors; i++) {
+ for (i = 0; i < resources->count_connectors; i++) {
drmModeConnector *conn = KMSDRM_drmModeGetConnector(drm_fd, resources->connectors[i]);
if (!conn) {
@@ -244,9 +245,10 @@ KMSDRM_DestroyDumbBuffer(_THIS, dumb_buffer *buffer)
static void
KMSDRM_FillDumbBuffer(dumb_buffer *buffer)
{
- for (unsigned int y = 0; y < buffer->height; y++) {
+ 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 (unsigned int x = 0; x < buffer->width; x++) {
+ for (x = 0; x < buffer->width; x++) {
*pix++ = (0x00000000);
}
}
@@ -550,13 +552,14 @@ setup_plane(_THIS, struct plane **plane, uint32_t plane_type)
/* Get the DRM plane properties. */
if ((*plane)->plane) {
+ unsigned int i;
(*plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
(*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);
(*plane)->props_info = SDL_calloc((*plane)->props->count_props,
sizeof(*(*plane)->props_info));
- for (unsigned int i = 0; i < (*plane)->props->count_props; i++) {
+ for (i = 0; i < (*plane)->props->count_props; i++) {
(*plane)->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
(*plane)->props->props[i]);
}
@@ -821,6 +824,7 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
unsigned width, height;
uint32_t format, strides[4] = {0}, handles[4] = {0}, offsets[4] = {0};
const int num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
+ unsigned int i;
int ret;
/* Check for an existing framebuffer */
@@ -845,7 +849,7 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
height = KMSDRM_gbm_bo_get_height(bo);
format = KMSDRM_gbm_bo_get_format(bo);
- for (int i = 0; i < num_planes; i++) {
+ 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);
@@ -1011,6 +1015,7 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
SDL_VideoData *viddata;
+ unsigned int i, j;
if (!windata) {
return;
@@ -1023,11 +1028,11 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
/********************************************/
viddata = windata->viddata;
- for (unsigned int i = 0; i < viddata->num_windows; i++) {
+ for (i = 0; i < viddata->num_windows; i++) {
if (viddata->windows[i] == window) {
viddata->num_windows--;
- for (unsigned int j = i; j < viddata->num_windows; j++) {
+ for (j = i; j < viddata->num_windows; j++) {
viddata->windows[j] = viddata->windows[j + 1];
}
@@ -1085,6 +1090,7 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
int
KMSDRM_VideoInit(_THIS)
{
+ unsigned int i, j;
int ret = 0;
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_DisplayData *dispdata = NULL;
@@ -1139,7 +1145,7 @@ KMSDRM_VideoInit(_THIS)
}
/* Iterate on the available connectors to find a connected connector. */
- for (unsigned int i = 0; i < resources->count_connectors; i++) {
+ for (i = 0; i < resources->count_connectors; i++) {
drmModeConnector *conn = KMSDRM_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]);
if (!conn) {
@@ -1162,7 +1168,7 @@ KMSDRM_VideoInit(_THIS)
}
/* Try to find the connector's current encoder */
- for (unsigned int i = 0; i < resources->count_encoders; i++) {
+ for (i = 0; i < resources->count_encoders; i++) {
encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]);
if (!encoder) {
@@ -1180,7 +1186,7 @@ KMSDRM_VideoInit(_THIS)
if (!encoder) {
/* No encoder was connected, find the first supported one */
- for (unsigned int i = 0, j; i < resources->count_encoders; i++) {
+ for (i = 0; i < resources->count_encoders; i++) {
encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]);
if (!encoder) {
@@ -1214,7 +1220,7 @@ KMSDRM_VideoInit(_THIS)
/* If no CRTC was connected to the encoder, find the first CRTC that is supported by the encoder, and use that. */
if (!dispdata->crtc->crtc) {
- for (unsigned int i = 0; i < resources->count_crtcs; i++) {
+ for (i = 0; i < resources->count_crtcs; i++) {
if (encoder->possible_crtcs & (1 << i)) {
encoder->crtc_id = resources->crtcs[i];
dispdata->crtc->crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
@@ -1293,7 +1299,7 @@ KMSDRM_VideoInit(_THIS)
dispdata->crtc->props_info = SDL_calloc(dispdata->crtc->props->count_props,
sizeof(*dispdata->crtc->props_info));
- for (unsigned int i = 0; i < dispdata->crtc->props->count_props; i++) {
+ for (i = 0; i < dispdata->crtc->props->count_props; i++) {
dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
dispdata->crtc->props->props[i]);
}
@@ -1305,7 +1311,7 @@ KMSDRM_VideoInit(_THIS)
dispdata->connector->props_info = SDL_calloc(dispdata->connector->props->count_props,
sizeof(*dispdata->connector->props_info));
- for (unsigned int i = 0; i < dispdata->connector->props->count_props; i++) {
+ for (i = 0; i < dispdata->connector->props->count_props; i++) {
dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
dispdata->connector->props->props[i]);
}
@@ -1529,8 +1535,9 @@ KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
SDL_DisplayData *dispdata = display->driverdata;
drmModeConnector *conn = dispdata->connector->connector;
SDL_DisplayMode mode;
+ int i;
- for (int i = 0; i < conn->count_modes; i++) {
+ for (i = 0; i < conn->count_modes; i++) {
SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
if (modedata) {
@@ -1560,6 +1567,7 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
drmModeConnector *conn = dispdata->connector->connector;
+ int i;
if (!modedata) {
return SDL_SetError("Mode doesn't have an associated index");
@@ -1571,7 +1579,7 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
dispdata->modeset_pending = SDL_TRUE;
- for (int i = 0; i < viddata->num_windows; i++) {
+ for (i = 0; i < viddata->num_windows; i++) {
SDL_Window *window = viddata->windows[i];
if (KMSDRM_CreateSurfaces(_this, window)) {