kmsdrm: merge patches from Ozkan Sezer for removing c-99'isms and raising libgbm version reqeriments.
authorManuel Alfayate Corchete
Sat, 26 Sep 2020 19:18:09 +0200
changeset 14057c9b9ade35084
parent 14056 3c1a6ba7eef0
child 14058 13382e1092cd
kmsdrm: merge patches from Ozkan Sezer for removing c-99'isms and raising libgbm version reqeriments.
configure
configure.ac
src/video/kmsdrm/SDL_kmsdrmmouse.c
src/video/kmsdrm/SDL_kmsdrmvideo.c
     1.1 --- a/configure	Fri Sep 25 10:42:07 2020 +0200
     1.2 +++ b/configure	Sat Sep 26 19:18:09 2020 +0200
     1.3 @@ -21986,12 +21986,12 @@
     1.4      pkg_cv_LIBDRM_CFLAGS="$LIBDRM_CFLAGS"
     1.5   elif test -n "$PKG_CONFIG"; then
     1.6      if test -n "$PKG_CONFIG" && \
     1.7 -    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.46\""; } >&5
     1.8 -  ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.46") 2>&5
     1.9 +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.82\""; } >&5
    1.10 +  ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.82") 2>&5
    1.11    ac_status=$?
    1.12    $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
    1.13    test $ac_status = 0; }; then
    1.14 -  pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 2.4.46" 2>/dev/null`
    1.15 +  pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 2.4.82" 2>/dev/null`
    1.16  else
    1.17    pkg_failed=yes
    1.18  fi
    1.19 @@ -22002,12 +22002,12 @@
    1.20      pkg_cv_LIBDRM_LIBS="$LIBDRM_LIBS"
    1.21   elif test -n "$PKG_CONFIG"; then
    1.22      if test -n "$PKG_CONFIG" && \
    1.23 -    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.46\""; } >&5
    1.24 -  ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.46") 2>&5
    1.25 +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 2.4.82\""; } >&5
    1.26 +  ($PKG_CONFIG --exists --print-errors "libdrm >= 2.4.82") 2>&5
    1.27    ac_status=$?
    1.28    $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
    1.29    test $ac_status = 0; }; then
    1.30 -  pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 2.4.46" 2>/dev/null`
    1.31 +  pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 2.4.82" 2>/dev/null`
    1.32  else
    1.33    pkg_failed=yes
    1.34  fi
    1.35 @@ -22027,9 +22027,9 @@
    1.36          _pkg_short_errors_supported=no
    1.37  fi
    1.38          if test $_pkg_short_errors_supported = yes; then
    1.39 -	        LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libdrm >= 2.4.46" 2>&1`
    1.40 +	        LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libdrm >= 2.4.82" 2>&1`
    1.41          else
    1.42 -	        LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors "libdrm >= 2.4.46" 2>&1`
    1.43 +	        LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors "libdrm >= 2.4.82" 2>&1`
    1.44          fi
    1.45  	# Put the nasty error message in config.log where it belongs
    1.46  	echo "$LIBDRM_PKG_ERRORS" >&5
    1.47 @@ -22055,12 +22055,12 @@
    1.48      pkg_cv_LIBGBM_CFLAGS="$LIBGBM_CFLAGS"
    1.49   elif test -n "$PKG_CONFIG"; then
    1.50      if test -n "$PKG_CONFIG" && \
    1.51 -    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 9.0.0\""; } >&5
    1.52 -  ($PKG_CONFIG --exists --print-errors "gbm >= 9.0.0") 2>&5
    1.53 +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 17.1.0\""; } >&5
    1.54 +  ($PKG_CONFIG --exists --print-errors "gbm >= 17.1.0") 2>&5
    1.55    ac_status=$?
    1.56    $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
    1.57    test $ac_status = 0; }; then
    1.58 -  pkg_cv_LIBGBM_CFLAGS=`$PKG_CONFIG --cflags "gbm >= 9.0.0" 2>/dev/null`
    1.59 +  pkg_cv_LIBGBM_CFLAGS=`$PKG_CONFIG --cflags "gbm >= 17.1.0" 2>/dev/null`
    1.60  else
    1.61    pkg_failed=yes
    1.62  fi
    1.63 @@ -22071,12 +22071,12 @@
    1.64      pkg_cv_LIBGBM_LIBS="$LIBGBM_LIBS"
    1.65   elif test -n "$PKG_CONFIG"; then
    1.66      if test -n "$PKG_CONFIG" && \
    1.67 -    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 9.0.0\""; } >&5
    1.68 -  ($PKG_CONFIG --exists --print-errors "gbm >= 9.0.0") 2>&5
    1.69 +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 17.1.0\""; } >&5
    1.70 +  ($PKG_CONFIG --exists --print-errors "gbm >= 17.1.0") 2>&5
    1.71    ac_status=$?
    1.72    $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
    1.73    test $ac_status = 0; }; then
    1.74 -  pkg_cv_LIBGBM_LIBS=`$PKG_CONFIG --libs "gbm >= 9.0.0" 2>/dev/null`
    1.75 +  pkg_cv_LIBGBM_LIBS=`$PKG_CONFIG --libs "gbm >= 17.1.0" 2>/dev/null`
    1.76  else
    1.77    pkg_failed=yes
    1.78  fi
    1.79 @@ -22096,9 +22096,9 @@
    1.80          _pkg_short_errors_supported=no
    1.81  fi
    1.82          if test $_pkg_short_errors_supported = yes; then
    1.83 -	        LIBGBM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gbm >= 9.0.0" 2>&1`
    1.84 +	        LIBGBM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gbm >= 17.1.0" 2>&1`
    1.85          else
    1.86 -	        LIBGBM_PKG_ERRORS=`$PKG_CONFIG --print-errors "gbm >= 9.0.0" 2>&1`
    1.87 +	        LIBGBM_PKG_ERRORS=`$PKG_CONFIG --print-errors "gbm >= 17.1.0" 2>&1`
    1.88          fi
    1.89  	# Put the nasty error message in config.log where it belongs
    1.90  	echo "$LIBGBM_PKG_ERRORS" >&5
     2.1 --- a/configure.ac	Fri Sep 25 10:42:07 2020 +0200
     2.2 +++ b/configure.ac	Sat Sep 26 19:18:09 2020 +0200
     2.3 @@ -2245,8 +2245,8 @@
     2.4      if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then
     2.5          video_kmsdrm=no
     2.6  
     2.7 -        PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.46], libdrm_avail=yes, libdrm_avail=no)
     2.8 -        PKG_CHECK_MODULES([LIBGBM], [gbm >= 9.0.0], libgbm_avail=yes, libgbm_avail=no)
     2.9 +        PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.82], libdrm_avail=yes, libdrm_avail=no)
    2.10 +        PKG_CHECK_MODULES([LIBGBM], [gbm >= 17.1.0], libgbm_avail=yes, libgbm_avail=no)
    2.11  
    2.12          if test x$libdrm_avail = xyes -a x$libgbm_avail = xyes; then
    2.13              video_kmsdrm=yes
     3.1 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c	Fri Sep 25 10:42:07 2020 +0200
     3.2 +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c	Sat Sep 26 19:18:09 2020 +0200
     3.3 @@ -109,6 +109,7 @@
     3.4      uint32_t bo_stride, pixel;
     3.5      uint32_t *buffer = NULL;
     3.6      size_t bufsize;
     3.7 +    unsigned int i, j;
     3.8  
     3.9      /* All code below assumes ARGB8888 format for the cursor surface, like other backends do.
    3.10         Also, the GBM BO pixels have to be alpha-premultiplied, but the SDL surface we receive has
    3.11 @@ -183,8 +184,8 @@
    3.12      SDL_memset(buffer, 0x00, bo_stride * curdata->h);
    3.13  
    3.14      /* Copy from SDL surface to buffer, pre-multiplying by alpha each pixel as we go. */
    3.15 -    for (int i = 0; i < surface->h; i++) {
    3.16 -        for (int j = 0; j < surface->w; j++) {
    3.17 +    for (i = 0; i < surface->h; i++) {
    3.18 +        for (j = 0; j < surface->w; j++) {
    3.19              pixel = ((uint32_t*)surface->pixels)[i * surface->w + j];
    3.20              alpha_premultiply_ARGB8888 (&pixel);
    3.21  	    SDL_memcpy(buffer + (i * curdata->w)  + j, &pixel, 4);
     4.1 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c	Fri Sep 25 10:42:07 2020 +0200
     4.2 +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c	Sat Sep 26 19:18:09 2020 +0200
     4.3 @@ -55,6 +55,7 @@
     4.4  {
     4.5      SDL_bool available = SDL_FALSE;
     4.6      char device[512];
     4.7 +    unsigned int i;
     4.8      int drm_fd;
     4.9  
    4.10      SDL_snprintf(device, sizeof (device), "%scard%d", KMSDRM_DRI_PATH, devindex);
    4.11 @@ -70,7 +71,7 @@
    4.12                               resources->count_connectors, resources->count_encoders, resources->count_crtcs);
    4.13  
    4.14                  if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) {
    4.15 -                    for (unsigned int i = 0; i < resources->count_connectors; i++) {
    4.16 +                    for (i = 0; i < resources->count_connectors; i++) {
    4.17                          drmModeConnector *conn = KMSDRM_drmModeGetConnector(drm_fd, resources->connectors[i]);
    4.18  
    4.19                          if (!conn) {
    4.20 @@ -244,9 +245,10 @@
    4.21  static void
    4.22  KMSDRM_FillDumbBuffer(dumb_buffer *buffer)
    4.23  {
    4.24 -    for (unsigned int y = 0; y < buffer->height; y++) {
    4.25 +    unsigned int x, y;
    4.26 +    for (y = 0; y < buffer->height; y++) {
    4.27  	uint32_t *pix = (uint32_t *) ((uint8_t *) buffer->dumb.mem + (y * buffer->pitches[0]));
    4.28 -	for (unsigned int x = 0; x < buffer->width; x++) {
    4.29 +	for (x = 0; x < buffer->width; x++) {
    4.30  	    *pix++ = (0x00000000);
    4.31  	}
    4.32      }
    4.33 @@ -550,13 +552,14 @@
    4.34  
    4.35      /* Get the DRM plane properties. */
    4.36      if ((*plane)->plane) {
    4.37 +        unsigned int i;
    4.38          (*plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
    4.39  	    (*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);	
    4.40  
    4.41          (*plane)->props_info = SDL_calloc((*plane)->props->count_props,
    4.42              sizeof(*(*plane)->props_info));
    4.43  
    4.44 -        for (unsigned int i = 0; i < (*plane)->props->count_props; i++) {
    4.45 +        for (i = 0; i < (*plane)->props->count_props; i++) {
    4.46              (*plane)->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
    4.47                  (*plane)->props->props[i]);
    4.48          }
    4.49 @@ -821,6 +824,7 @@
    4.50      unsigned width, height;
    4.51      uint32_t format, strides[4] = {0}, handles[4] = {0}, offsets[4] = {0};
    4.52      const int num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
    4.53 +    unsigned int i;
    4.54      int ret;
    4.55  
    4.56      /* Check for an existing framebuffer */
    4.57 @@ -845,7 +849,7 @@
    4.58      height = KMSDRM_gbm_bo_get_height(bo);
    4.59      format = KMSDRM_gbm_bo_get_format(bo);
    4.60  
    4.61 -    for (int i = 0; i < num_planes; i++) {
    4.62 +    for (i = 0; i < num_planes; i++) {
    4.63  	strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
    4.64  	handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
    4.65  	offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
    4.66 @@ -1011,6 +1015,7 @@
    4.67  {
    4.68      SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    4.69      SDL_VideoData *viddata;
    4.70 +    unsigned int i, j;
    4.71  
    4.72      if (!windata) {
    4.73          return;
    4.74 @@ -1023,11 +1028,11 @@
    4.75      /********************************************/
    4.76      viddata = windata->viddata;
    4.77  
    4.78 -    for (unsigned int i = 0; i < viddata->num_windows; i++) {
    4.79 +    for (i = 0; i < viddata->num_windows; i++) {
    4.80          if (viddata->windows[i] == window) {
    4.81              viddata->num_windows--;
    4.82  
    4.83 -            for (unsigned int j = i; j < viddata->num_windows; j++) {
    4.84 +            for (j = i; j < viddata->num_windows; j++) {
    4.85                  viddata->windows[j] = viddata->windows[j + 1];
    4.86              }
    4.87  
    4.88 @@ -1085,6 +1090,7 @@
    4.89  int
    4.90  KMSDRM_VideoInit(_THIS)
    4.91  {
    4.92 +    unsigned int i, j;
    4.93      int ret = 0;
    4.94      SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
    4.95      SDL_DisplayData *dispdata = NULL;
    4.96 @@ -1139,7 +1145,7 @@
    4.97      }
    4.98  
    4.99      /* Iterate on the available connectors to find a connected connector. */
   4.100 -    for (unsigned int i = 0; i < resources->count_connectors; i++) {
   4.101 +    for (i = 0; i < resources->count_connectors; i++) {
   4.102          drmModeConnector *conn = KMSDRM_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]);
   4.103  
   4.104          if (!conn) {
   4.105 @@ -1162,7 +1168,7 @@
   4.106      }
   4.107  
   4.108      /* Try to find the connector's current encoder */
   4.109 -    for (unsigned int i = 0; i < resources->count_encoders; i++) {
   4.110 +    for (i = 0; i < resources->count_encoders; i++) {
   4.111          encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]);
   4.112  
   4.113          if (!encoder) {
   4.114 @@ -1180,7 +1186,7 @@
   4.115  
   4.116      if (!encoder) {
   4.117          /* No encoder was connected, find the first supported one */
   4.118 -        for (unsigned int i = 0, j; i < resources->count_encoders; i++) {
   4.119 +        for (i = 0; i < resources->count_encoders; i++) {
   4.120              encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]);
   4.121  
   4.122              if (!encoder) {
   4.123 @@ -1214,7 +1220,7 @@
   4.124  
   4.125      /* If no CRTC was connected to the encoder, find the first CRTC that is supported by the encoder, and use that. */
   4.126      if (!dispdata->crtc->crtc) {
   4.127 -        for (unsigned int i = 0; i < resources->count_crtcs; i++) {
   4.128 +        for (i = 0; i < resources->count_crtcs; i++) {
   4.129              if (encoder->possible_crtcs & (1 << i)) {
   4.130                  encoder->crtc_id = resources->crtcs[i];
   4.131                  dispdata->crtc->crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
   4.132 @@ -1293,7 +1299,7 @@
   4.133      dispdata->crtc->props_info = SDL_calloc(dispdata->crtc->props->count_props,
   4.134          sizeof(*dispdata->crtc->props_info));
   4.135  
   4.136 -    for (unsigned int i = 0; i < dispdata->crtc->props->count_props; i++) {
   4.137 +    for (i = 0; i < dispdata->crtc->props->count_props; i++) {
   4.138  	dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
   4.139          dispdata->crtc->props->props[i]);
   4.140      }
   4.141 @@ -1305,7 +1311,7 @@
   4.142      dispdata->connector->props_info = SDL_calloc(dispdata->connector->props->count_props,
   4.143          sizeof(*dispdata->connector->props_info));
   4.144  
   4.145 -    for (unsigned int i = 0; i < dispdata->connector->props->count_props; i++) {
   4.146 +    for (i = 0; i < dispdata->connector->props->count_props; i++) {
   4.147  	dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
   4.148          dispdata->connector->props->props[i]);
   4.149      }
   4.150 @@ -1529,8 +1535,9 @@
   4.151      SDL_DisplayData *dispdata = display->driverdata;
   4.152      drmModeConnector *conn = dispdata->connector->connector;
   4.153      SDL_DisplayMode mode;
   4.154 +    int i;
   4.155  
   4.156 -    for (int i = 0; i < conn->count_modes; i++) {
   4.157 +    for (i = 0; i < conn->count_modes; i++) {
   4.158          SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
   4.159  
   4.160          if (modedata) {
   4.161 @@ -1560,6 +1567,7 @@
   4.162      SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
   4.163      SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
   4.164      drmModeConnector *conn = dispdata->connector->connector;
   4.165 +    int i;
   4.166  
   4.167      if (!modedata) {
   4.168          return SDL_SetError("Mode doesn't have an associated index");
   4.169 @@ -1571,7 +1579,7 @@
   4.170  
   4.171      dispdata->modeset_pending = SDL_TRUE;
   4.172  
   4.173 -    for (int i = 0; i < viddata->num_windows; i++) {
   4.174 +    for (i = 0; i < viddata->num_windows; i++) {
   4.175          SDL_Window *window = viddata->windows[i];
   4.176  
   4.177  	if (KMSDRM_CreateSurfaces(_this, window)) {