uterm: rename drm-dumb backend into drm2d module
authorDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 24 Jan 2013 13:42:54 +0000 (14:42 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 24 Jan 2013 13:42:54 +0000 (14:42 +0100)
This moves all the drm-dumb code into a new module that is now called
drm2d (which was already used internally before).

No conceptual changes, just renames and moves.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Makefile.am
configure.ac
src/kmscon_conf.c
src/kmscon_main.c
src/uterm_drm2d_internal.h [new file with mode: 0644]
src/uterm_drm2d_render.c [new file with mode: 0644]
src/uterm_drm2d_video.c [moved from src/uterm_video_dumb.c with 65% similarity]
src/uterm_video.c
src/uterm_video.h
src/uterm_video_internal.h
tests/test_output.c

index aeb1e0b..a17ab09 100644 (file)
@@ -273,8 +273,11 @@ libuterm_la_SOURCES += \
        src/uterm_fbdev_render.c
 endif
 
-if BUILD_ENABLE_VIDEO_DUMB
-libuterm_la_SOURCES += src/uterm_video_dumb.c
+if BUILD_ENABLE_VIDEO_DRM2D
+libuterm_la_SOURCES += \
+       src/uterm_drm2d_internal.h \
+       src/uterm_drm2d_video.c \
+       src/uterm_drm2d_render.c
 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
 libuterm_la_LIBADD += $(DRM_LIBS)
 endif
@@ -303,7 +306,7 @@ endif
 UTERM_DRM_SHARED_SRC = \
        src/uterm_drm_shared_internal.h \
        src/uterm_drm_shared.c
-if BUILD_ENABLE_VIDEO_DUMB
+if BUILD_ENABLE_VIDEO_DRM2D
 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
 else
 if BUILD_ENABLE_VIDEO_DRM
index 6075ece..0a0b04d 100644 (file)
@@ -227,21 +227,21 @@ AC_ARG_WITH([video],
             [AS_HELP_STRING([--with-video],
               [specify list of optional video backends])])
 enable_video_fbdev="no"
-enable_video_dumb="no"
+enable_video_drm2d="no"
 enable_video_drm="no"
 if test "x$with_video" = "x" ; then
         enable_video_fbdev="yes (default)"
-        enable_video_dumb="yes (default)"
+        enable_video_drm2d="yes (default)"
         enable_video_drm="yes (default)"
-        with_video="fbdev,dumb,drm (default)"
+        with_video="fbdev,drm2d,drm (default)"
 else
         SAVEIFS="$IFS"
         IFS=","
         for i in $with_video ; do
                 if test "x$i" = "xfbdev" ; then
                         enable_video_fbdev="yes"
-                elif test "x$i" = "xdumb" ; then
-                        enable_video_dumb="yes"
+                elif test "x$i" = "xdrm2d" ; then
+                        enable_video_drm2d="yes"
                 elif test "x$i" = "xdrm" ; then
                         enable_video_drm="yes"
                 else
@@ -434,23 +434,23 @@ else
         video_fbdev_missing="enable-video-fbdev"
 fi
 
-# video dumb
-video_dumb_avail=no
-video_dumb_missing=""
-if test ! "x$enable_video_dumb" = "xno" ; then
-        video_dumb_avail=yes
+# video drm2d
+video_drm2d_avail=no
+video_drm2d_missing=""
+if test ! "x$enable_video_drm2d" = "xno" ; then
+        video_drm2d_avail=yes
         if test "x$have_drm" = "xno" ; then
-                video_dumb_avail=no
-                video_dumb_missing="libdrm"
+                video_drm2d_avail=no
+                video_drm2d_missing="libdrm"
         fi
 
-        if test "x$video_dumb_avail" = "xno" ; then
-                if test "x$enable_video_dumb" = "xyes" ; then
-                        AC_ERROR([missing for dumb video backend: $video_dumb_missing])
+        if test "x$video_drm2d_avail" = "xno" ; then
+                if test "x$enable_video_drm2d" = "xyes" ; then
+                        AC_ERROR([missing for drm2d video backend: $video_drm2d_missing])
                 fi
         fi
 else
-        video_dumb_missing="enable-video-dumb"
+        video_drm2d_missing="enable-video-drm2d"
 fi
 
 # video drm
@@ -895,11 +895,11 @@ if test "x$video_drm_avail" = "xyes" ; then
         fi
 fi
 
-# video dumb
-video_dumb_enabled=no
-if test "x$video_dumb_avail" = "xyes" ; then
-        if test "x${enable_video_dumb% *}" = "xyes" ; then
-                video_dumb_enabled=yes
+# video drm2d
+video_drm2d_enabled=no
+if test "x$video_drm2d_avail" = "xyes" ; then
+        if test "x${enable_video_drm2d% *}" = "xyes" ; then
+                video_drm2d_enabled=yes
         fi
 fi
 
@@ -994,14 +994,14 @@ fi
 AM_CONDITIONAL([BUILD_ENABLE_VIDEO_FBDEV],
                [test "x$video_fbdev_enabled" = "xyes"])
 
-# video dumb
-if test "x$video_dumb_enabled" = "xyes" ; then
-        AC_DEFINE([BUILD_ENABLE_VIDEO_DUMB], [1],
-                  [Build uterm dumb drm video backend])
+# video drm2d
+if test "x$video_drm2d_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_VIDEO_DRM2D], [1],
+                  [Build uterm drm2d drm video backend])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_VIDEO_DUMB],
-               [test "x$video_dumb_enabled" = "xyes"])
+AM_CONDITIONAL([BUILD_ENABLE_VIDEO_DRM2D],
+               [test "x$video_drm2d_enabled" = "xyes"])
 
 # video drm
 if test "x$video_drm_enabled" = "xyes" ; then
@@ -1228,7 +1228,7 @@ AC_MSG_NOTICE([Build configuration:
 
   Video Backends:
                 fbdev: $video_fbdev_enabled ($video_fbdev_avail: $video_fbdev_missing)
-             dumb drm: $video_dumb_enabled ($video_dumb_avail: $video_dumb_missing)
+                drm2d: $video_drm2d_enabled ($video_drm2d_avail: $video_drm2d_missing)
                   drm: $video_drm_enabled ($video_drm_avail: $video_drm_missing)
 
   Font Backends:
index f88b696..d0f98df 100644 (file)
@@ -448,7 +448,7 @@ static int aftercheck_drm(struct conf_option *opt, int argc, char **argv,
         * remove this check. */
        if (conf->drm) {
                if (!uterm_video_available(UTERM_VIDEO_DRM) &&
-                   !uterm_video_available(UTERM_VIDEO_DUMB)) {
+                   !uterm_video_available(UTERM_VIDEO_DRM2D)) {
                        log_info("no DRM runtime support available; disabling --drm");
                        conf->drm = false;
                }
index 927ca4d..b223b35 100644 (file)
@@ -357,7 +357,7 @@ static int app_seat_add_video(struct app_seat *seat,
                if (seat->conf->hwaccel)
                        mode = UTERM_VIDEO_DRM;
                else
-                       mode = UTERM_VIDEO_DUMB;
+                       mode = UTERM_VIDEO_DRM2D;
        } else {
                mode = UTERM_VIDEO_FBDEV;
        }
@@ -365,10 +365,10 @@ static int app_seat_add_video(struct app_seat *seat,
        ret = uterm_video_new(&vid->video, seat->app->eloop, node, mode);
        if (ret) {
                if (mode == UTERM_VIDEO_DRM) {
-                       log_info("cannot create drm device %s on seat %s (%d); trying dumb drm mode",
+                       log_info("cannot create drm device %s on seat %s (%d); trying drm2d mode",
                                 vid->node, seat->name, ret);
                        ret = uterm_video_new(&vid->video, seat->app->eloop,
-                                             node, UTERM_VIDEO_DUMB);
+                                             node, UTERM_VIDEO_DRM2D);
                        if (ret)
                                goto err_node;
                } else {
diff --git a/src/uterm_drm2d_internal.h b/src/uterm_drm2d_internal.h
new file mode 100644 (file)
index 0000000..e2bcabe
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * uterm - Linux User-Space Terminal drm2d module
+ *
+ * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* Internal definitions */
+
+#ifndef UTERM_DRM2D_INTERNAL_H
+#define UTERM_DRM2D_INTERNAL_H
+
+#include <inttypes.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include "uterm_video.h"
+
+struct uterm_drm2d_rb {
+       uint32_t fb;
+       uint32_t handle;
+       uint32_t stride;
+       uint64_t size;
+       void *map;
+};
+
+struct uterm_drm2d_display {
+       int current_rb;
+       struct uterm_drm2d_rb rb[2];
+};
+
+struct uterm_drm2d_video {
+       int fd;
+       struct ev_fd *efd;
+};
+
+int uterm_drm2d_display_blit(struct uterm_display *disp,
+                            const struct uterm_video_buffer *buf,
+                            unsigned int x, unsigned int y);
+int uterm_drm2d_display_fake_blendv(struct uterm_display *disp,
+                                   const struct uterm_video_blend_req *req,
+                                   size_t num);
+int uterm_drm2d_display_fill(struct uterm_display *disp,
+                            uint8_t r, uint8_t g, uint8_t b,
+                            unsigned int x, unsigned int y,
+                            unsigned int width, unsigned int height);
+
+#endif /* UTERM_DRM2D_INTERNAL_H */
diff --git a/src/uterm_drm2d_render.c b/src/uterm_drm2d_render.c
new file mode 100644 (file)
index 0000000..6e50bd2
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * uterm - Linux User-Space Terminal drm2d module
+ *
+ * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * DRM2D Video backend rendering functions
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include "eloop.h"
+#include "log.h"
+#include "uterm_drm_shared_internal.h"
+#include "uterm_drm2d_internal.h"
+#include "uterm_video.h"
+#include "uterm_video_internal.h"
+
+#define LOG_SUBSYSTEM "uterm_drm2d_render"
+
+int uterm_drm2d_display_blit(struct uterm_display *disp,
+                            const struct uterm_video_buffer *buf,
+                            unsigned int x, unsigned int y)
+{
+       unsigned int tmp;
+       uint8_t *dst, *src;
+       unsigned int width, height;
+       unsigned int sw, sh;
+       struct uterm_drm2d_rb *rb;
+       struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
+
+       if (!buf || buf->format != UTERM_FORMAT_XRGB32)
+               return -EINVAL;
+
+       rb = &d2d->rb[d2d->current_rb ^ 1];
+       sw = uterm_drm_mode_get_width(disp->current_mode);
+       sh = uterm_drm_mode_get_height(disp->current_mode);
+
+       tmp = x + buf->width;
+       if (tmp < x || x >= sw)
+               return -EINVAL;
+       if (tmp > sw)
+               width = sw - x;
+       else
+               width = buf->width;
+
+       tmp = y + buf->height;
+       if (tmp < y || y >= sh)
+               return -EINVAL;
+       if (tmp > sh)
+               height = sh - y;
+       else
+               height = buf->height;
+
+       dst = rb->map;
+       dst = &dst[y * rb->stride + x * 4];
+       src = buf->data;
+
+       while (height--) {
+               memcpy(dst, src, 4 * width);
+               dst += rb->stride;
+               src += buf->stride;
+       }
+
+       return 0;
+}
+
+int uterm_drm2d_display_fake_blendv(struct uterm_display *disp,
+                                   const struct uterm_video_blend_req *req,
+                                   size_t num)
+{
+       unsigned int tmp;
+       uint8_t *dst, *src;
+       unsigned int width, height, i, j;
+       unsigned int sw, sh;
+       uint_fast32_t r, g, b, out;
+       struct uterm_drm2d_rb *rb;
+       struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
+
+       if (!req)
+               return -EINVAL;
+
+       rb = &d2d->rb[d2d->current_rb ^ 1];
+       sw = uterm_drm_mode_get_width(disp->current_mode);
+       sh = uterm_drm_mode_get_height(disp->current_mode);
+
+       for (j = 0; j < num; ++j, ++req) {
+               if (!req->buf)
+                       continue;
+
+               if (req->buf->format != UTERM_FORMAT_GREY)
+                       return -EOPNOTSUPP;
+
+               tmp = req->x + req->buf->width;
+               if (tmp < req->x || req->x >= sw)
+                       return -EINVAL;
+               if (tmp > sw)
+                       width = sw - req->x;
+               else
+                       width = req->buf->width;
+
+               tmp = req->y + req->buf->height;
+               if (tmp < req->y || req->y >= sh)
+                       return -EINVAL;
+               if (tmp > sh)
+                       height = sh - req->y;
+               else
+                       height = req->buf->height;
+
+               dst = rb->map;
+               dst = &dst[req->y * rb->stride + req->x * 4];
+               src = req->buf->data;
+
+               while (height--) {
+                       for (i = 0; i < width; ++i) {
+                               /* Division by 255 (t /= 255) is done with:
+                                *   t += 0x80
+                                *   t = (t + (t >> 8)) >> 8
+                                * This speeds up the computation by ~20% as the
+                                * division is not needed. */
+                               if (src[i] == 0) {
+                                       r = req->br;
+                                       g = req->bg;
+                                       b = req->bb;
+                                       out = (r << 16) | (g << 8) | b;
+                               } else if (src[i] == 255) {
+                                       r = req->fr;
+                                       g = req->fg;
+                                       b = req->fb;
+                                       out = (r << 16) | (g << 8) | b;
+                               } else {
+                                       r = req->fr * src[i] +
+                                           req->br * (255 - src[i]);
+                                       r += 0x80;
+                                       r = (r + (r >> 8)) >> 8;
+
+                                       g = req->fg * src[i] +
+                                           req->bg * (255 - src[i]);
+                                       g += 0x80;
+                                       g = (g + (g >> 8)) >> 8;
+
+                                       b = req->fb * src[i] +
+                                           req->bb * (255 - src[i]);
+                                       b += 0x80;
+                                       b = (b + (b >> 8)) >> 8;
+                                       out = (r << 16) | (g << 8) | b;
+                               }
+
+                               ((uint32_t*)dst)[i] = out;
+                       }
+                       dst += rb->stride;
+                       src += req->buf->stride;
+               }
+       }
+
+       return 0;
+}
+
+int uterm_drm2d_display_fill(struct uterm_display *disp,
+                            uint8_t r, uint8_t g, uint8_t b,
+                            unsigned int x, unsigned int y,
+                            unsigned int width, unsigned int height)
+{
+       unsigned int tmp, i;
+       uint8_t *dst;
+       unsigned int sw, sh;
+       struct uterm_drm2d_rb *rb;
+       struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
+
+       rb = &d2d->rb[d2d->current_rb ^ 1];
+       sw = uterm_drm_mode_get_width(disp->current_mode);
+       sh = uterm_drm_mode_get_height(disp->current_mode);
+
+       tmp = x + width;
+       if (tmp < x || x >= sw)
+               return -EINVAL;
+       if (tmp > sw)
+               width = sw - x;
+       tmp = y + height;
+       if (tmp < y || y >= sh)
+               return -EINVAL;
+       if (tmp > sh)
+               height = sh - y;
+
+       dst = rb->map;
+       dst = &dst[y * rb->stride + x * 4];
+
+       while (height--) {
+               for (i = 0; i < width; ++i)
+                       ((uint32_t*)dst)[i] = (r << 16) | (g << 8) | b;
+               dst += rb->stride;
+       }
+
+       return 0;
+}
similarity index 65%
rename from src/uterm_video_dumb.c
rename to src/uterm_drm2d_video.c
index d4ebe07..021d290 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * uterm - Linux User-Space Terminal
+ * uterm - Linux User-Space Terminal drm2d module
  *
  * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
  *
 #include "eloop.h"
 #include "log.h"
 #include "uterm_drm_shared_internal.h"
+#include "uterm_drm2d_internal.h"
 #include "uterm_video.h"
 #include "uterm_video_internal.h"
 
-#define LOG_SUBSYSTEM "video_dumb"
-
-struct uterm_drm2d_rb {
-       uint32_t fb;
-       uint32_t handle;
-       uint32_t stride;
-       uint64_t size;
-       void *map;
-};
-
-struct uterm_drm2d_display {
-       int current_rb;
-       struct uterm_drm2d_rb rb[2];
-};
-
-struct uterm_drm2d_video {
-       int fd;
-       struct ev_fd *efd;
-};
+#define LOG_SUBSYSTEM "video_drm2d"
 
 static int display_init(struct uterm_display *disp)
 {
@@ -287,183 +270,7 @@ static int display_swap(struct uterm_display *disp, bool immediate)
        return 0;
 }
 
-static int display_blit(struct uterm_display *disp,
-                       const struct uterm_video_buffer *buf,
-                       unsigned int x, unsigned int y)
-{
-       unsigned int tmp;
-       uint8_t *dst, *src;
-       unsigned int width, height;
-       unsigned int sw, sh;
-       struct uterm_drm2d_rb *rb;
-       struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
-
-       if (!buf || buf->format != UTERM_FORMAT_XRGB32)
-               return -EINVAL;
-
-       rb = &d2d->rb[d2d->current_rb ^ 1];
-       sw = uterm_drm_mode_get_width(disp->current_mode);
-       sh = uterm_drm_mode_get_height(disp->current_mode);
-
-       tmp = x + buf->width;
-       if (tmp < x || x >= sw)
-               return -EINVAL;
-       if (tmp > sw)
-               width = sw - x;
-       else
-               width = buf->width;
-
-       tmp = y + buf->height;
-       if (tmp < y || y >= sh)
-               return -EINVAL;
-       if (tmp > sh)
-               height = sh - y;
-       else
-               height = buf->height;
-
-       dst = rb->map;
-       dst = &dst[y * rb->stride + x * 4];
-       src = buf->data;
-
-       while (height--) {
-               memcpy(dst, src, 4 * width);
-               dst += rb->stride;
-               src += buf->stride;
-       }
-
-       return 0;
-}
-
-static int display_fake_blendv(struct uterm_display *disp,
-                              const struct uterm_video_blend_req *req,
-                              size_t num)
-{
-       unsigned int tmp;
-       uint8_t *dst, *src;
-       unsigned int width, height, i, j;
-       unsigned int sw, sh;
-       uint_fast32_t r, g, b, out;
-       struct uterm_drm2d_rb *rb;
-       struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
-
-       if (!req)
-               return -EINVAL;
-
-       rb = &d2d->rb[d2d->current_rb ^ 1];
-       sw = uterm_drm_mode_get_width(disp->current_mode);
-       sh = uterm_drm_mode_get_height(disp->current_mode);
-
-       for (j = 0; j < num; ++j, ++req) {
-               if (!req->buf)
-                       continue;
-
-               if (req->buf->format != UTERM_FORMAT_GREY)
-                       return -EOPNOTSUPP;
-
-               tmp = req->x + req->buf->width;
-               if (tmp < req->x || req->x >= sw)
-                       return -EINVAL;
-               if (tmp > sw)
-                       width = sw - req->x;
-               else
-                       width = req->buf->width;
-
-               tmp = req->y + req->buf->height;
-               if (tmp < req->y || req->y >= sh)
-                       return -EINVAL;
-               if (tmp > sh)
-                       height = sh - req->y;
-               else
-                       height = req->buf->height;
-
-               dst = rb->map;
-               dst = &dst[req->y * rb->stride + req->x * 4];
-               src = req->buf->data;
-
-               while (height--) {
-                       for (i = 0; i < width; ++i) {
-                               /* Division by 255 (t /= 255) is done with:
-                                *   t += 0x80
-                                *   t = (t + (t >> 8)) >> 8
-                                * This speeds up the computation by ~20% as the
-                                * division is not needed. */
-                               if (src[i] == 0) {
-                                       r = req->br;
-                                       g = req->bg;
-                                       b = req->bb;
-                                       out = (r << 16) | (g << 8) | b;
-                               } else if (src[i] == 255) {
-                                       r = req->fr;
-                                       g = req->fg;
-                                       b = req->fb;
-                                       out = (r << 16) | (g << 8) | b;
-                               } else {
-                                       r = req->fr * src[i] +
-                                           req->br * (255 - src[i]);
-                                       r += 0x80;
-                                       r = (r + (r >> 8)) >> 8;
-
-                                       g = req->fg * src[i] +
-                                           req->bg * (255 - src[i]);
-                                       g += 0x80;
-                                       g = (g + (g >> 8)) >> 8;
-
-                                       b = req->fb * src[i] +
-                                           req->bb * (255 - src[i]);
-                                       b += 0x80;
-                                       b = (b + (b >> 8)) >> 8;
-                                       out = (r << 16) | (g << 8) | b;
-                               }
-
-                               ((uint32_t*)dst)[i] = out;
-                       }
-                       dst += rb->stride;
-                       src += req->buf->stride;
-               }
-       }
-
-       return 0;
-}
-
-static int display_fill(struct uterm_display *disp,
-                       uint8_t r, uint8_t g, uint8_t b,
-                       unsigned int x, unsigned int y,
-                       unsigned int width, unsigned int height)
-{
-       unsigned int tmp, i;
-       uint8_t *dst;
-       unsigned int sw, sh;
-       struct uterm_drm2d_rb *rb;
-       struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
-
-       rb = &d2d->rb[d2d->current_rb ^ 1];
-       sw = uterm_drm_mode_get_width(disp->current_mode);
-       sh = uterm_drm_mode_get_height(disp->current_mode);
-
-       tmp = x + width;
-       if (tmp < x || x >= sw)
-               return -EINVAL;
-       if (tmp > sw)
-               width = sw - x;
-       tmp = y + height;
-       if (tmp < y || y >= sh)
-               return -EINVAL;
-       if (tmp > sh)
-               height = sh - y;
-
-       dst = rb->map;
-       dst = &dst[y * rb->stride + x * 4];
-
-       while (height--) {
-               for (i = 0; i < width; ++i)
-                       ((uint32_t*)dst)[i] = (r << 16) | (g << 8) | b;
-               dst += rb->stride;
-       }
-
-       return 0;
-}
-
-static const struct display_ops dumb_display_ops = {
+static const struct display_ops drm2d_display_ops = {
        .init = display_init,
        .destroy = display_destroy,
        .activate = display_activate,
@@ -472,9 +279,9 @@ static const struct display_ops dumb_display_ops = {
        .use = display_use,
        .get_buffers = display_get_buffers,
        .swap = display_swap,
-       .blit = display_blit,
-       .fake_blendv = display_fake_blendv,
-       .fill = display_fill,
+       .blit = uterm_drm2d_display_blit,
+       .fake_blendv = uterm_drm2d_display_fake_blendv,
+       .fill = uterm_drm2d_display_fill,
 };
 
 static void show_displays(struct uterm_video *video)
@@ -539,7 +346,7 @@ static void video_destroy(struct uterm_video *video)
 
 static int video_poll(struct uterm_video *video)
 {
-       return uterm_drm_video_poll(video, &dumb_display_ops);
+       return uterm_drm_video_poll(video, &drm2d_display_ops);
 }
 
 static void video_sleep(struct uterm_video *video)
@@ -552,7 +359,7 @@ static int video_wake_up(struct uterm_video *video)
 {
        int ret;
 
-       ret = uterm_drm_video_wake_up(video, &dumb_display_ops);
+       ret = uterm_drm_video_wake_up(video, &drm2d_display_ops);
        if (ret)
                return ret;
 
@@ -560,7 +367,7 @@ static int video_wake_up(struct uterm_video *video)
        return 0;
 }
 
-static const struct video_ops dumb_video_ops = {
+static const struct video_ops drm2d_video_ops = {
        .init = video_init,
        .destroy = video_destroy,
        .segfault = NULL, /* TODO: reset all saved CRTCs on segfault */
@@ -569,8 +376,8 @@ static const struct video_ops dumb_video_ops = {
        .wake_up = video_wake_up,
 };
 
-static const struct uterm_video_module dumb_module = {
-       .ops = &dumb_video_ops,
+static const struct uterm_video_module drm2d_module = {
+       .ops = &drm2d_video_ops,
 };
 
-const struct uterm_video_module *UTERM_VIDEO_DUMB = &dumb_module;
+const struct uterm_video_module *UTERM_VIDEO_DRM2D = &drm2d_module;
index fc440d0..259199c 100644 (file)
@@ -64,7 +64,7 @@ bool uterm_video_available(const struct uterm_video_module *mod)
        if (!mod)
                return false;
 
-       if (mod == UTERM_VIDEO_DUMB || mod == UTERM_VIDEO_DRM)
+       if (mod == UTERM_VIDEO_DRM2D || mod == UTERM_VIDEO_DRM)
                return video_drm_available();
 
        return true;
index 607fc14..3aaff8b 100644 (file)
@@ -214,10 +214,10 @@ extern const struct uterm_video_module *UTERM_VIDEO_FBDEV;
 #define UTERM_VIDEO_FBDEV NULL
 #endif
 
-#ifdef BUILD_ENABLE_VIDEO_DUMB
-extern const struct uterm_video_module *UTERM_VIDEO_DUMB;
+#ifdef BUILD_ENABLE_VIDEO_DRM2D
+extern const struct uterm_video_module *UTERM_VIDEO_DRM2D;
 #else
-#define UTERM_VIDEO_DUMB NULL
+#define UTERM_VIDEO_DRM2D NULL
 #endif
 
 #ifdef BUILD_ENABLE_VIDEO_DRM
index 712a552..801316a 100644 (file)
@@ -180,7 +180,7 @@ static inline bool video_need_hotplug(const struct uterm_video *video)
                        .action = (act), \
                })
 
-#if defined(BUILD_ENABLE_VIDEO_DRM) || defined(BUILD_ENABLE_VIDEO_DUMB)
+#if defined(BUILD_ENABLE_VIDEO_DRM) || defined(BUILD_ENABLE_VIDEO_DRM2D)
 
 #include <xf86drm.h>
 
index ff523cf..2c5ce86 100644 (file)
@@ -218,9 +218,9 @@ int main(int argc, char **argv)
        ret = uterm_video_new(&video, eloop, node, mode);
        if (ret) {
                if (mode == UTERM_VIDEO_DRM) {
-                       log_notice("cannot create drm device; trying dumb drm mode");
+                       log_notice("cannot create drm device; trying drm2d mode");
                        ret = uterm_video_new(&video, eloop, node,
-                                             UTERM_VIDEO_DUMB);
+                                             UTERM_VIDEO_DRM2D);
                        if (ret)
                                goto err_exit;
                } else {