Re: Sub 16ms render but missing swap

2023-10-18 Thread Emmanuel Gil Peyrot
Hi,

On Wed, Oct 18, 2023 at 12:00:45AM +, Joe M wrote:
> In a GLES app wired up to Weston/Wayland using EGL, we're calling 
> `eglSwapBuffers` in a render loop that takes about 12-13ms to draw our 
> content, based on CPU timing the run loop. However, the call to swap incurs a 
> duration of around 20ms, meaning we're only hitting 30fps.

Most GPUs nowadays aren’t synchronous, your driver creates command
buffers which are sent to the GPU asynchronously, and then the GPU does
its work.  But unless you call glFinish() or wait on a sync object, you
won’t know at which time the GPU is actually done executing your
commands.  Most notably, eglSwapBufers() will not wait until your buffer
is fully drawn, so that you can start preparing for the next frame ahead
of time.

> I've investigated a little bit into using the presentation callback protocol, 
> but my understanding is that the EGL display (part of drm-wayland in the mesa 
> source IIRC) is itself already plugged in to the necessary Wayland callbacks 
> such that using `eglSwapBuffers` is sufficient to maximize available draw 
> time.
> I also tried enabling the profile flag in weston.ini that allows you to 
> collect a trace, viewable in *wesgr*.  And I read Pekka's blog posts about 
> these diagrams, but I still can't understand if our app is doing something 
> suboptimally. I can't decipher what the wesgr diagram is saying.
> The other weston.ini knob I've tried is the `repaint` window, setting it to 
> 12 or 13 to match our drawing loop. This seems to help sometimes but not in 
> this case.
> A few questions:  1. What other avenues of investigation should I pursue for 
> the swap delay? As in, why when I take 12 ms to render do I not see about 4ms 
> for the swap call to return? My display is running in at 60hz.  2. Has EGL 
> been optimized to use the available wayland callbacks and maximize available 
> client drawing time?  3. Does EGL leverage "weston_direct_display_v1" when 
> available? What's required to take advantage of it in the app code? (ie. run 
> fullscreen?)
> Thanks!

-- 
Link Mauve


Re: Problem with mmap keyboard.

2023-10-04 Thread Emmanuel Gil Peyrot
On Wed, Oct 04, 2023 at 06:19:30PM +, Fred vS wrote:
> Hello.

Hi,

> 
> 
> I try to make work the "Keyboard event" step from the Wayland-book but the C 
> demo crash at loading.
> 
> The problem comes from the mapping: with that error:
> 
> 
> Line 301: wl_keyboard_keymap: Assertion map_shm != MAP_FAILED' failed.
> 
> 
> Here is the function:
> 
> static void
> wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
>  uint32_t format, int32_t fd, uint32_t size)
> {
>  struct client_state *client_state = data;
>  assert(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1);
> 
>  // Line 301: Here problem with mapping
>  char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);

We can read in the documentation of this protocol:
https://wayland.app/protocols/wayland#wl_keyboard:event:keymap

“From version 7 onwards, the fd must be mapped with MAP_PRIVATE by the
recipient, as MAP_SHARED may fail.”

I don’t know which wl_shell version you are using, but check that maybe.

>  assert(map_shm != MAP_FAILED);
> 
>  struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_string(
>  client_state->xkb_context, map_shm,
>  XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
>  munmap(map_shm, size);
>  close(fd);
> 
>  struct xkb_state *xkb_state = xkb_state_new(xkb_keymap);
>  xkb_keymap_unref(client_state->xkb_keymap);
>  xkb_state_unref(client_state->xkb_state);
>  client_state->xkb_keymap = xkb_keymap;
>  client_state->xkb_state = xkb_state;
> }
> 
> 
> 
> Why does the mapping fails, I did check fd and size and they are correctly 
> assigned?
> 
> 
> Thanks.
> 

-- 
Link Mauve


Re: Need support to display application at (0, 0) position on Weston desktop

2023-07-13 Thread Emmanuel Gil Peyrot
Hi,

On Wed, Jul 12, 2023 at 10:24:22PM +0700, huy nguyen wrote:
[…]
> In my application, I want to overlay an MPV video window on another
> application so that users can view both video content and other application
> static content so that a fullscreen MPV is not suitable.
> Is it possible to adjust the initial position of MPV video window at (0,0)
> on the weston desktop (I already hide the weston top bar).

I would recommend to use libmpv instead of mpv, which lets you render
inside of your application wherever you want, without forcing you
through X11.  You would typically have a GL or Vulkan widget in your UI
which you paint into using libmpv.

>
> Best regards,
> Huy
[…]

-- 
Link Mauve


Fwd: Empty IN_FORMATS in sun4i-drm

2021-12-14 Thread Emmanuel Gil Peyrot
Hi, this message I sent earlier about the kernel is also relevant to
this mailing list, I forgot to CC it:

- Forwarded message from Emmanuel Gil Peyrot  -

Date: Tue, 14 Dec 2021 13:02:48 +0100
From: Emmanuel Gil Peyrot 
To: Maxime Ripard , Chen-Yu Tsai , 
dri-de...@lists.freedesktop.org, linux-su...@lists.linux.dev
Subject: Empty IN_FORMATS in sun4i-drm

Hi,

After updating Weston from 9f8561e9 to 07326040 (latest master), it
fails to run on my PinePhone saying “format 0x34325258 not supported by
output DSI-1” and then exiting.

This format is XR24, which would be extremely surprising not to be
present, and drm_info[1] says it is present.  Looking into Weston’s
code, I found that drm_plane_populate_formats()’s docstring says it uses
“either the IN_FORMATS blob property (if available), or the plane's
format list if not.”  Looking back at drm_info, I saw said IN_FORMATS
blob being empty of formats (while the format list is fully populated):
"IN_FORMATS" (immutable): blob = 32
└───DRM_FORMAT_MOD_LINEAR (0x0)

This makes me think the kernel should populate IN_FORMATS with at least
the same formats as the format list when supported, or stop advertising
this property altogether.

Other compositors (such as phoc) still run file, probably because they
use the format list exclusively, without consideration for modifiers.

Besides fixing this driver, would it make sense to also make Weston
ignore an empty IN_FORMATS and fall back to the format list?

Thanks,

[1] https://github.com/ascent12/drm_info

-- 
Emmanuel Gil Peyrot

- End forwarded message -

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature


Re: surface-suspension wayland protcool development status?

2021-11-11 Thread Emmanuel Gil Peyrot
On Thu, Nov 11, 2021 at 10:00:33AM -0500, Neal Gompa wrote:
[…]
> >From a purely downstream perspective, I'd like to have Fedora Linux
> switch to Wayland by default for SDL-based applications (which we are
> able to do relatively quickly and easily since all SDL applications
> now use SDL2 since Fedora Linux 35[3]).

Hi, that’s very nice!

I wrote a similar library[1] for running applications using the GLFW 2
API on top of GLFW 3, and thus natively on Wayland, it’s been tested
with Crypt of the Necrodancer so far but should apply to all other
GLFW 2 applications, if you have any in Fedora.

[1] https://linkmauve.fr/dev/glfw2to3/

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature


Re: FW: xrandr and xwayland

2021-08-03 Thread Emmanuel Gil Peyrot
Hi,

On Tue, Aug 03, 2021 at 01:04:11PM +, David Deyo wrote:
[…]
> I believe our compositor (Weston) can do it, transform=90, but to use this 
> method, it has to be restarted; causing our gui app to crash and lose all 
> entered data.
> The client probably needs to drive the orientation.   Considering our gui 
> will likely be in python3/tkinter, I will need some way create a page and 
> rotate the display.

I once implemented such a plugin[1] for Weston, it never got merged
because it had issues I don’t completely remember, but could be a good
starting point.

It relies on the iio subsystem to provide accelerometer data, and then
automatically rotates once it detects the display is sideways.

Hope it’ll help. :)

[1] https://lists.freedesktop.org/archives/wayland-devel/2016-August/030396.html

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature


[PATCH wayland] cursor: Use memfd_create() when available

2019-02-16 Thread Emmanuel Gil Peyrot
This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.

It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.

This patch is best viewed with the -w option of git log -p.

Signed-off-by: Emmanuel Gil Peyrot 
---
 configure.ac  |  2 +-
 cursor/os-compatibility.c | 56 ---
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index 18fb649..27c4fb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,7 @@ fi
 AC_SUBST(GCC_CFLAGS)
 
 AC_CHECK_HEADERS([sys/prctl.h])
-AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate prctl])
+AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate prctl memfd_create])
 
 AC_ARG_ENABLE([libraries],
  [AC_HELP_STRING([--disable-libraries],
diff --git a/cursor/os-compatibility.c b/cursor/os-compatibility.c
index e972d21..37ed198 100644
--- a/cursor/os-compatibility.c
+++ b/cursor/os-compatibility.c
@@ -25,6 +25,8 @@
 
 #define _GNU_SOURCE
 
+#include "config.h"
+
 #include 
 #include 
 #include 
@@ -32,7 +34,10 @@
 #include 
 #include 
 
-#include "config.h"
+#ifdef HAVE_MEMFD_CREATE
+#include 
+#endif
+
 #include "os-compatibility.h"
 
 #ifndef HAVE_MKOSTEMP
@@ -99,6 +104,13 @@ create_tmpfile_cloexec(char *tmpname)
  * given size. If disk space is insufficent, errno is set to ENOSPC.
  * If posix_fallocate() is not supported, program may receive
  * SIGBUS on accessing mmap()'ed file contents instead.
+ *
+ * If the C library implements memfd_create(), it is used to create the
+ * file purely in memory, without any backing file name on the file
+ * system, and then sealing off the possibility of shrinking it.  This
+ * can then be checked before accessing mmap()'ed file contents, to
+ * make sure SIGBUS can't happen.  It also avoids requiring
+ * XDG_RUNTIME_DIR.
  */
 int
 os_create_anonymous_file(off_t size)
@@ -109,25 +121,39 @@ os_create_anonymous_file(off_t size)
int fd;
int ret;
 
-   path = getenv("XDG_RUNTIME_DIR");
-   if (!path) {
-   errno = ENOENT;
-   return -1;
-   }
+#ifdef HAVE_MEMFD_CREATE
+   fd = memfd_create("wayland-cursor", MFD_CLOEXEC | MFD_ALLOW_SEALING);
+   if (fd >= 0) {
+   /* We can add this seal before calling posix_fallocate(), as
+* the file is currently zero-sized anyway.
+*
+* There is also no need to check for the return value, we
+* couldn't doanything with it anyway.
+*/
+   fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+   } else
+#endif
+   {
+   path = getenv("XDG_RUNTIME_DIR");
+   if (!path) {
+   errno = ENOENT;
+   return -1;
+   }
 
-   name = malloc(strlen(path) + sizeof(template));
-   if (!name)
-   return -1;
+   name = malloc(strlen(path) + sizeof(template));
+   if (!name)
+   return -1;
 
-   strcpy(name, path);
-   strcat(name, template);
+   strcpy(name, path);
+   strcat(name, template);
 
-   fd = create_tmpfile_cloexec(name);
+   fd = create_tmpfile_cloexec(name);
 
-   free(name);
+   free(name);
 
-   if (fd < 0)
-   return -1;
+   if (fd < 0)
+   return -1;
+   }
 
 #ifdef HAVE_POSIX_FALLOCATE
ret = posix_fallocate(fd, 0, size);
-- 
2.20.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Re: weston: Add config option to enable pixman-based rendering

2018-09-18 Thread Emmanuel Gil Peyrot
Hi,

On Wed, Jun 06, 2018 at 04:46:47PM +0200, Thomas Zimmermann wrote:
> Pixman can be used for rendering if the default GLESv2 rendering
> is broken or cannot be used.
> 
> Pixman-based rendering is already available with the command-line
> switch '--use-pixman'. This patch adds support for this option to
> the configuration file. Putting
> 
>   [core]
>   use-pixman=true
> 
> into 'weston.ini' enables pixman-based rendering for all backends
> that support it. With this change, pixman has to be enabled once.

I’ve wanted to use that in the past, this sounds useful as configuration
is now entirely doable in the same place.

> 
> Signed-off-by: Thomas Zimmermann 
> ---
>  compositor/main.c  | 39 +++
>  man/weston.ini.man |  6 ++
>  2 files changed, 41 insertions(+), 4 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 1e827884..e7ac52ca 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -1104,18 +1104,26 @@ load_drm_backend(struct weston_compositor *c,
>   struct weston_config_section *section;
>   struct wet_compositor *wet = to_wet_compositor(c);
>   int ret = 0;
> + int use_pixman_config_ = 0;
> + int32_t use_pixman_ = 0;

Weston’s coding style doesn’t use underscore suffixes anywhere, and
these two don’t seem to add any semantics.

>  
>   wet->drm_use_current_mode = false;
>  
> + section = weston_config_get_section(wc, "core", NULL, NULL);
> + weston_config_section_get_bool(section, "use-pixman", 
> _pixman_config_,
> +use_pixman_config_);
> + use_pixman_ = use_pixman_config_;

Here you can use `false` as the default value, and remove the
`use_pixman_config_` variable altogether.

> +
>   const struct weston_option options[] = {
>   { WESTON_OPTION_STRING, "seat", 0, _id },
>   { WESTON_OPTION_INTEGER, "tty", 0,  },
>   { WESTON_OPTION_STRING, "drm-device", 0, 
> _device },
>   { WESTON_OPTION_BOOLEAN, "current-mode", 0, 
> >drm_use_current_mode },
> - { WESTON_OPTION_BOOLEAN, "use-pixman", 0, _pixman },
> + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, _pixman_ },
>   };
>  
>   parse_options(options, ARRAY_LENGTH(options), argc, argv);
> + config.use_pixman = use_pixman_;

Actually you can even remove both local variables and use
`config.use_pixman` everywhere, also make it a bool.

>  
>   section = weston_config_get_section(wc, "core", NULL, NULL);
>   weston_config_section_get_string(section,
[snip]

Same for the other parts of this file.

> diff --git a/man/weston.ini.man b/man/weston.ini.man
> index f237fd60..cc1cb409 100644
> --- a/man/weston.ini.man
> +++ b/man/weston.ini.man
> @@ -189,6 +189,12 @@ useful for debugging a crash on start-up when it would 
> be inconvenient to
>  launch weston directly from a debugger. Boolean, defaults to
>  .BR false .
>  There is also a command line option to do the same.
> +.TP 7
> +.BI "use-pixman=" true
> +Enables pixman-based rendering for all outputs on backends that support it.
> +Boolean, defaults to
> +.BR false .
> +There is also a command line option to do the same.
>  
>  .SH "LIBINPUT SECTION"
>  The
> -- 
> 2.14.4

Otherwise, LGTM!

Please open a merge request on Freedesktop’s GitLab[1] instead for the
v2 of these patches, the mailing list isn’t used for patches or reviews
anymore.

[1] https://gitlab.freedesktop.org/wayland/weston

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] xwm: Update input region on resize

2018-03-06 Thread Emmanuel Gil Peyrot
On Mon, Feb 19, 2018 at 12:18:51PM -0700, Scott Moreau wrote:
> Commit 332d1892 introduced a bug because the window was
> shaped only when the frame was created, leaving the input
> region unchanged regardless if the window was resized.
> This patch updates the input region shape on resize,
> fixing the problem.

This fixes the issue I had with Firefox, thanks!

Reviewed-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
Tested-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>

> ---
>  xwayland/window-manager.c | 46 +++---
>  1 file changed, 27 insertions(+), 19 deletions(-)
> 
> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> index c307e19..5588166 100644
> --- a/xwayland/window-manager.c
> +++ b/xwayland/window-manager.c
> @@ -659,6 +659,30 @@ weston_wm_window_get_input_rect(struct weston_wm_window 
> *window,
>  }
>  
>  static void
> +weston_wm_window_shape(struct weston_wm_window *window)
> +{
> + struct weston_wm *wm = window->wm;
> + xcb_rectangle_t rect;
> + int x, y, width, height;
> +
> + weston_wm_window_get_input_rect(window, , , , );
> +
> + rect.x = x;
> + rect.y = y;
> + rect.width = width;
> + rect.height = height;
> +
> + /* The window frame was created with position and size which include
> +  * an offset for margins and shadow. Set the input region to ignore
> +  * shadow. */
> + xcb_shape_rectangles(wm->conn,
> +  XCB_SHAPE_SO_SET,
> +  XCB_SHAPE_SK_INPUT,
> +  0, window->frame_id,
> +  0, 0, 1, );
> +}
> +
> +static void
>  weston_wm_window_send_configure_notify(struct weston_wm_window *window)
>  {
>   xcb_configure_notify_event_t configure_notify;
> @@ -789,6 +813,8 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, 
> xcb_generic_event_t *eve
>   xwayland_api->set_xwayland(window->shsurf,
>  window->x, window->y);
>   }
> +
> + weston_wm_window_shape(window);
>  }
>  
>  static void
> @@ -983,7 +1009,6 @@ weston_wm_window_create_frame(struct weston_wm_window 
> *window)
>  {
>   struct weston_wm *wm = window->wm;
>   uint32_t values[3];
> - xcb_rectangle_t rect;
>   int x, y, width, height;
>   int buttons = FRAME_BUTTON_CLOSE;
>  
> @@ -1040,24 +1065,7 @@ weston_wm_window_create_frame(struct weston_wm_window 
> *window)
>>format_rgba,
>width, height);
>  
> - weston_wm_window_get_input_rect(window, , , , );
> - rect.x = x;
> - rect.y = y;
> - rect.width = width;
> - rect.height = height;
> -
> - /* The window frame was created with position and size which include
> -  * an offset for margins and shadow. Set the input region to ignore
> -  * shadow. */
> - xcb_shape_rectangles(wm->conn,
> -  XCB_SHAPE_SO_SET,
> -  XCB_SHAPE_SK_INPUT,
> -  0,
> -  window->frame_id,
> -  0,
> -  0,
> -  1,
> -  );
> + weston_wm_window_shape(window);
>  
>   hash_table_insert(wm->window_hash, window->frame_id, window);
>  }
> -- 
> 2.7.4
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] autoconf: Remove configure line forgotten in bb707dc0fe331c9af112a0552b7aa6fde755dd83

2018-03-05 Thread Emmanuel Gil Peyrot
Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 configure.ac | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index a0a7a271..0b326ccc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,6 +718,5 @@ AC_MSG_RESULT([
LCMS2 Support   ${have_lcms}
libjpeg Support ${have_jpeglib}
libwebp Support ${have_webp}
-   libunwind Support   ${have_libunwind}
VA H.264 encoding Support   ${have_libva}
 ])
-- 
2.16.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] xwm: Fix icon surface ownership

2018-01-24 Thread Emmanuel Gil Peyrot
The cairo surface used for the icon must be completely given to the
frame as soon as said frame has been created.  To prevent both the
window and the frame from sharing ownership of the icon, we set
window->icon_surface back to NULL right after creating or changing the
frame, only keeping it there when no frame has been created yet.

Fixes 
https://lists.freedesktop.org/archives/wayland-devel/2018-January/036655.html
Reported-by: Derek Foreman <der...@osg.samsung.com>
Tested-by: Derek Foreman <der...@osg.samsung.com>
Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 shared/cairo-util.h   |  4 
 shared/frame.c| 14 ++
 xwayland/window-manager.c | 16 ++--
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index bab48083..6fd11f6b 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -135,6 +135,10 @@ frame_destroy(struct frame *frame);
 int
 frame_set_title(struct frame *frame, const char *title);
 
+/* May set FRAME_STATUS_REPAINT */
+void
+frame_set_icon(struct frame *frame, cairo_surface_t *icon);
+
 /* May set FRAME_STATUS_REPAINT */
 void
 frame_set_flag(struct frame *frame, enum frame_flag flag);
diff --git a/shared/frame.c b/shared/frame.c
index dc7ff85c..3a7d9199 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -423,6 +423,20 @@ frame_set_title(struct frame *frame, const char *title)
return 0;
 }
 
+void
+frame_set_icon(struct frame *frame, cairo_surface_t *icon)
+{
+   struct frame_button *button;
+   wl_list_for_each(button, >buttons, link) {
+   if (button->status_effect != FRAME_STATUS_MENU)
+   continue;
+   if (button->icon)
+   cairo_surface_destroy(button->icon);
+   button->icon = icon;
+   frame->status |= FRAME_STATUS_REPAINT;
+   }
+}
+
 void
 frame_set_flag(struct frame *frame, enum frame_flag flag)
 {
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index ac44a29a..c307e199 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -139,7 +139,7 @@ struct weston_wm_window {
struct frame *frame;
cairo_surface_t *cairo_surface;
int icon;
-   cairo_surface_t *icon_surface;
+   cairo_surface_t *icon_surface; /* A temporary slot, to be passed to 
frame on creation */
uint32_t surface_id;
struct weston_surface *surface;
struct weston_desktop_xwayland_surface *shsurf;
@@ -994,6 +994,7 @@ weston_wm_window_create_frame(struct weston_wm_window 
*window)
 window->width, window->height,
 buttons, window->name,
 window->icon_surface);
+   window->icon_surface = NULL;
frame_resize_inside(window->frame, window->width, window->height);
 
weston_wm_window_get_frame_size(window, , );
@@ -1392,10 +1393,10 @@ weston_wm_handle_icon(struct weston_wm *wm, struct 
weston_wm_window *window)
return;
}
 
-   if (window->icon_surface)
-   cairo_surface_destroy(window->icon_surface);
-
-   window->icon_surface = new_surface;
+   if (window->frame)
+   frame_set_icon(window->frame, new_surface);
+   else /* We don’t have a frame yet */
+   window->icon_surface = new_surface;
 }
 
 static void
@@ -1422,7 +1423,10 @@ weston_wm_handle_property_notify(struct weston_wm *wm, 
xcb_generic_event_t *even
if (property_notify->state != XCB_PROPERTY_DELETE) {
weston_wm_handle_icon(wm, window);
} else {
-   cairo_surface_destroy(window->icon_surface);
+   if (window->frame)
+   frame_set_icon(window->frame, NULL);
+   if (window->icon_surface)
+   cairo_surface_destroy(window->icon_surface);
window->icon_surface = NULL;
}
weston_wm_window_schedule_repaint(window);
-- 
2.16.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Unconditionally add linux-dmabuf’s protocol to BUILT_SOURCES

2018-01-07 Thread Emmanuel Gil Peyrot
This was preventing weston-info from building if both
weston-simple-dmabuf-drm and weston-simple-dmabuf-v4l2 were disabled at
build-time.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
Reported-by: Cedric Sodhi <man...@openmail.cc>
Tested-by: Cedric Sodhi <man...@openmail.cc>
---
 Makefile.am | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 883249c0..64cceec4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -638,7 +638,6 @@ nodist_weston_simple_dmabuf_drm_SOURCES =   \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
 weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS)
 weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) 
$(LIBDRM_PLATFORM_LIBS) libshared.la
-BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
 if BUILD_SIMPLE_DMABUF_V4L_CLIENT
@@ -653,7 +652,6 @@ nodist_weston_simple_dmabuf_v4l_SOURCES =   \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
 weston_simple_dmabuf_v4l_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_V4L_CLIENT_CFLAGS)
 weston_simple_dmabuf_v4l_LDADD = $(SIMPLE_DMABUF_V4L_CLIENT_LIBS) libshared.la
-BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
 noinst_LTLIBRARIES += libtoytoolkit.la
@@ -894,7 +892,9 @@ BUILT_SOURCES +=\
protocol/ivi-hmi-controller-protocol.c  \
protocol/ivi-hmi-controller-client-protocol.h   \
protocol/ivi-application-protocol.c \
-   protocol/ivi-application-client-protocol.h
+   protocol/ivi-application-client-protocol.h  \
+   protocol/linux-dmabuf-unstable-v1-protocol.c\
+   protocol/linux-dmabuf-unstable-v1-client-protocol.h
 
 westondatadir = $(datadir)/weston
 dist_westondata_DATA = \
-- 
2.15.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v4] xwm: Add icon support to the frame

2017-12-03 Thread Emmanuel Gil Peyrot
On Fri, Dec 01, 2017 at 09:47:57PM +0100, Quentin Glidic wrote:
> On 12/1/17 7:20 PM, Emmanuel Gil Peyrot wrote:
> > This fetches the _NET_WM_ICON property of the X11 window, and use the
> > first image found as the frame icon.
> > 
> > This has been tested with various X11 programs, and improves usability
> > and user-friendliness a bit.
> > 
> > Changes since v1:
> > - Changed frame_button_create() to use
> >frame_button_create_from_surface() internally.
> > - Removed a check that should never have been commited.
> > 
> > Changes since v2:
> > - Request UINT32_MAX items instead of 2048, to avoid cutting valid
> >icons.
> > - Strengthen checks against malformed input.
> > - Handle XCB_PROPERTY_DELETE to remove the icon.
> > - Schedule a repaint if the icon changed.
> > 
> > Changes since v3:
> > - Keep the previous Cairo surface until the new one has been
> >successfully loaded.
> > - Use uint32_t for cardinals.  Unsigned is the same type except on
> >    16-bit machines, but uint32_t is clearer.
> > - Declare length as uint32_t too, like in xcb_get_property_reply_t.
> > 
> > Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
> > Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>
> 
> Just re-checked to be sure, found a tiny thing I overlooked (see below), but
> the Rb still stands anyway.
> 
> 
> > ---
> >   clients/window.c   |  4 +--
> >   libweston/compositor-wayland.c |  2 +-
> >   shared/cairo-util.h|  2 +-
> >   shared/frame.c | 54 ++-
> >   xwayland/window-manager.c  | 65 
> > --
> >   5 files changed, 107 insertions(+), 20 deletions(-)
> > 
> > diff --git a/clients/window.c b/clients/window.c
> > index 95796d46..15a86e15 100644
> > --- a/clients/window.c
> > +++ b/clients/window.c
> > @@ -2546,7 +2546,7 @@ window_frame_create(struct window *window, void *data)
> > frame = xzalloc(sizeof *frame);
> > frame->frame = frame_create(window->display->theme, 0, 0,
> > -   buttons, window->title);
> > +   buttons, window->title, NULL);
> > frame->widget = window_add_widget(window, frame);
> > frame->child = widget_add_widget(frame->widget, data);
> > @@ -5449,7 +5449,7 @@ create_menu(struct display *display,
> > menu->user_data = user_data;
> > menu->widget = window_add_widget(menu->window, menu);
> > menu->frame = frame_create(window->display->theme, 0, 0,
> > -  FRAME_BUTTON_NONE, NULL);
> > +  FRAME_BUTTON_NONE, NULL, NULL);
> > fail_on_null(menu->frame, 0, __FILE__, __LINE__);
> > menu->entries = entries;
> > menu->count = count;
> > diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
> > index 3bdfb03e..c5290d85 100644
> > --- a/libweston/compositor-wayland.c
> > +++ b/libweston/compositor-wayland.c
> > @@ -869,7 +869,7 @@ wayland_output_set_windowed(struct wayland_output 
> > *output)
> > return -1;
> > }
> > output->frame = frame_create(b->theme, 100, 100,
> > -FRAME_BUTTON_CLOSE, output->title);
> > +FRAME_BUTTON_CLOSE, output->title, NULL);
> > if (!output->frame)
> > return -1;
> > diff --git a/shared/cairo-util.h b/shared/cairo-util.h
> > index 84cf005e..7893ca24 100644
> > --- a/shared/cairo-util.h
> > +++ b/shared/cairo-util.h
> > @@ -126,7 +126,7 @@ enum {
> >   struct frame *
> >   frame_create(struct theme *t, int32_t width, int32_t height, uint32_t 
> > buttons,
> > -const char *title);
> > + const char *title, cairo_surface_t *icon);
> >   void
> >   frame_destroy(struct frame *frame);
> > diff --git a/shared/frame.c b/shared/frame.c
> > index eb0cd77a..32779856 100644
> > --- a/shared/frame.c
> > +++ b/shared/frame.c
> > @@ -106,9 +106,9 @@ struct frame {
> >   };
> >   static struct frame_button *
> > -frame_button_create(struct frame *frame, const char *icon,
> > -   enum frame_status status_effect,
> > -   enum frame_button_flags flags)
> > +frame_button_create_from_surface(struct frame *frame, cairo_surface_t 
> > *icon,
> > + enum frame

[PATCH weston v4] xwm: Add icon support to the frame

2017-12-01 Thread Emmanuel Gil Peyrot
This fetches the _NET_WM_ICON property of the X11 window, and use the
first image found as the frame icon.

This has been tested with various X11 programs, and improves usability
and user-friendliness a bit.

Changes since v1:
- Changed frame_button_create() to use
  frame_button_create_from_surface() internally.
- Removed a check that should never have been commited.

Changes since v2:
- Request UINT32_MAX items instead of 2048, to avoid cutting valid
  icons.
- Strengthen checks against malformed input.
- Handle XCB_PROPERTY_DELETE to remove the icon.
- Schedule a repaint if the icon changed.

Changes since v3:
- Keep the previous Cairo surface until the new one has been
  successfully loaded.
- Use uint32_t for cardinals.  Unsigned is the same type except on
  16-bit machines, but uint32_t is clearer.
- Declare length as uint32_t too, like in xcb_get_property_reply_t.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 clients/window.c   |  4 +--
 libweston/compositor-wayland.c |  2 +-
 shared/cairo-util.h|  2 +-
 shared/frame.c | 54 ++-
 xwayland/window-manager.c  | 65 --
 5 files changed, 107 insertions(+), 20 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 95796d46..15a86e15 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2546,7 +2546,7 @@ window_frame_create(struct window *window, void *data)
 
frame = xzalloc(sizeof *frame);
frame->frame = frame_create(window->display->theme, 0, 0,
-   buttons, window->title);
+   buttons, window->title, NULL);
 
frame->widget = window_add_widget(window, frame);
frame->child = widget_add_widget(frame->widget, data);
@@ -5449,7 +5449,7 @@ create_menu(struct display *display,
menu->user_data = user_data;
menu->widget = window_add_widget(menu->window, menu);
menu->frame = frame_create(window->display->theme, 0, 0,
-  FRAME_BUTTON_NONE, NULL);
+  FRAME_BUTTON_NONE, NULL, NULL);
fail_on_null(menu->frame, 0, __FILE__, __LINE__);
menu->entries = entries;
menu->count = count;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 3bdfb03e..c5290d85 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -869,7 +869,7 @@ wayland_output_set_windowed(struct wayland_output *output)
return -1;
}
output->frame = frame_create(b->theme, 100, 100,
-FRAME_BUTTON_CLOSE, output->title);
+FRAME_BUTTON_CLOSE, output->title, NULL);
if (!output->frame)
return -1;
 
diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index 84cf005e..7893ca24 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -126,7 +126,7 @@ enum {
 
 struct frame *
 frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
-const char *title);
+ const char *title, cairo_surface_t *icon);
 
 void
 frame_destroy(struct frame *frame);
diff --git a/shared/frame.c b/shared/frame.c
index eb0cd77a..32779856 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -106,9 +106,9 @@ struct frame {
 };
 
 static struct frame_button *
-frame_button_create(struct frame *frame, const char *icon,
-   enum frame_status status_effect,
-   enum frame_button_flags flags)
+frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
+ enum frame_status status_effect,
+ enum frame_button_flags flags)
 {
struct frame_button *button;
 
@@ -116,12 +116,7 @@ frame_button_create(struct frame *frame, const char *icon,
if (!button)
return NULL;
 
-   button->icon = cairo_image_surface_create_from_png(icon);
-   if (!button->icon) {
-   free(button);
-   return NULL;
-   }
-
+   button->icon = icon;
button->frame = frame;
button->flags = flags;
button->status_effect = status_effect;
@@ -131,6 +126,30 @@ frame_button_create(struct frame *frame, const char *icon,
return button;
 }
 
+static struct frame_button *
+frame_button_create(struct frame *frame, const char *icon_name,
+enum frame_status status_effect,
+enum frame_button_flags flags)
+{
+   struct frame_button *button;
+   cairo_surface_t *icon;
+
+   icon = cairo_image_surface_create_from_png(icon_name);
+   if (cairo_surface_status(icon) != CAIRO_STATUS_SUCCESS)
+ 

Re: [PATCH wayland] connection: Print the content of arrays in closures

2017-12-01 Thread Emmanuel Gil Peyrot
On Fri, Dec 01, 2017 at 05:08:15PM +, Daniel Stone wrote:
> Hi,
> 
> On 10 July 2017 at 19:28, Emmanuel Gil Peyrot
> <emmanuel.pey...@collabora.com> wrote:
> > The current behaviour when WAYLAND_DEBUG is set is to print “array”,
> > which is quite unhelpful.
> >
> > This patch prints a list of the bytes present in the array.  It doesn’t
> > try to interpret it as uint32_t or anything, leaving that to the reader
> > because this information isn’t present in the protocol description.
> 
> To be honest, I'm not really wild about this one. All the array users
> I know of (key/button, xdg surface states) are uint32_t. I'd prefer to
> add a pretty-printing hint to the protocol - this could specify how to
> interpret arrays, and also scratch my long-standing itch of printing
> uints with %x rather than %u when it makes sense to ...

I would be all for a machine-readable description of the array’s
content, especially to help bindings in languages such as Java or Rust,
which currently have to hardcode the representation on a case by case
basis.  Better debug would only be a nice side effect.

In the meantime, displaying each byte as an uint8_t guarantees there is
no unintended (wrong) interpretation, and reminds us that we don’t have
that yet. :)

> 
> Cheers,
> Daniel

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 12/13] main, compositor: Add a stereoscopy config option.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

It can take the values "", "frame-packing", "top-and-bottom" and
"side-by-side".  Any mode not corresponding to one of these will be
discarded.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 Makefile.am|  4 +++-
 compositor/main.c  | 60 ++
 libweston/compositor.c | 24 
 libweston/compositor.h |  7 ++
 man/weston-drm.man |  6 -
 5 files changed, 99 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e1cdb289..39b71b88 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -691,7 +691,9 @@ nodist_libtoytoolkit_la_SOURCES =   \
protocol/pointer-constraints-unstable-v1-protocol.c \
protocol/pointer-constraints-unstable-v1-client-protocol.h  \
protocol/relative-pointer-unstable-v1-protocol.c\
-   protocol/relative-pointer-unstable-v1-client-protocol.h
+   protocol/relative-pointer-unstable-v1-client-protocol.h \
+   protocol/stereoscopy-unstable-v1-protocol.c \
+   protocol/stereoscopy-unstable-v1-client-protocol.h
 
 BUILT_SOURCES += $(nodist_libtoytoolkit_la_SOURCES)
 
diff --git a/compositor/main.c b/compositor/main.c
index 9e4451e5..ffbfeb95 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -65,6 +65,8 @@
 #include "compositor-wayland.h"
 #include "windowed-output-api.h"
 
+#include "stereoscopy-unstable-v1-server-protocol.h"
+
 #define WINDOW_TITLE "Weston Compositor"
 
 struct wet_output_config {
@@ -978,6 +980,28 @@ weston_transform_to_string(uint32_t output_transform)
return "";
 }
 
+static const struct { const char *name; uint32_t token; } 
stereoscopy_layouts[] = {
+   { "",   ZWP_STEREOSCOPY_V1_LAYOUT_NONE },
+   { "frame-packing",  ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING },
+   { "top-and-bottom", ZWP_STEREOSCOPY_V1_LAYOUT_TOP_AND_BOTTOM },
+   { "side-by-side",   ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE },
+};
+
+WL_EXPORT int
+weston_parse_stereoscopy_layout(const char *layout, uint32_t *out)
+{
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_LENGTH(stereoscopy_layouts); i++)
+   if (strcmp(stereoscopy_layouts[i].name, layout) == 0) {
+   *out = stereoscopy_layouts[i].token;
+   return 0;
+   }
+
+   *out = ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+   return -1;
+}
+
 static int
 load_configuration(struct weston_config **config, int32_t noconfig,
   const char *config_file)
@@ -1068,6 +1092,36 @@ wet_output_set_transform(struct weston_output *output,
weston_output_set_transform(output, transform);
 }
 
+/* UINT32_MAX is treated as invalid because 0 is a valid
+ * enumeration value and the parameter is unsigned
+ */
+static void
+wet_output_set_stereoscopy_layout(struct weston_output *output,
+  struct weston_config_section *section,
+  uint32_t default_layout,
+  uint32_t parsed_layout)
+{
+   char *t;
+   uint32_t layout = default_layout;
+
+   if (section) {
+   weston_config_section_get_string(section,
+"stereoscopy", , "");
+
+   if (weston_parse_stereoscopy_layout(t, ) < 0) {
+   weston_log("Invalid stereoscopy layout \"%s\" for 
output %s\n",
+  t, output->name);
+   layout = default_layout;
+   }
+   free(t);
+   }
+
+   if (parsed_layout != UINT32_MAX)
+   layout = parsed_layout;
+
+   weston_output_set_stereoscopy_layout(output, layout);
+}
+
 static int
 wet_configure_windowed_output_from_config(struct weston_output *output,
  struct wet_output_config *defaults)
@@ -1185,6 +1239,12 @@ drm_backend_output_configure(struct wl_listener 
*listener, void *data)
}
free(s);
 
+   /* This must be parsed before setting the mode, otherwise we will
+* always choose a mono mode. */
+   wet_output_set_stereoscopy_layout(output, section,
+ ZWP_STEREOSCOPY_V1_LAYOUT_NONE,
+ UINT32_MAX);
+
if (api->set_mode(output, mode, modeline) < 0) {
weston_log("Cannot configure an output using 
weston_drm_output_api.\n");
free(modeline);
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 723dec02..7766e8c4 100644
--- a/libweston/compositor.c
+++ b/libweston/compo

[PATCH weston 10/13] gl-renderer: Add stereoscopy support.

2017-11-14 Thread Emmanuel Gil Peyrot
Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor.c  |   5 +-
 libweston/gl-renderer.c | 135 ++--
 libweston/gl-renderer.h |   6 +++
 3 files changed, 128 insertions(+), 18 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 9343bdbf..723dec02 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5187,10 +5187,13 @@ destroy_stereoscopy_description(struct wl_resource 
*resource)
struct weston_surface *surface =
wl_resource_get_user_data(resource);
 
+   bool was_stereo = 
surface->pending.buffer_viewport.buffer.stereoscopy_layout !=
+ ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+
surface->stereoscopy_description_resource = NULL;
surface->pending.buffer_viewport.buffer.stereoscopy_layout = 
ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
surface->pending.buffer_viewport.surface.default_side = 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
-   surface->pending.buffer_viewport.changed = 1;
+   surface->pending.buffer_viewport.changed |= was_stereo;
 }
 
 static void
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 244ce309..73b0d358 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -54,6 +54,7 @@
 #include "vertex-clipping.h"
 #include "linux-dmabuf.h"
 #include "linux-dmabuf-unstable-v1-server-protocol.h"
+#include "stereoscopy-unstable-v1-server-protocol.h"
 
 #include "shared/helpers.h"
 #include "shared/platform.h"
@@ -771,7 +772,8 @@ triangle_fan_debug(struct weston_view *view, int first, int 
count)
 
 static void
 repaint_region(struct weston_view *ev, pixman_region32_t *region,
-   pixman_region32_t *surf_region)
+   pixman_region32_t *surf_region,
+   enum gl_renderer_stereoscopy_side side)
 {
struct weston_compositor *ec = ev->surface->compositor;
struct gl_renderer *gr = get_renderer(ec);
@@ -792,6 +794,36 @@ repaint_region(struct weston_view *ev, pixman_region32_t 
*region,
v = gr->vertices.data;
vtxcnt = gr->vtxcnt.data;
 
+   assert(side == GL_RENDERER_SIDE_LEFT || side == GL_RENDERER_SIDE_RIGHT);
+   switch (ev->surface->buffer_viewport.buffer.stereoscopy_layout) {
+   case ZWP_STEREOSCOPY_V1_LAYOUT_NONE:
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING:
+   for (i = 0; i < nfans * 4; i++) {
+   if (side == GL_RENDERER_SIDE_RIGHT)
+   v[i * 4 + 3] += 25. / 24.;
+   }
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE:
+   for (i = 0; i < nfans * 4; i++) {
+   v[i * 4 + 2] *= 0.5;
+   if (side == GL_RENDERER_SIDE_RIGHT)
+   v[i * 4 + 2] += 0.5;
+   }
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_TOP_AND_BOTTOM:
+   for (i = 0; i < nfans * 4; i++) {
+   v[i * 4 + 3] *= 0.5;
+   if (side == GL_RENDERER_SIDE_RIGHT)
+   v[i * 4 + 3] += 0.5;
+   }
+   break;
+   default:
+   /* We currently only support side-by-side and
+* top-and-bottom layouts for client buffers. */
+   assert(0);
+   }
+
/* position: */
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, [0]);
glEnableVertexAttribArray(0);
@@ -881,7 +913,8 @@ shader_uniforms(struct gl_shader *shader,
 
 static void
 draw_view(struct weston_view *ev, struct weston_output *output,
- pixman_region32_t *damage) /* in global coordinates */
+  pixman_region32_t *damage, /* in global coordinates */
+  enum gl_renderer_stereoscopy_side side)
 {
struct weston_compositor *ec = ev->surface->compositor;
struct gl_renderer *gr = get_renderer(ec);
@@ -920,11 +953,22 @@ draw_view(struct weston_view *ev, struct weston_output 
*output,
shader_uniforms(gs->shader, ev, output);
 
if (ev->transform.enabled || output->zoom.active ||
-   output->current_scale != ev->surface->buffer_viewport.buffer.scale)
+   output->current_scale != ev->surface->buffer_viewport.buffer.scale 
||
+   (output->stereoscopy_layout != ZWP_STEREOSCOPY_V1_LAYOUT_NONE &&
+output->stereoscopy_layout != 
ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING) ||
+   ev->surface->buffer_viewport.buffer.stereoscopy_layout != 
ZWP_STEREOSCOPY_V1_LAYOUT_NONE)
filter = GL_LINEAR;
else
filter = GL_NEAREST;
 
+   if (output->stereoscopy_layout == ZWP_STEREOSCOPY_V1_LAYOUT_NONE &&
+   side == 

[PATCH weston 13/13] compositor-drm: Select stereo modes based on the configuration.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor-drm.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 00f85e8b..eaf60132 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3024,7 +3024,8 @@ drm_output_choose_initial_mode(struct drm_backend 
*backend,
   struct drm_output *output,
   enum weston_drm_backend_output_mode mode,
   const char *modeline,
-  const drmModeModeInfo *current_mode)
+  const drmModeModeInfo *current_mode,
+  uint32_t stereoscopy_layout)
 {
struct drm_mode *preferred = NULL;
struct drm_mode *current = NULL;
@@ -3054,6 +3055,28 @@ drm_output_choose_initial_mode(struct drm_backend 
*backend,
}
 
wl_list_for_each_reverse(drm_mode, >base.mode_list, base.link) {
+   uint32_t stereo_flags = drm_mode->mode_info.flags & 
DRM_MODE_FLAG_3D_MASK;
+   switch (output->base.stereoscopy_layout) {
+   case ZWP_STEREOSCOPY_V1_LAYOUT_NONE:
+   if (stereo_flags != 0)
+   continue;
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING:
+   if (stereo_flags != DRM_MODE_FLAG_3D_FRAME_PACKING)
+   continue;
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_TOP_AND_BOTTOM:
+   if (stereo_flags != DRM_MODE_FLAG_3D_TOP_AND_BOTTOM)
+   continue;
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE:
+   if (stereo_flags != DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF)
+   continue;
+   break;
+   default:
+   assert(0);
+   }
+
if (width == drm_mode->base.width &&
height == drm_mode->base.height &&
(refresh == 0 || refresh == drm_mode->mode_info.vrefresh))
@@ -3132,7 +3155,9 @@ drm_output_set_mode(struct weston_output *base,
if (connector_get_current_mode(output->connector, b->drm.fd, 
_mode) < 0)
return -1;
 
-   current = drm_output_choose_initial_mode(b, output, mode, modeline, 
_mode);
+   current = drm_output_choose_initial_mode(b, output, mode, modeline,
+_mode,
+
output->base.stereoscopy_layout);
if (!current)
return -1;
 
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 06/13] compositor: Store the stereoscopy layout of an output.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Backends are responsible for setting it to the expected value, as
specified in wp_stereoscopy.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor.c | 1 +
 libweston/compositor.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index a2f624f6..9343bdbf 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4791,6 +4791,7 @@ weston_output_init(struct weston_output *output,
output->mm_width = 0;
output->mm_height = 0;
output->scale = 0;
+   output->stereoscopy_layout = ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
/* Can't use -1 on uint32_t and 0 is valid enum value */
output->transform = UINT32_MAX;
 
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 6d3fa315..165f257c 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -235,6 +235,7 @@ struct weston_output {
 
bool enabled; /**< is in the output_list, not pending list */
int scale;
+   uint32_t stereoscopy_layout;
 
int (*enable)(struct weston_output *output);
int (*disable)(struct weston_output *output);
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 07/13] compositor-drm: Enable the stereo capability.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

This makes DRM list the stereo modes in addition to the usual mono
ones, it’s now just a matter of modeset whether we enable stereo or
not.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor-drm.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index b641d61e..d3480f08 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2081,6 +2081,13 @@ init_kms_caps(struct drm_backend *b)
 
weston_log("using %s\n", b->drm.filename);
 
+   if (!b->use_pixman) {
+   ret = drmSetClientCap(b->drm.fd, DRM_CLIENT_CAP_STEREO_3D, 1);
+   if (ret == 0)
+   b->compositor->capabilities |= WESTON_CAP_STEREOSCOPY;
+   weston_log("DRM: %sstereo support\n", ret != 0 ? "no " : "");
+   }
+
ret = drmGetCap(b->drm.fd, DRM_CAP_TIMESTAMP_MONOTONIC, );
if (ret == 0 && cap == 1)
clk_id = CLOCK_MONOTONIC;
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 11/13] compositor-drm: Cursors need to be broken with stereoscopy.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

There is only one cursor plane per output, and we need to render two
cursors on stereo outputs, so currently set cursors_are_broken
globally.  In the future, this option could be changed to be per-output
to keep the plane optimisation for non-stereo outputs.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor-drm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 1d28d09d..00f85e8b 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2087,6 +2087,9 @@ init_kms_caps(struct drm_backend *b)
if (ret == 0)
b->compositor->capabilities |= WESTON_CAP_STEREOSCOPY;
weston_log("DRM: %sstereo support\n", ret != 0 ? "no " : "");
+
+   /* TODO: We need to make that per-output. */
+   b->cursors_are_broken = 1;
}
 
ret = drmGetCap(b->drm.fd, DRM_CAP_TIMESTAMP_MONOTONIC, );
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 08/13] compositor-drm: Print stereo modes as such.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor-drm.c | 38 +++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index d3480f08..c0f1ebee 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3156,6 +3156,34 @@ drm_output_set_seat(struct weston_output *base,
 seat ? seat : "");
 }
 
+static const char *
+format_stereo_flag(uint32_t flag)
+{
+   switch (flag) {
+   case DRM_MODE_FLAG_3D_NONE:
+   return "";
+   case DRM_MODE_FLAG_3D_FRAME_PACKING:
+   return ", stereo (frame packing)";
+   case DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE:
+   return ", stereo (field alternative)";
+   case DRM_MODE_FLAG_3D_LINE_ALTERNATIVE:
+   return ", stereo (line alternative)";
+   case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL:
+   return ", stereo (side-by-side full)";
+   case DRM_MODE_FLAG_3D_L_DEPTH:
+   return ", stereo (L + depth)";
+   case DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH:
+   return ", stereo (L + depth + GFX + GFX-depth)";
+   case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM:
+   return ", stereo (top-and-bottom)";
+   case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF:
+   return ", stereo (side-by-side half)";
+   default:
+   /* There should never be multiple 3D flags per mode. */
+   assert(0);
+   }
+}
+
 static int
 drm_output_enable(struct weston_output *base)
 {
@@ -3204,15 +3232,19 @@ drm_output_enable(struct weston_output *base)
 
weston_log("Output %s, (connector %d, crtc %d)\n",
   output->base.name, output->connector_id, output->crtc_id);
-   wl_list_for_each(m, >base.mode_list, link)
-   weston_log_continue(STAMP_SPACE "mode %dx%d@%.1f%s%s%s\n",
+   wl_list_for_each(m, >base.mode_list, link) {
+   struct drm_mode *mode = (struct drm_mode*)m;
+   weston_log_continue(STAMP_SPACE "mode %dx%d@%.1f%s%s%s%s\n",
m->width, m->height, m->refresh / 1000.0,
m->flags & WL_OUTPUT_MODE_PREFERRED ?
", preferred" : "",
m->flags & WL_OUTPUT_MODE_CURRENT ?
", current" : "",
output->connector->count_modes == 0 ?
-   ", built-in" : "");
+   ", built-in" : "",
+   format_stereo_flag(mode->mode_info.flags
+  & 
DRM_MODE_FLAG_3D_MASK));
+   }
 
output->state_invalid = true;
 
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 09/13] compositor-drm: Create a correctly-sized gbm buffer.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Makes frame packing modes work, the normal-sized buffer was way too
small to contain both images.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor-drm.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index c0f1ebee..1d28d09d 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -62,6 +62,7 @@
 #include "presentation-time-server-protocol.h"
 #include "linux-dmabuf.h"
 #include "linux-dmabuf-unstable-v1-server-protocol.h"
+#include "stereoscopy-unstable-v1-server-protocol.h"
 
 #ifndef DRM_CAP_TIMESTAMP_MONOTONIC
 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
@@ -2642,9 +2643,17 @@ drm_output_init_egl(struct drm_output *output, struct 
drm_backend *b)
};
int n_formats = 1;
 
+   int32_t width = output->base.current_mode->width;
+   int32_t height = output->base.current_mode->height;
+
+   /* This layout has two full-size buffers, with a hole of 1/24th of
+* their height at the middle. */
+   if (output->base.stereoscopy_layout == 
ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING)
+   height = height * 2 + height / 24;
+
output->gbm_surface = gbm_surface_create(b->gbm,
-output->base.current_mode->width,
-output->base.current_mode->height,
+width,
+height,
 format[0],
 GBM_BO_USE_SCANOUT |
 GBM_BO_USE_RENDERING);
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 0/13] Add stereoscopy support

2017-11-14 Thread Emmanuel Gil Peyrot
This series adds a new protocol to specify the stereoscopic layout of a
surface, and a way for a compositor to tell the client what the native
layout is, in order to allow direct scanout in the fullscreen case.  It
then implements said protocol in Weston.

The only stereoscopy-enabled backend is currently the DRM backend using
gl-renderer; the Wayland one will follow shortly after, I have no plan
to implement it anywhere else for now.

I’m not too happy with the mode selection as it is currently, ideally
the compositor would expose all of the available modes, and only modeset
to the best stereo mode once a client asks for stereo, to avoid
rendering twice at any time, but this can probably be left to a
follow-up series as well.

I wrote a blog post[1] detailing my approach, it can be interesting in
relation to this series.  You can also find git branches of
wayland-protocols[2] and weston[3] for easier testing.

Thanks for your feedback!

[1] 
https://linkmauve.fr/blog/post/2017/09/08/adding-a-third-dimension-to-wayland/
[2] https://gitlab.collabora.com/emmanuel/wayland-protocols/tree/stereoscopy
[3] https://gitlab.collabora.com/emmanuel/weston/tree/stereoscopy

Emmanuel Gil Peyrot (13):
  wayland-protocols: Add stereoscopy protocol
  clients: Add a simple-stereo client, based on simple-shm.
  compositor: Implement stereoscopy as a noop.
  compositor: Add a stereoscopy capability.
  compositor: Display the correct default buffer.
  compositor: Store the stereoscopy layout of an output.
  compositor-drm: Enable the stereo capability.
  compositor-drm: Print stereo modes as such.
  compositor-drm: Create a correctly-sized gbm buffer.
  gl-renderer: Add stereoscopy support.
  compositor-drm: Cursors need to be broken with stereoscopy.
  main, compositor: Add a stereoscopy config option.
  compositor-drm: Select stereo modes based on the configuration.

 Makefile.am  |  27 +-
 clients/simple-stereo.c  | 647 
+
 compositor/main.c|  60 +
 libweston/compositor-drm.c   |  90 ++-
 libweston/compositor.c   | 224 +++-
 libweston/compositor.h   |  22 ++
 libweston/gl-renderer.c  | 135 --
 libweston/gl-renderer.h  |   6 +
 man/weston-drm.man   |   6 +-
 unstable/stereoscopy/README  |   4 +
 unstable/stereoscopy/stereoscopy-unstable-v1.xml | 187 +++
 11 files changed, 1377 insertions(+), 31 deletions(-)
 create mode 100644 clients/simple-stereo.c
 create mode 100644 unstable/stereoscopy/README
 create mode 100644 unstable/stereoscopy/stereoscopy-unstable-v1.xml

-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 05/13] compositor: Display the correct default buffer.

2017-11-14 Thread Emmanuel Gil Peyrot
When a backend isn’t stereoscopy-aware, the compositor itself will
calculate the correct offset.

Backends which are aware of stereoscopy should do this computation
themselves, in the correct place.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor.c | 56 +++---
 1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index dc2b563a..a2f624f6 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -788,6 +788,53 @@ viewport_surface_to_buffer(struct weston_surface *surface,
*by = sy * src_height / surface->height + src_y;
 }
 
+static void
+stereo_surface_to_buffer(struct weston_surface *surface,
+float sx, float sy, float *bx, float *by)
+{
+   struct weston_buffer_viewport *vp = >buffer_viewport;
+   uint32_t default_side = vp->surface.default_side;
+
+   if (surface->compositor->capabilities & WESTON_CAP_STEREOSCOPY) {
+   /* The backend supports stereoscopy natively, we don’t have to
+* do anything here. */
+   *bx = sx;
+   *by = sy;
+   } else {
+   switch (vp->buffer.stereoscopy_layout) {
+   case ZWP_STEREOSCOPY_V1_LAYOUT_NONE:
+   *bx = sx;
+   *by = sy;
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING:
+   /* TODO: Frame-packing support for clients doesn’t work
+* currently, since the buffer size needs to be bigger
+* than the surface size, and we have no provision for
+* that currently. */
+   *bx = sx;
+   *by = sy;
+   if (default_side == 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_RIGHT)
+   *by += surface->height * 25.0 / 24.0;
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_TOP_AND_BOTTOM:
+   *bx = sx;
+   *by = sy / 2.0;
+   if (default_side == 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_RIGHT)
+   *by += surface->height / 2.0;
+   break;
+   case ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE:
+   *bx = sx / 2.0;
+   *by = sy;
+   if (default_side == 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_RIGHT)
+   *bx += surface->width / 2.0;
+   break;
+   default:
+   // TODO: add support for the other layouts.
+   assert(0);
+   }
+   }
+}
+
 WL_EXPORT void
 weston_surface_to_buffer_float(struct weston_surface *surface,
   float sx, float sy, float *bx, float *by)
@@ -795,7 +842,8 @@ weston_surface_to_buffer_float(struct weston_surface 
*surface,
struct weston_buffer_viewport *vp = >buffer_viewport;
 
/* first transform coordinates if the viewport is set */
-   viewport_surface_to_buffer(surface, sx, sy, bx, by);
+   stereo_surface_to_buffer(surface, sx, sy, bx, by);
+   viewport_surface_to_buffer(surface, *bx, *by, bx, by);
 
weston_transformed_coord(surface->width_from_buffer,
 surface->height_from_buffer,
@@ -829,11 +877,13 @@ weston_surface_to_buffer_rect(struct weston_surface 
*surface,
float xf, yf;
 
/* first transform box coordinates if the viewport is set */
-   viewport_surface_to_buffer(surface, rect.x1, rect.y1, , );
+   stereo_surface_to_buffer(surface, rect.x1, rect.y1, , );
+   viewport_surface_to_buffer(surface, xf, yf, , );
rect.x1 = floorf(xf);
rect.y1 = floorf(yf);
 
-   viewport_surface_to_buffer(surface, rect.x2, rect.y2, , );
+   stereo_surface_to_buffer(surface, rect.x2, rect.y2, , );
+   viewport_surface_to_buffer(surface, xf, yf, , );
rect.x2 = ceilf(xf);
rect.y2 = ceilf(yf);
 
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 02/13] clients: Add a simple-stereo client, based on simple-shm.

2017-11-14 Thread Emmanuel Gil Peyrot
Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 Makefile.am |  22 +-
 clients/simple-stereo.c | 647 
 2 files changed, 667 insertions(+), 2 deletions(-)
 create mode 100644 clients/simple-stereo.c

diff --git a/Makefile.am b/Makefile.am
index 9d99c694..e1cdb289 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -181,7 +181,9 @@ nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES = 
\
protocol/relative-pointer-unstable-v1-protocol.c\
protocol/relative-pointer-unstable-v1-server-protocol.h \
protocol/pointer-constraints-unstable-v1-protocol.c \
-   protocol/pointer-constraints-unstable-v1-server-protocol.h
+   protocol/pointer-constraints-unstable-v1-server-protocol.h  \
+   protocol/stereoscopy-unstable-v1-protocol.c \
+   protocol/stereoscopy-unstable-v1-server-protocol.h
 
 BUILT_SOURCES += $(nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES)
 
@@ -565,6 +567,7 @@ endif
 if BUILD_SIMPLE_CLIENTS
 demo_clients +=\
weston-simple-shm   \
+   weston-simple-stereo\
weston-simple-damage\
weston-simple-touch \
weston-presentation-shm \
@@ -581,6 +584,19 @@ nodist_weston_simple_shm_SOURCES = \
 weston_simple_shm_CFLAGS = $(AM_CFLAGS) $(SIMPLE_CLIENT_CFLAGS)
 weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la
 
+weston_simple_stereo_SOURCES = clients/simple-stereo.c
+nodist_weston_simple_stereo_SOURCES =  \
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
+   protocol/fullscreen-shell-unstable-v1-protocol.c\
+   protocol/fullscreen-shell-unstable-v1-client-protocol.h \
+   protocol/ivi-application-protocol.c \
+   protocol/ivi-application-client-protocol.h  \
+   protocol/stereoscopy-unstable-v1-protocol.c \
+   protocol/stereoscopy-unstable-v1-client-protocol.h
+weston_simple_stereo_CFLAGS = $(AM_CFLAGS) $(SIMPLE_CLIENT_CFLAGS)
+weston_simple_stereo_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la
+
 weston_simple_damage_SOURCES = clients/simple-damage.c
 nodist_weston_simple_damage_SOURCES =  \
protocol/viewporter-protocol.c  \
@@ -892,7 +908,9 @@ BUILT_SOURCES +=\
protocol/ivi-hmi-controller-protocol.c  \
protocol/ivi-hmi-controller-client-protocol.h   \
protocol/ivi-application-protocol.c \
-   protocol/ivi-application-client-protocol.h
+   protocol/ivi-application-client-protocol.h  \
+   protocol/stereoscopy-unstable-v1-protocol.c \
+   protocol/stereoscopy-unstable-v1-client-protocol.h
 
 westondatadir = $(datadir)/weston
 dist_westondata_DATA = \
diff --git a/clients/simple-stereo.c b/clients/simple-stereo.c
new file mode 100644
index ..491bf1e2
--- /dev/null
+++ b/clients/simple-stereo.c
@@ -0,0 +1,647 @@
+/*
+ * Copyright © 2017 Emmanuel Gil Peyrot
+ * Copyright © 2011 Benjamin Franzke
+ * Copyright © 2010 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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.
+ */
+
+#include "config.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "shared/os-compatibility.h"
+#include "shared/zalloc.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "stereoscopy-unstable-v1-client-protocol.h"
+
+#include 
+#include "ivi-application-cl

[PATCH wayland-protocols 01/13] Add stereoscopy protocol

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

This protocols allows clients to describe the stereoscopic layout of
their surfaces, to make the compositor render all sides on 3DTVs or
HMDs.

It also gives a way for the compositor to describe the native stereo
layout of the current mode, so that clients can adapt their buffers to
do direct scanout.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 Makefile.am  |   1 +
 unstable/stereoscopy/README  |   4 +
 unstable/stereoscopy/stereoscopy-unstable-v1.xml | 187 +++
 3 files changed, 192 insertions(+)
 create mode 100644 unstable/stereoscopy/README
 create mode 100644 unstable/stereoscopy/stereoscopy-unstable-v1.xml

diff --git a/Makefile.am b/Makefile.am
index 0296d5d..93cca5a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ unstable_protocols =  
\
unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml  
\

unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml \
unstable/xdg-output/xdg-output-unstable-v1.xml  
\
+   unstable/stereoscopy/stereoscopy-unstable-v1.xml
\
$(NULL)
 
 stable_protocols = 
\
diff --git a/unstable/stereoscopy/README b/unstable/stereoscopy/README
new file mode 100644
index 000..f092267
--- /dev/null
+++ b/unstable/stereoscopy/README
@@ -0,0 +1,4 @@
+Stereoscopy protocol
+
+Maintainers:
+Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
diff --git a/unstable/stereoscopy/stereoscopy-unstable-v1.xml 
b/unstable/stereoscopy/stereoscopy-unstable-v1.xml
new file mode 100644
index 000..8e7db23
--- /dev/null
+++ b/unstable/stereoscopy/stereoscopy-unstable-v1.xml
@@ -0,0 +1,187 @@
+
+
+
+  
+Copyright © 2016-2017 Emmanuel Gil Peyrot
+Copyright © 2017 Collabora, Ltd.
+
+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 (including the next
+paragraph) 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.
+  
+
+  
+
+  This interface exposes outputs’ ability to display an image for
+  both eyes to the client.  Displays can accept different kind of
+  layouts, which can be different per mode, and are sent with the
+  'layout' event.  The client then calls the 'create_description'
+  request and selects the layout they prefer.  This layout isn’t
+  required to be supported by the output the surface is on, but
+  otherwise the compositor will have to convert it, which is
+  possibly lossy depending on the source and destination layouts.
+
+  Warning! The protocol described in this file is experimental and
+  backward incompatible changes may be made. Backward compatible
+  changes may be added together with the corresponding interface
+  version bump.
+  Backward incompatible changes are done by bumping the version
+  number in the protocol and interface names and resetting the
+  interface version. Once the protocol is to be declared stable,
+  the 'z' prefix and the version number in the protocol and
+  interface names are removed and the interface version number is
+  reset.
+
+
+
+  
+Informs the server that the client will not be using this
+protocol object anymore.  Objects created through this
+interface will remain valid.
+  
+
+
+
+  
+These fatal protocol errors may be emitted in response to
+illegal stereoscopy requests.
+  
+  
+
+
+
+  
+This enum describes the list of possible stereoscopy layouts.
+
+   It is loosely based on the DRM flags from the Linux kernel.
+  
+  
+  
+  
+  
+  
+  
+
+
+
+  
+Instantiate an interf

[PATCH weston 03/13] compositor: Implement stereoscopy as a noop.

2017-11-14 Thread Emmanuel Gil Peyrot
Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor.c | 140 +
 libweston/compositor.h |  11 
 2 files changed, 151 insertions(+)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 71a9b38c..dc2b563a 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -56,6 +56,7 @@
 #include "compositor.h"
 #include "viewporter-server-protocol.h"
 #include "presentation-time-server-protocol.h"
+#include "stereoscopy-unstable-v1-server-protocol.h"
 #include "shared/helpers.h"
 #include "shared/os-compatibility.h"
 #include "shared/string-helpers.h"
@@ -411,6 +412,8 @@ weston_surface_state_init(struct weston_surface_state 
*state)
state->buffer_viewport.buffer.scale = 1;
state->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
state->buffer_viewport.surface.width = -1;
+   state->buffer_viewport.buffer.stereoscopy_layout = 
ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+   state->buffer_viewport.surface.default_side = 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
state->buffer_viewport.changed = 0;
 }
 
@@ -469,6 +472,8 @@ weston_surface_create(struct weston_compositor *compositor)
surface->buffer_viewport.buffer.scale = 1;
surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
surface->buffer_viewport.surface.width = -1;
+   surface->buffer_viewport.buffer.stereoscopy_layout = 
ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+   surface->buffer_viewport.surface.default_side = 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
 
weston_surface_state_init(>pending);
 
@@ -3070,6 +3075,8 @@ weston_surface_commit_state(struct weston_surface 
*surface,
/* wl_surface.set_buffer_scale */
/* wp_viewport.set_source */
/* wp_viewport.set_destination */
+   /* wp_stereoscopy_description.set_layout */
+   /* wp_stereoscopy_description.set_default_side */
surface->buffer_viewport = state->buffer_viewport;
 
/* wl_surface.attach */
@@ -5123,6 +5130,135 @@ bind_viewporter(struct wl_client *client,
   NULL, NULL);
 }
 
+static void
+destroy_stereoscopy_description(struct wl_resource *resource)
+{
+   struct weston_surface *surface =
+   wl_resource_get_user_data(resource);
+
+   surface->stereoscopy_description_resource = NULL;
+   surface->pending.buffer_viewport.buffer.stereoscopy_layout = 
ZWP_STEREOSCOPY_V1_LAYOUT_NONE;
+   surface->pending.buffer_viewport.surface.default_side = 
ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_DEFAULT;
+   surface->pending.buffer_viewport.changed = 1;
+}
+
+static void
+stereoscopy_description_destroy(struct wl_client *client,
+struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static void
+stereoscopy_description_set_layout(struct wl_client *client,
+   struct wl_resource *resource,
+   uint32_t layout)
+{
+   struct weston_surface *surface =
+   wl_resource_get_user_data(resource);
+
+   assert(surface->stereoscopy_description_resource != NULL);
+
+   if (layout > ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE) {
+   wl_resource_post_error(resource,
+   ZWP_STEREOSCOPY_DESCRIPTION_V1_ERROR_INVALID_LAYOUT,
+   "wrong stereoscopy layout %u",
+   layout);
+   return;
+   }
+
+   surface->pending.buffer_viewport.buffer.stereoscopy_layout = layout;
+   surface->pending.buffer_viewport.changed = 1;
+}
+
+static void
+stereoscopy_description_set_default_side(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t default_side)
+{
+   struct weston_surface *surface =
+   wl_resource_get_user_data(resource);
+
+   assert(surface->stereoscopy_description_resource != NULL);
+
+   if (default_side > ZWP_STEREOSCOPY_DESCRIPTION_V1_SIDE_RIGHT) {
+   wl_resource_post_error(resource,
+   
ZWP_STEREOSCOPY_DESCRIPTION_V1_ERROR_INVALID_DEFAULT_SIDE,
+   "default side can only be default, left or right, not 
%u",
+   default_side);
+   return;
+   }
+
+   surface->pending.buffer_viewport.surface.default_side = default_side;
+   surface->pending.buffer_viewport.changed = 1;
+}
+
+static const struct zwp_stereoscopy_description_v1_interface 
stereoscopy_description_interface = {
+   stereoscopy_description_destroy,
+   stereoscopy_description_set_layout,
+   stereoscopy_description_set_default_side
+};
+
+static void
+stereoscopy_de

[PATCH weston 04/13] compositor: Add a stereoscopy capability.

2017-11-14 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Will be used by backends to say they are compatible or not.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 libweston/compositor.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libweston/compositor.h b/libweston/compositor.h
index fd4fb2ed..6d3fa315 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -771,6 +771,9 @@ enum weston_capability {
 
/* renderer supports weston_view_set_mask() clipping */
WESTON_CAP_VIEW_CLIP_MASK   = 0x0010,
+
+   /* renderer supports weston_view_set_mask() clipping */
+   WESTON_CAP_STEREOSCOPY  = 0x0020,
 };
 
 /* Configuration struct for a backend.
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] cursor: Use shm_open() instead of XDG_RUNTIME_DIR files

2017-10-19 Thread Emmanuel Gil Peyrot
On Wed, Oct 18, 2017 at 09:05:46AM -0500, Matt Hoosier wrote:
> On Wed, Oct 18, 2017 at 4:23 AM, Quentin Glidic
> <sardemff7+wayl...@sardemff7.net> wrote:
> > +   fd = shm_open("/wayland-cursor-shared", O_CREAT | O_RDWR, 0);
> > +   shm_unlink("/wayland-cursor-shared");
> 
> This seems to be a departure from the anonymous behavior that
> mkstemp() previously offered. shm_open() says that it will open an
> existing shared-memory object if that pathname already exists. Isn't
> there a race between one thread doing shm_open() and a different
> thread doing shm_unlink() such that you could accidentally end up with
> two different filedescriptors pointing at the same SHM object?

On Linux I would recommend using memfd_create(2), which has all of the
guarantees you want.  You still need a fallback for Linux older than
3.17 and for other POSIX systems; shm_open(3) is fine for that but your
implementation is naive, you should generate a random name, fail if it
already exists, and retry with another name in that case.

Thanks,

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] weston-info: Add support for zwp_linux_dmabuf_v1

2017-10-03 Thread Emmanuel Gil Peyrot
This now prints each (format, modifier) tuple, to show which ones the
compositor sends to its clients.  It is only implemented for version 3+,
since I didn’t have any compositor implementing previous versions, and
the old `format` event is deprecated anyway.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 Makefile.am   |  4 ++-
 clients/weston-info.c | 92 +++
 2 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 9d99c694..e7e6a0ed 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -835,7 +835,9 @@ weston_info_SOURCES =   
\
shared/helpers.h
 nodist_weston_info_SOURCES =   \
protocol/presentation-time-protocol.c   \
-   protocol/presentation-time-client-protocol.h
+   protocol/presentation-time-client-protocol.h\
+   protocol/linux-dmabuf-unstable-v1-protocol.c\
+   protocol/linux-dmabuf-unstable-v1-client-protocol.h
 weston_info_LDADD = $(WESTON_INFO_LIBS) libshared.la
 weston_info_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
 
diff --git a/clients/weston-info.c b/clients/weston-info.c
index c07134d1..386bd412 100644
--- a/clients/weston-info.c
+++ b/clients/weston-info.c
@@ -40,6 +40,7 @@
 #include "shared/xalloc.h"
 #include "shared/zalloc.h"
 #include "presentation-time-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
 
 typedef void (*print_info_t)(void *info);
 typedef void (*destroy_info_t)(void *info);
@@ -96,6 +97,20 @@ struct shm_info {
struct wl_list formats;
 };
 
+struct linux_dmabuf_modifier {
+   struct wl_list link;
+
+   uint32_t format;
+   uint64_t modifier;
+};
+
+struct linux_dmabuf_info {
+   struct global_info global;
+   struct zwp_linux_dmabuf_v1 *dmabuf;
+
+   struct wl_list modifiers;
+};
+
 struct seat_info {
struct global_info global;
struct wl_seat *seat;
@@ -296,6 +311,25 @@ print_shm_info(void *data)
printf("\n");
 }
 
+static void
+print_linux_dmabuf_info(void *data)
+{
+   char str[5];
+   struct linux_dmabuf_info *dmabuf = data;
+   struct linux_dmabuf_modifier *modifier;
+
+   print_global_info(data);
+
+   printf("\tformats:");
+
+   wl_list_for_each(modifier, >modifiers, link) {
+   fourcc2str(modifier->format, str, sizeof(str));
+   printf("\n\t'%s'(0x%08x), modifier: 0x%016"PRIx64, str, 
modifier->format, modifier->modifier);
+   }
+
+   printf("\n");
+}
+
 static void
 print_seat_info(void *data)
 {
@@ -491,6 +525,62 @@ add_shm_info(struct weston_info *info, uint32_t id, 
uint32_t version)
info->roundtrip_needed = true;
 }
 
+static void
+linux_dmabuf_handle_format(void *data, struct zwp_linux_dmabuf_v1 
*zwp_linux_dmabuf_v1, uint32_t format)
+{
+   /* This is a deprecated event, don’t use it. */
+}
+
+static void
+linux_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 
*zwp_linux_dmabuf_v1, uint32_t format, uint32_t modifier_hi, uint32_t 
modifier_lo)
+{
+   struct linux_dmabuf_info *dmabuf = data;
+   struct linux_dmabuf_modifier *linux_dmabuf_modifier = xzalloc(sizeof 
*linux_dmabuf_modifier);
+
+   wl_list_insert(>modifiers, _dmabuf_modifier->link);
+   linux_dmabuf_modifier->format = format;
+   linux_dmabuf_modifier->modifier = ((uint64_t)modifier_hi) << 32 | 
modifier_lo;
+}
+
+static const struct zwp_linux_dmabuf_v1_listener linux_dmabuf_listener = {
+   linux_dmabuf_handle_format,
+   linux_dmabuf_handle_modifier,
+};
+
+static void
+destroy_linux_dmabuf_info(void *data)
+{
+   struct linux_dmabuf_info *dmabuf = data;
+   struct linux_dmabuf_modifier *modifier, *tmp;
+
+   wl_list_for_each_safe(modifier, tmp, >modifiers, link) {
+   wl_list_remove(>link);
+   free(modifier);
+   }
+
+   zwp_linux_dmabuf_v1_destroy(dmabuf->dmabuf);
+}
+
+static void
+add_linux_dmabuf_info(struct weston_info *info, uint32_t id, uint32_t version)
+{
+   struct linux_dmabuf_info *dmabuf = xzalloc(sizeof *dmabuf);
+
+   init_global_info(info, >global, id, "zwp_linux_dmabuf_v1", 
version);
+   dmabuf->global.print = print_linux_dmabuf_info;
+   dmabuf->global.destroy = destroy_linux_dmabuf_info;
+
+   wl_list_init(>modifiers);
+
+   if (version >= 3) {
+   dmabuf->dmabuf = wl_registry_bind(info->registry,
+ id, 
_linux_dmabuf_v1_interface, 3);
+   zwp_linux_dmabuf_v1_add_listener(dmabuf->dmabuf, 
_dmabuf_listener, dmabuf);
+
+   info->roundtrip_needed = true;
+   }
+}
+
 static void
 output_handle_geometry(void *data, struct wl_output *wl_output,
 

[PATCH wayland] connection: Print the content of arrays in closures

2017-07-10 Thread Emmanuel Gil Peyrot
The current behaviour when WAYLAND_DEBUG is set is to print “array”,
which is quite unhelpful.

This patch prints a list of the bytes present in the array.  It doesn’t
try to interpret it as uint32_t or anything, leaving that to the reader
because this information isn’t present in the protocol description.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/connection.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 5c3d187..d616ddd 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1170,11 +1170,13 @@ wl_closure_queue(struct wl_closure *closure, struct 
wl_connection *connection)
 void
 wl_closure_print(struct wl_closure *closure, struct wl_object *target, int 
send)
 {
-   int i;
+   int i, j;
struct argument_details arg;
const char *signature = closure->message->signature;
struct timespec tp;
unsigned int time;
+   size_t size;
+   char *data;
 
clock_gettime(CLOCK_REALTIME, );
time = (tp.tv_sec * 100L) + (tp.tv_nsec / 1000);
@@ -1223,7 +1225,15 @@ wl_closure_print(struct wl_closure *closure, struct 
wl_object *target, int send)
fprintf(stderr, "nil");
break;
case 'a':
-   fprintf(stderr, "array");
+   fprintf(stderr, "array(");
+   size = closure->args[i].a->size;
+   data = (char*)closure->args[i].a->data;
+   if (size) {
+   for (j = 0; j < (int)size - 1; j++)
+   fprintf(stderr, "0x%02x, ", data[j]);
+   fprintf(stderr, "0x%02x", data[size - 1]);
+   }
+   fprintf(stderr, ")");
break;
case 'h':
fprintf(stderr, "fd %d", closure->args[i].h);
-- 
2.13.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/4] tests: Mark tests as used, so they don’t get removed at link-time.

2017-04-14 Thread Emmanuel Gil Peyrot
Without this attribute, the test macros were making Weston fail to
build with LTO enabled.

Signed-off-by: Markus Trippelsdorf <mar...@trippelsdorf.de>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 tests/weston-test-runner.h   | 2 +-
 tools/zunitc/inc/zunitc/zunitc.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h
index b9f966e0..eb9a488a 100644
--- a/tests/weston-test-runner.h
+++ b/tests/weston-test-runner.h
@@ -53,7 +53,7 @@ struct weston_test {
static void func(void *);   \
\
const struct weston_test test##name \
-   __attribute__ ((section ("test_section"))) =\
+   __attribute__ ((used, section ("test_section"))) =  \
{   \
#name, func, data, size, n_elem, ret\
};
diff --git a/tools/zunitc/inc/zunitc/zunitc.h b/tools/zunitc/inc/zunitc/zunitc.h
index 6ac6f391..16b211ba 100644
--- a/tools/zunitc/inc/zunitc/zunitc.h
+++ b/tools/zunitc/inc/zunitc/zunitc.h
@@ -268,7 +268,7 @@ zuc_set_output_junit(bool enable);
static void zuctest_##tcase##_##test(void); \
\
const struct zuc_registration zzz_##tcase##_##test \
-   __attribute__ ((section ("zuc_tsect"))) = \
+   __attribute__ ((used, section ("zuc_tsect"))) = \
{ \
#tcase, #test, 0,   \
zuctest_##tcase##_##test,   \
@@ -298,7 +298,7 @@ zuc_set_output_junit(bool enable);
static void zuctest_##tcase##_##test(void *param); \
\
const struct zuc_registration zzz_##tcase##_##test \
-   __attribute__ ((section ("zuc_tsect"))) = \
+   __attribute__ ((used, section ("zuc_tsect"))) = \
{ \
#tcase, #test, ,  \
0,  \
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/4] tests: Mark tests as used, so they don’t get removed at link-time.

2017-04-14 Thread Emmanuel Gil Peyrot
Without this attribute, the test macros were making Weston fail to
build with LTO enabled.

Signed-off-by: Markus Trippelsdorf <mar...@trippelsdorf.de>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 tests/weston-test-runner.h   | 2 +-
 tools/zunitc/inc/zunitc/zunitc.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h
index b9f966e0..eb9a488a 100644
--- a/tests/weston-test-runner.h
+++ b/tests/weston-test-runner.h
@@ -53,7 +53,7 @@ struct weston_test {
static void func(void *);   \
\
const struct weston_test test##name \
-   __attribute__ ((section ("test_section"))) =\
+   __attribute__ ((used, section ("test_section"))) =  \
{   \
#name, func, data, size, n_elem, ret\
};
diff --git a/tools/zunitc/inc/zunitc/zunitc.h b/tools/zunitc/inc/zunitc/zunitc.h
index 6ac6f391..16b211ba 100644
--- a/tools/zunitc/inc/zunitc/zunitc.h
+++ b/tools/zunitc/inc/zunitc/zunitc.h
@@ -268,7 +268,7 @@ zuc_set_output_junit(bool enable);
static void zuctest_##tcase##_##test(void); \
\
const struct zuc_registration zzz_##tcase##_##test \
-   __attribute__ ((section ("zuc_tsect"))) = \
+   __attribute__ ((used, section ("zuc_tsect"))) = \
{ \
#tcase, #test, 0,   \
zuctest_##tcase##_##test,   \
@@ -298,7 +298,7 @@ zuc_set_output_junit(bool enable);
static void zuctest_##tcase##_##test(void *param); \
\
const struct zuc_registration zzz_##tcase##_##test \
-   __attribute__ ((section ("zuc_tsect"))) = \
+   __attribute__ ((used, section ("zuc_tsect"))) = \
{ \
#tcase, #test, ,  \
0,  \
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland 2/4] tests: Mark tests as used, so they don’t get removed at link-time.

2017-04-14 Thread Emmanuel Gil Peyrot
Without this attribute, these macros were making Weston’s tests fail to
build with LTO enabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94602
Signed-off-by: Markus Trippelsdorf <mar...@trippelsdorf.de>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 tests/test-runner.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test-runner.h b/tests/test-runner.h
index c7a84aa..81ed034 100644
--- a/tests/test-runner.h
+++ b/tests/test-runner.h
@@ -41,7 +41,7 @@ struct test {
static void name(void); \
\
const struct test test##name\
-__attribute__ ((section ("test_section"))) = { \
+__attribute__ ((used, section ("test_section"))) = {   \
#name, name, 0  \
};  \
\
@@ -51,7 +51,7 @@ struct test {
static void name(void); \
\
const struct test test##name\
-__attribute__ ((section ("test_section"))) = { \
+__attribute__ ((used, section ("test_section"))) = {   \
#name, name, 1  \
};  \
\
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland 1/4] tests: Add one more indentation level to some macros

2017-04-14 Thread Emmanuel Gil Peyrot
This is a preparatory patch for the next one.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 tests/test-runner.h | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/tests/test-runner.h b/tests/test-runner.h
index 64f8d4c..c7a84aa 100644
--- a/tests/test-runner.h
+++ b/tests/test-runner.h
@@ -37,24 +37,24 @@ struct test {
int must_fail;
 } __attribute__ ((aligned (16)));
 
-#define TEST(name) \
-   static void name(void); \
-   \
-   const struct test test##name\
-__attribute__ ((section ("test_section"))) = { \
-   #name, name, 0  \
-   };  \
-   \
+#define TEST(name) \
+   static void name(void); \
+   \
+   const struct test test##name\
+__attribute__ ((section ("test_section"))) = { \
+   #name, name, 0  \
+   };  \
+   \
static void name(void)
 
-#define FAIL_TEST(name)\
-   static void name(void); \
-   \
-   const struct test test##name\
-__attribute__ ((section ("test_section"))) = { \
-   #name, name, 1  \
-   };  \
-   \
+#define FAIL_TEST(name)
\
+   static void name(void); \
+   \
+   const struct test test##name\
+__attribute__ ((section ("test_section"))) = { \
+   #name, name, 1  \
+   };  \
+   \
static void name(void)
 
 int
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/4] tests: Add one more indentation level to some macros

2017-04-14 Thread Emmanuel Gil Peyrot
This is a preparatory patch for the next one.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 tests/weston-test-runner.h | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h
index 21a059d6..b9f966e0 100644
--- a/tests/weston-test-runner.h
+++ b/tests/weston-test-runner.h
@@ -46,34 +46,34 @@ struct weston_test {
int must_fail;
 } __attribute__ ((aligned (32)));
 
-#define TEST_BEGIN(name, arg)  \
+#define TEST_BEGIN(name, arg)  \
static void name(arg)
 
-#define TEST_COMMON(func, name, ret, data, size, n_elem)   \
-   static void func(void *);   \
-   \
-   const struct weston_test test##name \
-   __attribute__ ((section ("test_section"))) =\
-   {   \
-   #name, func, data, size, n_elem, ret\
+#define TEST_COMMON(func, name, ret, data, size, n_elem)   \
+   static void func(void *);   \
+   \
+   const struct weston_test test##name \
+   __attribute__ ((section ("test_section"))) =\
+   {   \
+   #name, func, data, size, n_elem, ret\
};
 
-#define NO_ARG_TEST(name, ret) \
-   TEST_COMMON(wrap##name, name, ret, NULL, 0, 1)  \
-   static void name(void); \
-   static void wrap##name(void *data)  \
-   {   \
-   (void) data;\
-   name(); \
-   }   \
-   \
+#define NO_ARG_TEST(name, ret) \
+   TEST_COMMON(wrap##name, name, ret, NULL, 0, 1)  \
+   static void name(void); \
+   static void wrap##name(void *data)  \
+   {   \
+   (void) data;\
+   name(); \
+   }   \
+   \
TEST_BEGIN(name, void)
 
-#define ARG_TEST(name, ret, test_data) \
-   TEST_COMMON(name, name, ret, test_data, \
-   sizeof(test_data[0]),   \
-   ARRAY_LENGTH(test_data))\
-   TEST_BEGIN(name, void *data)\
+#define ARG_TEST(name, ret, test_data) \
+   TEST_COMMON(name, name, ret, test_data, \
+   sizeof(test_data[0]),   \
+   ARRAY_LENGTH(test_data))\
+   TEST_BEGIN(name, void *data)\
 
 #define TEST(name) NO_ARG_TEST(name, 0)
 #define FAIL_TEST(name) NO_ARG_TEST(name, 1)
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] desktop-shell: Position maximized surfaces on the correct output.

2017-04-04 Thread Emmanuel Gil Peyrot
During a maximize event, a surface was previously always put back to
the primary output after one frame on the correct output, while keeping
its size.  This was caused by the shell surface’s last_{width,height}
not being reset when it was either fullscreen or maximized, leading to
the unmaximize/maximize dance being done at each commit.

This was introduced in 8f9d90a84bb2888b074fea93c4a28778bc6439c6.

Changes since v1:
- Fix the actual issue instead of a symptom.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 desktop-shell/shell.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c9058795..6b1876d2 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2545,9 +2545,6 @@ desktop_surface_committed(struct weston_desktop_surface 
*desktop_surface,
if (shsurf->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP)
sy = shsurf->last_height - surface->height;
 
-   shsurf->last_width = surface->width;
-   shsurf->last_height = surface->height;
-
weston_view_to_global_float(shsurf->view, 0, 0, _x, 
_y);
weston_view_to_global_float(shsurf->view, sx, sy, _x, _y);
x = shsurf->view->geometry.x + to_x - from_x;
@@ -2556,6 +2553,9 @@ desktop_surface_committed(struct weston_desktop_surface 
*desktop_surface,
weston_view_set_position(shsurf->view, x, y);
}
 
+   shsurf->last_width = surface->width;
+   shsurf->last_height = surface->height;
+
/* XXX: would a fullscreen surface need the same handling? */
if (surface->output) {
wl_list_for_each(view, >views, surface_link)
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] desktop-shell: Position maximized surfaces on the correct output.

2017-04-04 Thread Emmanuel Gil Peyrot
During a maximize event, a surface was previously always put back to
the primary output after one frame on the correct output, while keeping
its size.  This was due to unset_maximized() resetting the output of
the shell surface to the primary output whenever the surface received a
commit.

This fix simply leaves the shell surface’s output as it was before the
unmaximize operation.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 desktop-shell/shell.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c9058795..1e97feba 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1965,8 +1965,6 @@ unset_maximized(struct shell_surface *shsurf)
weston_desktop_surface_get_surface(shsurf->desktop_surface);
 
/* undo all maximized things here */
-   shsurf->output = get_default_output(surface->compositor);
-
if (shsurf->saved_position_valid)
weston_view_set_position(shsurf->view,
 shsurf->saved_x, shsurf->saved_y);
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v3] xwm: Add icon support to the frame

2017-04-04 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>

This fetches the _NET_WM_ICON property of the X11 window, and use the
first image found as the frame icon.

This has been tested with various X11 programs, and improves usability
and user-friendliness a bit.

Changes since v1:
- Changed frame_button_create() to use
  frame_button_create_from_surface() internally.
- Removed a check that should never have been commited.

Changes since v2:
- Request UINT32_MAX items instead of 2048, to avoid cutting valid
  icons.
- Strengthen checks against malformed input.
- Handle XCB_PROPERTY_DELETE to remove the icon.
- Schedule a repaint if the icon changed.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 clients/window.c   |  4 +--
 libweston/compositor-wayland.c |  2 +-
 shared/cairo-util.h|  2 +-
 shared/frame.c | 54 +++--
 xwayland/window-manager.c  | 61 --
 5 files changed, 103 insertions(+), 20 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 95796d46..15a86e15 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2546,7 +2546,7 @@ window_frame_create(struct window *window, void *data)
 
frame = xzalloc(sizeof *frame);
frame->frame = frame_create(window->display->theme, 0, 0,
-   buttons, window->title);
+   buttons, window->title, NULL);
 
frame->widget = window_add_widget(window, frame);
frame->child = widget_add_widget(frame->widget, data);
@@ -5449,7 +5449,7 @@ create_menu(struct display *display,
menu->user_data = user_data;
menu->widget = window_add_widget(menu->window, menu);
menu->frame = frame_create(window->display->theme, 0, 0,
-  FRAME_BUTTON_NONE, NULL);
+  FRAME_BUTTON_NONE, NULL, NULL);
fail_on_null(menu->frame, 0, __FILE__, __LINE__);
menu->entries = entries;
menu->count = count;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 14f2c8db..aa6e5043 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -862,7 +862,7 @@ wayland_output_set_windowed(struct wayland_output *output)
return -1;
}
output->frame = frame_create(b->theme, 100, 100,
-FRAME_BUTTON_CLOSE, output->title);
+FRAME_BUTTON_CLOSE, output->title, NULL);
if (!output->frame)
return -1;
 
diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index 84cf005e..7893ca24 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -126,7 +126,7 @@ enum {
 
 struct frame *
 frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
-const char *title);
+ const char *title, cairo_surface_t *icon);
 
 void
 frame_destroy(struct frame *frame);
diff --git a/shared/frame.c b/shared/frame.c
index eb0cd77a..32779856 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -106,9 +106,9 @@ struct frame {
 };
 
 static struct frame_button *
-frame_button_create(struct frame *frame, const char *icon,
-   enum frame_status status_effect,
-   enum frame_button_flags flags)
+frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
+ enum frame_status status_effect,
+ enum frame_button_flags flags)
 {
struct frame_button *button;
 
@@ -116,12 +116,7 @@ frame_button_create(struct frame *frame, const char *icon,
if (!button)
return NULL;
 
-   button->icon = cairo_image_surface_create_from_png(icon);
-   if (!button->icon) {
-   free(button);
-   return NULL;
-   }
-
+   button->icon = icon;
button->frame = frame;
button->flags = flags;
button->status_effect = status_effect;
@@ -131,6 +126,30 @@ frame_button_create(struct frame *frame, const char *icon,
return button;
 }
 
+static struct frame_button *
+frame_button_create(struct frame *frame, const char *icon_name,
+enum frame_status status_effect,
+enum frame_button_flags flags)
+{
+   struct frame_button *button;
+   cairo_surface_t *icon;
+
+   icon = cairo_image_surface_create_from_png(icon_name);
+   if (cairo_surface_status(icon) != CAIRO_STATUS_SUCCESS)
+   goto error;
+
+   button = frame_button_create_from_surface(frame, icon, status_effect,
+ flags);
+   if (!button)
+   goto error;
+
+ 

[PATCH weston v4] compositor-drm: pageflip timeout implementation

2017-03-07 Thread Emmanuel Gil Peyrot
Weston will not repaint until previous update has been acked by a
pageflip event coming from the drm driver. However, some buggy drivers
won’t return those events or will stop sending them at some point and
Weston output repaints will completely freeze. To ease developers’ task
in testing their drivers, this patch makes compositor-drm use a timer
to detect cases where those pageflip events stop coming.

This timeout implementation is software only and includes basic
features usually found in a watchdog. We simply exit Weston gracefully
with a log message and an exit code when the timout is reached.

The timeout value can be set via weston.ini by adding a
pageflip-timeout= entry under a new [compositor-drm]
section. Setting it to 0 disables the timeout feature.

v2:
- Made sure we would get both the pageflip and the vblank events before
  stopping the timer.
- Reordered the error and success cases in
  drm_output_pageflip_timer_create() to be more in line with the rest
  of the code.

v3:
- Reordered (de)arming of the timer with the code around it to avoid it
  being rearmed before the current dearming.
- Return the proper value for the dispatcher in the pageflip_timeout
  callback.
- Also display the output name in case the timer fires.

v4:
- Reordered a forgotten timer rearming after its drmModePageFlip().

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83884
Signed-off-by: Frederic Plourde 
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Daniel Stone <dani...@collabora.com>
---
 compositor/main.c  |  2 ++
 libweston/compositor-drm.c | 65 ++
 libweston/compositor-drm.h |  7 +
 man/weston.ini.man |  5 
 4 files changed, 79 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 72c3cd10..e870dd4a 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1235,6 +1235,8 @@ load_drm_backend(struct weston_compositor *c,
weston_config_section_get_string(section,
 "gbm-format", _format,
 NULL);
+   weston_config_section_get_uint(section, "pageflip-timeout",
+  _timeout, 0);
 
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_drm_backend_config);
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 7f78699c..00623076 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -119,6 +119,7 @@ struct drm_backend {
int32_t cursor_height;
 
uint32_t connector;
+   uint32_t pageflip_timeout;
 };
 
 struct drm_mode {
@@ -182,6 +183,8 @@ struct drm_output {
 
struct vaapi_recorder *recorder;
struct wl_listener recorder_frame_listener;
+
+   struct wl_event_source *pageflip_timer;
 };
 
 /*
@@ -225,6 +228,45 @@ to_drm_backend(struct weston_compositor *base)
return container_of(base->backend, struct drm_backend, base);
 }
 
+static int
+pageflip_timeout(void *data) {
+   /*
+* Our timer just went off, that means we're not receiving drm
+* page flip events anymore for that output. Let's gracefully exit
+* weston with a return value so devs can debug what's going on.
+*/
+   struct drm_output *output = data;
+   struct weston_compositor *compositor = output->base.compositor;
+
+   weston_log("Pageflip timeout reached on output %s, your "
+  "driver is probably buggy!  Exiting.\n",
+  output->base.name);
+   weston_compositor_exit_with_code(compositor, EXIT_FAILURE);
+
+   return 0;
+}
+
+/* Creates the pageflip timer. Note that it isn't armed by default */
+static int
+drm_output_pageflip_timer_create(struct drm_output *output)
+{
+   struct wl_event_loop *loop = NULL;
+   struct weston_compositor *ec = output->base.compositor;
+
+   loop = wl_display_get_event_loop(ec->wl_display);
+   assert(loop);
+   output->pageflip_timer = wl_event_loop_add_timer(loop,
+pageflip_timeout,
+output);
+
+   if (output->pageflip_timer == NULL) {
+   weston_log("creating drm pageflip timer failed: %m\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 static void
 drm_output_set_cursor(struct drm_output *output);
 
@@ -758,6 +800,10 @@ drm_output_repaint(struct weston_output *output_base,
 
output->page_flip_pending = 1;
 
+   if (output->pageflip_timer)
+   wl_event_source_timer_update(output->pageflip_timer,
+backend->pageflip_timeout);
+
drm_output_set_cursor(output);
 
/*
@@ -878,6 +924,10 @@ drm_

[PATCH weston v3] compositor-drm: pageflip timeout implementation

2017-03-06 Thread Emmanuel Gil Peyrot
Weston will not repaint until previous update has been acked by a
pageflip event coming from the drm driver. However, some buggy drivers
won’t return those events or will stop sending them at some point and
Weston output repaints will completely freeze. To ease developers’ task
in testing their drivers, this patch makes compositor-drm use a timer
to detect cases where those pageflip events stop coming.

This timeout implementation is software only and includes basic
features usually found in a watchdog. We simply exit Weston gracefully
with a log message and an exit code when the timout is reached.

The timeout value can be set via weston.ini by adding a
pageflip-timeout= entry under a new [compositor-drm]
section. Setting it to 0 disables the timeout feature.

v2:
- Made sure we would get both the pageflip and the vblank events before
  stopping the timer.
- Reordered the error and success cases in
  drm_output_pageflip_timer_create() to be more in line with the rest
  of the code.

v3:
- Reordered (de)arming of the timer with the code around it to avoid it
  being rearmed before the current dearming.
- Return the proper value for the dispatcher in the pageflip_timeout
  callback.
- Also display the output name in case the timer fires.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83884
Signed-off-by: Frederic Plourde 
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Daniel Stone <dani...@collabora.com>
---
 compositor/main.c  |  2 ++
 libweston/compositor-drm.c | 65 ++
 libweston/compositor-drm.h |  7 +
 man/weston.ini.man |  5 
 4 files changed, 79 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 72c3cd10..e870dd4a 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1235,6 +1235,8 @@ load_drm_backend(struct weston_compositor *c,
weston_config_section_get_string(section,
 "gbm-format", _format,
 NULL);
+   weston_config_section_get_uint(section, "pageflip-timeout",
+  _timeout, 0);
 
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_drm_backend_config);
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 7f78699c..fe63d421 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -119,6 +119,7 @@ struct drm_backend {
int32_t cursor_height;
 
uint32_t connector;
+   uint32_t pageflip_timeout;
 };
 
 struct drm_mode {
@@ -182,6 +183,8 @@ struct drm_output {
 
struct vaapi_recorder *recorder;
struct wl_listener recorder_frame_listener;
+
+   struct wl_event_source *pageflip_timer;
 };
 
 /*
@@ -225,6 +228,45 @@ to_drm_backend(struct weston_compositor *base)
return container_of(base->backend, struct drm_backend, base);
 }
 
+static int
+pageflip_timeout(void *data) {
+   /*
+* Our timer just went off, that means we're not receiving drm
+* page flip events anymore for that output. Let's gracefully exit
+* weston with a return value so devs can debug what's going on.
+*/
+   struct drm_output *output = data;
+   struct weston_compositor *compositor = output->base.compositor;
+
+   weston_log("Pageflip timeout reached on output %s, your "
+  "driver is probably buggy!  Exiting.\n",
+  output->base.name);
+   weston_compositor_exit_with_code(compositor, EXIT_FAILURE);
+
+   return 0;
+}
+
+/* Creates the pageflip timer. Note that it isn't armed by default */
+static int
+drm_output_pageflip_timer_create(struct drm_output *output)
+{
+   struct wl_event_loop *loop = NULL;
+   struct weston_compositor *ec = output->base.compositor;
+
+   loop = wl_display_get_event_loop(ec->wl_display);
+   assert(loop);
+   output->pageflip_timer = wl_event_loop_add_timer(loop,
+pageflip_timeout,
+output);
+
+   if (output->pageflip_timer == NULL) {
+   weston_log("creating drm pageflip timer failed: %m\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 static void
 drm_output_set_cursor(struct drm_output *output);
 
@@ -749,6 +791,10 @@ drm_output_repaint(struct weston_output *output_base,
output_base->set_dpms(output_base, WESTON_DPMS_ON);
}
 
+   if (output->pageflip_timer)
+   wl_event_source_timer_update(output->pageflip_timer,
+backend->pageflip_timeout);
+
if (drmModePageFlip(backend->drm.fd, output->crtc_id,
output

Re: [PATCH weston v2] compositor-drm: pageflip timeout implementation

2017-02-28 Thread Emmanuel Gil Peyrot
On Tue, Feb 28, 2017 at 06:35:11PM +, Emmanuel Gil Peyrot wrote:
> Weston will not repaint until previous update has been acked by a
> pageflip event coming from the drm driver. However, some buggy drivers
> won’t return those events or will stop sending them at some point and
> Weston output repaints will completely freeze. To ease developers’ task
> in testing their drivers, this patch makes compositor-drm use a timer
> to detect cases where those pageflip events stop coming.
> 
> This timeout implementation is software only and includes basic
> features usually found in a watchdog. We simply exit Weston gracefully
> with a log message and an exit code when the timout is reached.
> 
> The timeout value can be set via weston.ini by adding a
> pageflip-timeout= entry under a new [compositor-drm]
> section. Setting it to 0 disables the timeout feature.
> 
> v2:
> - Made sure we would get both the pageflip and the vblank events before
>   stopping the timer.
> - Reordered the error and success cases in
>   drm_output_pageflip_timer_create() to be more in line with the rest
>   of the code.
> 
> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83884
> Signed-off-by: Frederic Plourde 
> Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Err, I forgot to include this:
Reviewed-by: Daniel Stone <dani...@collabora.com>

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] compositor-drm: pageflip timeout implementation

2017-02-28 Thread Emmanuel Gil Peyrot
Weston will not repaint until previous update has been acked by a
pageflip event coming from the drm driver. However, some buggy drivers
won’t return those events or will stop sending them at some point and
Weston output repaints will completely freeze. To ease developers’ task
in testing their drivers, this patch makes compositor-drm use a timer
to detect cases where those pageflip events stop coming.

This timeout implementation is software only and includes basic
features usually found in a watchdog. We simply exit Weston gracefully
with a log message and an exit code when the timout is reached.

The timeout value can be set via weston.ini by adding a
pageflip-timeout= entry under a new [compositor-drm]
section. Setting it to 0 disables the timeout feature.

v2:
- Made sure we would get both the pageflip and the vblank events before
  stopping the timer.
- Reordered the error and success cases in
  drm_output_pageflip_timer_create() to be more in line with the rest
  of the code.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83884
Signed-off-by: Frederic Plourde 
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 compositor/main.c  |  2 ++
 libweston/compositor-drm.c | 64 ++
 libweston/compositor-drm.h |  7 +
 man/weston.ini.man |  5 
 4 files changed, 78 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 72c3cd10..e870dd4a 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1235,6 +1235,8 @@ load_drm_backend(struct weston_compositor *c,
weston_config_section_get_string(section,
 "gbm-format", _format,
 NULL);
+   weston_config_section_get_uint(section, "pageflip-timeout",
+  _timeout, 0);
 
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_drm_backend_config);
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 7f78699c..e85ebab8 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -119,6 +119,7 @@ struct drm_backend {
int32_t cursor_height;
 
uint32_t connector;
+   uint32_t pageflip_timeout;
 };
 
 struct drm_mode {
@@ -182,6 +183,8 @@ struct drm_output {
 
struct vaapi_recorder *recorder;
struct wl_listener recorder_frame_listener;
+
+   struct wl_event_source *pageflip_timer;
 };
 
 /*
@@ -225,6 +228,44 @@ to_drm_backend(struct weston_compositor *base)
return container_of(base->backend, struct drm_backend, base);
 }
 
+static int
+pageflip_timeout(void *data) {
+   /*
+* Our timer just went off, that means we're not receiving drm
+* page flip events anymore for that output. Let's gracefully exit
+* weston with a return value so devs can debug what's going on.
+*/
+   struct drm_output *output = data;
+   struct weston_compositor *compositor = output->base.compositor;
+
+   weston_log("Pageflip timeout reached, your driver is probably "
+  "buggy!  Exiting.\n");
+   weston_compositor_exit_with_code(compositor, EXIT_FAILURE);
+
+   return -1;
+}
+
+/* Creates the pageflip timer. Note that it isn't armed by default */
+static int
+drm_output_pageflip_timer_create(struct drm_output *output)
+{
+   struct wl_event_loop *loop = NULL;
+   struct weston_compositor *ec = output->base.compositor;
+
+   loop = wl_display_get_event_loop(ec->wl_display);
+   assert(loop);
+   output->pageflip_timer = wl_event_loop_add_timer(loop,
+pageflip_timeout,
+output);
+
+   if (output->pageflip_timer == NULL) {
+   weston_log("creating drm pageflip timer failed: %m\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 static void
 drm_output_set_cursor(struct drm_output *output);
 
@@ -749,6 +790,10 @@ drm_output_repaint(struct weston_output *output_base,
output_base->set_dpms(output_base, WESTON_DPMS_ON);
}
 
+   if (output->pageflip_timer)
+   wl_event_source_timer_update(output->pageflip_timer,
+backend->pageflip_timeout);
+
if (drmModePageFlip(backend->drm.fd, output->crtc_id,
output->next->fb_id,
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
@@ -872,6 +917,10 @@ drm_output_start_repaint_loop(struct weston_output 
*output_base)
 */
fb_id = output->current->fb_id;
 
+   if (output->pageflip_timer)
+   wl_event_source_timer_update(output->pageflip_timer,
+

[PATCH weston] config-parser: Export weston_config_next_section

2017-02-21 Thread Emmanuel Gil Peyrot
This symbol wasn’t exported from the weston binary, most likely due to
an oversight in 6e2c12496bbef3cc913cfe9d5f0aeb4d8b23b368, and because
internal modules can link against libshared.la directly it hasn’t been
found ever since.

This commit makes it possible for external modules to iterate over the
configuration file.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 shared/config-parser.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/shared/config-parser.c b/shared/config-parser.c
index e2b5fa25..2a595b1f 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -490,6 +490,7 @@ weston_config_get_full_path(struct weston_config *config)
return config == NULL ? NULL : config->path;
 }
 
+WL_EXPORT
 int
 weston_config_next_section(struct weston_config *config,
   struct weston_config_section **section,
-- 
2.11.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] xwm: fix intermittent half-drawn decorations problem

2017-01-17 Thread Emmanuel Gil Peyrot
Hi,

On Tue, Jan 17, 2017 at 05:33:20PM +0200, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paala...@collabora.co.uk>
> 
> To reproduce the problem:
> - start weston (x11 backend worked, glamor in Xwayland makes no
>   difference)
> - start xterm
> - very very slowly move the pointer in the xterm decorations onto or
>   away from a button
> - the moment the decorations are updated, they will appear incomplete,
>   e.g. completely without buttons and title text
> - if you cause just one more pointer motion event, the decorations will
>   update to completely drawn appearance
> 
> Another way to reproduce the problem is to have an xterm and change its
> window title. This is easy if you use a shell prompt that updates the
> terminal window title. When the title updates, decorations will be
> half-drawn until something happens in XWM.
> 
> The fix: flush.
> 
> Apparently the drawing commands did not get flushed to the X server
> until any other X11 action pushed them through.
> 
> xcb_flush() is the real fix here. cairo_surface_flush() is added just
> for good measure, because documentation indicates it would be better
> used, however it was not strictly necessary to fix the problem in my
> experiments.
> 
> Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>

I tried dolphin-emu which was affected by this problem due to changing
its title to display the current performances of the emulation, and
this fixes it.  Thanks!

Tested-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

> ---
>  xwayland/window-manager.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> index 1dd8083..832f824 100644
> --- a/xwayland/window-manager.c
> +++ b/xwayland/window-manager.c
> @@ -1148,6 +1148,8 @@ weston_wm_window_draw_decoration(void *data)
>   }
>  
>   cairo_destroy(cr);
> + cairo_surface_flush(window->cairo_surface);
> + xcb_flush(window->wm->conn);
>  
>   if (window->surface) {
>   pixman_region32_fini(>surface->pending.opaque);
> -- 
> 2.10.2
> 
> _______
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
Emmanuel Gil Peyrot
Collabora Ltd.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] desktop-shell: Stop asking for a RGB565 background

2017-01-15 Thread Emmanuel Gil Peyrot
This makes the background image look much nicer, at the expense of
slightly more memory bandwidth used.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 clients/desktop-shell.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a1cf51df..bd0032a7 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -1101,8 +1101,6 @@ background_create(struct desktop *desktop)
window_set_user_data(background->window, background);
widget_set_redraw_handler(background->widget, background_draw);
widget_set_transparent(background->widget, 0);
-   window_set_preferred_format(background->window,
-   WINDOW_PREFERRED_FORMAT_RGB565);
 
s = weston_config_get_section(desktop->config, "shell", NULL, NULL);
weston_config_section_get_string(s, "background-image",
-- 
2.11.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] compositor-drm: pageflip timeout implementation

2017-01-06 Thread Emmanuel Gil Peyrot
Weston will not repaint until previous update has been acked by a
pageflip event coming from the drm driver. However, some buggy drivers
won’t return those events or will stop sending them at some point and
Weston output repaints will completely freeze. To ease developers’ task
in testing their drivers, this patch makes compositor-drm use a timer
to detect cases where those pageflip events stop coming.

This timeout implementation is software only and includes basic
features usually found in a watchdog. We simply exit Weston gracefully
with a log message and an exit code when the timout is reached.

The timeout value can be set via weston.ini by adding a
pageflip-timeout= entry under a new [compositor-drm]
section. Setting it to 0 disables the timeout feature.

https://bugs.freedesktop.org/show_bug.cgi?id=83884

Signed-off-by: Frederic Plourde <frederic.plou...@collabora.co.uk>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 compositor/main.c  |  2 ++
 libweston/compositor-drm.c | 64 ++
 libweston/compositor-drm.h |  7 +
 man/weston.ini.man |  5 
 4 files changed, 78 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 2aa4936e..abc2c2e4 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1201,6 +1201,8 @@ load_drm_backend(struct weston_compositor *c,
weston_config_section_get_string(section,
 "gbm-format", _format,
 NULL);
+   weston_config_section_get_uint(section, "pageflip-timeout",
+  _timeout, 0);
 
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_drm_backend_config);
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index ecc872ef..8682b11d 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -120,6 +120,8 @@ struct drm_backend {
int32_t cursor_height;
 
bool use_current_mode;
+
+   uint32_t pageflip_timeout;
 };
 
 struct drm_mode {
@@ -183,6 +185,8 @@ struct drm_output {
 
struct vaapi_recorder *recorder;
struct wl_listener recorder_frame_listener;
+
+   struct wl_event_source *pageflip_timer;
 };
 
 /*
@@ -226,6 +230,43 @@ to_drm_backend(struct weston_compositor *base)
return container_of(base->backend, struct drm_backend, base);
 }
 
+static int
+pageflip_timeout(void *data) {
+   /*
+* Our timer just went off, that means we're not receiving drm
+* page flip events anymore for that output. Let's gracefully exit
+* weston with a return value so devs can debug what's going on.
+*/
+   struct drm_output *output = data;
+   struct weston_compositor *compositor = output->base.compositor;
+
+   weston_log("Pageflip timeout reached, your driver is probably "
+  "buggy!  Exiting.\n");
+   weston_compositor_exit_with_code(compositor, EXIT_FAILURE);
+
+   return -1;
+}
+
+/* Creates the pageflip timer. Note that it isn't armed by default */
+static int
+drm_output_pageflip_timer_create(struct drm_output *output)
+{
+   struct wl_event_loop *loop = NULL;
+   struct weston_compositor *ec = output->base.compositor;
+
+   loop = wl_display_get_event_loop(ec->wl_display);
+   assert(loop);
+   output->pageflip_timer = wl_event_loop_add_timer(loop,
+pageflip_timeout,
+output);
+
+   if (output->pageflip_timer)
+   return 0;
+
+   weston_log("creating drm pageflip timer failed: %m\n");
+   return -1;
+}
+
 static void
 drm_output_set_cursor(struct drm_output *output);
 
@@ -692,6 +733,10 @@ drm_output_repaint(struct weston_output *output_base,
output_base->set_dpms(output_base, WESTON_DPMS_ON);
}
 
+   if (output->pageflip_timer)
+   wl_event_source_timer_update(output->pageflip_timer,
+backend->pageflip_timeout);
+
if (drmModePageFlip(backend->drm.fd, output->crtc_id,
output->next->fb_id,
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
@@ -815,6 +860,10 @@ drm_output_start_repaint_loop(struct weston_output 
*output_base)
 */
fb_id = output->current->fb_id;
 
+   if (output->pageflip_timer)
+   wl_event_source_timer_update(output->pageflip_timer,
+backend->pageflip_timeout);
+
if (drmModePageFlip(backend->drm.fd, output->crtc_id, fb_id,
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
weston_log

Re: How to do mode setting in Wayland

2016-12-23 Thread Emmanuel Gil Peyrot
On Fri, Dec 23, 2016 at 08:59:20AM +, Zhu, Lingyun wrote:
> Hi,

Hi,

> 
> I'm trying to set mode for a monitor from 4K@60Hz to 4K@30Hz (all supported) 
> under wayland/weston.
> But it seems there's no api for doing this.

That’s correct.

> The only mode setting related api is wl_output::mode event, but it's a 
> notifying event.
> 
> How can I change the mode of a monitor under wayland/weston?

The mode can currently only be set at launch time, in the weston.ini
configuration file, output section, in the mode option.

To set a specific refresh rate, you will have to generate a modeline
using the `cvt` tool and paste that in the mode option, see `man
weston.ini` and `man cvt` for more information.

> 
> 
> Thanks,
> Lingyun
> 

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] xwm: Add icon support to the frame

2016-12-07 Thread Emmanuel Gil Peyrot
This fetches the _NET_WM_ICON property of the X11 window, and use the
first image found as the frame icon.

This has been tested with various X11 programs, and improves usability
and user-friendliness a bit.

Changes since v1:
- Changed frame_button_create() to use
  frame_button_create_from_surface() internally.
- Removed a check that should never have been commited.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---

As for checking frame for NULL, there is no codepath in this file that
could lead to this situation, maybe we should add an assert but I doubt
it would catch any bug ever.

 clients/window.c   |  4 ++--
 libweston/compositor-wayland.c |  2 +-
 shared/cairo-util.h|  2 +-
 shared/frame.c | 54 +++---
 xwayland/window-manager.c  | 53 +++--
 5 files changed, 95 insertions(+), 20 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index ac35c3d..7e15969 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2546,7 +2546,7 @@ window_frame_create(struct window *window, void *data)
 
frame = xzalloc(sizeof *frame);
frame->frame = frame_create(window->display->theme, 0, 0,
-   buttons, window->title);
+   buttons, window->title, NULL);
 
frame->widget = window_add_widget(window, frame);
frame->child = widget_add_widget(frame->widget, data);
@@ -5444,7 +5444,7 @@ create_menu(struct display *display,
menu->user_data = user_data;
menu->widget = window_add_widget(menu->window, menu);
menu->frame = frame_create(window->display->theme, 0, 0,
-  FRAME_BUTTON_NONE, NULL);
+  FRAME_BUTTON_NONE, NULL, NULL);
fail_on_null(menu->frame, 0, __FILE__, __LINE__);
menu->entries = entries;
menu->count = count;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1e387d..4b053bf 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -848,7 +848,7 @@ wayland_output_set_windowed(struct wayland_output *output)
}
}
output->frame = frame_create(b->theme, 100, 100,
-FRAME_BUTTON_CLOSE, title);
+FRAME_BUTTON_CLOSE, title, NULL);
free(title);
if (!output->frame)
return -1;
diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index 84cf005..7893ca2 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -126,7 +126,7 @@ enum {
 
 struct frame *
 frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
-const char *title);
+ const char *title, cairo_surface_t *icon);
 
 void
 frame_destroy(struct frame *frame);
diff --git a/shared/frame.c b/shared/frame.c
index eb0cd77..3277985 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -106,9 +106,9 @@ struct frame {
 };
 
 static struct frame_button *
-frame_button_create(struct frame *frame, const char *icon,
-   enum frame_status status_effect,
-   enum frame_button_flags flags)
+frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
+ enum frame_status status_effect,
+ enum frame_button_flags flags)
 {
struct frame_button *button;
 
@@ -116,12 +116,7 @@ frame_button_create(struct frame *frame, const char *icon,
if (!button)
return NULL;
 
-   button->icon = cairo_image_surface_create_from_png(icon);
-   if (!button->icon) {
-   free(button);
-   return NULL;
-   }
-
+   button->icon = icon;
button->frame = frame;
button->flags = flags;
button->status_effect = status_effect;
@@ -131,6 +126,30 @@ frame_button_create(struct frame *frame, const char *icon,
return button;
 }
 
+static struct frame_button *
+frame_button_create(struct frame *frame, const char *icon_name,
+enum frame_status status_effect,
+enum frame_button_flags flags)
+{
+   struct frame_button *button;
+   cairo_surface_t *icon;
+
+   icon = cairo_image_surface_create_from_png(icon_name);
+   if (cairo_surface_status(icon) != CAIRO_STATUS_SUCCESS)
+   goto error;
+
+   button = frame_button_create_from_surface(frame, icon, status_effect,
+ flags);
+   if (!button)
+   goto error;
+
+   return button;
+
+error:
+   cairo_surface_destroy(icon);
+   return NULL;
+}
+
 static void
 frame_button_destroy(struct frame_button *button)
 {
@@ -303,7 +322,7 @@ frame_destroy(struct frame *f

[PATCH weston] autoconf: Fix AC_MSG_RESULT message when disabling features

2016-12-04 Thread Emmanuel Gil Peyrot
Some variables were previously only set inside conditions, making their
output empty.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 configure.ac | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 1e251bf..8aba62c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,7 @@ PKG_CHECK_MODULES(LIBDRM, [libdrm],
 AC_ARG_ENABLE(x11-compositor, [  --enable-x11-compositor],,
  enable_x11_compositor=yes)
 AM_CONDITIONAL(ENABLE_X11_COMPOSITOR, test x$enable_x11_compositor = xyes)
+have_xcb_xkb=no
 if test x$enable_x11_compositor = xyes; then
   PKG_CHECK_MODULES([XCB], xcb)
   xcb_save_LIBS=$LIBS
@@ -353,6 +354,7 @@ AS_IF([test "x$have_webp" = "xyes"],
 
 AC_ARG_ENABLE(vaapi-recorder, [  --enable-vaapi-recorder],,
  enable_vaapi_recorder=auto)
+have_libva=no
 if test x$enable_vaapi_recorder != xno; then
   PKG_CHECK_MODULES(LIBVA, [libva >= 0.34.0 libva-drm >= 0.34.0],
 [have_libva=yes], [have_libva=no])
@@ -417,6 +419,7 @@ AM_CONDITIONAL(BUILD_SIMPLE_DMABUF_V4L_CLIENT, test 
"x$enable_simple_dmabuf_v4l_
 
 AC_ARG_ENABLE(clients, [  --enable-clients],, enable_clients=yes)
 AM_CONDITIONAL(BUILD_CLIENTS, test x$enable_clients = xyes)
+have_cairo_egl=no
 if test x$enable_clients = xyes; then
   AC_DEFINE([BUILD_CLIENTS], [1], [Build the Wayland clients])
 
@@ -477,6 +480,7 @@ AC_ARG_ENABLE(colord,
   AS_HELP_STRING([--disable-colord],
  [do not build colord CMS support]),,
  enable_colord=auto)
+have_colord=no
 if test "x$enable_colord" != "xno"; then
PKG_CHECK_MODULES(COLORD,
  colord >= 0.1.27,
@@ -602,6 +606,7 @@ AC_ARG_ENABLE(libunwind,
  [Disable libunwind usage for backtraces]),,
   enable_libunwind=auto)
 AM_CONDITIONAL(HAVE_LIBUNWIND, [test "x$enable_libunwind" = xyes])
+have_libunwind=no
 if test "x$enable_libunwind" != "xno"; then
 PKG_CHECK_MODULES(LIBUNWIND,
   libunwind,
@@ -641,6 +646,7 @@ AC_ARG_ENABLE(lcms,
   AS_HELP_STRING([--disable-lcms],
  [Disable lcms support]),,
   enable_lcms=auto)
+have_lcms=no
 if test "x$enable_lcms" != "xno"; then
 PKG_CHECK_MODULES(LCMS,
   lcms2,
-- 
2.10.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] xwm: Add icon support to the frame

2016-12-04 Thread Emmanuel Gil Peyrot
This fetches the _NET_WM_ICON property of the X11 window, and use the
first image found as the frame icon.

This has been tested with various X11 programs, and improves usability
and user-friendliness a bit.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 clients/window.c   |  4 +--
 libweston/compositor-wayland.c |  2 +-
 shared/cairo-util.h|  2 +-
 shared/frame.c | 38 
 xwayland/window-manager.c  | 56 +++---
 5 files changed, 90 insertions(+), 12 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index ac35c3d..7e15969 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2546,7 +2546,7 @@ window_frame_create(struct window *window, void *data)
 
frame = xzalloc(sizeof *frame);
frame->frame = frame_create(window->display->theme, 0, 0,
-   buttons, window->title);
+   buttons, window->title, NULL);
 
frame->widget = window_add_widget(window, frame);
frame->child = widget_add_widget(frame->widget, data);
@@ -5444,7 +5444,7 @@ create_menu(struct display *display,
menu->user_data = user_data;
menu->widget = window_add_widget(menu->window, menu);
menu->frame = frame_create(window->display->theme, 0, 0,
-  FRAME_BUTTON_NONE, NULL);
+  FRAME_BUTTON_NONE, NULL, NULL);
fail_on_null(menu->frame, 0, __FILE__, __LINE__);
menu->entries = entries;
menu->count = count;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1e387d..4b053bf 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -848,7 +848,7 @@ wayland_output_set_windowed(struct wayland_output *output)
}
}
output->frame = frame_create(b->theme, 100, 100,
-FRAME_BUTTON_CLOSE, title);
+FRAME_BUTTON_CLOSE, title, NULL);
free(title);
if (!output->frame)
return -1;
diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index 84cf005..7893ca2 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -126,7 +126,7 @@ enum {
 
 struct frame *
 frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
-const char *title);
+ const char *title, cairo_surface_t *icon);
 
 void
 frame_destroy(struct frame *frame);
diff --git a/shared/frame.c b/shared/frame.c
index eb0cd77..69f3e90 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -131,6 +131,27 @@ frame_button_create(struct frame *frame, const char *icon,
return button;
 }
 
+static struct frame_button *
+frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
+ enum frame_status status_effect,
+ enum frame_button_flags flags)
+{
+   struct frame_button *button;
+
+   button = calloc(1, sizeof *button);
+   if (!button)
+   return NULL;
+
+   button->icon = icon;
+   button->frame = frame;
+   button->flags = flags;
+   button->status_effect = status_effect;
+
+   wl_list_insert(frame->buttons.prev, >link);
+
+   return button;
+}
+
 static void
 frame_button_destroy(struct frame_button *button)
 {
@@ -303,7 +324,7 @@ frame_destroy(struct frame *frame)
 
 struct frame *
 frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
-const char *title)
+ const char *title, cairo_surface_t *icon)
 {
struct frame *frame;
struct frame_button *button;
@@ -330,10 +351,17 @@ frame_create(struct theme *t, int32_t width, int32_t 
height, uint32_t buttons,
}
 
if (title) {
-   button = frame_button_create(frame,
-DATADIR "/weston/icon_window.png",
-FRAME_STATUS_MENU,
-FRAME_BUTTON_CLICK_DOWN);
+   if (icon) {
+   button = frame_button_create_from_surface(frame,
+ icon,
+ 
FRAME_STATUS_MENU,
+ 
FRAME_BUTTON_CLICK_DOWN);
+   } else {
+   button = frame_button_create(frame,
+DATADIR 
"/weston/icon_window.png",
+FRAME_STATUS_MENU,
+FRAME_BUTTON_CLICK_DOWN);
+   }

Re: [PATCH weston] gl-renderer: Use EGL_KHR_no_config_context

2016-09-27 Thread Emmanuel Gil Peyrot
On Tue, Sep 27, 2016 at 12:29:51PM +0200, Armin Krezović wrote:
> This patch makes use of recently implemented
> EGL_KHR_no_config_context extension in Mesa,
> which superseeds EGL_MESA_configless_context.
> 
> See also (and the follow-up patch):
> 
> https://lists.freedesktop.org/archives/mesa-dev/2016-September/128510.html
> 
> Signed-off-by: Armin Krezović <krezovic.ar...@gmail.com>
> ---
>  libweston/gl-renderer.c| 14 +++---
>  libweston/weston-egl-ext.h |  3 +++
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
> index 031576b..7ef7b89 100644
> --- a/libweston/gl-renderer.c
> +++ b/libweston/gl-renderer.c
> @@ -199,6 +199,8 @@ struct gl_renderer {
>  
>   int has_egl_buffer_age;
>  
> + int has_no_config_context;
> +
>   int has_configless_context;

You don’t need to keep two different booleans for that, both extensions
are implemented and exposed the same way, only the wording changes a
bit.

>  
>   int has_surfaceless_context;
> @@ -2564,10 +2566,11 @@ gl_renderer_output_create(struct weston_output 
> *output,
>   }
>  
>   if (egl_config != gr->egl_config &&
> + !gr->has_no_config_context &&
>   !gr->has_configless_context) {
>   weston_log("attempted to use a different EGL config for an "
> -"output but EGL_MESA_configless_context is not "
> -"supported\n");
> +"output but EGL_KHR_no_config_context or "
> +"EGL_MESA_configless_context is not supported\n");
>   return -1;
>   }
>  
> @@ -2726,6 +2729,9 @@ gl_renderer_setup_egl_extensions(struct 
> weston_compositor *ec)
>   weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
>  "supported. Performance could be affected.\n");
>  
> + if (weston_check_egl_extension(extensions, "EGL_KHR_no_config_context"))
> + gr->has_no_config_context = 1;
> +
>   if (weston_check_egl_extension(extensions, 
> "EGL_MESA_configless_context"))
>   gr->has_configless_context = 1;

Same here, you can safely set gr->has_no_config_context instead.

>  
> @@ -3101,7 +3107,9 @@ gl_renderer_setup(struct weston_compositor *ec, 
> EGLSurface egl_surface)
>  
>   context_config = gr->egl_config;
>  
> - if (gr->has_configless_context)
> + if (gr->has_no_config_context)
> + context_config = EGL_NO_CONFIG_KHR;
> + else if (gr->has_configless_context)
>   context_config = EGL_NO_CONFIG_MESA;

And same here, the EGL_NO_CONFIG_KHR and EGL_NO_CONFIG_MESA values are
the same, so as long as you have both in the header (you do), it will
not be an issue.

>  
>   gr->egl_context = eglCreateContext(gr->egl_display, context_config,
> diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
> index 6e36996..50964a8 100644
> --- a/libweston/weston-egl-ext.h
> +++ b/libweston/weston-egl-ext.h
> @@ -152,5 +152,8 @@ typedef EGLSurface (EGLAPIENTRYP 
> PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLD
>  #define EGL_PLATFORM_X11_KHR 0x31D5
>  #endif
>  
> +#ifndef EGL_NO_CONFIG_KHR
> +#define EGL_NO_CONFIG_KHR ((EGLConfig)0)
> +#endif
>  
>  #endif
> -- 
> 2.10.0
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
Emmanuel Gil Peyrot
Collabora Ltd.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] compositor-wayland: Only destroy the egl_window when using GLES.

2016-09-01 Thread Emmanuel Gil Peyrot
This prevents a segfault when unplugging an output when using pixman.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 libweston/compositor-wayland.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 7c12b4c..c223baa 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -627,9 +627,9 @@ wayland_output_destroy(struct weston_output *output_base)
pixman_renderer_output_destroy(output_base);
} else {
gl_renderer->output_destroy(output_base);
+   wl_egl_window_destroy(output->gl.egl_window);
}
 
-   wl_egl_window_destroy(output->gl.egl_window);
wl_surface_destroy(output->parent.surface);
if (output->parent.shell_surface)
wl_shell_surface_destroy(output->parent.shell_surface);
-- 
2.9.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] gl-renderer: Add a #define to obtain the prototypes from the gl2 header.

2016-09-01 Thread Emmanuel Gil Peyrot
This prevents a segfault when running on Mesa master, due to the GLES2
symbols not being declared with the correct prototype (or at all).

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 libweston/gl-renderer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 031576b..3979c3a 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -26,6 +26,7 @@
 
 #include "config.h"
 
+#define GL_GLEXT_PROTOTYPES
 #include 
 #include 
 
-- 
2.9.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] libweston-desktop/{wl_shell, xwayland}: Fix changing between toplevel states

2016-08-16 Thread Emmanuel Gil Peyrot
On Tue, Aug 16, 2016 at 11:42:47AM +0200, Quentin Glidic wrote:
> From: Quentin Glidic <sardemff7+...@sardemff7.net>

Tested-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

> 
> Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
> ---
>  libweston-desktop/wl-shell.c | 4 +++-
>  libweston-desktop/xwayland.c | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libweston-desktop/wl-shell.c b/libweston-desktop/wl-shell.c
> index 7c6a589..74ce473 100644
> --- a/libweston-desktop/wl-shell.c
> +++ b/libweston-desktop/wl-shell.c
> @@ -151,8 +151,10 @@ weston_desktop_wl_shell_change_state(struct 
> weston_desktop_wl_shell_surface *sur
>  
>   assert(state != NONE);
>  
> - if (to_add && surface->added)
> + if (to_add && surface->added) {
> + surface->state = state;
>   return;
> + }
>  
>   if (surface->state != state) {
>   if (surface->state == POPUP)
> diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
> index da04f7f..cb08323 100644
> --- a/libweston-desktop/xwayland.c
> +++ b/libweston-desktop/xwayland.c
> @@ -75,8 +75,10 @@ weston_desktop_xwayland_surface_change_state(struct 
> weston_desktop_xwayland_surf
>  
>   assert(state != NONE);
>  
> - if (to_add && surface->added)
> + if (to_add && surface->added) {
> + surface->state = state;
>   return;
> + }
>  
>   if (surface->state != state) {
>   if (surface->state == XWAYLAND) {
> -- 
> 2.9.2
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
Emmanuel Gil Peyrot
Collabora Ltd.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] clients: Add a weston-autorotater client and rotater protocol

2016-08-08 Thread Emmanuel Gil Peyrot
On Mon, May 23, 2016 at 12:00:13PM +0300, Pekka Paalanen wrote:
> On Sat, 21 May 2016 03:43:04 +0100
> Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com> wrote:
> 
> > This client uses libiio to retrieve accelerometer values from the iio
> > subsystem on Linux (and maybe some other kernels), and automatically
> > rotate the output whenever orientation changed.
> > 
> > I tested it with a mma8453 accelerometer, but everything needed should
> > be available in the configuration to make it work with any other iio
> > device.
> > 
> > Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
> > ---
> >  Makefile.am |  24 +++
> >  clients/autorotater.c   | 472 
> > 
> >  configure.ac|  15 ++
> >  desktop-shell/shell.c   |   1 +
> >  protocol/weston-rotater.xml |  26 +++
> >  src/compositor.h|   3 +
> >  src/rotater.c   | 150 ++
> >  7 files changed, 691 insertions(+)
> >  create mode 100644 clients/autorotater.c
> >  create mode 100644 protocol/weston-rotater.xml
> >  create mode 100644 src/rotater.c
> 
> Hi Emmanuel,

Hi Pekka,

> 
> why is there a new client for this? Could it not be a plugin?
> 
> Is IIO potentially so slow and blocking we cannot use it in the server
> process?
> 
> Why the polling approach, cannot IIO deliver events?

The actual issue here is driver support for event-based IIO is spotty
at best, as I found out while trying to implement that method.  I
haven’t been able to find out programatically whether a driver will
behave as expected in the event-based API (which IIO people call “the
high-speed mode”), and implementing both methods with a blacklist
doesn’t seem sensible.  Having a method working with every driver seems
to be the most sensible and generic way.

> 
> Should there be a way to set which outputs get rotated by a specific
> IIO device, rather than assuming there is just one device rotating all
> outputs at once?

This has been added to the v2, an arbitrary number of autorotators can
now be used to drive an arbitrary number of weston_outputs.

> 
> Any reason why this is limited to desktop-shell rather than being a
> shell-agnostic feature?

In the v2 I made it a Weston module, it now won’t be used without being
listed in the modules option of the [core] section.

> 
> 
> Thanks,
> pq
> 
[snip]

Thanks for the review,

-- 
Emmanuel Gil Peyrot
Collabora Ltd.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] clients: Add a weston-autorotator client and rotator protocol

2016-08-08 Thread Emmanuel Gil Peyrot
This client uses libiio to retrieve accelerometer values from the iio
subsystem on Linux (and maybe some other kernels), and automatically
rotate the output whenever orientation changed.

I tested it with a mma8453 accelerometer, but everything needed should
be available in the configuration to make it work with any other iio
device.

v2:
- Rename rotater to rotator, which is actual English.
- Add documentation for every new option, and a default value.
- Add the bare minimum of those options in the sample weston.ini.
- Fix for an inaccurate sampling frequency due to integer downcasting.
- Make the server-side a module instead of a simple function that has to be
  called by every shell.
- Remove the mostly-useless smoothing of the captured input.
- Make the protocol take an accelerometer name, to let the rotator
  match its name with the outputs using it.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 .gitignore  |   1 +
 Makefile.am |  28 +++
 clients/autorotator.c   | 435 
 compositor/rotator.c| 246 +
 configure.ac|  15 ++
 libweston/compositor.c  |   1 +
 libweston/compositor.h  |   1 +
 man/weston.ini.man  |  41 +
 protocol/weston-rotator.xml |  26 +++
 weston.ini.in   |   4 +
 10 files changed, 798 insertions(+)
 create mode 100644 clients/autorotator.c
 create mode 100644 compositor/rotator.c
 create mode 100644 protocol/weston-rotator.xml

diff --git a/.gitignore b/.gitignore
index 41a140b..72cea9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,7 @@ protocol/*.[ch]
 
 00*.patch
 
+weston-autorotator
 weston-calibrator
 weston-clickdot
 weston-cliptest
diff --git a/Makefile.am b/Makefile.am
index 32627f5..0e990ab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -124,6 +124,8 @@ endif
 nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES =
\
protocol/weston-screenshooter-protocol.c\
protocol/weston-screenshooter-server-protocol.h \
+   protocol/weston-rotator-protocol.c  \
+   protocol/weston-rotator-server-protocol.h   \
protocol/text-cursor-position-protocol.c\
protocol/text-cursor-position-server-protocol.h \
protocol/text-input-unstable-v1-protocol.c  \
@@ -610,6 +612,32 @@ nodist_weston_screenshooter_SOURCES =  
\
 weston_screenshooter_LDADD = $(CLIENT_LIBS) libshared.la
 weston_screenshooter_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
 
+if BUILD_AUTOROTATOR
+libexec_PROGRAMS += weston-autorotator
+
+weston_autorotator_SOURCES =   \
+   clients/autorotator.c
+nodist_weston_autorotator_SOURCES =\
+   protocol/weston-rotator-protocol.c  \
+   protocol/weston-rotator-client-protocol.h
+weston_autorotator_LDADD = $(CLIENT_LIBS) $(LIBIIO_LIBS) libshared.la
+weston_autorotator_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS) $(LIBIIO_CFLAGS)
+
+module_LTLIBRARIES += rotator.la
+rotator_la_LDFLAGS = -module -avoid-version
+rotator_la_LIBADD = $(COMPOSITOR_LIBS) libshared.la
+rotator_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
+rotator_la_SOURCES =   \
+   compositor/rotator.c
+
+BUILT_SOURCES +=   \
+   protocol/weston-rotator-protocol.c  \
+   protocol/weston-rotator-client-protocol.h
+
+EXTRA_DIST +=  \
+   protocol/weston-rotator.xml
+endif
+
 weston_terminal_SOURCES =  \
clients/terminal.c  \
shared/helpers.h
diff --git a/clients/autorotator.c b/clients/autorotator.c
new file mode 100644
index 000..89697c9
--- /dev/null
+++ b/clients/autorotator.c
@@ -0,0 +1,435 @@
+/*
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * LIABI

Re: [PATCH] gl-renderer: Add support for DRM_FORMAT_YUV444 buffers

2016-07-25 Thread Emmanuel Gil Peyrot
On Mon, Jul 25, 2016 at 12:15:41PM +0200, Matthias Treydte wrote:
> This uses the existing infrastructure for dealing with planar YUV buffers and 
> only adds the
> relevant yuv_format_descriptor to the table.
> ---
>  libweston/gl-renderer.c | 21 +
>  1 file changed, 21 insertions(+)
> 
> diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
> index be6b11e..cdb7d14 100644
> --- a/libweston/gl-renderer.c
> +++ b/libweston/gl-renderer.c
> @@ -1596,6 +1596,27 @@ struct yuv_format_descriptor yuv_formats[] = {
>   .format = DRM_FORMAT_R8,
>   .plane_index = 2
>   }}
> + }, {
> + .format = DRM_FORMAT_YUV444,
> + .input_planes = 3,
> + .output_planes = 3,
> + .texture_type = EGL_TEXTURE_Y_U_V_WL,
> + {{
> + .width_divisor = 1,
> + .height_divisor = 1,
> + .format = DRM_FORMAT_R8,
> + .plane_index = 0
> + }, {
> + .width_divisor = 1,
> + .height_divisor = 1,
> + .format = DRM_FORMAT_R8,
> + .plane_index = 1
> + }, {
> + .width_divisor = 1,
> + .height_divisor = 1,
> + .format = DRM_FORMAT_R8,
> + .plane_index = 2
> + }}
>   }
>  };
>  
> -- 
> 2.9.0

Hi, thanks for this patch, I originally only implemented very few
formats just to demonstrate the capabilities of linux_dmabuf but it’s
always useful to have other formats supported.

Which program did you test it with?  Have you tested it with
weston-simple-dmabuf-v4l alongside the vivid kernel module in 4:4:4
mode?

Anyway, the code is
Reviewed-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
Emmanuel Gil Peyrot
Collabora Ltd.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] Remove a wrong closing “extern "C"” in shared/xalloc.c

2016-07-13 Thread Emmanuel Gil Peyrot
On Wed, Jul 13, 2016 at 05:13:24PM -0700, Thiago Macieira wrote:
> > -#ifdef  __cplusplus
> > -}
> > -#endif
> 
> Out of curiosity: why are you compiling C sources as C++?
> 
> Is that the Arduino compiler?

I wasn’t, I just noticed this leftover from a previous copy (likely the
file creation), and just fixed it.

I don’t have any particular reason to compile C code as C++, as this
might break things in non-obvious ways.

> 
> -- 
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>Software Architect - Intel Open Source Technology Center
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] Remove a wrong closing “extern "C"” in shared/xalloc.c

2016-07-11 Thread Emmanuel Gil Peyrot
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 shared/xalloc.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/shared/xalloc.c b/shared/xalloc.c
index 4bf8a3e..9bf5245 100644
--- a/shared/xalloc.c
+++ b/shared/xalloc.c
@@ -47,8 +47,3 @@ fail_on_null(void *p, size_t size, char *file, int32_t line)
 
return p;
 }
-
-
-#ifdef  __cplusplus
-}
-#endif
-- 
2.9.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] clients: Add a weston-autorotater client and rotater protocol

2016-05-20 Thread Emmanuel Gil Peyrot
This client uses libiio to retrieve accelerometer values from the iio
subsystem on Linux (and maybe some other kernels), and automatically
rotate the output whenever orientation changed.

I tested it with a mma8453 accelerometer, but everything needed should
be available in the configuration to make it work with any other iio
device.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 Makefile.am |  24 +++
 clients/autorotater.c   | 472 
 configure.ac|  15 ++
 desktop-shell/shell.c   |   1 +
 protocol/weston-rotater.xml |  26 +++
 src/compositor.h|   3 +
 src/rotater.c   | 150 ++
 7 files changed, 691 insertions(+)
 create mode 100644 clients/autorotater.c
 create mode 100644 protocol/weston-rotater.xml
 create mode 100644 src/rotater.c

diff --git a/Makefile.am b/Makefile.am
index 00b74e5..b1e0ade 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -122,6 +122,8 @@ endif
 nodist_weston_SOURCES =\
protocol/weston-screenshooter-protocol.c\
protocol/weston-screenshooter-server-protocol.h \
+   protocol/weston-rotater-protocol.c  \
+   protocol/weston-rotater-server-protocol.h   \
protocol/text-cursor-position-protocol.c\
protocol/text-cursor-position-server-protocol.h \
protocol/text-input-unstable-v1-protocol.c  \
@@ -611,6 +613,28 @@ nodist_weston_screenshooter_SOURCES =  
\
 weston_screenshooter_LDADD = $(CLIENT_LIBS) libshared.la
 weston_screenshooter_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
 
+if BUILD_AUTOROTATER
+libexec_PROGRAMS += weston-autorotater
+
+weston_autorotater_SOURCES =   \
+   clients/autorotater.c
+nodist_weston_autorotater_SOURCES =\
+   protocol/weston-rotater-protocol.c  \
+   protocol/weston-rotater-client-protocol.h
+weston_autorotater_LDADD = $(CLIENT_LIBS) $(LIBIIO_LIBS) libshared.la
+weston_autorotater_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS) $(LIBIIO_CFLAGS)
+
+weston_SOURCES +=  \
+   src/rotater.c
+
+BUILT_SOURCES +=   \
+   protocol/weston-rotater-protocol.c  \
+   protocol/weston-rotater-client-protocol.h
+
+EXTRA_DIST +=  \
+   protocol/weston-rotater.xml
+endif
+
 weston_terminal_SOURCES =  \
clients/terminal.c  \
shared/helpers.h
diff --git a/clients/autorotater.c b/clients/autorotater.c
new file mode 100644
index 000..0547f83
--- /dev/null
+++ b/clients/autorotater.c
@@ -0,0 +1,472 @@
+/*
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * 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 (including the next
+ * paragraph) 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.
+ */
+
+#include "config.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "weston-rotater-client-protocol.h"
+#include "shared/config-parser.h"
+#include "shared/helpers.h"
+#include "shared/xalloc.h"
+
+#include 
+
+#define BUFFER_SIZE 256
+
+static struct weston_rotater *rotater;
+static struct wl_list output_list;
+
+struct rotater_output {
+   struct wl_output *output;
+   struct wl_list link;
+};
+
+#define DEFAULT_SAMPLING_FREQUENCY 100.
+
+struct config {
+   char *device_name;
+   char *channel_x_name, *channel_y_name;
+   char *sampling_frequency_name;
+   double wanted_sampling_frequency;
+   int threshold;
+   int smooth_capture;
+   struct wl_array allowed_rotations;
+};
+
+#define MAX_CAPTURE_BUFFER_LENGTH 16
+
+struct accelerometer {
+   struct iio_context *conte

Re: [PATCH weston] zunitc: use platform-independent macros for integer formatting

2016-05-18 Thread Emmanuel Gil Peyrot
On Wed, May 18, 2016 at 05:18:18PM +0100, Emmanuel Gil Peyrot wrote:
> From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
> 
> Fixes warnings and potential issues on 32-bit platforms, tested only on
> ARM but I’d expect the same issue on i686.
> 
> Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>

This should read “Signed-off-by: Emmanuel Gil Peyrot 
<emmanuel.pey...@collabora.com>”

Sorry.

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] zunitc: use platform-independent macros for integer formatting

2016-05-18 Thread Emmanuel Gil Peyrot
From: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Fixes warnings and potential issues on 32-bit platforms, tested only on
ARM but I’d expect the same issue on i686.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---

This patch should be fine to land during the 1.11 beta, it doesn’t
change any functional element and is just about cleaner build.

 tools/zunitc/src/zuc_base_logger.c| 15 +--
 tools/zunitc/src/zuc_junit_reporter.c | 34 ++
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/tools/zunitc/src/zuc_base_logger.c 
b/tools/zunitc/src/zuc_base_logger.c
index cdbd9ea..ffa127f 100644
--- a/tools/zunitc/src/zuc_base_logger.c
+++ b/tools/zunitc/src/zuc_base_logger.c
@@ -27,6 +27,7 @@
 
 #include "zuc_base_logger.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -363,9 +364,9 @@ check_triggered(void *data, char const *file, int line,
} else {
printf("%s:%d: error: Value of: %s\n", file, line,
   expr2);
-   printf("  Actual: %ld\n", val2);
+   printf("  Actual: %"PRIdPTR"\n", val2);
printf("Expected: %s\n", expr1);
-   printf("Which is: %ld\n", val1);
+   printf("Which is: %"PRIdPTR"\n", val1);
}
break;
case ZUC_OP_NE:
@@ -376,8 +377,9 @@ check_triggered(void *data, char const *file, int line,
   (char *)val1, (char *)val2);
} else {
printf("%s:%d: error: ", file, line);
-   printf("Expected: (%s) %s (%s), actual: %ld vs %ld\n",
-  expr1, zuc_get_opstr(op), expr2, val1, val2);
+   printf("Expected: (%s) %s (%s), actual: %"PRIdPTR" vs "
+  "%"PRIdPTR"\n", expr1, zuc_get_opstr(op), expr2,
+  val1, val2);
}
break;
case ZUC_OP_TERMINATE: {
@@ -392,7 +394,8 @@ check_triggered(void *data, char const *file, int line,
break;
default:
printf("%s:%d: error: ", file, line);
-   printf("Expected: (%s) %s (%s), actual: %ld vs %ld\n",
-  expr1, zuc_get_opstr(op), expr2, val1, val2);
+   printf("Expected: (%s) %s (%s), actual: %"PRIdPTR" vs "
+  "%"PRIdPTR"\n", expr1, zuc_get_opstr(op), expr2, val1,
+  val2);
}
 }
diff --git a/tools/zunitc/src/zuc_junit_reporter.c 
b/tools/zunitc/src/zuc_junit_reporter.c
index a33b33f..369f035 100644
--- a/tools/zunitc/src/zuc_junit_reporter.c
+++ b/tools/zunitc/src/zuc_junit_reporter.c
@@ -30,6 +30,7 @@
 #if ENABLE_JUNIT_XML
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -128,12 +129,12 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
}
} else {
if (asprintf(, "%s:%d: error: Value of: %s\n"
-"  Actual: %ld\n"
-"Expected: %s\n"
-"Which is: %ld\n",
-event->file, event->line, event->expr2,
-event->val2, event->expr1,
-event->val1) < 0) {
+"  Actual: %"PRIdPTR"\n"
+"Expected: %s\n"
+"Which is: %"PRIdPTR"\n",
+event->file, event->line, event->expr2,
+event->val2, event->expr1,
+event->val1) < 0) {
msg = NULL;
}
}
@@ -151,12 +152,12 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
}
} else {
if (asprintf(, "%s:%d: error: "
-"Expected: (%s) %s (%s),"
-" actual: %ld vs %ld\n",
-event->file, event->line,
-event->expr1, zuc_get_opstr(event->op),
-event->expr2, event->val1,
-event->val2) < 0) {
+"Expected: (%s) %s (%s),"
+

[PATCH weston] desktop-shell: Don’t reconfigure an already fullscreen surface

2016-05-09 Thread Emmanuel Gil Peyrot
When we receive an wl_shell_surface::set_fullscreen request for a
surface that was already fullscreen, don’t do anything if the
parameters are the same as the initial request.

This prevents bogus or malicious clients from being able to always stay
on front by flooding the compositor with set_fullscreen requests after
the user has put them in the background with a mod+tab.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 desktop-shell/shell.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 1c39a12..7d5bca9 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2561,6 +2561,13 @@ shell_surface_set_fullscreen(struct wl_client *client,
struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_output *output;
 
+   if (shsurf->fullscreen_output == shsurf->output &&
+   shsurf->fullscreen.type == method &&
+   shsurf->fullscreen.framerate == framerate) {
+   send_configure_for_surface(shsurf);
+   return;
+   }
+
if (output_resource)
output = wl_resource_get_user_data(output_resource);
else
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Dual Monitor mirror/twinview

2016-05-02 Thread Emmanuel Gil Peyrot
On Mon, May 02, 2016 at 06:10:34PM +, Engelmann Florian wrote:
> Dear list,
> 
> I am running an old HP thin client to display our monitoring dashboard. The 
> thin client got a i965 (i915 module) VGA adapter with a VGA and a HDMI 
> connector. I am able to start weston-launch (drm backend) having both 
> connectors enabled via kernel cmdline (acpi=off i915.modeset=1 
> video=VGA-1:1280x1024@60e video=HDMI-A-1:1280x1024@60D) to display a double 
> size desktop but I am not able to enable twinview/mirroring to get the same 
> output on both monitors. Is that possible via some "output" settings?

Heh, funny that I posted my cloning series just a few hours after you
asked that, once they will be reviewed and merged you will just have to
add such a section to your weston.ini:

[output]
name=HDMI-A-1
same-as=VGA-1

This isn’t possible on current master.

> 
> Thank you so much,
> Flo

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/8] compositor-drm: Make some functions take a weston_output directly

2016-05-02 Thread Emmanuel Gil Peyrot
Makes it clearer that they don’t use any field specific to drm_output,
and reduce the amount of churn from the following commits.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/compositor-drm.c | 48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 5938d53..1edcaab 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -232,7 +232,7 @@ static void
 drm_output_set_cursor(struct drm_output *output);
 
 static void
-drm_output_update_msc(struct drm_output *output, unsigned int seq);
+drm_output_update_msc(struct weston_output *output_base, unsigned int seq);
 
 static int
 drm_sprite_crtc_supported(struct drm_output *output, uint32_t supported)
@@ -775,7 +775,7 @@ drm_output_start_repaint_loop(struct weston_output 
*output_base)
refresh_nsec =
millihz_to_nsec(output_base->current_mode->refresh);
if (timespec_to_nsec() < refresh_nsec) {
-   drm_output_update_msc(output, vbl.reply.sequence);
+   drm_output_update_msc(output_base, vbl.reply.sequence);
weston_output_finish_frame(output_base, ,

WP_PRESENTATION_FEEDBACK_INVALID);
return;
@@ -803,14 +803,14 @@ finish_frame:
 }
 
 static void
-drm_output_update_msc(struct drm_output *output, unsigned int seq)
+drm_output_update_msc(struct weston_output *output_base, unsigned int seq)
 {
-   uint64_t msc_hi = output->base.msc >> 32;
+   uint64_t msc_hi = output_base->msc >> 32;
 
-   if (seq < (output->base.msc & 0x))
+   if (seq < (output_base->msc & 0x))
msc_hi++;
 
-   output->base.msc = (msc_hi << 32) + seq;
+   output_base->msc = (msc_hi << 32) + seq;
 }
 
 static void
@@ -823,7 +823,7 @@ vblank_handler(int fd, unsigned int frame, unsigned int 
sec, unsigned int usec,
uint32_t flags = WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
 WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
 
-   drm_output_update_msc(output, frame);
+   drm_output_update_msc(>base, frame);
output->vblank_pending = 0;
 
drm_output_release_fb(output, s->current);
@@ -850,7 +850,7 @@ page_flip_handler(int fd, unsigned int frame,
 WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
 WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
 
-   drm_output_update_msc(output, frame);
+   drm_output_update_msc(>base, frame);
 
/* We don't set page_flip_pending on start_repaint_loop, in that case
 * we just want to page flip to the current buffer to get an accurate
@@ -1367,17 +1367,17 @@ drm_output_destroy(struct weston_output *output_base)
  * @returns Pointer to a mode from the output's mode list
  */
 static struct drm_mode *
-choose_mode (struct drm_output *output, struct weston_mode *target_mode)
+choose_mode (struct weston_output *output_base, struct weston_mode 
*target_mode)
 {
struct drm_mode *tmp_mode = NULL, *mode;
 
-   if (output->base.current_mode->width == target_mode->width &&
-   output->base.current_mode->height == target_mode->height &&
-   (output->base.current_mode->refresh == target_mode->refresh ||
+   if (output_base->current_mode->width == target_mode->width &&
+   output_base->current_mode->height == target_mode->height &&
+   (output_base->current_mode->refresh == target_mode->refresh ||
 target_mode->refresh == 0))
-   return (struct drm_mode *)output->base.current_mode;
+   return (struct drm_mode *)output_base->current_mode;
 
-   wl_list_for_each(mode, >base.mode_list, base.link) {
+   wl_list_for_each(mode, _base->mode_list, base.link) {
if (mode->mode_info.hdisplay == target_mode->width &&
mode->mode_info.vdisplay == target_mode->height) {
if (mode->base.refresh == target_mode->refresh ||
@@ -1415,7 +1415,7 @@ drm_output_switch_mode(struct weston_output *output_base, 
struct weston_mode *mo
 
b = (struct drm_backend *)output_base->compositor->backend;
output = (struct drm_output *)output_base;
-   drm_mode  = choose_mode (output, mode);
+   drm_mode = choose_mode(>base, mode);
 
if (!drm_mode) {
weston_log("%s, invalid resolution:%dx%d\n", __func__, 
mode->width, mode->height);
@@ -1630,7 +1630,7 @@ init_pixman(struct drm_backend *b)
  * @returns Newly-allocated Weston/DRM mode structure
  */
 static struct drm_mode *
-drm_output_add_mode(struct d

[PATCH weston 2/8] compositor-drm: Write a name in the mode generated from a modeline

2016-05-02 Thread Emmanuel Gil Peyrot
The current behaviour leaves the name empty, making it somewhat harder
to determine the characteristics of this mode from a debugger.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/compositor-drm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 7c5e1af..ea118fa 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2121,6 +2121,8 @@ parse_modeline(const char *s, drmModeModeInfo *mode)
else
return -1;
 
+   snprintf(mode->name, sizeof mode->name, "%dx%d@%.3f", mode->hdisplay, 
mode->vdisplay, fclock);
+
return 0;
 }
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 7/8] compositor-drm: Implement clone mode, refactor output into logical ones

2016-05-02 Thread Emmanuel Gil Peyrot
Introduces a “same-as” configuration option for each output, which
bypasses the rest of the output configuration (mode, scale, transform
and seat) and instead makes it a clone of the specified output.

This is implemented by splitting the drm_output struct into the
per-connector drm_output and the per-weston_output drm_logical_output,
with the latter containing one or more of the former in a wl_list.

I tested it on both i915 and etnaviv platforms, with various external
monitors and configurations, as well as hotplugging.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/compositor-drm.c | 794 +++
 1 file changed, 477 insertions(+), 317 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 1edcaab..a0ed45f 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -157,8 +157,12 @@ struct drm_edid {
char serial_number[13];
 };
 
+struct drm_logical_output;
+
 struct drm_output {
-   struct weston_output   base;
+   struct wl_list link;
+   struct drm_logical_output *base;
+   char *name;
 
uint32_t crtc_id;
int pipe;
@@ -166,13 +170,21 @@ struct drm_output {
drmModeCrtcPtr original_crtc;
struct drm_edid edid;
drmModePropertyPtr dpms_prop;
-   uint32_t gbm_format;
 
-   enum dpms_enum dpms;
+   struct backlight *backlight;
 
int vblank_pending;
int page_flip_pending;
int destroy_pending;
+};
+
+struct drm_logical_output {
+   struct weston_output   base;
+   struct wl_list output_list;
+
+   int page_flip_refcount;
+   uint32_t gbm_format;
+   enum dpms_enum dpms;
 
struct gbm_surface *gbm_surface;
struct gbm_bo *gbm_cursor_bo[2];
@@ -181,7 +193,6 @@ struct drm_output {
struct weston_view *cursor_view;
int current_cursor;
struct drm_fb *current, *next;
-   struct backlight *backlight;
 
struct drm_fb *dumb[2];
pixman_image_t *image[2];
@@ -229,7 +240,7 @@ static struct gl_renderer_interface *gl_renderer;
 static const char default_seat[] = "seat0";
 
 static void
-drm_output_set_cursor(struct drm_output *output);
+drm_output_set_cursor(struct drm_logical_output *output);
 
 static void
 drm_output_update_msc(struct weston_output *output_base, unsigned int seq);
@@ -237,7 +248,7 @@ drm_output_update_msc(struct weston_output *output_base, 
unsigned int seq);
 static int
 drm_sprite_crtc_supported(struct drm_output *output, uint32_t supported)
 {
-   struct weston_compositor *ec = output->base.compositor;
+   struct weston_compositor *ec = output->base->base.compositor;
struct drm_backend *b =(struct drm_backend *)ec->backend;
int crtc;
 
@@ -423,7 +434,7 @@ drm_fb_set_buffer(struct drm_fb *fb, struct weston_buffer 
*buffer)
 }
 
 static void
-drm_output_release_fb(struct drm_output *output, struct drm_fb *fb)
+drm_output_release_fb(struct drm_logical_output *output, struct drm_fb *fb)
 {
if (!fb)
return;
@@ -441,7 +452,7 @@ drm_output_release_fb(struct drm_output *output, struct 
drm_fb *fb)
 }
 
 static uint32_t
-drm_output_check_scanout_format(struct drm_output *output,
+drm_output_check_scanout_format(struct drm_logical_output *output,
struct weston_surface *es, struct gbm_bo *bo)
 {
uint32_t format;
@@ -471,7 +482,7 @@ drm_output_check_scanout_format(struct drm_output *output,
 }
 
 static struct weston_plane *
-drm_output_prepare_scanout_view(struct drm_output *output,
+drm_output_prepare_scanout_view(struct drm_logical_output *output,
struct weston_view *ev)
 {
struct weston_output *output_base = >base;
@@ -519,7 +530,8 @@ drm_output_prepare_scanout_view(struct drm_output *output,
 }
 
 static void
-drm_output_render_gl(struct drm_output *output, pixman_region32_t *damage)
+drm_output_render_gl(struct drm_logical_output *output,
+ pixman_region32_t *damage)
 {
struct drm_backend *b =
(struct drm_backend *)output->base.compositor->backend;
@@ -543,7 +555,8 @@ drm_output_render_gl(struct drm_output *output, 
pixman_region32_t *damage)
 }
 
 static void
-drm_output_render_pixman(struct drm_output *output, pixman_region32_t *damage)
+drm_output_render_pixman(struct drm_logical_output *output,
+ pixman_region32_t *damage)
 {
struct weston_compositor *ec = output->base.compositor;
pixman_region32_t total_damage, previous_damage;
@@ -569,7 +582,7 @@ drm_output_render_pixman(struct drm_output *output, 
pixman_region32_t *damage)
 }
 
 static void
-drm_output_render(struct drm_output *output, pixman_region32_t *damage)
+drm_output_render(struct drm_logical_output *output, pixman_region32_t *damage)
 {
struct weston_compositor *c = output->base.compositor;
stru

[PATCH weston 0/8] Implement clone mode for the DRM renderer

2016-05-02 Thread Emmanuel Gil Peyrot
This series implements a clone mode in the DRM renderer.  It starts
with a few one-liner fixes I found while implementing the feature,
which wouldn’t really merit their own series, followed by some light
refactoring.

The core of the series, patch 7/8, implements this feature by splitting
the physical DRM connector from the logical weston_output, as a
wl_list.

Emmanuel Gil Peyrot (8):
  compositor-drm: Remove unused output reference in drm_fb
  compositor-drm: Write a name in the mode generated from a modeline
  compositor-drm: Don’t try to set the cursor anymore once we know it’s
broken
  compositor-drm: Prevent a crash in the pixman renderer
  compositor-drm: Take a reference to the drm_output's base where it
makes sense
  compositor-drm: Make some functions take a weston_output directly
  compositor-drm: Implement clone mode, refactor output into logical
ones
  compositor-drm: Make output detection order irrelevant

 src/compositor-drm.c | 945 ++-
 1 file changed, 567 insertions(+), 378 deletions(-)

-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/8] compositor-drm: Remove unused output reference in drm_fb

2016-05-02 Thread Emmanuel Gil Peyrot
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/compositor-drm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index a47b453..7c5e1af 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -137,10 +137,7 @@ struct drm_mode {
drmModeModeInfo mode_info;
 };
 
-struct drm_output;
-
 struct drm_fb {
-   struct drm_output *output;
uint32_t fb_id, stride, handle, size;
int fd;
int is_client_buffer;
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/8] compositor-drm: Take a reference to the drm_output's base where it makes sense

2016-05-02 Thread Emmanuel Gil Peyrot
This makes the code more uniform with the functions taking a
weston_output* as argument, and reduces the churn of the following
commits.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/compositor-drm.c | 130 ++-
 1 file changed, 67 insertions(+), 63 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index f9a997b..5938d53 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -474,19 +474,20 @@ static struct weston_plane *
 drm_output_prepare_scanout_view(struct drm_output *output,
struct weston_view *ev)
 {
+   struct weston_output *output_base = >base;
struct drm_backend *b =
-   (struct drm_backend *)output->base.compositor->backend;
+   (struct drm_backend *)output_base->compositor->backend;
struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
struct weston_buffer_viewport *viewport = >surface->buffer_viewport;
struct gbm_bo *bo;
uint32_t format;
 
-   if (ev->geometry.x != output->base.x ||
-   ev->geometry.y != output->base.y ||
+   if (ev->geometry.x != output_base->x ||
+   ev->geometry.y != output_base->y ||
buffer == NULL || b->gbm == NULL ||
-   buffer->width != output->base.current_mode->width ||
-   buffer->height != output->base.current_mode->height ||
-   output->base.transform != viewport->buffer.transform ||
+   buffer->width != output_base->current_mode->width ||
+   buffer->height != output_base->current_mode->height ||
+   output_base->transform != viewport->buffer.transform ||
ev->transform.enabled)
return NULL;
 
@@ -589,7 +590,7 @@ drm_output_set_gamma(struct weston_output *output_base,
int rc;
struct drm_output *output = (struct drm_output *) output_base;
struct drm_backend *backend =
-   (struct drm_backend *) output->base.compositor->backend;
+   (struct drm_backend *) output_base->compositor->backend;
 
/* check */
if (output_base->gamma_size != size)
@@ -635,7 +636,7 @@ drm_output_repaint(struct weston_output *output_base,
 {
struct drm_output *output = (struct drm_output *) output_base;
struct drm_backend *backend =
-   (struct drm_backend *)output->base.compositor->backend;
+   (struct drm_backend *)output_base->compositor->backend;
struct drm_sprite *s;
struct drm_mode *mode;
int ret = 0;
@@ -648,7 +649,7 @@ drm_output_repaint(struct weston_output *output_base,
if (!output->next)
return -1;
 
-   mode = container_of(output->base.current_mode, struct drm_mode, base);
+   mode = container_of(output_base->current_mode, struct drm_mode, base);
if (!output->current ||
output->current->stride != output->next->stride) {
ret = drmModeSetCrtc(backend->drm.fd, output->crtc_id,
@@ -772,7 +773,7 @@ drm_output_start_repaint_loop(struct weston_output 
*output_base)
  );
timespec_sub(, , );
refresh_nsec =
-   millihz_to_nsec(output->base.current_mode->refresh);
+   millihz_to_nsec(output_base->current_mode->refresh);
if (timespec_to_nsec() < refresh_nsec) {
drm_output_update_msc(output, vbl.reply.sequence);
weston_output_finish_frame(output_base, ,
@@ -916,7 +917,8 @@ static struct weston_plane *
 drm_output_prepare_overlay_view(struct drm_output *output,
struct weston_view *ev)
 {
-   struct weston_compositor *ec = output->base.compositor;
+   struct weston_output *output_base = >base;
+   struct weston_compositor *ec = output_base->compositor;
struct drm_backend *b = (struct drm_backend *)ec->backend;
struct weston_buffer_viewport *viewport = >surface->buffer_viewport;
struct wl_resource *buffer_resource;
@@ -932,16 +934,16 @@ drm_output_prepare_overlay_view(struct drm_output *output,
if (b->gbm == NULL)
return NULL;
 
-   if (viewport->buffer.transform != output->base.transform)
+   if (viewport->buffer.transform != output_base->transform)
return NULL;
 
-   if (viewport->buffer.scale != output->base.current_scale)
+   if (viewport->buffer.scale != output_base->current_scale)
return NULL;
 
if (b->sprites_are_broken)
return NULL;
 
-   if (ev->output_mask != (1u <<

[PATCH weston 8/8] compositor-drm: Make output detection order irrelevant

2016-05-02 Thread Emmanuel Gil Peyrot
When using the clone mode, the order of detection of outputs shouldn’t
matter for them to be included in a virtual_output or not, this fixes
this issue from the previous patch.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
---
 src/compositor-drm.c | 34 +-
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index a0ed45f..ed72817 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2426,7 +2426,7 @@ create_output_for_connector(struct drm_backend *b,
}
}
if (logical_output == NULL)
-   return -1;
+   return -2;
is_clone = true;
} else {
logical_output = zalloc(sizeof *logical_output);
@@ -2704,7 +2704,8 @@ create_outputs(struct drm_backend *b, uint32_t 
option_connector,
 {
drmModeConnector *connector;
drmModeRes *resources;
-   int i;
+   struct wl_array clones;
+   int i, ret, *clone;
int x = 0, y = 0;
 
resources = drmModeGetResources(b->drm.fd);
@@ -2727,6 +2728,8 @@ create_outputs(struct drm_backend *b, uint32_t 
option_connector,
b->num_crtcs = resources->count_crtcs;
memcpy(b->crtcs, resources->crtcs, sizeof(uint32_t) * b->num_crtcs);
 
+   wl_array_init();
+
for (i = 0; i < resources->count_connectors; i++) {
connector = drmModeGetConnector(b->drm.fd,
resources->connectors[i]);
@@ -2736,9 +2739,14 @@ create_outputs(struct drm_backend *b, uint32_t 
option_connector,
if (connector->connection == DRM_MODE_CONNECTED &&
(option_connector == 0 ||
 connector->connector_id == option_connector)) {
-   if (create_output_for_connector(b, resources,
-   connector, x, y,
-   drm_device) < 0) {
+   ret = create_output_for_connector(b, resources,
+ connector, x, y,
+ drm_device);
+   if (ret == -2) {
+   clone = wl_array_add(, sizeof(int));
+   *clone = i;
+   }
+   if (ret < 0) {
drmModeFreeConnector(connector);
continue;
}
@@ -2750,6 +2758,22 @@ create_outputs(struct drm_backend *b, uint32_t 
option_connector,
 
drmModeFreeConnector(connector);
}
+   wl_array_for_each(clone, ) {
+   i = *clone;
+   connector = drmModeGetConnector(b->drm.fd,
+   resources->connectors[i]);
+   if (create_output_for_connector(b, resources,
+   connector, x, y,
+   drm_device) < 0) {
+   drmModeFreeConnector(connector);
+   continue;
+   }
+   x += container_of(b->compositor->output_list.prev,
+ struct weston_output,
+ link)->width;
+   drmModeFreeConnector(connector);
+   }
+   wl_array_release();
 
if (wl_list_empty(>compositor->output_list)) {
weston_log("No currently active connector found.\n");
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] configure: Add an option to disable tests.

2016-03-24 Thread Emmanuel Gil Peyrot
This makes LTO builds compile, and also reduces the build time.
---
 Makefile.am  | 2 ++
 configure.ac | 8 
 2 files changed, 10 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index d1644ac..08a18eb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1073,6 +1073,7 @@ libzunitcmain_la_LIBADD = \
 # tests subdirectory
 #
 
+if ENABLE_TESTS
 TESTS = $(internal_tests) $(shared_tests) $(module_tests) $(weston_tests) 
$(ivi_tests)
 
 internal_tests =   \
@@ -1371,6 +1372,7 @@ surface_screenshot_la_LIBADD = $(COMPOSITOR_LIBS) 
libshared.la
 surface_screenshot_la_LDFLAGS = $(test_module_ldflags)
 surface_screenshot_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
 surface_screenshot_la_SOURCES = tests/surface-screenshot.c
+endif # ENABLE_TESTS
 
 
 #
diff --git a/configure.ac b/configure.ac
index 9e8115a..17ed666 100644
--- a/configure.ac
+++ b/configure.ac
@@ -516,6 +516,12 @@ AS_IF([test "x$have_systemd_login_209" = "xyes"],
   [AC_DEFINE([HAVE_SYSTEMD_LOGIN_209], [1], [Have systemd-login >= 209])])
 
 
+AC_ARG_ENABLE(tests,
+  AS_HELP_STRING([--disable-tests],
+ [do not build tests]))
+AM_CONDITIONAL([ENABLE_TESTS],
+   [test x$enable_tests != xno])
+
 # Note that other features might want libxml2, or this feature might use
 # alternative xml libraries at some point. Therefore the feature and
 # pre-requisite concepts are split.
@@ -677,6 +683,8 @@ AC_MSG_RESULT([
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
Screen Sharing  ${enable_screen_sharing}
+
+   Enable tests${enable_tests}
JUnit XML output${enable_junit_xml}
 
Raspberry Pi BCM headers${have_bcm_host}
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v2 2/2] configure: Make jpeglib an optional dependency.

2016-02-24 Thread Emmanuel Gil Peyrot
On Wed, Feb 17, 2016 at 11:04:16AM -0800, Bryce Harrington wrote:
> On Wed, Feb 17, 2016 at 12:28:48PM +0100, Emmanuel Gil Peyrot wrote:
> > On Tue, Feb 16, 2016 at 10:29:34PM -0800, Bryce Harrington wrote:
> > > On Tue, Feb 16, 2016 at 01:57:52AM +0000, Emmanuel Gil Peyrot wrote:
> > > > It doesn’t make sense to fail the entire build when jpeglib isn’t
> > > > present, so this commit makes it optional just like libwebp in the
> > > > previous one, disabled with --without-jpeg and forced with --with-jpeg.
> > > > 
> > > > Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
> > > 
> > > Is there any functional loss when jpg support is missing?
> > 
> > Yes, Weston as a whole loses the ability to load JPEG files, be it in
> > weston-image, in icons, or maybe more importantly in the background.
> > 
> > There is no JPEG image being installed by Weston though, so only
> > user-installed images would break.
> 
> Ok, yeah that's about what you'd expect.  The patch looks technically
> fine to me, and presuming there's no other more fundamental lossage
> involved here:
> 
> Reviewed-by: Bryce Harrington <br...@osg.samsung.com>
> 
> Out of curiousity does this solve a particular issue you're aware of, or
> is this just for symmetry with the webp build control?

While packaging weston for some distribution, I found out that it
failed to compile when jpeglib wasn’t present, and didn’t see any
reason for it.

WebP was actually the one I modified for symmetry, and because it’s
much nicer to be able to control the dependencies which gets compiled
in. :)

> 
> Bryce

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v2 2/2] configure: Make jpeglib an optional dependency.

2016-02-17 Thread Emmanuel Gil Peyrot
On Tue, Feb 16, 2016 at 10:29:34PM -0800, Bryce Harrington wrote:
> On Tue, Feb 16, 2016 at 01:57:52AM +0000, Emmanuel Gil Peyrot wrote:
> > It doesn’t make sense to fail the entire build when jpeglib isn’t
> > present, so this commit makes it optional just like libwebp in the
> > previous one, disabled with --without-jpeg and forced with --with-jpeg.
> > 
> > Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
> 
> Is there any functional loss when jpg support is missing?

Yes, Weston as a whole loses the ability to load JPEG files, be it in
weston-image, in icons, or maybe more importantly in the background.

There is no JPEG image being installed by Weston though, so only
user-installed images would break.

[snip]

-- 
Emmanuel Gil Peyrot
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 2/2] configure: Make jpeglib an optional dependency.

2016-02-15 Thread Emmanuel Gil Peyrot
It doesn’t make sense to fail the entire build when jpeglib isn’t
present, so this commit makes it optional just like libwebp in the
previous one, disabled with --without-jpeg and forced with --with-jpeg.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
Changes since v1:
- Added a --without-jpeg and a --with-jpeg options
- Added an error message when trying to load a JPEG file with jpeglig
  disabled.

I also chose to use auto by default instead of yes, as it makes the
most sense when building anywhere, the other option of having the build
fail with a message asking the user to pass --without-jpeg didn’t seem
appealing.

 configure.ac  | 23 ++-
 shared/image-loader.c | 30 +++---
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index 878b30a..e8689bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -294,6 +294,19 @@ fi
 PKG_CHECK_MODULES(PIXMAN, [pixman-1])
 PKG_CHECK_MODULES(PNG, [libpng])
 
+AC_ARG_WITH([jpeg],
+AS_HELP_STRING([--without-jpeg],
+   [Use jpeglib for JPEG decoding support 
[default=auto]]))
+AS_IF([test "x$with_jpeg" != "xno"],
+  [AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpeglib=yes], 
[have_jpeglib=no])],
+  [have_jpeglib=no])
+AS_IF([test "x$have_jpeglib" = "xyes"],
+  [JPEG_LIBS="-ljpeg"
+   AC_SUBST([JPEG_LIBS])
+   AC_DEFINE([HAVE_JPEG], [1], [Have jpeglib])],
+  [AS_IF([test "x$with_jpeg" = "xyes"],
+ [AC_MSG_ERROR([JPEG support explicitly requested, but jpeglib 
couldn't be found])])])
+
 AC_ARG_WITH([webp],
 AS_HELP_STRING([--without-webp],
[Use libwebp for WebP decoding support 
[default=auto]]))
@@ -318,15 +331,6 @@ if test x$enable_vaapi_recorder != xno; then
 fi
 AM_CONDITIONAL(ENABLE_VAAPI_RECORDER, test "x$have_libva" = xyes)
 
-
-AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], have_jpeglib=yes)
-if test x$have_jpeglib = xyes; then
-  JPEG_LIBS="-ljpeg"
-else
-  AC_ERROR([libjpeg not found])
-fi
-AC_SUBST(JPEG_LIBS)
-
 PKG_CHECK_MODULES(CAIRO, [cairo])
 
 PKG_CHECK_MODULES(TEST_CLIENT, [wayland-client >= 1.9.91])
@@ -684,6 +688,7 @@ AC_MSG_RESULT([
 
Colord Support  ${have_colord}
LCMS2 Support   ${have_lcms}
+   libjpeg Support ${have_jpeglib}
libwebp Support ${have_webp}
libunwind Support   ${have_libunwind}
VA H.264 encoding Support   ${have_libva}
diff --git a/shared/image-loader.c b/shared/image-loader.c
index 050f067..f477dfd 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -30,13 +30,16 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include "shared/helpers.h"
 #include "image-loader.h"
 
+#ifdef HAVE_JPEG
+#include 
+#endif
+
 #ifdef HAVE_WEBP
 #include 
 #endif
@@ -48,6 +51,14 @@ stride_for_width(int width)
 }
 
 static void
+pixman_image_destroy_func(pixman_image_t *image, void *data)
+{
+   free(data);
+}
+
+#ifdef HAVE_JPEG
+
+static void
 swizzle_row(JSAMPLE *row, JDIMENSION width)
 {
JSAMPLE *s;
@@ -68,12 +79,6 @@ error_exit(j_common_ptr cinfo)
longjmp(cinfo->client_data, 1);
 }
 
-static void
-pixman_image_destroy_func(pixman_image_t *image, void *data)
-{
-   free(data);
-}
-
 static pixman_image_t *
 load_jpeg(FILE *fp)
 {
@@ -132,6 +137,17 @@ load_jpeg(FILE *fp)
return pixman_image;
 }
 
+#else
+
+static pixman_image_t *
+load_jpeg(FILE *fp)
+{
+   fprintf(stderr, "JPEG support disabled at compile-time\n");
+   return NULL;
+}
+
+#endif
+
 static inline int
 multiply_alpha(int alpha, int color)
 {
-- 
2.7.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 1/2] configure: Make WebP support togglable, and improve its error message.

2016-02-15 Thread Emmanuel Gil Peyrot
The current way was enabling WebP support whenever libwebp was found,
giving no way to the user to disable it if they had the library
installed but didn’t want to link against it.  This adds a
--without-webp configure option to never link against it, and a
--with-webp one to fail the build if it isn’t found, the default being
to use it if it is present.

Additionally, we now tell the user when WebP support has been disabled
and they try to load a WebP file.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 configure.ac  | 12 ++--
 shared/image-loader.c | 11 +--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index c32ddc9..878b30a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,9 +293,17 @@ fi
 
 PKG_CHECK_MODULES(PIXMAN, [pixman-1])
 PKG_CHECK_MODULES(PNG, [libpng])
-PKG_CHECK_MODULES(WEBP, [libwebp], [have_webp=yes], [have_webp=no])
+
+AC_ARG_WITH([webp],
+AS_HELP_STRING([--without-webp],
+   [Use libwebp for WebP decoding support 
[default=auto]]))
+AS_IF([test "x$with_webp" != "xno"],
+  [PKG_CHECK_MODULES(WEBP, [libwebp], [have_webp=yes], [have_webp=no])],
+  [have_webp=no])
 AS_IF([test "x$have_webp" = "xyes"],
-  [AC_DEFINE([HAVE_WEBP], [1], [Have webp])])
+  [AC_DEFINE([HAVE_WEBP], [1], [Have webp])],
+  [AS_IF([test "x$with_webp" = "xyes"],
+ [AC_MSG_ERROR([WebP support explicitly requested, but libwebp 
couldn't be found])])])
 
 AC_ARG_ENABLE(vaapi-recorder, [  --enable-vaapi-recorder],,
  enable_vaapi_recorder=auto)
diff --git a/shared/image-loader.c b/shared/image-loader.c
index ec75bd4..050f067 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -352,6 +352,15 @@ load_webp(FILE *fp)
config.output.u.RGBA.stride);
 }
 
+#else
+
+static pixman_image_t *
+load_webp(FILE *fp)
+{
+   fprintf(stderr, "WebP support disabled at compile-time\n");
+   return NULL;
+}
+
 #endif
 
 
@@ -364,9 +373,7 @@ struct image_loader {
 static const struct image_loader loaders[] = {
{ { 0x89, 'P', 'N', 'G' }, 4, load_png },
{ { 0xff, 0xd8 }, 2, load_jpeg },
-#ifdef HAVE_WEBP
{ { 'R', 'I', 'F', 'F' }, 4, load_webp }
-#endif
 };
 
 pixman_image_t *
-- 
2.7.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] configure: Make libjpeg an optional dependency

2016-02-05 Thread Emmanuel Gil Peyrot
libjpeg is only used in shared/image-loader.c in weston, like libwebp
it doesn’t make sense to fail the entire build if it isn’t present, for
any reason.

I kept libpng a hard dependency in the image-loader because so many
other parts of weston depend on PNG, it is already mandatory from
everywhere else.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
---
 configure.ac  |  8 
 shared/image-loader.c | 23 ---
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index bff6380..c42e32b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,13 +311,12 @@ fi
 AM_CONDITIONAL(ENABLE_VAAPI_RECORDER, test "x$have_libva" = xyes)
 
 
-AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], have_jpeglib=yes)
+AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpeglib=yes], 
[have_jpeglib=no])
 if test x$have_jpeglib = xyes; then
   JPEG_LIBS="-ljpeg"
-else
-  AC_ERROR([libjpeg not found])
+  AC_SUBST(JPEG_LIBS)
+  AC_DEFINE([HAVE_JPEG], [1], [Have jpeg])
 fi
-AC_SUBST(JPEG_LIBS)
 
 PKG_CHECK_MODULES(CAIRO, [cairo])
 
@@ -676,6 +675,7 @@ AC_MSG_RESULT([
 
Colord Support  ${have_colord}
LCMS2 Support   ${have_lcms}
+   libjpeg Support ${have_jpeglib}
libwebp Support ${have_webp}
libunwind Support   ${have_libunwind}
VA H.264 encoding Support   ${have_libva}
diff --git a/shared/image-loader.c b/shared/image-loader.c
index ec75bd4..e6c0c7d 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -30,13 +30,16 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include "shared/helpers.h"
 #include "image-loader.h"
 
+#ifdef HAVE_JPEG
+#include 
+#endif
+
 #ifdef HAVE_WEBP
 #include 
 #endif
@@ -48,6 +51,14 @@ stride_for_width(int width)
 }
 
 static void
+pixman_image_destroy_func(pixman_image_t *image, void *data)
+{
+   free(data);
+}
+
+#ifdef HAVE_JPEG
+
+static void
 swizzle_row(JSAMPLE *row, JDIMENSION width)
 {
JSAMPLE *s;
@@ -68,12 +79,6 @@ error_exit(j_common_ptr cinfo)
longjmp(cinfo->client_data, 1);
 }
 
-static void
-pixman_image_destroy_func(pixman_image_t *image, void *data)
-{
-   free(data);
-}
-
 static pixman_image_t *
 load_jpeg(FILE *fp)
 {
@@ -132,6 +137,8 @@ load_jpeg(FILE *fp)
return pixman_image;
 }
 
+#endif
+
 static inline int
 multiply_alpha(int alpha, int color)
 {
@@ -363,7 +370,9 @@ struct image_loader {
 
 static const struct image_loader loaders[] = {
{ { 0x89, 'P', 'N', 'G' }, 4, load_png },
+#ifdef HAVE_JPEG
{ { 0xff, 0xd8 }, 2, load_jpeg },
+#endif
 #ifdef HAVE_WEBP
{ { 'R', 'I', 'F', 'F' }, 4, load_webp }
 #endif
-- 
2.7.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] clients: fix build on Linux

2016-01-14 Thread Emmanuel Gil Peyrot
On Thu, Jan 14, 2016 at 02:46:14PM +0100, Olivier Fourdan wrote:
> Cannot find out why stropts.h is needed and Linux doesn't support
> streams anyway, so there is no stropts.h.

POSIX.1-2008 (and likely prior versions), and thus Linux as well,
define ioctl() in this header, so it seems strange it doesn’t exist on
your system.

Linux also defines it in sys/ioctl.h, do you think we should be using
this one instead of the portable header?

Cheers,

-- 
Emmanuel Gil Peyrot
Collabora Ltd.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v3 3/5] clients: rename simple-dmabuf into simple-dmabuf-intel

2016-01-11 Thread Emmanuel Gil Peyrot
This client was using an Intel-specific way to allocate a dmabuf, so it
makes sense to have that in its name.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Differential Revision: https://phabricator.freedesktop.org/D342
---
Just rebased against master, no other difference.

 .gitignore|   2 +-
 Makefile.am   |  12 +-
 clients/simple-dmabuf-intel.c | 591 ++
 clients/simple-dmabuf.c   | 591 --
 configure.ac  |  20 +-
 5 files changed, 608 insertions(+), 608 deletions(-)
 create mode 100644 clients/simple-dmabuf-intel.c
 delete mode 100644 clients/simple-dmabuf.c

diff --git a/.gitignore b/.gitignore
index 11d23da..719054d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,7 +66,7 @@ weston-nested-client
 weston-presentation-shm
 weston-resizor
 weston-scaler
-weston-simple-dmabuf
+weston-simple-dmabuf-intel
 weston-simple-egl
 weston-simple-shm
 weston-simple-touch
diff --git a/Makefile.am b/Makefile.am
index cbb3b57..1eb66ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -523,18 +523,18 @@ weston_simple_egl_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_EGL_CLIENT_CFLAGS)
 weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
 endif
 
-if BUILD_SIMPLE_INTEL_DMABUF_CLIENT
-demo_clients += weston-simple-dmabuf
-weston_simple_dmabuf_SOURCES = clients/simple-dmabuf.c
-nodist_weston_simple_dmabuf_SOURCES =  \
+if BUILD_SIMPLE_DMABUF_INTEL_CLIENT
+demo_clients += weston-simple-dmabuf-intel
+weston_simple_dmabuf_intel_SOURCES = clients/simple-dmabuf-intel.c
+nodist_weston_simple_dmabuf_intel_SOURCES =\
protocol/xdg-shell-unstable-v5-protocol.c   \
protocol/xdg-shell-unstable-v5-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
-weston_simple_dmabuf_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_CLIENT_CFLAGS)
-weston_simple_dmabuf_LDADD = $(SIMPLE_DMABUF_CLIENT_LIBS) libshared.la
+weston_simple_dmabuf_intel_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_INTEL_CLIENT_CFLAGS)
+weston_simple_dmabuf_intel_LDADD = $(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) 
libshared.la
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
new file mode 100644
index 000..f371d80
--- /dev/null
+++ b/clients/simple-dmabuf-intel.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright © 2011 Benjamin Franzke
+ * Copyright © 2010 Intel Corporation
+ * Copyright © 2014 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+struct display {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct xdg_shell *shell;
+   struct zwp_fullscreen_shell_v1 *fshell;
+   struct zwp_linux_dmabuf_v1 *dmabuf;
+   int xrgb_format_found;
+};
+
+struct buffer {
+   struct wl_buffer *buffer;
+   int busy;
+
+   int drm_fd;
+
+   drm_intel_bufmgr *bufmgr;
+   drm_intel_bo *bo;
+
+   uint32_t gem_handle;
+

[PATCH weston v3 4/5] clients: Fix a few issues in simple-dmabuf-intel

2016-01-11 Thread Emmanuel Gil Peyrot
Those were found while working on simple-dmabuf-v4l, as found in the
next patch of this series.

After each buffer’s params were ready to be submitted to the
compositor, a roundtrip was done, which is wasteful since we can do it
only once after having queued all the params we want.  Removing those
nested roundtrips also prevent the potentially dangerous side-effect of
calling callbacks for later events while previous events were still
being processed.

An extraneous surface damage was also removed.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Differential Revision: https://phabricator.freedesktop.org/D344
---
Just rebased against master, no other difference.

 clients/simple-dmabuf-intel.c | 41 +++--
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index f371d80..0ceefeb 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -35,9 +35,9 @@
 #include 
 
 #include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include "xdg-shell-unstable-v5-client-protocol.h"
@@ -204,6 +204,7 @@ create_failed(void *data, struct zwp_linux_buffer_params_v1 
*params)
struct buffer *buffer = data;
 
buffer->buffer = NULL;
+   running = 0;
 
zwp_linux_buffer_params_v1_destroy(params);
 
@@ -274,13 +275,6 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
  DRM_FORMAT_XRGB,
  flags);
 
-   /* params is destroyed by the event handlers */
-
-   wl_display_roundtrip(display->display);
-   if (buffer->buffer == NULL) {
-   goto error2;
-   }
-
return 0;
 
 error2:
@@ -313,6 +307,8 @@ static struct window *
 create_window(struct display *display, int width, int height)
 {
struct window *window;
+   int i;
+   int ret;
 
window = calloc(1, sizeof *window);
if (!window)
@@ -344,6 +340,14 @@ create_window(struct display *display, int width, int 
height)
assert(0);
}
 
+   for (i = 0; i < 2; ++i) {
+   ret = create_dmabuf_buffer(display, >buffers[i],
+  width, height);
+
+   if (ret < 0)
+   return NULL;
+   }
+
return window;
 }
 
@@ -375,7 +379,6 @@ static struct buffer *
 window_next_buffer(struct window *window)
 {
struct buffer *buffer;
-   int ret = 0;
 
if (!window->buffers[0].busy)
buffer = >buffers[0];
@@ -384,14 +387,6 @@ window_next_buffer(struct window *window)
else
return NULL;
 
-   if (!buffer->buffer) {
-   ret = create_dmabuf_buffer(window->display, buffer,
-  window->width, window->height);
-
-   if (ret < 0)
-   return NULL;
-   }
-
return buffer;
 }
 
@@ -574,9 +569,11 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, , NULL);
 
-   /* Initialise damage to full surface, so the padding gets painted */
-   wl_surface_damage(window->surface, 0, 0,
- window->width, window->height);
+   /* Here we retrieve the linux-dmabuf objects, or error */
+   wl_display_roundtrip(display->display);
+
+   if (!running)
+   return 1;
 
redraw(window, NULL, 0);
 
-- 
2.7.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v3 5/5] clients: add simple-v4l-dmabuf client

2016-01-11 Thread Emmanuel Gil Peyrot
This client opens a V4L2 device, usually exposed as /dev/videoN, and
retrieves its frames as dmabuf for later import into the compositor.

It supports both single- and multi-planar devices, and any format
exposed by the V4L2 device the Wayland compositor accepts.

This client never changes the v4l2 settings, use `v4l2-ctl -c` if you
want to change those.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Acked-by: Derek Foreman <der...@osg.samsung.com>

Maniphest Tasks: T90

Differential Revision: https://phabricator.freedesktop.org/D339
---
Just rebased against master, no other difference.

 .gitignore  |   1 +
 Makefile.am |  15 +
 clients/simple-dmabuf-v4l.c | 945 
 configure.ac|  14 +
 4 files changed, 975 insertions(+)
 create mode 100644 clients/simple-dmabuf-v4l.c

diff --git a/.gitignore b/.gitignore
index 719054d..dfbb4d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@ weston-presentation-shm
 weston-resizor
 weston-scaler
 weston-simple-dmabuf-intel
+weston-simple-dmabuf-v4l
 weston-simple-egl
 weston-simple-shm
 weston-simple-touch
diff --git a/Makefile.am b/Makefile.am
index 1eb66ae..623621d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -538,6 +538,21 @@ weston_simple_dmabuf_intel_LDADD = 
$(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) libshared.
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
+if BUILD_SIMPLE_DMABUF_V4L_CLIENT
+demo_clients += weston-simple-dmabuf-v4l
+weston_simple_dmabuf_v4l_SOURCES = clients/simple-dmabuf-v4l.c
+nodist_weston_simple_dmabuf_v4l_SOURCES =  \
+   protocol/xdg-shell-unstable-v5-protocol.c   \
+   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/fullscreen-shell-unstable-v1-protocol.c\
+   protocol/fullscreen-shell-unstable-v1-client-protocol.h \
+   protocol/linux-dmabuf-unstable-v1-protocol.c \
+   protocol/linux-dmabuf-unstable-v1-client-protocol.h
+weston_simple_dmabuf_v4l_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_V4L_CLIENT_CFLAGS)
+weston_simple_dmabuf_v4l_LDADD = $(SIMPLE_DMABUF_V4L_CLIENT_LIBS) libshared.la
+BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
+endif
+
 noinst_LTLIBRARIES += libtoytoolkit.la
 
 libtoytoolkit_la_SOURCES = \
diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
new file mode 100644
index 000..2334e09
--- /dev/null
+++ b/clients/simple-dmabuf-v4l.c
@@ -0,0 +1,945 @@
+/*
+ * Copyright © 2015 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+#define CLEAR(x) memset(&(x), 0, sizeof(x))
+
+static int
+xioctl(int fh, int request, void *arg)
+{
+   int r;
+
+   do {
+   r = ioctl(fh, request, arg);
+   } while (r == -1 && errno == EINTR);
+
+   return r;
+}
+
+static uint32_t
+parse_format(const char fmt[4])
+{
+   return fourcc_code(fmt[0], fmt[1], fmt[2], fmt[3]);
+}
+
+static inline const char *
+dump_format(uint32_t format, char out[4])
+{
+#if BYTE_ORDER == BIG_ENDIAN
+   format = __builtin_bswap32(format);
+#endif
+   memcpy(out, , 4);
+   return out;
+}
+
+struct buffer_format {
+   int width;
+   int height;
+   enum v4l2_buf_type type;
+   uint32_t format;
+
+   unsigned num_planes;
+   unsigned strides[VIDEO_MAX_PLA

[PATCH weston v3 2/5] gl-renderer: Add support for a few YUV dmabuf formats

2016-01-11 Thread Emmanuel Gil Peyrot
Namely the single-planar YUYV, the two-planar NV12, and the
three-planar YUV420, using the shaders already present in Weston.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Maniphest Tasks: T13

Differential Revision: https://phabricator.freedesktop.org/D334
---
Rebased against master, and added the DRM_FORMAT_R8 and DRM_FORMAT_GR88
#defines that were missing from libdrm’s drm_fourcc.h.

 src/gl-renderer.c | 295 ++
 1 file changed, 252 insertions(+), 43 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d4d9287..0ee2075 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -101,11 +101,36 @@ struct egl_image {
int refcount;
 };
 
+enum import_type {
+   IMPORT_TYPE_INVALID,
+   IMPORT_TYPE_DIRECT,
+   IMPORT_TYPE_GL_CONVERSION
+};
+
 struct dmabuf_image {
struct linux_dmabuf_buffer *dmabuf;
int num_images;
struct egl_image *images[3];
struct wl_list link;
+
+   enum import_type import_type;
+   GLenum target;
+   struct gl_shader *shader;
+};
+
+struct yuv_plane_descriptor {
+   int width_divisor;
+   int height_divisor;
+   uint32_t format;
+   int plane_index;
+};
+
+struct yuv_format_descriptor {
+   uint32_t format;
+   int input_planes;
+   int output_planes;
+   int texture_type;
+   struct yuv_plane_descriptor plane[4];
 };
 
 struct gl_surface_state {
@@ -1517,25 +1542,219 @@ import_simple_dmabuf(struct gl_renderer *gr,
return image;
 }
 
+/* The kernel header drm_fourcc.h defines the DRM formats below.  We duplicate
+ * some of the definitions here so that building Weston won't require
+ * bleeding-edge kernel headers.
+ */
+#ifndef DRM_FORMAT_R8
+#define DRM_FORMAT_R8fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
+#endif
+
+#ifndef DRM_FORMAT_GR88
+#define DRM_FORMAT_GR88  fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 
8:8 little endian */
+#endif
+
+struct yuv_format_descriptor yuv_formats[] = {
+   {
+   .format = DRM_FORMAT_YUYV,
+   .input_planes = 1,
+   .output_planes = 2,
+   .texture_type = EGL_TEXTURE_Y_XUXV_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_GR88,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_ARGB,
+   .plane_index = 0
+   }}
+   }, {
+   .format = DRM_FORMAT_NV12,
+   .input_planes = 2,
+   .output_planes = 2,
+   .texture_type = EGL_TEXTURE_Y_UV_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_GR88,
+   .plane_index = 1
+   }}
+   }, {
+   .format = DRM_FORMAT_YUV420,
+   .input_planes = 3,
+   .output_planes = 3,
+   .texture_type = EGL_TEXTURE_Y_U_V_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 1
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 2
+   }}
+   }
+};
+
+static struct egl_image *
+import_dmabuf_single_plane(struct gl_renderer *gr,
+   const struct dmabuf_attributes *attributes,
+   struct yuv_plane_descriptor *descriptor)
+{
+   struct dmabuf_attributes plane;
+   struct egl_image *image;
+   char fmt[4];
+
+   plane.width = attributes->width / descriptor->width_divisor;
+   plane.height = attributes->height / descriptor->height_divisor;
+   plane.format = descriptor->format;
+   plane.n_planes = 1;
+   plane.fd[0] = attributes->fd[descriptor->plane_index];
+   plane.offset[0] = attributes->offset[descriptor->plane_index];
+   plane.stride[0] = attributes->stride[descriptor->plane_index];
+   plane.modifier[0] = attributes->modifier[descriptor->plan

[PATCH weston v3 1/5] gl-renderer: introduce a new struct dmabuf_image

2016-01-11 Thread Emmanuel Gil Peyrot
This struct serves as renderer data for linux-dmabuf buffers, and can
contain multiple struct egl_image, simplifying this latter in the
common non-dmabuf case.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Differential Revision: https://phabricator.freedesktop.org/D333
---
Just rebased against master, no other difference.

 src/gl-renderer.c | 171 --
 1 file changed, 113 insertions(+), 58 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d5356b6..d4d9287 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -99,9 +99,12 @@ struct egl_image {
struct gl_renderer *renderer;
EGLImageKHR image;
int refcount;
+};
 
-   /* Only used for dmabuf imported buffer */
+struct dmabuf_image {
struct linux_dmabuf_buffer *dmabuf;
+   int num_images;
+   struct egl_image *images[3];
struct wl_list link;
 };
 
@@ -191,6 +194,16 @@ struct gl_renderer {
 
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
 
+static inline const char *
+dump_format(uint32_t format, char out[4])
+{
+#if BYTE_ORDER == BIG_ENDIAN
+   format = __builtin_bswap32(format);
+#endif
+   memcpy(out, , 4);
+   return out;
+}
+
 static inline struct gl_output_state *
 get_output_state(struct weston_output *output)
 {
@@ -222,7 +235,6 @@ egl_image_create(struct gl_renderer *gr, EGLenum target,
struct egl_image *img;
 
img = zalloc(sizeof *img);
-   wl_list_init(>link);
img->renderer = gr;
img->refcount = 1;
img->image = gr->create_image(gr->egl_display, EGL_NO_CONTEXT,
@@ -255,16 +267,37 @@ egl_image_unref(struct egl_image *image)
if (image->refcount > 0)
return image->refcount;
 
-   if (image->dmabuf)
-   linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
-
gr->destroy_image(gr->egl_display, image->image);
-   wl_list_remove(>link);
free(image);
 
return 0;
 }
 
+static struct dmabuf_image*
+dmabuf_image_create(void)
+{
+   struct dmabuf_image *img;
+
+   img = zalloc(sizeof *img);
+   wl_list_init(>link);
+
+   return img;
+}
+
+static void
+dmabuf_image_destroy(struct dmabuf_image *image)
+{
+   int i;
+
+   for (i = 0; i < image->num_images; ++i)
+   egl_image_unref(image->images[i]);
+
+   if (image->dmabuf)
+   linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
+
+   wl_list_remove(>link);
+}
+
 static const char *
 egl_error_string(EGLint code)
 {
@@ -1420,23 +1453,19 @@ gl_renderer_attach_egl(struct weston_surface *es, 
struct weston_buffer *buffer,
 static void
 gl_renderer_destroy_dmabuf(struct linux_dmabuf_buffer *dmabuf)
 {
-   struct egl_image *image = dmabuf->user_data;
+   struct dmabuf_image *image = dmabuf->user_data;
 
-   egl_image_unref(image);
+   dmabuf_image_destroy(image);
 }
 
 static struct egl_image *
-import_dmabuf(struct gl_renderer *gr,
- struct linux_dmabuf_buffer *dmabuf)
+import_simple_dmabuf(struct gl_renderer *gr,
+ struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
EGLint attribs[30];
int atti = 0;
 
-   image = linux_dmabuf_buffer_get_user_data(dmabuf);
-   if (image)
-   return egl_image_ref(image);
-
/* This requires the Mesa commit in
 * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or
 * Mesa 10.2.7 (55d28925e6109a4afd61f109e845a8a51bd17652).
@@ -1446,38 +1475,38 @@ import_dmabuf(struct gl_renderer *gr,
 */
 
attribs[atti++] = EGL_WIDTH;
-   attribs[atti++] = dmabuf->attributes.width;
+   attribs[atti++] = attributes->width;
attribs[atti++] = EGL_HEIGHT;
-   attribs[atti++] = dmabuf->attributes.height;
+   attribs[atti++] = attributes->height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
-   attribs[atti++] = dmabuf->attributes.format;
+   attribs[atti++] = attributes->format;
/* XXX: Add modifier here when supported */
 
-   if (dmabuf->attributes.n_planes > 0) {
+   if (attributes->n_planes > 0) {
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
-   attribs[atti++] = dmabuf->attributes.fd[0];
+   attribs[atti++] = attributes->fd[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
-   attribs[atti++] = dmabuf->attributes.offset[0];
+   attribs[atti++] = attributes->offset[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
-   attribs[atti++] = 

Re: [PATCH] test: add make check

2015-12-21 Thread Emmanuel Gil Peyrot
On Mon, Dec 21, 2015 at 02:48:49PM -0600, Derek Foreman wrote:
> We can now test all the protocol files by running make check (or distcheck)
> which will pass them through the scanner.
> 
> Signed-off-by: Derek Foreman <der...@osg.samsung.com>
> ---
>  .gitignore   | 3 +++
>  Makefile.am  | 6 ++
>  test/scan.sh | 5 +
>  3 files changed, 14 insertions(+)
>  create mode 100755 test/scan.sh
> 
> diff --git a/.gitignore b/.gitignore
> index e6f85d0..ca19ecf 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -9,3 +9,6 @@ missing
>  *.pc
>  autom4te.cache
>  aclocal.m4
> +*.trs
> +*.log
> +test-driver
> diff --git a/Makefile.am b/Makefile.am
> index 5926a41..3a88c39 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -16,3 +16,9 @@ dist_noinst_DATA =  
> \
>   $(NULL)
>  
>  noarch_pkgconfig_DATA = wayland-protocols.pc
> +
> +EXTRA_DIST = test/scan.sh
> +
> +TESTS = $(unstable_protocols)
> +TEST_EXTENSIONS = .xml
> +XML_LOG_COMPILER = $(srcdir)/test/scan.sh
> diff --git a/test/scan.sh b/test/scan.sh
> new file mode 100755
> index 000..dc3dfc0
> --- /dev/null
> +++ b/test/scan.sh
> @@ -0,0 +1,5 @@
> +#!/bin/bash

You should use /bin/sh instead, as you are not using any bash feature.

If you add the -e option to the shebang, you can also drop the && on
the next lines and the script will exit on any command not returning 0.

> +
> +wayland-scanner client-header $1 /dev/null &&
> +wayland-scanner server-header $1 /dev/null &&
> +wayland-scanner code $1 /dev/null
> --
> 2.6.4

With that done,
Reviewed-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>

Btw, shouldn’t the ML add a Reply-To field in the header to make the
MUA ask to answer it directly?  And sorry Derek for the double mail.

-- 
Emmanuel Gil Peyrot


signature.asc
Description: PGP signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 5/5] clients: add simple-v4l-dmabuf client

2015-12-10 Thread Emmanuel Gil Peyrot
This client opens a V4L2 device, usually exposed as /dev/videoN, and
retrieves its frames as dmabuf for later import into the compositor.

It supports both single- and multi-planar devices, and any format
exposed by the V4L2 device the Wayland compositor accepts.

This client never changes the v4l2 settings, use `v4l2-ctl -c` if you
want to change those.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Acked-by: Derek Foreman <der...@osg.samsung.com>

Maniphest Tasks: T90

Differential Revision: https://phabricator.freedesktop.org/D339
---
 .gitignore  |   1 +
 Makefile.am |  15 +
 clients/simple-dmabuf-v4l.c | 945 
 configure.ac|  14 +
 4 files changed, 975 insertions(+)
 create mode 100644 clients/simple-dmabuf-v4l.c

diff --git a/.gitignore b/.gitignore
index 719054d..dfbb4d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@ weston-presentation-shm
 weston-resizor
 weston-scaler
 weston-simple-dmabuf-intel
+weston-simple-dmabuf-v4l
 weston-simple-egl
 weston-simple-shm
 weston-simple-touch
diff --git a/Makefile.am b/Makefile.am
index 1eb66ae..623621d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -538,6 +538,21 @@ weston_simple_dmabuf_intel_LDADD = 
$(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) libshared.
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
+if BUILD_SIMPLE_DMABUF_V4L_CLIENT
+demo_clients += weston-simple-dmabuf-v4l
+weston_simple_dmabuf_v4l_SOURCES = clients/simple-dmabuf-v4l.c
+nodist_weston_simple_dmabuf_v4l_SOURCES =  \
+   protocol/xdg-shell-unstable-v5-protocol.c   \
+   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/fullscreen-shell-unstable-v1-protocol.c\
+   protocol/fullscreen-shell-unstable-v1-client-protocol.h \
+   protocol/linux-dmabuf-unstable-v1-protocol.c \
+   protocol/linux-dmabuf-unstable-v1-client-protocol.h
+weston_simple_dmabuf_v4l_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_V4L_CLIENT_CFLAGS)
+weston_simple_dmabuf_v4l_LDADD = $(SIMPLE_DMABUF_V4L_CLIENT_LIBS) libshared.la
+BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
+endif
+
 noinst_LTLIBRARIES += libtoytoolkit.la
 
 libtoytoolkit_la_SOURCES = \
diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
new file mode 100644
index 000..2334e09
--- /dev/null
+++ b/clients/simple-dmabuf-v4l.c
@@ -0,0 +1,945 @@
+/*
+ * Copyright © 2015 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+#define CLEAR(x) memset(&(x), 0, sizeof(x))
+
+static int
+xioctl(int fh, int request, void *arg)
+{
+   int r;
+
+   do {
+   r = ioctl(fh, request, arg);
+   } while (r == -1 && errno == EINTR);
+
+   return r;
+}
+
+static uint32_t
+parse_format(const char fmt[4])
+{
+   return fourcc_code(fmt[0], fmt[1], fmt[2], fmt[3]);
+}
+
+static inline const char *
+dump_format(uint32_t format, char out[4])
+{
+#if BYTE_ORDER == BIG_ENDIAN
+   format = __builtin_bswap32(format);
+#endif
+   memcpy(out, , 4);
+   return out;
+}
+
+struct buffer_format {
+   int width;
+   int height;
+   enum v4l2_buf_type type;
+   uint32_t format;
+
+   unsigned num_planes;
+   unsigned strides[VIDEO_MAX_PLANES];
+};
+
+struct display {
+   struct wl_displa

[PATCH weston v2 4/5] clients: Fix a few issues in simple-dmabuf-intel

2015-12-10 Thread Emmanuel Gil Peyrot
Those were found while working on simple-dmabuf-v4l, as found in the
next patch of this series.

After each buffer’s params were ready to be submitted to the
compositor, a roundtrip was done, which is wasteful since we can do it
only once after having queued all the params we want.  Removing those
nested roundtrips also prevent the potentially dangerous side-effect of
calling callbacks for later events while previous events were still
being processed.

An extraneous surface damage was also removed.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Differential Revision: https://phabricator.freedesktop.org/D344
---
 clients/simple-dmabuf-intel.c | 41 +++--
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index f371d80..0ceefeb 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -35,9 +35,9 @@
 #include 
 
 #include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include "xdg-shell-unstable-v5-client-protocol.h"
@@ -204,6 +204,7 @@ create_failed(void *data, struct zwp_linux_buffer_params_v1 
*params)
struct buffer *buffer = data;
 
buffer->buffer = NULL;
+   running = 0;
 
zwp_linux_buffer_params_v1_destroy(params);
 
@@ -274,13 +275,6 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
  DRM_FORMAT_XRGB,
  flags);
 
-   /* params is destroyed by the event handlers */
-
-   wl_display_roundtrip(display->display);
-   if (buffer->buffer == NULL) {
-   goto error2;
-   }
-
return 0;
 
 error2:
@@ -313,6 +307,8 @@ static struct window *
 create_window(struct display *display, int width, int height)
 {
struct window *window;
+   int i;
+   int ret;
 
window = calloc(1, sizeof *window);
if (!window)
@@ -344,6 +340,14 @@ create_window(struct display *display, int width, int 
height)
assert(0);
}
 
+   for (i = 0; i < 2; ++i) {
+   ret = create_dmabuf_buffer(display, >buffers[i],
+  width, height);
+
+   if (ret < 0)
+   return NULL;
+   }
+
return window;
 }
 
@@ -375,7 +379,6 @@ static struct buffer *
 window_next_buffer(struct window *window)
 {
struct buffer *buffer;
-   int ret = 0;
 
if (!window->buffers[0].busy)
buffer = >buffers[0];
@@ -384,14 +387,6 @@ window_next_buffer(struct window *window)
else
return NULL;
 
-   if (!buffer->buffer) {
-   ret = create_dmabuf_buffer(window->display, buffer,
-  window->width, window->height);
-
-   if (ret < 0)
-   return NULL;
-   }
-
return buffer;
 }
 
@@ -574,9 +569,11 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, , NULL);
 
-   /* Initialise damage to full surface, so the padding gets painted */
-   wl_surface_damage(window->surface, 0, 0,
- window->width, window->height);
+   /* Here we retrieve the linux-dmabuf objects, or error */
+   wl_display_roundtrip(display->display);
+
+   if (!running)
+   return 1;
 
redraw(window, NULL, 0);
 
-- 
2.6.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 2/5] gl-renderer: Add support for a few YUV dmabuf formats

2015-12-10 Thread Emmanuel Gil Peyrot
Namely the single-planar YUYV, the two-planar NV12, and the
three-planar YUV420, using the shaders already present in Weston.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Maniphest Tasks: T13

Differential Revision: https://phabricator.freedesktop.org/D334
---
 src/gl-renderer.c | 283 +-
 1 file changed, 240 insertions(+), 43 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d4d9287..00e51ba 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -101,11 +101,36 @@ struct egl_image {
int refcount;
 };
 
+enum import_type {
+   IMPORT_TYPE_INVALID,
+   IMPORT_TYPE_DIRECT,
+   IMPORT_TYPE_GL_CONVERSION
+};
+
 struct dmabuf_image {
struct linux_dmabuf_buffer *dmabuf;
int num_images;
struct egl_image *images[3];
struct wl_list link;
+
+   enum import_type import_type;
+   GLenum target;
+   struct gl_shader *shader;
+};
+
+struct yuv_plane_descriptor {
+   int width_divisor;
+   int height_divisor;
+   uint32_t format;
+   int plane_index;
+};
+
+struct yuv_format_descriptor {
+   uint32_t format;
+   int input_planes;
+   int output_planes;
+   int texture_type;
+   struct yuv_plane_descriptor plane[4];
 };
 
 struct gl_surface_state {
@@ -1517,25 +1542,207 @@ import_simple_dmabuf(struct gl_renderer *gr,
return image;
 }
 
+struct yuv_format_descriptor yuv_formats[] = {
+   {
+   .format = DRM_FORMAT_YUYV,
+   .input_planes = 1,
+   .output_planes = 2,
+   .texture_type = EGL_TEXTURE_Y_XUXV_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_GR88,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_ARGB,
+   .plane_index = 0
+   }}
+   }, {
+   .format = DRM_FORMAT_NV12,
+   .input_planes = 2,
+   .output_planes = 2,
+   .texture_type = EGL_TEXTURE_Y_UV_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_GR88,
+   .plane_index = 1
+   }}
+   }, {
+   .format = DRM_FORMAT_YUV420,
+   .input_planes = 3,
+   .output_planes = 3,
+   .texture_type = EGL_TEXTURE_Y_U_V_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 1
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 2
+   }}
+   }
+};
+
+static struct egl_image *
+import_dmabuf_single_plane(struct gl_renderer *gr,
+   const struct dmabuf_attributes *attributes,
+   struct yuv_plane_descriptor *descriptor)
+{
+   struct dmabuf_attributes plane;
+   struct egl_image *image;
+   char fmt[4];
+
+   plane.width = attributes->width / descriptor->width_divisor;
+   plane.height = attributes->height / descriptor->height_divisor;
+   plane.format = descriptor->format;
+   plane.n_planes = 1;
+   plane.fd[0] = attributes->fd[descriptor->plane_index];
+   plane.offset[0] = attributes->offset[descriptor->plane_index];
+   plane.stride[0] = attributes->stride[descriptor->plane_index];
+   plane.modifier[0] = attributes->modifier[descriptor->plane_index];
+
+   image = import_simple_dmabuf(gr, );
+   if (!image) {
+   weston_log("Failed to import plane %d as %.4s\n",
+  descriptor->plane_index,
+  dump_format(descriptor->format, fmt));
+   return NULL;
+   }
+
+   return image;
+}
+
+static bool
+import_yuv_dmabuf(struct gl_renderer *gr,
+  struct dmabuf_image *image)
+{
+   unsigned i;
+   int j;
+   int ret;
+   struct yuv_format_descriptor *format = NULL;
+   struct dmab

[PATCH weston v2 3/5] clients: rename simple-dmabuf into simple-dmabuf-intel

2015-12-10 Thread Emmanuel Gil Peyrot
This client was using an Intel-specific way to allocate a dmabuf, so it
makes sense to have that in its name.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Differential Revision: https://phabricator.freedesktop.org/D342
---
 .gitignore|   2 +-
 Makefile.am   |  12 +-
 clients/simple-dmabuf-intel.c | 591 ++
 clients/simple-dmabuf.c   | 591 --
 configure.ac  |  20 +-
 5 files changed, 608 insertions(+), 608 deletions(-)
 create mode 100644 clients/simple-dmabuf-intel.c
 delete mode 100644 clients/simple-dmabuf.c

diff --git a/.gitignore b/.gitignore
index 11d23da..719054d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,7 +66,7 @@ weston-nested-client
 weston-presentation-shm
 weston-resizor
 weston-scaler
-weston-simple-dmabuf
+weston-simple-dmabuf-intel
 weston-simple-egl
 weston-simple-shm
 weston-simple-touch
diff --git a/Makefile.am b/Makefile.am
index cbb3b57..1eb66ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -523,18 +523,18 @@ weston_simple_egl_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_EGL_CLIENT_CFLAGS)
 weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
 endif
 
-if BUILD_SIMPLE_INTEL_DMABUF_CLIENT
-demo_clients += weston-simple-dmabuf
-weston_simple_dmabuf_SOURCES = clients/simple-dmabuf.c
-nodist_weston_simple_dmabuf_SOURCES =  \
+if BUILD_SIMPLE_DMABUF_INTEL_CLIENT
+demo_clients += weston-simple-dmabuf-intel
+weston_simple_dmabuf_intel_SOURCES = clients/simple-dmabuf-intel.c
+nodist_weston_simple_dmabuf_intel_SOURCES =\
protocol/xdg-shell-unstable-v5-protocol.c   \
protocol/xdg-shell-unstable-v5-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
-weston_simple_dmabuf_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_CLIENT_CFLAGS)
-weston_simple_dmabuf_LDADD = $(SIMPLE_DMABUF_CLIENT_LIBS) libshared.la
+weston_simple_dmabuf_intel_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_INTEL_CLIENT_CFLAGS)
+weston_simple_dmabuf_intel_LDADD = $(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) 
libshared.la
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
new file mode 100644
index 000..f371d80
--- /dev/null
+++ b/clients/simple-dmabuf-intel.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright © 2011 Benjamin Franzke
+ * Copyright © 2010 Intel Corporation
+ * Copyright © 2014 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+struct display {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct xdg_shell *shell;
+   struct zwp_fullscreen_shell_v1 *fshell;
+   struct zwp_linux_dmabuf_v1 *dmabuf;
+   int xrgb_format_found;
+};
+
+struct buffer {
+   struct wl_buffer *buffer;
+   int busy;
+
+   int drm_fd;
+
+   drm_intel_bufmgr *bufmgr;
+   drm_intel_bo *bo;
+
+   uint32_t gem_handle;
+   int dmabuf_fd;
+   uint8_t *mmap;
+
+   int w

[PATCH weston v2 1/5] gl-renderer: introduce a new struct dmabuf_image

2015-12-10 Thread Emmanuel Gil Peyrot
This struct serves as renderer data for linux-dmabuf buffers, and can
contain multiple struct egl_image, simplifying this latter in the
common non-dmabuf case.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Derek Foreman <der...@osg.samsung.com>

Differential Revision: https://phabricator.freedesktop.org/D333
---
 src/gl-renderer.c | 171 --
 1 file changed, 113 insertions(+), 58 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d5356b6..d4d9287 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -99,9 +99,12 @@ struct egl_image {
struct gl_renderer *renderer;
EGLImageKHR image;
int refcount;
+};
 
-   /* Only used for dmabuf imported buffer */
+struct dmabuf_image {
struct linux_dmabuf_buffer *dmabuf;
+   int num_images;
+   struct egl_image *images[3];
struct wl_list link;
 };
 
@@ -191,6 +194,16 @@ struct gl_renderer {
 
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
 
+static inline const char *
+dump_format(uint32_t format, char out[4])
+{
+#if BYTE_ORDER == BIG_ENDIAN
+   format = __builtin_bswap32(format);
+#endif
+   memcpy(out, , 4);
+   return out;
+}
+
 static inline struct gl_output_state *
 get_output_state(struct weston_output *output)
 {
@@ -222,7 +235,6 @@ egl_image_create(struct gl_renderer *gr, EGLenum target,
struct egl_image *img;
 
img = zalloc(sizeof *img);
-   wl_list_init(>link);
img->renderer = gr;
img->refcount = 1;
img->image = gr->create_image(gr->egl_display, EGL_NO_CONTEXT,
@@ -255,16 +267,37 @@ egl_image_unref(struct egl_image *image)
if (image->refcount > 0)
return image->refcount;
 
-   if (image->dmabuf)
-   linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
-
gr->destroy_image(gr->egl_display, image->image);
-   wl_list_remove(>link);
free(image);
 
return 0;
 }
 
+static struct dmabuf_image*
+dmabuf_image_create(void)
+{
+   struct dmabuf_image *img;
+
+   img = zalloc(sizeof *img);
+   wl_list_init(>link);
+
+   return img;
+}
+
+static void
+dmabuf_image_destroy(struct dmabuf_image *image)
+{
+   int i;
+
+   for (i = 0; i < image->num_images; ++i)
+   egl_image_unref(image->images[i]);
+
+   if (image->dmabuf)
+   linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
+
+   wl_list_remove(>link);
+}
+
 static const char *
 egl_error_string(EGLint code)
 {
@@ -1420,23 +1453,19 @@ gl_renderer_attach_egl(struct weston_surface *es, 
struct weston_buffer *buffer,
 static void
 gl_renderer_destroy_dmabuf(struct linux_dmabuf_buffer *dmabuf)
 {
-   struct egl_image *image = dmabuf->user_data;
+   struct dmabuf_image *image = dmabuf->user_data;
 
-   egl_image_unref(image);
+   dmabuf_image_destroy(image);
 }
 
 static struct egl_image *
-import_dmabuf(struct gl_renderer *gr,
- struct linux_dmabuf_buffer *dmabuf)
+import_simple_dmabuf(struct gl_renderer *gr,
+ struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
EGLint attribs[30];
int atti = 0;
 
-   image = linux_dmabuf_buffer_get_user_data(dmabuf);
-   if (image)
-   return egl_image_ref(image);
-
/* This requires the Mesa commit in
 * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or
 * Mesa 10.2.7 (55d28925e6109a4afd61f109e845a8a51bd17652).
@@ -1446,38 +1475,38 @@ import_dmabuf(struct gl_renderer *gr,
 */
 
attribs[atti++] = EGL_WIDTH;
-   attribs[atti++] = dmabuf->attributes.width;
+   attribs[atti++] = attributes->width;
attribs[atti++] = EGL_HEIGHT;
-   attribs[atti++] = dmabuf->attributes.height;
+   attribs[atti++] = attributes->height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
-   attribs[atti++] = dmabuf->attributes.format;
+   attribs[atti++] = attributes->format;
/* XXX: Add modifier here when supported */
 
-   if (dmabuf->attributes.n_planes > 0) {
+   if (attributes->n_planes > 0) {
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
-   attribs[atti++] = dmabuf->attributes.fd[0];
+   attribs[atti++] = attributes->fd[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
-   attribs[atti++] = dmabuf->attributes.offset[0];
+   attribs[atti++] = attributes->offset[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
-   attribs[atti++] = dmabuf->attributes.stride[0];
+  

[PATCH 2/6] gl-renderer: introduce a new struct dmabuf_image

2015-11-24 Thread Emmanuel Gil Peyrot
This struct serves as renderer data for linux-dmabuf buffers, and can
contain multiple struct egl_image, simplifying this latter in the
common non-dmabuf case.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D333
---
 src/gl-renderer.c | 167 +++---
 1 file changed, 109 insertions(+), 58 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d5356b6..90e4842 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -99,9 +99,12 @@ struct egl_image {
struct gl_renderer *renderer;
EGLImageKHR image;
int refcount;
+};
 
-   /* Only used for dmabuf imported buffer */
+struct dmabuf_image {
struct linux_dmabuf_buffer *dmabuf;
+   int num_images;
+   struct egl_image *images[3];
struct wl_list link;
 };
 
@@ -191,6 +194,13 @@ struct gl_renderer {
 
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
 
+static inline const char *
+dump_format(uint32_t *format)
+{
+   // FIXME: this won’t work properly on big-endian.
+   return (const char *)format;
+}
+
 static inline struct gl_output_state *
 get_output_state(struct weston_output *output)
 {
@@ -222,7 +232,6 @@ egl_image_create(struct gl_renderer *gr, EGLenum target,
struct egl_image *img;
 
img = zalloc(sizeof *img);
-   wl_list_init(>link);
img->renderer = gr;
img->refcount = 1;
img->image = gr->create_image(gr->egl_display, EGL_NO_CONTEXT,
@@ -255,16 +264,37 @@ egl_image_unref(struct egl_image *image)
if (image->refcount > 0)
return image->refcount;
 
-   if (image->dmabuf)
-   linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
-
gr->destroy_image(gr->egl_display, image->image);
-   wl_list_remove(>link);
free(image);
 
return 0;
 }
 
+static struct dmabuf_image*
+dmabuf_image_create(void)
+{
+   struct dmabuf_image *img;
+
+   img = zalloc(sizeof *img);
+   wl_list_init(>link);
+
+   return img;
+}
+
+static void
+dmabuf_image_destroy(struct dmabuf_image *image)
+{
+   int i;
+
+   for (i = 0; i < image->num_images; ++i)
+   egl_image_unref(image->images[i]);
+
+   if (image->dmabuf)
+   linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
+
+   wl_list_remove(>link);
+}
+
 static const char *
 egl_error_string(EGLint code)
 {
@@ -1420,23 +1450,19 @@ gl_renderer_attach_egl(struct weston_surface *es, 
struct weston_buffer *buffer,
 static void
 gl_renderer_destroy_dmabuf(struct linux_dmabuf_buffer *dmabuf)
 {
-   struct egl_image *image = dmabuf->user_data;
+   struct dmabuf_image *image = dmabuf->user_data;
 
-   egl_image_unref(image);
+   dmabuf_image_destroy(image);
 }
 
 static struct egl_image *
-import_dmabuf(struct gl_renderer *gr,
- struct linux_dmabuf_buffer *dmabuf)
+import_simple_dmabuf(struct gl_renderer *gr,
+ struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
EGLint attribs[30];
int atti = 0;
 
-   image = linux_dmabuf_buffer_get_user_data(dmabuf);
-   if (image)
-   return egl_image_ref(image);
-
/* This requires the Mesa commit in
 * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or
 * Mesa 10.2.7 (55d28925e6109a4afd61f109e845a8a51bd17652).
@@ -1446,38 +1472,38 @@ import_dmabuf(struct gl_renderer *gr,
 */
 
attribs[atti++] = EGL_WIDTH;
-   attribs[atti++] = dmabuf->attributes.width;
+   attribs[atti++] = attributes->width;
attribs[atti++] = EGL_HEIGHT;
-   attribs[atti++] = dmabuf->attributes.height;
+   attribs[atti++] = attributes->height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
-   attribs[atti++] = dmabuf->attributes.format;
+   attribs[atti++] = attributes->format;
/* XXX: Add modifier here when supported */
 
-   if (dmabuf->attributes.n_planes > 0) {
+   if (attributes->n_planes > 0) {
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
-   attribs[atti++] = dmabuf->attributes.fd[0];
+   attribs[atti++] = attributes->fd[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
-   attribs[atti++] = dmabuf->attributes.offset[0];
+   attribs[atti++] = attributes->offset[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
-   attribs[atti++] = dmabuf->attributes.stride[0];
+   attribs[atti++] = attributes->stride[0];
}
 
-   if (dmabuf->attributes.n_planes > 1)

[PATCH 1/6] linux-dmabuf: Move the attributes part of linux_dmabuf_buffer into its own struct

2015-11-24 Thread Emmanuel Gil Peyrot
This allows renderers to use that struct to create their own dmabufs,
in case they can’t import the one provided by the client directly but
know how to convert it into a format they can render.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D332
---
 src/compositor-drm.c | 12 +--
 src/gl-renderer.c| 50 ++--
 src/linux-dmabuf.c   | 58 ++--
 src/linux-dmabuf.h   | 14 -
 4 files changed, 69 insertions(+), 65 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index a84d869..55bc187 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -983,14 +983,14 @@ drm_output_prepare_overlay_view(struct drm_output *output,
 * support a mix of gbm_bos and drmfbs.
 */
struct gbm_import_fd_data gbm_dmabuf = {
-   .fd = dmabuf->dmabuf_fd[0],
-   .width  = dmabuf->width,
-   .height = dmabuf->height,
-   .stride = dmabuf->stride[0],
-   .format = dmabuf->format
+   .fd = dmabuf->attributes.fd[0],
+   .width  = dmabuf->attributes.width,
+   .height = dmabuf->attributes.height,
+   .stride = dmabuf->attributes.stride[0],
+   .format = dmabuf->attributes.format
};
 
-   if (dmabuf->n_planes != 1 || dmabuf->offset[0] != 0)
+   if (dmabuf->attributes.n_planes != 1 || 
dmabuf->attributes.offset[0] != 0)
return NULL;
 
bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_FD, _dmabuf,
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index ae72f32..d5356b6 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1446,38 +1446,38 @@ import_dmabuf(struct gl_renderer *gr,
 */
 
attribs[atti++] = EGL_WIDTH;
-   attribs[atti++] = dmabuf->width;
+   attribs[atti++] = dmabuf->attributes.width;
attribs[atti++] = EGL_HEIGHT;
-   attribs[atti++] = dmabuf->height;
+   attribs[atti++] = dmabuf->attributes.height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
-   attribs[atti++] = dmabuf->format;
+   attribs[atti++] = dmabuf->attributes.format;
/* XXX: Add modifier here when supported */
 
-   if (dmabuf->n_planes > 0) {
+   if (dmabuf->attributes.n_planes > 0) {
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
-   attribs[atti++] = dmabuf->dmabuf_fd[0];
+   attribs[atti++] = dmabuf->attributes.fd[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
-   attribs[atti++] = dmabuf->offset[0];
+   attribs[atti++] = dmabuf->attributes.offset[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
-   attribs[atti++] = dmabuf->stride[0];
+   attribs[atti++] = dmabuf->attributes.stride[0];
}
 
-   if (dmabuf->n_planes > 1) {
+   if (dmabuf->attributes.n_planes > 1) {
attribs[atti++] = EGL_DMA_BUF_PLANE1_FD_EXT;
-   attribs[atti++] = dmabuf->dmabuf_fd[1];
+   attribs[atti++] = dmabuf->attributes.fd[1];
attribs[atti++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT;
-   attribs[atti++] = dmabuf->offset[1];
+   attribs[atti++] = dmabuf->attributes.offset[1];
attribs[atti++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
-   attribs[atti++] = dmabuf->stride[1];
+   attribs[atti++] = dmabuf->attributes.stride[1];
}
 
-   if (dmabuf->n_planes > 2) {
+   if (dmabuf->attributes.n_planes > 2) {
attribs[atti++] = EGL_DMA_BUF_PLANE2_FD_EXT;
-   attribs[atti++] = dmabuf->dmabuf_fd[2];
+   attribs[atti++] = dmabuf->attributes.fd[2];
attribs[atti++] = EGL_DMA_BUF_PLANE2_OFFSET_EXT;
-   attribs[atti++] = dmabuf->offset[2];
+   attribs[atti++] = dmabuf->attributes.offset[2];
attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
-   attribs[atti++] = dmabuf->stride[2];
+   attribs[atti++] = dmabuf->attributes.stride[2];
}
 
attribs[atti++] = EGL_NONE;
@@ -1507,14 +1507,14 @@ gl_renderer_import_dmabuf(struct weston_compositor *ec,
 
assert(gr->has_dmabuf_import);
 
-   for (i = 0; i < dmabuf->n_planes; i++) {
+   for (i = 0; i < dmabuf->attributes.n_planes; i++) {
  

[PATCH 3/6] gl-renderer: Add support for a few YUV dmabuf formats

2015-11-24 Thread Emmanuel Gil Peyrot
Namely the single-planar YUYV, the two-planar NV12, and the
three-planar YUV420, using the shaders already present in Weston.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Maniphest Tasks: T13

Differential Revision: https://phabricator.freedesktop.org/D334
---
 src/gl-renderer.c | 280 +-
 1 file changed, 237 insertions(+), 43 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 90e4842..cce93ee 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -101,11 +101,36 @@ struct egl_image {
int refcount;
 };
 
+enum import_type {
+   IMPORT_TYPE_INVALID,
+   IMPORT_TYPE_DIRECT,
+   IMPORT_TYPE_GL_CONVERSION
+};
+
 struct dmabuf_image {
struct linux_dmabuf_buffer *dmabuf;
int num_images;
struct egl_image *images[3];
struct wl_list link;
+
+   enum import_type import_type;
+   GLenum target;
+   struct gl_shader *shader;
+};
+
+struct yuv_plane_descriptor {
+   int width_divisor;
+   int height_divisor;
+   uint32_t format;
+   int plane_index;
+};
+
+struct yuv_format_descriptor {
+   uint32_t format;
+   int input_planes;
+   int output_planes;
+   int texture_type;
+   struct yuv_plane_descriptor plane[4];
 };
 
 struct gl_surface_state {
@@ -197,7 +222,7 @@ static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display 
= NULL;
 static inline const char *
 dump_format(uint32_t *format)
 {
-   // FIXME: this won’t work properly on big-endian.
+   /* FIXME: this won’t work properly on big-endian. */
return (const char *)format;
 }
 
@@ -1514,6 +1539,171 @@ import_simple_dmabuf(struct gl_renderer *gr,
return image;
 }
 
+struct yuv_format_descriptor yuv_formats[] = {
+   {
+   .format = DRM_FORMAT_YUYV,
+   .input_planes = 1,
+   .output_planes = 2,
+   .texture_type = EGL_TEXTURE_Y_XUXV_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_GR88,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_ARGB,
+   .plane_index = 0
+   }}
+   }, {
+   .format = DRM_FORMAT_NV12,
+   .input_planes = 2,
+   .output_planes = 2,
+   .texture_type = EGL_TEXTURE_Y_UV_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_GR88,
+   .plane_index = 1
+   }}
+   }, {
+   .format = DRM_FORMAT_YUV420,
+   .input_planes = 3,
+   .output_planes = 3,
+   .texture_type = EGL_TEXTURE_Y_U_V_WL,
+   {{
+   .width_divisor = 1,
+   .height_divisor = 1,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 0
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 1
+   }, {
+   .width_divisor = 2,
+   .height_divisor = 2,
+   .format = DRM_FORMAT_R8,
+   .plane_index = 2
+   }}
+   }
+};
+
+static struct egl_image *
+import_dmabuf_single_plane(struct gl_renderer *gr,
+   const struct dmabuf_attributes *attributes,
+   struct yuv_plane_descriptor *descriptor)
+{
+   struct dmabuf_attributes plane;
+   struct egl_image *image;
+
+   plane.width = attributes->width / descriptor->width_divisor;
+   plane.height = attributes->height / descriptor->height_divisor;
+   plane.format = descriptor->format;
+   plane.n_planes = 1;
+   plane.fd[0] = attributes->fd[descriptor->plane_index];
+   plane.offset[0] = attributes->offset[descriptor->plane_index];
+   plane.stride[0] = attributes->stride[descriptor->plane_index];
+   plane.modifier[0] = attributes->modifier[descriptor->plane_index];
+
+   image = import_simple_dmabuf(gr, );
+   if (!image) {
+   weston_log("Failed to import plane %d as %.4s\n",
+  descriptor->plane_index,
+  dump_format(>format));
+   return NULL;
+   }
+
+   return image

[PATCH 5/6] clients: Fix a few issues in simple-dmabuf-intel

2015-11-24 Thread Emmanuel Gil Peyrot
Those were found while working on simple-dmabuf-v4l, as found in the
next patch of this series.

After each buffer’s params were ready to be submitted to the
compositor, a roundtrip was done, which is wasteful since we can do it
only once after having queued all the params we want.  Removing those
nested roundtrips also prevent the potentially dangerous side-effect of
calling callbacks for later events while previous events were still
being processed.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D344
---
 clients/simple-dmabuf-intel.c | 41 +++--
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index f371d80..0ceefeb 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -35,9 +35,9 @@
 #include 
 
 #include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include "xdg-shell-unstable-v5-client-protocol.h"
@@ -204,6 +204,7 @@ create_failed(void *data, struct zwp_linux_buffer_params_v1 
*params)
struct buffer *buffer = data;
 
buffer->buffer = NULL;
+   running = 0;
 
zwp_linux_buffer_params_v1_destroy(params);
 
@@ -274,13 +275,6 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
  DRM_FORMAT_XRGB,
  flags);
 
-   /* params is destroyed by the event handlers */
-
-   wl_display_roundtrip(display->display);
-   if (buffer->buffer == NULL) {
-   goto error2;
-   }
-
return 0;
 
 error2:
@@ -313,6 +307,8 @@ static struct window *
 create_window(struct display *display, int width, int height)
 {
struct window *window;
+   int i;
+   int ret;
 
window = calloc(1, sizeof *window);
if (!window)
@@ -344,6 +340,14 @@ create_window(struct display *display, int width, int 
height)
assert(0);
}
 
+   for (i = 0; i < 2; ++i) {
+   ret = create_dmabuf_buffer(display, >buffers[i],
+  width, height);
+
+   if (ret < 0)
+   return NULL;
+   }
+
return window;
 }
 
@@ -375,7 +379,6 @@ static struct buffer *
 window_next_buffer(struct window *window)
 {
struct buffer *buffer;
-   int ret = 0;
 
if (!window->buffers[0].busy)
buffer = >buffers[0];
@@ -384,14 +387,6 @@ window_next_buffer(struct window *window)
else
return NULL;
 
-   if (!buffer->buffer) {
-   ret = create_dmabuf_buffer(window->display, buffer,
-  window->width, window->height);
-
-   if (ret < 0)
-   return NULL;
-   }
-
return buffer;
 }
 
@@ -574,9 +569,11 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, , NULL);
 
-   /* Initialise damage to full surface, so the padding gets painted */
-   wl_surface_damage(window->surface, 0, 0,
- window->width, window->height);
+   /* Here we retrieve the linux-dmabuf objects, or error */
+   wl_display_roundtrip(display->display);
+
+   if (!running)
+   return 1;
 
redraw(window, NULL, 0);
 
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 4/6] clients: rename simple-dmabuf into simple-dmabuf-intel

2015-11-24 Thread Emmanuel Gil Peyrot
This client was using an Intel-specific way to allocate a dmabuf, so it
makes sense to have that in its name.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Reviewed-by: Daniel Stone <dani...@collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D342
---
 .gitignore|   2 +-
 Makefile.am   |  12 +-
 clients/simple-dmabuf-intel.c | 591 ++
 clients/simple-dmabuf.c   | 591 --
 configure.ac  |  20 +-
 5 files changed, 608 insertions(+), 608 deletions(-)
 create mode 100644 clients/simple-dmabuf-intel.c
 delete mode 100644 clients/simple-dmabuf.c

diff --git a/.gitignore b/.gitignore
index 11d23da..719054d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,7 +66,7 @@ weston-nested-client
 weston-presentation-shm
 weston-resizor
 weston-scaler
-weston-simple-dmabuf
+weston-simple-dmabuf-intel
 weston-simple-egl
 weston-simple-shm
 weston-simple-touch
diff --git a/Makefile.am b/Makefile.am
index cbb3b57..1eb66ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -523,18 +523,18 @@ weston_simple_egl_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_EGL_CLIENT_CFLAGS)
 weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
 endif
 
-if BUILD_SIMPLE_INTEL_DMABUF_CLIENT
-demo_clients += weston-simple-dmabuf
-weston_simple_dmabuf_SOURCES = clients/simple-dmabuf.c
-nodist_weston_simple_dmabuf_SOURCES =  \
+if BUILD_SIMPLE_DMABUF_INTEL_CLIENT
+demo_clients += weston-simple-dmabuf-intel
+weston_simple_dmabuf_intel_SOURCES = clients/simple-dmabuf-intel.c
+nodist_weston_simple_dmabuf_intel_SOURCES =\
protocol/xdg-shell-unstable-v5-protocol.c   \
protocol/xdg-shell-unstable-v5-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
-weston_simple_dmabuf_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_CLIENT_CFLAGS)
-weston_simple_dmabuf_LDADD = $(SIMPLE_DMABUF_CLIENT_LIBS) libshared.la
+weston_simple_dmabuf_intel_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_INTEL_CLIENT_CFLAGS)
+weston_simple_dmabuf_intel_LDADD = $(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) 
libshared.la
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
new file mode 100644
index 000..f371d80
--- /dev/null
+++ b/clients/simple-dmabuf-intel.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright © 2011 Benjamin Franzke
+ * Copyright © 2010 Intel Corporation
+ * Copyright © 2014 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+struct display {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct xdg_shell *shell;
+   struct zwp_fullscreen_shell_v1 *fshell;
+   struct zwp_linux_dmabuf_v1 *dmabuf;
+   int xrgb_format_found;
+};
+
+struct buffer {
+   struct wl_buffer *buffer;
+   int busy;
+
+   int drm_fd;
+
+   drm_intel_bufmgr *bufmgr;
+   drm_intel_bo *bo;
+
+   uint32_t gem_handle;
+   int dmabuf_fd;
+   uint8_t *mmap;
+
+   int width;
+   int height;
+   int bpp;
+   u

[PATCH 0/6] Add YUV formats support to dmabuf, and a v4l2 client

2015-11-24 Thread Emmanuel Gil Peyrot
This series makes the gl-renderer accept the YUYV, NV12 and YUV420
dmabuf formats using the existing shader path.  There is no
implementation in pixman-renderer, nor any drm passthrough in case the
hardware supports this.

It also adds a new client, weston-simple-dmabuf-v4l, which retrieves
dmabuf fds from V4L2 and sends them to the compositor.  It supports
both single- and multi-planar v4l2 APIs, and was tested against both
the uvcvideo and the vivid module in Linux 4.2 and 4.3.

I also renamed the old Intel-specific simple-dmabuf to
simple-dmabuf-intel, and fixed a few deficiencies found during the
development of simple-dmabuf-v4l.

Emmanuel Gil Peyrot (6):
  linux-dmabuf: Move the attributes part of linux_dmabuf_buffer into its
own struct
  gl-renderer: introduce a new struct dmabuf_image
  gl-renderer: Add support for a few YUV dmabuf formats
  clients: rename simple-dmabuf into simple-dmabuf-intel
  clients: Fix a few issues in simple-dmabuf-intel
  clients: add simple-v4l-dmabuf client

 .gitignore|   3 +-
 Makefile.am   |  27 +-
 clients/simple-dmabuf-intel.c | 588 ++
 clients/simple-dmabuf-v4l.c   | 939 ++
 clients/simple-dmabuf.c   | 591 --
 configure.ac  |  34 +-
 src/compositor-drm.c  |  12 +-
 src/gl-renderer.c | 413 +++
 src/linux-dmabuf.c|  58 +--
 src/linux-dmabuf.h|  14 +-
 10 files changed, 1947 insertions(+), 732 deletions(-)
 create mode 100644 clients/simple-dmabuf-intel.c
 create mode 100644 clients/simple-dmabuf-v4l.c
 delete mode 100644 clients/simple-dmabuf.c

-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 6/6] clients: add simple-v4l-dmabuf client

2015-11-24 Thread Emmanuel Gil Peyrot
This client opens a V4L2 device, usually exposed as /dev/videoN, and
retrieves its frames as dmabuf for later import into the compositor.

It supports both single- and multi-planar devices, and any format
exposed by the V4L2 device the Wayland compositor accepts.

This client never changes the v4l2 settings, use `v4l2-ctl -c` if you
want to change those.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>

Maniphest Tasks: T90

Differential Revision: https://phabricator.freedesktop.org/D339
---
 .gitignore  |   1 +
 Makefile.am |  15 +
 clients/simple-dmabuf-v4l.c | 939 
 configure.ac|  14 +
 4 files changed, 969 insertions(+)
 create mode 100644 clients/simple-dmabuf-v4l.c

diff --git a/.gitignore b/.gitignore
index 719054d..dfbb4d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@ weston-presentation-shm
 weston-resizor
 weston-scaler
 weston-simple-dmabuf-intel
+weston-simple-dmabuf-v4l
 weston-simple-egl
 weston-simple-shm
 weston-simple-touch
diff --git a/Makefile.am b/Makefile.am
index 1eb66ae..31e4216 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -538,6 +538,21 @@ weston_simple_dmabuf_intel_LDADD = 
$(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) libshared.
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
+if BUILD_SIMPLE_DMABUF_V4L_CLIENT
+demo_clients += weston-simple-dmabuf-v4l
+weston_simple_dmabuf_v4l_SOURCES = clients/simple-dmabuf-v4l.c
+nodist_weston_simple_dmabuf_v4l_SOURCES =  \
+   protocol/xdg-shell-unstable-v5-protocol.c   \
+   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/fullscreen-shell-unstable-v1-protocol.c\
+   protocol/fullscreen-shell-unstable-v1-client-protocol.h \
+   protocol/linux-dmabuf-unstable-v1-protocol.c \
+   protocol/linux-dmabuf-unstable-v1-client-protocol.h
+weston_simple_dmabuf_v4l_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_V4L_CLIENT_CFLAGS)
+weston_simple_dmabuf_v4l_LDADD = $(SIMPLE_DMABUF_V4L_CLIENT_LIBS) libshared.la
+BUILT_SOURCES += protocol/linux-dmabuf-client-protocol.h
+endif
+
 noinst_LTLIBRARIES += libtoytoolkit.la
 
 libtoytoolkit_la_SOURCES = \
diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
new file mode 100644
index 000..4899b05
--- /dev/null
+++ b/clients/simple-dmabuf-v4l.c
@@ -0,0 +1,939 @@
+/*
+ * Copyright © 2015 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+#define CLEAR(x) memset(&(x), 0, sizeof(x))
+
+static int
+xioctl(int fh, int request, void *arg)
+{
+   int r;
+
+   do {
+   r = ioctl(fh, request, arg);
+   } while (r == -1 && errno == EINTR);
+
+   return r;
+}
+
+static uint32_t
+parse_format(const char fmt[4])
+{
+   /* FIXME: this won’t work on big-endian. */
+   return fourcc_code(fmt[0], fmt[1], fmt[2], fmt[3]);
+}
+
+static const char *
+dump_format(uint32_t *format)
+{
+   /* FIXME: this won’t work properly on big-endian. */
+   return (const char *)format;
+}
+
+struct buffer_format {
+   int width;
+   int height;
+   enum v4l2_buf_type type;
+   uint32_t format;
+
+   unsigned num_planes;
+   unsigned strides[VIDEO_MAX_PLANES];
+};
+
+struct display {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   stru

[PATCH] compositor-wayland: Expose zlinux_dmabuf

2015-09-25 Thread Emmanuel Gil Peyrot
This mirrors what 5ffb440c3fe19669de73e51b90ea337fa2d5ae78 did for
compositor-x11, and allows testing without having to restart the
compositor-drm everytime.
---
 src/compositor-wayland.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index f6c84d4..900c331 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -48,6 +48,7 @@
 #include "shared/cairo-util.h"
 #include "fullscreen-shell-client-protocol.h"
 #include "presentation_timing-server-protocol.h"
+#include "linux-dmabuf.h"
 
 #define WINDOW_TITLE "Weston Compositor"
 
@@ -2022,6 +2023,12 @@ wayland_backend_create(struct weston_compositor 
*compositor, int use_pixman,
 
wl_event_source_check(b->parent.wl_source);
 
+   if (compositor->renderer->import_dmabuf) {
+   if (linux_dmabuf_setup(compositor) < 0)
+   weston_log("Error: initializing dmabuf "
+  "support failed.\n");
+   }
+
compositor->backend = >base;
return b;
 err_display:
-- 
2.4.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Partially revert xwayland: Always free reply from xcb_get_property_reply()

2015-07-15 Thread Emmanuel Gil Peyrot
This reverts commit d3553c721c0fed07f85b70fea418ca65ed974fbb.

weston_wm_write_property() takes the ownership of the reply it gets as
a parameter, and will eventually free it later in writable_callback.

This change introduced a double-free when Xwayland programs triggered a
copy to the clipboard, leading to a Weston crash.
---
 xwayland/selection.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xwayland/selection.c b/xwayland/selection.c
index 452cd69..0ef1e52 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -117,13 +117,13 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
dump_property(wm, wm-atom.wl_selection, reply);
 
if (xcb_get_property_value_length(reply)  0) {
+   /* reply's ownership is transfered to wm, which is responsible 
of freeing it */
weston_wm_write_property(wm, reply);
} else {
weston_log(transfer complete\n);
close(wm-data_source_fd);
+   free(reply);
}
-
-   free(reply);
 }
 
 struct x11_data_source {
@@ -247,12 +247,12 @@ weston_wm_get_selection_data(struct weston_wm *wm)
return;
} else if (reply-type == wm-atom.incr) {
wm-incr = 1;
+   free(reply);
} else {
wm-incr = 0;
+   /* reply's ownership is transfered to wm, which is responsible 
of freeing it */
weston_wm_write_property(wm, reply);
}
-
-   free(reply);
 }
 
 static void
-- 
2.4.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


  1   2   >