<div dir="ltr"><div>Couple thoughs.  First, we need to also update drm_output_prepare_cursor_view to check against the size coming from GBM instead of against the hard-coded 64x64 it's currently checking against.  Without changing that, we are still restricted to 64x64 regardless of the GBM checking.<br>
<br></div>Other questions below.<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 28, 2014 at 2:30 PM, Alvaro Fernando García <span dir="ltr"><<a href="mailto:alvarofernandogarcia@gmail.com" target="_blank">alvarofernandogarcia@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Init cursor size to 64x64 if drmGetCap() fails.<br>
<br>
Use Mesa GBM_BO_USE_CURSOR define (which removes 64x64 restriction)<br>
<br>
Signed-off-by: Alvaro Fernando García <<a href="mailto:alvarofernandogarcia@gmail.com">alvarofernandogarcia@gmail.com</a>><br>
---<br>
 src/compositor-drm.c | 41 ++++++++++++++++++++++++++++++++++-------<br>
 1 file changed, 34 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/compositor-drm.c b/src/compositor-drm.c<br>
index 7d514e4..9c83b1a 100644<br>
--- a/src/compositor-drm.c<br>
+++ b/src/compositor-drm.c<br>
@@ -55,6 +55,18 @@<br>
 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6<br>
 #endif<br>
<br>
+#ifndef DRM_CAP_CURSOR_WIDTH<br>
+#define DRM_CAP_CURSOR_WIDTH 0x8<br>
+#endif<br>
+<br>
+#ifndef DRM_CAP_CURSOR_HEIGHT<br>
+#define DRM_CAP_CURSOR_HEIGHT 0x9<br>
+#endif<br>
+<br>
+#ifndef GBM_BO_USE_CURSOR<br>
+#define GBM_BO_USE_CURSOR GBM_BO_USE_CURSOR_64X64<br>
+#endif<br></blockquote><div><br></div><div>Is GBM_BO_USE_CURSOR a valid vallback for GBM_BO_USE_CURSOR_64x64?  What happens if drmGetCap fails but GBM_BO_USE_CURSOR is defined?  Is that going to be ok?<br></div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
 static int option_current_mode = 0;<br>
<br>
 enum output_config {<br>
@@ -108,6 +120,9 @@ struct drm_compositor {<br>
<br>
        clockid_t clock;<br>
        struct udev_input input;<br>
+<br>
+       uint32_t cursor_width;<br>
+       uint32_t cursor_height;<br>
 };<br>
<br>
 struct drm_mode {<br>
@@ -987,7 +1002,7 @@ drm_output_set_cursor(struct drm_output *output)<br>
                (struct drm_compositor *) output->base.compositor;<br>
        EGLint handle, stride;<br>
        struct gbm_bo *bo;<br>
-       uint32_t buf[64 * 64];<br>
+       uint32_t buf[c->cursor_width * c->cursor_height];<br>
        unsigned char *s;<br>
        int i, x, y;<br>
<br>
@@ -1010,7 +1025,7 @@ drm_output_set_cursor(struct drm_output *output)<br>
                s = wl_shm_buffer_get_data(buffer->shm_buffer);<br>
                wl_shm_buffer_begin_access(buffer->shm_buffer);<br>
                for (i = 0; i < ev->surface->height; i++)<br>
-                       memcpy(buf + i * 64, s + i * stride,<br>
+                       memcpy(buf + i * c->cursor_width, s + i * stride,<br>
                               ev->surface->width * 4);<br>
                wl_shm_buffer_end_access(buffer->shm_buffer);<br>
<br>
@@ -1018,8 +1033,8 @@ drm_output_set_cursor(struct drm_output *output)<br>
                        weston_log("failed update cursor: %m\n");<br>
<br>
                handle = gbm_bo_get_handle(bo).s32;<br>
-               if (drmModeSetCursor(c->drm.fd,<br>
-                                    output->crtc_id, handle, 64, 64)) {<br>
+               if (drmModeSetCursor(c->drm.fd, output->crtc_id, handle,<br>
+                               c->cursor_width, c->cursor_height)) {<br>
                        weston_log("failed to set cursor: %m\n");<br>
                        c->cursors_are_broken = 1;<br>
                }<br>
@@ -1296,6 +1311,18 @@ init_drm(struct drm_compositor *ec, struct udev_device *device)<br>
        else<br>
                ec->clock = CLOCK_REALTIME;<br>
<br>
+       ret = drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &cap);<br>
+       if (ret == 0)<br>
+               ec->cursor_width = cap;<br>
+       else<br>
+               ec->cursor_width = 64;<br>
+<br>
+       ret = drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &cap);<br>
+       if (ret == 0)<br>
+               ec->cursor_height = cap;<br>
+       else<br>
+               ec->cursor_height = 64;<br>
+<br></blockquote><div><br></div><div>I think this was asked before, but never answered.  Do we have known bounds on these values?  I guess they come from GBM so we can probably trust that they're reasonable, but what are the guarantees?<br>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        return 0;<br>
 }<br>
<br>
@@ -1554,15 +1581,15 @@ drm_output_init_egl(struct drm_output *output, struct drm_compositor *ec)<br>
                return -1;<br>
        }<br>
<br>
-       flags = GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE;<br>
+       flags = GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE;<br>
<br>
        for (i = 0; i < 2; i++) {<br>
                if (output->cursor_bo[i])<br>
                        continue;<br>
<br>
                output->cursor_bo[i] =<br>
-                       gbm_bo_create(ec->gbm, 64, 64, GBM_FORMAT_ARGB8888,<br>
-                                     flags);<br>
+                       gbm_bo_create(ec->gbm, ec->cursor_width, ec->cursor_height,<br>
+                               GBM_FORMAT_ARGB8888, flags);<br>
        }<br>
<br>
        if (output->cursor_bo[0] == NULL || output->cursor_bo[1] == NULL) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.0.3<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div></div></div>