Re: [RFC PATCH wayland-protocols] presentation: New protocol for presenting surfaces to the user
Hi Carlos, On Fri, Oct 18, 2019 at 01:08:36AM +0200, Carlos Garnacho wrote: > Hi Pekka, > > Thank you for your comments! > > On Wed, Oct 16, 2019 at 11:31 AM Pekka Paalanen wrote: > > > On Wed, 16 Oct 2019 10:54:08 +0200 > > Olivier Fourdan wrote: > > > > > Hey Carlos, > > > > > > On Wed, Oct 16, 2019 at 10:43 AM Carlos Garnacho > > wrote: > > > > > > > > This protocol takes over 3 different, but interrelated aspects of > > > > DE/client interaction: > > > > - Startup notification: presenting feedback about applications > > > > being launched, either through the compositor or another client > > > > - Focus stealing prevention: letting the compositor figure out > > > > whether immediately switching focus to a surface makes sense. > > > > - Window raising/activation: allowing existing clients to request > > > > focus in a controlled manner. > > > > > > > > Signed-off-by: Carlos Garnacho > > > > Hi Carlos, > > > > this seems well written and a good idea to me. More comments inline. > > > > > > --- > > > > Makefile.am | 1 + > > > > unstable/presentation/README | 5 + > > > > .../presentation/presentation-unstable-v1.xml | 175 ++ > > > > 3 files changed, 181 insertions(+) > > > > create mode 100644 unstable/presentation/README > > > > create mode 100644 unstable/presentation/presentation-unstable-v1.xml > > > > > > > > diff --git a/Makefile.am b/Makefile.am > > > > index d2c89a8..bd0e52d 100644 > > > > --- a/Makefile.am > > > > +++ b/Makefile.am > > > > @@ -24,6 +24,7 @@ unstable_protocols = > > \ > > > > unstable/xdg-decoration/xdg-decoration-unstable-v1.xml \ > > > > > > > > unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml > > \ > > > > unstable/primary-selection/primary-selection-unstable-v1.xml > > \ > > > > + unstable/presentation/presentation-unstable-v1.xml > > \ > > > > $(NULL) > > > > > > > > stable_protocols = > > \ > > > > diff --git a/unstable/presentation/README > > b/unstable/presentation/README > > > > new file mode 100644 > > > > index 000..5a77e97 > > > > --- /dev/null > > > > +++ b/unstable/presentation/README > > > > @@ -0,0 +1,5 @@ > > > > +Presentation protocol > > > > + > > > > +Maintainers: > > > > +Carlos Garnacho > > > > + > > > > diff --git a/unstable/presentation/presentation-unstable-v1.xml > > b/unstable/presentation/presentation-unstable-v1.xml > > > > new file mode 100644 > > > > index 000..84bf961 > > > > --- /dev/null > > > > +++ b/unstable/presentation/presentation-unstable-v1.xml > > > > @@ -0,0 +1,175 @@ > > > > + > > > > + > > > > + > > > > +Copyright 2018-2019 © Red Hat, Inc. > > > > + > > > > +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 description provides a high-level overview of the interplay > > between > > > > +the interfaces defined this protocol. For details, see the > > protocol > > > > +specification. > > > > This is the protocol specification, the whole file. > > > > Uh, got that bit of the wording from zwp_tablet, removed locally :). > > > > > > > > + > > > > +The finality of the protocol is defining a compositor context for > > > > +surfaces requesting to be presented. Presentation requests are > > usually > > > > +initiated by an existing surface, and acknowledged by a surface > > being > > > > +mapped. By having both ends talk with the compositor through this > > protocol, > > > > +the compositor has the information to implement different > > commonplace > > > > +policies: > > > > + > > > > +-
Re: [PATCH weston 3/3 v4] simple-dmabuf-drm: use GBM generic calls
Hi, On Fri, Jul 20, 2018 at 11:10:29PM +0200, Guido Günther wrote: > Hi, > On Fri, Jul 13, 2018 at 05:43:50PM +0200, Guido Günther wrote: > > Hi, > > On Thu, Jul 12, 2018 at 01:46:25PM +0200, Emilio Pozuelo Monfort wrote: > > > No need to write libdrm driver specific code for each supported > > > driver, we can just let GBM call the right one for us now. > > > > This one breaks NV12 on intel when using rootston as compositor for me. > > > > $ ./weston-simple-dmabuf-drm --import-format=NV12 > > Error: zwp_linux_buffer_params.create failed. > > Error: zwp_linux_buffer_params.create failed. > > Error: zwp_linux_buffer_params.create failed. > > Reason is that in wlroot's wlr_egl_create_image_from_wl_drm[1] this > > return eglCreateImageKHR(egl->display, EGL_NO_CONTEXT, > EGL_LINUX_DMA_BUF_EXT, NULL, attribs); > > returns ELG_BAD_ALLOC. The attribs passed in look sane. Looking at > mesa's dri2_create_image_khr_texture that doesn't make much sense so I > wonder if this rings a bell here? I think I can answer this myself. While (in weston terms) the old NV12 code tested this code path: https://gitlab.freedesktop.org/wayland/weston/blob/master/libweston/gl-renderer.c#L2071 (with > 1 plane so): https://gitlab.freedesktop.org/wayland/weston/blob/master/libweston/gl-renderer.c#L1805 (which was the intention) the new code now tests https://gitlab.freedesktop.org/wayland/weston/blob/master/libweston/gl-renderer.c#L2085 which is already covered by simple-dmabuf-v4l. Since wlroots does not yet support importing multi planar formats by splitting them into singe plane dmabufs NV12 fails now. Can we achieve the same with gbm somehow? As a related question: the current way to try one format first and then fall back to import_yuv_dmabuf looks wired. Would it be better to check if the format is in yuv_formats beforehand or is there a reason not to do so? Cheers, -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 3/3 v4] simple-dmabuf-drm: use GBM generic calls
Hi, On Fri, Jul 13, 2018 at 05:43:50PM +0200, Guido Günther wrote: > Hi, > On Thu, Jul 12, 2018 at 01:46:25PM +0200, Emilio Pozuelo Monfort wrote: > > No need to write libdrm driver specific code for each supported > > driver, we can just let GBM call the right one for us now. > > This one breaks NV12 on intel when using rootston as compositor for me. > > $ ./weston-simple-dmabuf-drm --import-format=NV12 > Error: zwp_linux_buffer_params.create failed. > Error: zwp_linux_buffer_params.create failed. > Error: zwp_linux_buffer_params.create failed. Reason is that in wlroot's wlr_egl_create_image_from_wl_drm[1] this return eglCreateImageKHR(egl->display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attribs); returns ELG_BAD_ALLOC. The attribs passed in look sane. Looking at mesa's dri2_create_image_khr_texture that doesn't make much sense so I wonder if this rings a bell here? Cheers, -- Guido > > I have to check why yet. > -- Guido [1] https://github.com/swaywm/wlroots/blob/master/render/egl.c#L457 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 2/2] simple-dmabuf-drm: use GBM generic calls
Hi, On Thu, Jul 19, 2018 at 04:45:02PM +0200, Emilio Pozuelo Monfort wrote: > No need to write libdrm driver specific code for each supported > driver, we can just let GBM call the right one for us now. > > Signed-off-by: Emilio Pozuelo Monfort > --- > Some improvements from Daniel (thanks!). I also added missing error messages, > formatting fixes and a logic error in your improvements that caused NV12 to > abort if create_bo was working fine. > > No changes to XRGB, so that's likely to still fail for you. I suspect > a bug in mesa's i965 code, I can look at that separately. > > Cheers, > Emilio > > clients/simple-dmabuf-drm.c | 444 ++-- > configure.ac| 2 +- > 2 files changed, 122 insertions(+), 324 deletions(-) > > diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c > index 5bc5323e..5cbd2bb1 100644 > --- a/clients/simple-dmabuf-drm.c > +++ b/clients/simple-dmabuf-drm.c > @@ -41,21 +41,11 @@ > #include > #include > > -#include > - > -#ifdef HAVE_LIBDRM_INTEL > -#include > -#include > -#endif > -#ifdef HAVE_LIBDRM_FREEDRENO > -#include > -#endif > -#ifdef HAVE_LIBDRM_ETNAVIV > -#include > -#endif > +#include > #include > > #include > +#include "shared/helpers.h" > #include "shared/zalloc.h" > #include "xdg-shell-unstable-v6-client-protocol.h" > #include "fullscreen-shell-unstable-v1-client-protocol.h" > @@ -65,14 +55,10 @@ > #define DRM_FORMAT_MOD_LINEAR 0 > #endif > > -struct buffer; > - > /* Possible options that affect the displayed image */ > #define OPT_Y_INVERTED 1 /* contents has y axis inverted */ > #define OPT_IMMEDIATE 2 /* create wl_buffer immediately */ > > -#define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) > - > struct display { > struct wl_display *display; > struct wl_registry *registry; > @@ -86,46 +72,24 @@ struct display { > int req_dmabuf_immediate; > }; > > -struct drm_device { > - int fd; > - char *name; > - > - int (*alloc_bo)(struct buffer *buf); > - void (*free_bo)(struct buffer *buf); > - int (*export_bo_to_prime)(struct buffer *buf); > - int (*map_bo)(struct buffer *buf); > - void (*unmap_bo)(struct buffer *buf); > - void (*device_destroy)(struct buffer *buf); > -}; > - > struct buffer { > struct wl_buffer *buffer; > int busy; > > - struct drm_device *dev; > int drm_fd; > + struct gbm_device *dev; > + struct gbm_bo *bo; > + struct gbm_bo *bo2; > > -#ifdef HAVE_LIBDRM_INTEL > - drm_intel_bufmgr *bufmgr; > - drm_intel_bo *intel_bo; > -#endif /* HAVE_LIBDRM_INTEL */ > -#if HAVE_LIBDRM_FREEDRENO > - struct fd_device *fd_dev; > - struct fd_bo *fd_bo; > -#endif /* HAVE_LIBDRM_FREEDRENO */ > -#if HAVE_LIBDRM_ETNAVIV > - struct etna_device *etna_dev; > - struct etna_bo *etna_bo; > -#endif /* HAVE_LIBDRM_ETNAVIV */ > - > - uint32_t gem_handle; > int dmabuf_fd; > - uint8_t *mmap; > + int dmabuf_fd2; > + void *mmap; > + void *mmap2; > > int width; > int height; > - int bpp; > - unsigned long stride; > + uint32_t stride; > + uint32_t stride2; > int format; > }; > > @@ -161,170 +125,6 @@ static const struct wl_buffer_listener buffer_listener > = { > buffer_release > }; > > - > -#ifdef HAVE_LIBDRM_INTEL > -static int > -intel_alloc_bo(struct buffer *my_buf) > -{ > - /* XXX: try different tiling modes for testing FB modifiers. */ > - uint32_t tiling = I915_TILING_NONE; > - > - assert(my_buf->bufmgr); > - > - my_buf->intel_bo = drm_intel_bo_alloc_tiled(my_buf->bufmgr, "test", > - my_buf->width, > my_buf->height, > - (my_buf->bpp / 8), , > - _buf->stride, 0); > - > - printf("buffer allocated w %d, h %d, stride %lu, size %lu\n", > -my_buf->width, my_buf->height, my_buf->stride, > my_buf->intel_bo->size); > - > - if (!my_buf->intel_bo) > - return 0; > - > - if (tiling != I915_TILING_NONE) > - return 0; > - > - return 1; > -} > - > -static void > -intel_free_bo(struct buffer *my_buf) > -{ > - drm_intel_bo_unreference(my_buf->intel_bo); > -} > - > -static int > -intel_map_bo(struct buffer *my_buf) > -{ > - if (drm_intel_gem_bo_map_gtt(my_buf->intel_bo) != 0) > - return 0; > - > - my_buf->mmap = my_buf->intel_bo->virtual; > - > - return 1; > -} > - > -static int > -intel_bo_export_to_prime(struct buffer *buffer) > -{ > - return drm_intel_bo_gem_export_to_prime(buffer->intel_bo, > >dmabuf_fd); > -} > - > -static void > -intel_unmap_bo(struct buffer *my_buf) > -{ > - drm_intel_gem_bo_unmap_gtt(my_buf->intel_bo); > -} > - > -static void > -intel_device_destroy(struct buffer *my_buf) > -{ > - drm_intel_bufmgr_destroy(my_buf->bufmgr); > -} > - > -#endif /*
Re: [PATCH weston 3/3 v4] simple-dmabuf-drm: use GBM generic calls
Hi, On Thu, Jul 12, 2018 at 01:46:25PM +0200, Emilio Pozuelo Monfort wrote: > No need to write libdrm driver specific code for each supported > driver, we can just let GBM call the right one for us now. This one breaks NV12 on intel when using rootston as compositor for me. $ ./weston-simple-dmabuf-drm --import-format=NV12 Error: zwp_linux_buffer_params.create failed. Error: zwp_linux_buffer_params.create failed. Error: zwp_linux_buffer_params.create failed. I have to check why yet. -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] simple-dmabuf-drm: use GBM generic calls
Hi, On Tue, Jul 10, 2018 at 05:53:15PM +0200, Emilio Pozuelo Monfort wrote: > No need to write libdrm driver specific code for each supported > driver, we can just let GBM call the right one for us now. > > Signed-off-by: Emilio Pozuelo Monfort > --- > > Hi, > > This simplifies the code a lot, using gbm_bo as Emil suggested. Some problems > I still see: > > - NV12 doesn't work, it seems that > backends/dri/gbm_dri.c:gbm_format_to_dri_format() > doesn't support it. Simple means of testing NV12 is a useful feature so it'd be sad to see that go. Using weston-simple-dmabuf-v4l is much more involved as it requires more setup. Cheers, -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] parse_modeline: Ignore case of {h,v}sync flags
Hi, On Tue, Jul 03, 2018 at 12:04:37PM +0300, Pekka Paalanen wrote: > On Tue, 26 Jun 2018 20:40:08 +0200 > Guido Günther wrote: > > > Some modeline generators put out e.g. +HSync instead of +hsync. Accept > > that too since it's not ambigous. > > > > Signed-off-by: Guido Günther > > --- > > libweston/compositor-drm.c | 8 > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c > > index 8b1ea66d..1c9b7134 100644 > > --- a/libweston/compositor-drm.c > > +++ b/libweston/compositor-drm.c > > @@ -4341,16 +4341,16 @@ parse_modeline(const char *s, drmModeModeInfo *mode) > > return -1; > > > > mode->clock = fclock * 1000; > > - if (strcmp(hsync, "+hsync") == 0) > > + if (strcasecmp(hsync, "+hsync") == 0) > > mode->flags |= DRM_MODE_FLAG_PHSYNC; > > - else if (strcmp(hsync, "-hsync") == 0) > > + else if (strcasecmp(hsync, "-hsync") == 0) > > mode->flags |= DRM_MODE_FLAG_NHSYNC; > > else > > return -1; > > > > - if (strcmp(vsync, "+vsync") == 0) > > + if (strcasecmp(vsync, "+vsync") == 0) > > mode->flags |= DRM_MODE_FLAG_PVSYNC; > > - else if (strcmp(vsync, "-vsync") == 0) > > + else if (strcasecmp(vsync, "-vsync") == 0) > > mode->flags |= DRM_MODE_FLAG_NVSYNC; > > else > > return -1; > > Hi, > > I suppose this does no harm. Pushed: Yeah, that was my intend when sending the patch. >35280448..92278e08 master -> master Thanks, -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] parse_modeline: Ignore case of {h,v}sync flags
Hi, On Wed, Jun 27, 2018 at 11:30:40AM +0100, Emil Velikov wrote: > On 26 June 2018 at 19:40, Guido Günther wrote: > > Some modeline generators put out e.g. +HSync instead of +hsync. Accept > > that too since it's not ambigous. > > > Hmm which generator is that? The cvt one, given as an example seems to > produce lowercase ones. The xorg.conf manpage uses +HSync and a calculator generating just that is https://arachnoid.com/modelines/ and I don't see why doing this case insensitive would hurt anyone and make things less error prone for users. Cheers, -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] parse_modeline: Ignore case of {h,v}sync flags
Some modeline generators put out e.g. +HSync instead of +hsync. Accept that too since it's not ambigous. Signed-off-by: Guido Günther --- libweston/compositor-drm.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 8b1ea66d..1c9b7134 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -4341,16 +4341,16 @@ parse_modeline(const char *s, drmModeModeInfo *mode) return -1; mode->clock = fclock * 1000; - if (strcmp(hsync, "+hsync") == 0) + if (strcasecmp(hsync, "+hsync") == 0) mode->flags |= DRM_MODE_FLAG_PHSYNC; - else if (strcmp(hsync, "-hsync") == 0) + else if (strcasecmp(hsync, "-hsync") == 0) mode->flags |= DRM_MODE_FLAG_NHSYNC; else return -1; - if (strcmp(vsync, "+vsync") == 0) + if (strcasecmp(vsync, "+vsync") == 0) mode->flags |= DRM_MODE_FLAG_PVSYNC; - else if (strcmp(vsync, "-vsync") == 0) + else if (strcasecmp(vsync, "-vsync") == 0) mode->flags |= DRM_MODE_FLAG_NVSYNC; else return -1; -- 2.17.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston v2 1/1] simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well
Hi, On Tue, May 29, 2018 at 11:44:36AM +0300, Pekka Paalanen wrote: > On Mon, 28 May 2018 17:41:57 +0200 > Guido Günther wrote: > > > This makes --import-format=NV12 testable on e.g. intel > > > > We only set nv12_format_found to true if we found that format and at > > least one understood modifier. Store modifier verbatim instead of using > > a boolean flag. Last advertised and supported modifier currently wins. > > > > The NV12 DRM_FORMAT_LINEAR image should be green in the upper left > > corner and white in the lower right. > > > > Signed-off-by: Guido Günther > > --- > > clients/simple-dmabuf-drm.c | 55 + > > 1 file changed, 38 insertions(+), 17 deletions(-) > > > > Pushed: >74742e05..da188835 master -> master Thanks for handling this! -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 3/3] simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well
Hi, On Mon, May 28, 2018 at 04:31:14PM +0300, Pekka Paalanen wrote: > On Tue, 20 Mar 2018 11:36:38 +0100 > Guido Günther <a...@sigxcpu.org> wrote: > > > This makes --import-format=NV12 testable on e.g. intel > > > > We only set nv12_format_found to true if we found that format and at > > least one understood modifier. Store modifier verbatim instead of using > > a boolean flag. Last advertised and supported modifier currently wins. > > > > Signed-off-by: Guido Günther <a...@sigxcpu.org> > > --- > > clients/simple-dmabuf-drm.c | 54 > > +++-- > > 1 file changed, 37 insertions(+), 17 deletions(-) > > > > diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c > > index b9681ca4..7175f2d7 100644 > > --- a/clients/simple-dmabuf-drm.c > > +++ b/clients/simple-dmabuf-drm.c > > @@ -75,7 +75,7 @@ struct display { > > struct zwp_linux_dmabuf_v1 *dmabuf; > > int xrgb_format_found; > > int nv12_format_found; > > - int nv12_modifier_found; > > + uint64_t nv12_modifier; > > int req_dmabuf_immediate; > > int req_dmabuf_modifiers; > > }; > > @@ -273,7 +273,7 @@ fd_device_destroy(struct buffer *buf) > > #endif /* HAVE_LIBDRM_FREEDRENO */ > > > > static void > > -fill_content(struct buffer *my_buf) > > +fill_content(struct buffer *my_buf, uint64_t modifier) > > { > > int x = 0, y = 0; > > uint32_t *pix; > > @@ -281,11 +281,31 @@ fill_content(struct buffer *my_buf) > > assert(my_buf->mmap); > > > > if (my_buf->format == DRM_FORMAT_NV12) { > > - pix = (uint32_t *) my_buf->mmap; > > - for (y = 0; y < my_buf->height; y++) > > - memcpy([y * my_buf->width / 4], > > - _tiled[my_buf->width * y / 4], > > - my_buf->width); > > + if (modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) { > > + pix = (uint32_t *) my_buf->mmap; > > + for (y = 0; y < my_buf->height; y++) > > + memcpy([y * my_buf->width / 4], > > + _tiled[my_buf->width * y / 4], > > + my_buf->width); > > + } > > + else if (modifier == DRM_FORMAT_MOD_LINEAR) { > > + uint8_t *pix8; > > + /* first plane: Y (2/3 of the buffer) */ > > + for (y = 0; y < my_buf->height * 2/3; y++) { > > + pix8 = my_buf->mmap + y * my_buf->stride; > > + for (x = 0; x < my_buf->width; x++) > > + *pix8++ = x % 0xff; > > + } > > + /* second plane (CbCr) is half the size of Y > > + plane (last 1/3 of the buffer) */ > > + for (y = my_buf->height * 2/3; y < my_buf->height; y++) > > { > > + pix8 = my_buf->mmap + y * my_buf->stride; > > + for (x = 0; x < my_buf->width; x+=2) { > > + *pix8++ = x % 256; > > + *pix8++ = y % 256; > > + } > > + } > > Was the LINEAR branch supposed to produce the same image as the XRGB > path? It doesn't, the colors are different on intel, so I assume there > is no such intention. > > If there was, I'd call for an image that can be described in words what > it should look like, and would be identifiable if it was flipped or > rotated or had wrong colors. There was no intention to reproduce it. I've added a hint how it should look like to the commit message. > > > + } > > } > > else { > > for (y = 0; y < my_buf->height; y++) { > > @@ -420,7 +440,6 @@ create_dmabuf_buffer(struct display *display, struct > > buffer *buffer, > > /* adjust height for allocation of NV12 Y and UV planes */ > > buffer->height = height * 3 / 2; > > buffer->bpp = 8; > > - modifier = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE; > > break; > > default: > > buffer->height = height; > > @@ -437,7 +456,7 @@ create_dmabuf_buffer(struct display *display, struct > > buffer *buffer, > > fprintf(stderr, "map_bo failed\n"); > > goto error2; > > } > > - fill_content(buffer); > > + fill_content(buffer, modifier); > > Doesn't this call have modifier=0 always? > Which by luck turns out to be DRM_FORMAT_MOD_LINEAR. I fixed that in my branch a while ago but forget to push that to the list. Sent out a new version now. > > The first two patches are pushed: >bff90630..577b3464 master -> master > > Without this one issue I would have push the third one too. Thanks! -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 1/1] simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well
This makes --import-format=NV12 testable on e.g. intel We only set nv12_format_found to true if we found that format and at least one understood modifier. Store modifier verbatim instead of using a boolean flag. Last advertised and supported modifier currently wins. The NV12 DRM_FORMAT_LINEAR image should be green in the upper left corner and white in the lower right. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 55 + 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 725b35d9..df96758c 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -79,7 +79,7 @@ struct display { struct zwp_linux_dmabuf_v1 *dmabuf; int xrgb_format_found; int nv12_format_found; - int nv12_modifier_found; + uint64_t nv12_modifier; int req_dmabuf_immediate; int req_dmabuf_modifiers; }; @@ -324,7 +324,7 @@ etna_device_destroy(struct buffer *buf) #endif /* HAVE_LIBDRM_ENTAVIV */ static void -fill_content(struct buffer *my_buf) +fill_content(struct buffer *my_buf, uint64_t modifier) { int x = 0, y = 0; uint32_t *pix; @@ -332,11 +332,31 @@ fill_content(struct buffer *my_buf) assert(my_buf->mmap); if (my_buf->format == DRM_FORMAT_NV12) { - pix = (uint32_t *) my_buf->mmap; - for (y = 0; y < my_buf->height; y++) - memcpy([y * my_buf->width / 4], - _tiled[my_buf->width * y / 4], - my_buf->width); + if (modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) { + pix = (uint32_t *) my_buf->mmap; + for (y = 0; y < my_buf->height; y++) + memcpy([y * my_buf->width / 4], + _tiled[my_buf->width * y / 4], + my_buf->width); + } + else if (modifier == DRM_FORMAT_MOD_LINEAR) { + uint8_t *pix8; + /* first plane: Y (2/3 of the buffer) */ + for (y = 0; y < my_buf->height * 2/3; y++) { + pix8 = my_buf->mmap + y * my_buf->stride; + for (x = 0; x < my_buf->width; x++) + *pix8++ = x % 0xff; + } + /* second plane (CbCr) is half the size of Y + plane (last 1/3 of the buffer) */ + for (y = my_buf->height * 2/3; y < my_buf->height; y++) { + pix8 = my_buf->mmap + y * my_buf->stride; + for (x = 0; x < my_buf->width; x+=2) { + *pix8++ = x % 256; + *pix8++ = y % 256; + } + } + } } else { for (y = 0; y < my_buf->height; y++) { @@ -481,7 +501,7 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, /* adjust height for allocation of NV12 Y and UV planes */ buffer->height = height * 3 / 2; buffer->bpp = 8; - modifier = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE; + modifier = display->nv12_modifier; break; default: buffer->height = height; @@ -498,7 +518,7 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, fprintf(stderr, "map_bo failed\n"); goto error2; } - fill_content(buffer); + fill_content(buffer, modifier); drm_dev->unmap_bo(buffer); if (drm_dev->export_bo_to_prime(buffer) != 0) { @@ -746,10 +766,13 @@ dmabuf_modifiers(void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf, d->xrgb_format_found = 1; break; case DRM_FORMAT_NV12: - d->nv12_format_found = 1; - if (modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) - d->nv12_modifier_found = 1; - break; + switch (modifier) { + case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: + case DRM_FORMAT_MOD_LINEAR: + d->nv12_format_found = 1; + d->nv12_modifier = modifier; + break; + } default: break; } @@ -857,12 +880,10 @@ create_display(int opts, int format) wl_display_roundtrip(display->display); if ((format == DRM_FORMAT_XRGB && !display->xrgb
[PATCH weston v2 0/1] simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12
simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 This makes things testable on non freedreno as well. E.g. intel supports it. Changes from v1: * don't forget to set modifier in dmabuf_modifiers * give an idea how the image should look like Guido Günther (1): simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well clients/simple-dmabuf-drm.c | 55 + 1 file changed, 38 insertions(+), 17 deletions(-) -- 2.17.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston v5 0/3] simple-dmabuf-drm: Support etnaviv and freedreno cleanups
On Tue, Mar 20, 2018 at 09:41:57AM +0100, Guido Günther wrote: > Former patches 1-2 where already applied thanks Derek. > > Changes from v4 > - configure: use true if etnaviv drm was not found as with > other drm backends (avoids an unused variable assignment) > - configure: use (hopefully) correct english > - simplify several if (cond) return 1; return 0; statements > - unmap buffer > > Former patches 1-3 where already applied thanks Peka. > > Changes from v3: > - Use ALIGN macro by default > - Don't multiply by bpp twice > - unmap buffer > > Changes from v2: > - Use stride to calculate buffer size (etnaviv) > - Use stride to calculate buffer size (freedreno) > - Use less generic name for ALIGN macro > > Changes from v1: > - Split up changes > - autoconf: > - don't define unused have_ variables. Use true instead to > prevent abort of PKG_CHECK_MODULES > - use && instead of -a in test > - properly check variables > - use vfunc for drm_device_destroy > > > Guido Günther (3): > simple-dmabuf-drm: 0 is a valid fd (freedreno) > simple-dmabuf-drm: simplify fd_map_bo > simple-dmabuf-drm: support etnaviv drm as well > > Makefile.am | 1 + > clients/simple-dmabuf-drm.c | 79 > +++-- > configure.ac| 5 ++- > 3 files changed, 75 insertions(+), 10 deletions(-) Ping? -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 3/3] simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well
This makes --import-format=NV12 testable on e.g. intel We only set nv12_format_found to true if we found that format and at least one understood modifier. Store modifier verbatim instead of using a boolean flag. Last advertised and supported modifier currently wins. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 54 +++-- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index b9681ca4..7175f2d7 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -75,7 +75,7 @@ struct display { struct zwp_linux_dmabuf_v1 *dmabuf; int xrgb_format_found; int nv12_format_found; - int nv12_modifier_found; + uint64_t nv12_modifier; int req_dmabuf_immediate; int req_dmabuf_modifiers; }; @@ -273,7 +273,7 @@ fd_device_destroy(struct buffer *buf) #endif /* HAVE_LIBDRM_FREEDRENO */ static void -fill_content(struct buffer *my_buf) +fill_content(struct buffer *my_buf, uint64_t modifier) { int x = 0, y = 0; uint32_t *pix; @@ -281,11 +281,31 @@ fill_content(struct buffer *my_buf) assert(my_buf->mmap); if (my_buf->format == DRM_FORMAT_NV12) { - pix = (uint32_t *) my_buf->mmap; - for (y = 0; y < my_buf->height; y++) - memcpy([y * my_buf->width / 4], - _tiled[my_buf->width * y / 4], - my_buf->width); + if (modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) { + pix = (uint32_t *) my_buf->mmap; + for (y = 0; y < my_buf->height; y++) + memcpy([y * my_buf->width / 4], + _tiled[my_buf->width * y / 4], + my_buf->width); + } + else if (modifier == DRM_FORMAT_MOD_LINEAR) { + uint8_t *pix8; + /* first plane: Y (2/3 of the buffer) */ + for (y = 0; y < my_buf->height * 2/3; y++) { + pix8 = my_buf->mmap + y * my_buf->stride; + for (x = 0; x < my_buf->width; x++) + *pix8++ = x % 0xff; + } + /* second plane (CbCr) is half the size of Y + plane (last 1/3 of the buffer) */ + for (y = my_buf->height * 2/3; y < my_buf->height; y++) { + pix8 = my_buf->mmap + y * my_buf->stride; + for (x = 0; x < my_buf->width; x+=2) { + *pix8++ = x % 256; + *pix8++ = y % 256; + } + } + } } else { for (y = 0; y < my_buf->height; y++) { @@ -420,7 +440,6 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, /* adjust height for allocation of NV12 Y and UV planes */ buffer->height = height * 3 / 2; buffer->bpp = 8; - modifier = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE; break; default: buffer->height = height; @@ -437,7 +456,7 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, fprintf(stderr, "map_bo failed\n"); goto error2; } - fill_content(buffer); + fill_content(buffer, modifier); drm_dev->unmap_bo(buffer); if (drm_dev->export_bo_to_prime(buffer) != 0) { @@ -685,10 +704,13 @@ dmabuf_modifiers(void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf, d->xrgb_format_found = 1; break; case DRM_FORMAT_NV12: - d->nv12_format_found = 1; - if (modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) - d->nv12_modifier_found = 1; - break; + switch (modifier) { + case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: + case DRM_FORMAT_MOD_LINEAR: + d->nv12_format_found = 1; + d->nv12_modifier = modifier; + break; + } default: break; } @@ -796,12 +818,10 @@ create_display(int opts, int format) wl_display_roundtrip(display->display); if ((format == DRM_FORMAT_XRGB && !display->xrgb_format_found) || - (format == DRM_FORMAT_NV12 && (!display->nv12_format_found || - !display->nv12_modif
[PATCH weston 1/3] simple-dmabuf-drm: drop superfluous declaration
variable is defined in simple-dmabuf-drm.h Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 2975f3a5..1c062fad 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -58,7 +58,6 @@ #include "fullscreen-shell-unstable-v1-client-protocol.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" -extern const unsigned nv12_tiled[]; struct buffer; /* Possible options that affect the displayed image */ -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 0/3] simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12
This makes NV12 testable on non freedreno as well. E.g. intel supports it. Guido Günther (3): simple-dmabuf-drm: drop superfluous declaration simple-dmabuf-drm: don't exit from create_display simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well clients/simple-dmabuf-drm.c | 63 ++--- 1 file changed, 42 insertions(+), 21 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/3] simple-dmabuf-drm: don't exit from create_display
Only exit from main so control flow is in one place. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 1c062fad..b9681ca4 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -767,7 +767,7 @@ create_display(int opts, int format) display = malloc(sizeof *display); if (display == NULL) { fprintf(stderr, "out of memory\n"); - exit(1); + return NULL; } display->display = wl_display_connect(NULL); assert(display->display); @@ -790,7 +790,7 @@ create_display(int opts, int format) wl_display_roundtrip(display->display); if (display->dmabuf == NULL) { fprintf(stderr, "No zwp_linux_dmabuf global\n"); - exit(1); + return NULL; } wl_display_roundtrip(display->display); @@ -799,7 +799,7 @@ create_display(int opts, int format) (format == DRM_FORMAT_NV12 && (!display->nv12_format_found || !display->nv12_modifier_found))) { fprintf(stderr, "requested format is not available\n"); - exit(1); + return NULL; } return display; @@ -909,6 +909,8 @@ main(int argc, char **argv) } display = create_display(opts, import_format); + if (!display) + return 1; window = create_window(display, 256, 256, import_format, opts); if (!window) return 1; -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v5 3/3] simple-dmabuf-drm: support etnaviv drm as well
Reviewed-by: Derek Foreman <der...@osg.samsung.com> Signed-off-by: Guido Günther <a...@sigxcpu.org> --- Makefile.am | 1 + clients/simple-dmabuf-drm.c | 68 + configure.ac| 5 +++- 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 69ca6cba..64a8006c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -629,6 +629,7 @@ nodist_weston_simple_dmabuf_drm_SOURCES = \ weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS) weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) \ $(LIBDRM_PLATFORM_FREEDRENO_LIBS) \ + $(LIBDRM_PLATFORM_ETNAVIV_LIBS) \ $(LIBDRM_PLATFORM_INTEL_LIBS) \ libshared.la endif diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index cb04622f..e7a7b0ed 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -49,6 +50,9 @@ #ifdef HAVE_LIBDRM_FREEDRENO #include #endif +#ifdef HAVE_LIBDRM_ETNAVIV +#include +#endif #include #include @@ -108,6 +112,10 @@ struct buffer { struct fd_device *fd_dev; struct fd_bo *fd_bo; #endif /* HAVE_LIBDRM_FREEDRENO */ +#if HAVE_LIBDRM_ETNAVIV + struct etna_device *etna_dev; + struct etna_bo *etna_bo; +#endif /* HAVE_LIBDRM_ETNAVIV */ uint32_t gem_handle; int dmabuf_fd; @@ -265,6 +273,56 @@ fd_device_destroy(struct buffer *buf) fd_device_del(buf->fd_dev); } #endif /* HAVE_LIBDRM_FREEDRENO */ +#ifdef HAVE_LIBDRM_ETNAVIV + +static int +etna_alloc_bo(struct buffer *buf) +{ + int flags = DRM_ETNA_GEM_CACHE_WC; + int size; + + buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; + size = buf->stride * buf->height; + buf->etna_dev = etna_device_new(buf->drm_fd); + buf->etna_bo = etna_bo_new(buf->etna_dev, size, flags); + + return buf->etna_bo != NULL; +} + +static void +etna_free_bo(struct buffer *buf) +{ + etna_bo_del(buf->etna_bo); +} + +static int +etna_bo_export_to_prime(struct buffer *buf) +{ + buf->dmabuf_fd = etna_bo_dmabuf(buf->etna_bo); + return buf->dmabuf_fd < 0; +} + +static int +etna_map_bo(struct buffer *buf) +{ + buf->mmap = etna_bo_map(buf->etna_bo); + return buf->mmap != NULL; +} + +static void +etna_unmap_bo(struct buffer *buf) +{ + if (munmap(buf->mmap, buf->stride * buf->height) < 0) + fprintf(stderr, "Failed to unmap buffer: %s", strerror(errno)); + buf->mmap = NULL; +} + +static void +etna_device_destroy(struct buffer *buf) +{ + etna_device_del(buf->etna_dev); +} +#endif /* HAVE_LIBDRM_ENTAVIV */ static void fill_content(struct buffer *my_buf) @@ -332,6 +390,16 @@ drm_device_init(struct buffer *buf) dev->unmap_bo = fd_unmap_bo; dev->device_destroy = fd_device_destroy; } +#endif +#ifdef HAVE_LIBDRM_ETNAVIV + else if (!strcmp(dev->name, "etnaviv")) { + dev->alloc_bo = etna_alloc_bo; + dev->free_bo = etna_free_bo; + dev->export_bo_to_prime = etna_bo_export_to_prime; + dev->map_bo = etna_map_bo; + dev->unmap_bo = etna_unmap_bo; + dev->device_destroy = etna_device_destroy; + } #endif else { fprintf(stderr, "Error: drm device %s unsupported.\n", diff --git a/configure.ac b/configure.ac index 070e61b9..d35f2255 100644 --- a/configure.ac +++ b/configure.ac @@ -393,11 +393,14 @@ if ! test "x$enable_simple_dmabuf_drm_client" = "xno"; then PKG_CHECK_MODULES(LIBDRM_PLATFORM_INTEL, [libdrm_intel], AC_DEFINE([HAVE_LIBDRM_INTEL], [1], [Build intel dmabuf client]) have_simple_dmabuf_drm_client=yes, [true]) + PKG_CHECK_MODULES(LIBDRM_PLATFORM_ETNAVIV, [libdrm_etnaviv], + AC_DEFINE([HAVE_LIBDRM_ETNAVIV], [1], [Build etnaviv dmabuf client]) have_simple_dmabuf_drm_client=yes, + [true]) if test "x$have_simple_dmabuf_drm_client" != "xyes" -o \ "x$have_simple_dmabuf_libs" = "xno" && \ test "x$enable_simple_dmabuf_drm_client" = "xyes"; then -AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but libdrm_intel or libdrm_freedreno not found]) +AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but none of libdrm_{intel,freedreno,etnaviv} found]) fi if test "x$have_simple_dmabuf_drm_client" = "xyes" -a "x$have_simple_dmabuf_libs" = "xyes"; then -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v5 2/3] simple-dmabuf-drm: simplify fd_map_bo
Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 19e8dbb1..cb04622f 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -251,11 +251,7 @@ static int fd_map_bo(struct buffer *buf) { buf->mmap = fd_bo_map(buf->fd_bo); - - if (buf->mmap != NULL) - return 1; - - return 0; + return buf->mmap != NULL; } static void -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v5 1/3] simple-dmabuf-drm: 0 is a valid fd (freedreno)
Reviewed-by: Eric Engestrom <eric.engest...@imgtec.com> Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 2975f3a5..19e8dbb1 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -244,10 +244,7 @@ static int fd_bo_export_to_prime(struct buffer *buf) { buf->dmabuf_fd = fd_bo_dmabuf(buf->fd_bo); - if (buf->dmabuf_fd > 0) - return 0; - - return 1; + return buf->dmabuf_fd < 0; } static int -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v5 0/3] simple-dmabuf-drm: Support etnaviv and freedreno cleanups
Former patches 1-2 where already applied thanks Derek. Changes from v4 - configure: use true if etnaviv drm was not found as with other drm backends (avoids an unused variable assignment) - configure: use (hopefully) correct english - simplify several if (cond) return 1; return 0; statements - unmap buffer Former patches 1-3 where already applied thanks Peka. Changes from v3: - Use ALIGN macro by default - Don't multiply by bpp twice - unmap buffer Changes from v2: - Use stride to calculate buffer size (etnaviv) - Use stride to calculate buffer size (freedreno) - Use less generic name for ALIGN macro Changes from v1: - Split up changes - autoconf: - don't define unused have_ variables. Use true instead to prevent abort of PKG_CHECK_MODULES - use && instead of -a in test - properly check variables - use vfunc for drm_device_destroy Guido Günther (3): simple-dmabuf-drm: 0 is a valid fd (freedreno) simple-dmabuf-drm: simplify fd_map_bo simple-dmabuf-drm: support etnaviv drm as well Makefile.am | 1 + clients/simple-dmabuf-drm.c | 79 +++-- configure.ac| 5 ++- 3 files changed, 75 insertions(+), 10 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v4 4/4] simple-dmabuf-drm: support etnaviv drm as well
Signed-off-by: Guido Günther <a...@sigxcpu.org> --- Makefile.am | 1 + clients/simple-dmabuf-drm.c | 77 + configure.ac| 5 ++- 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 69ca6cba..64a8006c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -629,6 +629,7 @@ nodist_weston_simple_dmabuf_drm_SOURCES = \ weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS) weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) \ $(LIBDRM_PLATFORM_FREEDRENO_LIBS) \ + $(LIBDRM_PLATFORM_ETNAVIV_LIBS) \ $(LIBDRM_PLATFORM_INTEL_LIBS) \ libshared.la endif diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 22891639..0bc99a59 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -49,6 +50,9 @@ #ifdef HAVE_LIBDRM_FREEDRENO #include #endif +#ifdef HAVE_LIBDRM_ETNAVIV +#include +#endif #include #include @@ -108,6 +112,10 @@ struct buffer { struct fd_device *fd_dev; struct fd_bo *fd_bo; #endif /* HAVE_LIBDRM_FREEDRENO */ +#if HAVE_LIBDRM_ETNAVIV + struct etna_device *etna_dev; + struct etna_bo *etna_bo; +#endif /* HAVE_LIBDRM_ETNAVIV */ uint32_t gem_handle; int dmabuf_fd; @@ -272,6 +280,65 @@ fd_device_destroy(struct buffer *buf) fd_device_del(buf->fd_dev); } #endif /* HAVE_LIBDRM_FREEDRENO */ +#ifdef HAVE_LIBDRM_ETNAVIV + +static int +etna_alloc_bo(struct buffer *buf) +{ + int flags = DRM_ETNA_GEM_CACHE_WC; + int size; + + buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; + size = buf->stride * buf->height; + buf->etna_dev = etna_device_new(buf->drm_fd); + buf->etna_bo = etna_bo_new(buf->etna_dev, size, flags); + + if (!buf->etna_bo) + return 0; + return 1; +} + +static void +etna_free_bo(struct buffer *buf) +{ + etna_bo_del(buf->etna_bo); +} + +static int +etna_bo_export_to_prime(struct buffer *buf) +{ + buf->dmabuf_fd = etna_bo_dmabuf(buf->etna_bo); + if (buf->dmabuf_fd < 0) + return 1; + + return 0; +} + +static int +etna_map_bo(struct buffer *buf) +{ + buf->mmap = etna_bo_map(buf->etna_bo); + + if (buf->mmap != NULL) + return 1; + + return 0; +} + +static void +etna_unmap_bo(struct buffer *buf) +{ + if (munmap(buf->mmap, buf->stride * buf->height) < 0) + fprintf(stderr, "Failed to unmap buffer: %s", strerror(errno)); + buf->mmap = NULL; +} + +static void +etna_device_destroy(struct buffer *buf) +{ + etna_device_del(buf->etna_dev); +} +#endif /* HAVE_LIBDRM_ENTAVIV */ static void fill_content(struct buffer *my_buf) @@ -339,6 +406,16 @@ drm_device_init(struct buffer *buf) dev->unmap_bo = fd_unmap_bo; dev->device_destroy = fd_device_destroy; } +#endif +#ifdef HAVE_LIBDRM_ETNAVIV + else if (!strcmp(dev->name, "etnaviv")) { + dev->alloc_bo = etna_alloc_bo; + dev->free_bo = etna_free_bo; + dev->export_bo_to_prime = etna_bo_export_to_prime; + dev->map_bo = etna_map_bo; + dev->unmap_bo = etna_unmap_bo; + dev->device_destroy = etna_device_destroy; + } #endif else { fprintf(stderr, "Error: drm device %s unsupported.\n", diff --git a/configure.ac b/configure.ac index 90ffc88d..29926388 100644 --- a/configure.ac +++ b/configure.ac @@ -393,11 +393,14 @@ if ! test "x$enable_simple_dmabuf_drm_client" = "xno"; then PKG_CHECK_MODULES(LIBDRM_PLATFORM_INTEL, [libdrm_intel], AC_DEFINE([HAVE_LIBDRM_INTEL], [1], [Build intel dmabuf client]) have_simple_dmabuf_drm_client=yes, [true]) + PKG_CHECK_MODULES(LIBDRM_PLATFORM_ETNAVIV, [libdrm_etnaviv], + AC_DEFINE([HAVE_LIBDRM_ETNAVIV], [1], [Build etnaviv dmabuf client]) have_simple_dmabuf_drm_client=yes, + [have_etnaviv=no]) if test "x$have_simple_dmabuf_drm_client" != "xyes" -o \ "x$have_simple_dmabuf_libs" = "xno" && \ test "x$enable_simple_dmabuf_drm_client" = "xyes"; then -AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but libdrm_intel or libdrm_freedreno not found]) +AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but neither libdrm_intel, libdrm_freedreno or libdrm_etnaviv found]) fi if test "x$have_simple_dmabuf_drm_client" = "xyes" -a "x$have_simple_dmabuf_libs" = "xyes"; then -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v4 0/4] simple-dmabuf-drm: Support etnaviv and freedreno cleanups
Changes from v3: - Use ALIGN macro by default - Don't multiply by bpp twice - unmap buffer Former patches 1-3 where already applied. Thanks! Changes from v2: - Use stride to calculate buffer size (etnaviv) - Use stride to calculate buffer size (freedreno) - Use less generic name for ALIGN macro Changes from v1: - Split up changes - autoconf: - don't define unused have_ variables. Use true instead to prevent abort of PKG_CHECK_MODULES - use && instead of -a in test - properly check variables - use vfunc for drm_device_destroy Guido Günther (4): simple-dmabuf-drm: Always define ALIGN simple-dmabuf-drm: use large enough buffer (freedreno) simple-dmabuf-drm: 0 is a valid fd (freedreno) simple-dmabuf-drm: support etnaviv drm as well Makefile.am | 1 + clients/simple-dmabuf-drm.c | 91 ++--- configure.ac| 5 ++- 3 files changed, 90 insertions(+), 7 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v4 3/4] simple-dmabuf-drm: 0 is a valid fd (freedreno)
Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index a184d7e7..22891639 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -244,10 +244,10 @@ static int fd_bo_export_to_prime(struct buffer *buf) { buf->dmabuf_fd = fd_bo_dmabuf(buf->fd_bo); - if (buf->dmabuf_fd > 0) - return 0; + if (buf->dmabuf_fd < 0) + return 1; - return 1; + return 0; } static int -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v4 1/4] simple-dmabuf-drm: Always define ALIGN
Other backends might want to use it. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 4f26e4a9..efe3b7f5 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -65,6 +65,7 @@ struct buffer; #define OPT_Y_INVERTED 1 /* contents has y axis inverted */ #define OPT_IMMEDIATE 2 /* create wl_buffer immediately */ +#define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) struct display { struct wl_display *display; @@ -215,7 +216,6 @@ intel_device_destroy(struct buffer *my_buf) #endif /* HAVE_LIBDRM_INTEL */ #ifdef HAVE_LIBDRM_FREEDRENO -#define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) static int fd_alloc_bo(struct buffer *buf) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v4 2/4] simple-dmabuf-drm: use large enough buffer (freedreno)
Use stride instead of width for buffer calculation. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index efe3b7f5..a184d7e7 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -222,13 +222,15 @@ fd_alloc_bo(struct buffer *buf) { int flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE; int size = buf->width * buf->height * buf->bpp / 8; - buf->fd_dev = fd_device_new(buf->drm_fd); + buf->fd_dev = fd_device_new(buf->drm_fd); + buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; + size = buf->stride * buf->height; + buf->fd_dev = fd_device_new(buf->drm_fd); buf->fd_bo = fd_bo_new(buf->fd_dev, size, flags); if (!buf->fd_bo) return 0; - buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; return 1; } -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 3/3] simple-dmabuf-drm: name ALIGN FD_ALIGN
Other backends might have different alignment requirements and since we can have several backends we want a less generic name. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 08e794c8..2779712e 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -222,7 +222,7 @@ intel_device_destroy(struct buffer *my_buf) #endif /* HAVE_LIBDRM_INTEL */ #ifdef HAVE_LIBDRM_FREEDRENO -#define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) +#define FD_ALIGN(v, a) ((v + a - 1) & ~(a - 1)) static int fd_alloc_bo(struct buffer *buf) @@ -230,7 +230,7 @@ fd_alloc_bo(struct buffer *buf) int flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE; int size = buf->width * buf->height * buf->bpp / 8; - buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; + buf->stride = FD_ALIGN(buf->width, 32) * buf->bpp / 8; size = buf->stride * buf->height * buf->bpp / 8; buf->fd_dev = fd_device_new(buf->drm_fd); buf->fd_bo = fd_bo_new(buf->fd_dev, size, flags); -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 2/3] simple-dmabuf-drm: use large enough buffer for freedreno
Use stride instead of width fur buffer calculation. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 174d0f85..08e794c8 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -229,13 +229,14 @@ fd_alloc_bo(struct buffer *buf) { int flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE; int size = buf->width * buf->height * buf->bpp / 8; - buf->fd_dev = fd_device_new(buf->drm_fd); + buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; + size = buf->stride * buf->height * buf->bpp / 8; + buf->fd_dev = fd_device_new(buf->drm_fd); buf->fd_bo = fd_bo_new(buf->fd_dev, size, flags); if (!buf->fd_bo) return 0; - buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; return 1; } -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 1/3] simple-dmabuf-drm: support etnaviv drm as well
Signed-off-by: Guido Günther <a...@sigxcpu.org> --- Makefile.am | 1 + clients/simple-dmabuf-drm.c | 74 + configure.ac| 5 ++- 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 69ca6cba..64a8006c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -629,6 +629,7 @@ nodist_weston_simple_dmabuf_drm_SOURCES = \ weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS) weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) \ $(LIBDRM_PLATFORM_FREEDRENO_LIBS) \ + $(LIBDRM_PLATFORM_ETNAVIV_LIBS) \ $(LIBDRM_PLATFORM_INTEL_LIBS) \ libshared.la endif diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 4f26e4a9..174d0f85 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -49,6 +49,9 @@ #ifdef HAVE_LIBDRM_FREEDRENO #include #endif +#ifdef HAVE_LIBDRM_ETNAVIV +#include +#endif #include #include @@ -107,6 +110,10 @@ struct buffer { struct fd_device *fd_dev; struct fd_bo *fd_bo; #endif /* HAVE_LIBDRM_FREEDRENO */ +#if HAVE_LIBDRM_ETNAVIV + struct etna_device *etna_dev; + struct etna_bo *etna_bo; +#endif /* HAVE_LIBDRM_ETNAVIV */ uint32_t gem_handle; int dmabuf_fd; @@ -270,6 +277,63 @@ fd_device_destroy(struct buffer *buf) fd_device_del(buf->fd_dev); } #endif /* HAVE_LIBDRM_FREEDRENO */ +#ifdef HAVE_LIBDRM_ETNAVIV +#define ETNA_ALIGN(v, a) ((v + a - 1) & ~(a - 1)) + +static int +etna_alloc_bo(struct buffer *buf) +{ + int flags = DRM_ETNA_GEM_CACHE_WC; + int size; + + buf->stride = ETNA_ALIGN(buf->width, 32) * buf->bpp / 8; + size = buf->stride * buf->height * buf->bpp / 8; + buf->etna_dev = etna_device_new(buf->drm_fd); + buf->etna_bo = etna_bo_new(buf->etna_dev, size, flags); + + if (!buf->etna_bo) + return 0; + return 1; +} + +static void +etna_free_bo(struct buffer *buf) +{ + etna_bo_del(buf->etna_bo); +} + +static int +etna_bo_export_to_prime(struct buffer *buf) +{ + buf->dmabuf_fd = etna_bo_dmabuf(buf->etna_bo); + if (buf->dmabuf_fd > 0) + return 0; + + return 1; +} + +static int +etna_map_bo(struct buffer *buf) +{ + buf->mmap = etna_bo_map(buf->etna_bo); + + if (buf->mmap != NULL) + return 1; + + return 0; +} + +static void +etna_unmap_bo(struct buffer *buf) +{ +} + +static void +etna_device_destroy(struct buffer *buf) +{ + etna_device_del(buf->etna_dev); +} +#endif /* HAVE_LIBDRM_ENTAVIV */ static void fill_content(struct buffer *my_buf) @@ -337,6 +401,16 @@ drm_device_init(struct buffer *buf) dev->unmap_bo = fd_unmap_bo; dev->device_destroy = fd_device_destroy; } +#endif +#ifdef HAVE_LIBDRM_ETNAVIV + else if (!strcmp(dev->name, "etnaviv")) { + dev->alloc_bo = etna_alloc_bo; + dev->free_bo = etna_free_bo; + dev->export_bo_to_prime = etna_bo_export_to_prime; + dev->map_bo = etna_map_bo; + dev->unmap_bo = etna_unmap_bo; + dev->device_destroy = etna_device_destroy; + } #endif else { fprintf(stderr, "Error: drm device %s unsupported.\n", diff --git a/configure.ac b/configure.ac index 90ffc88d..29926388 100644 --- a/configure.ac +++ b/configure.ac @@ -393,11 +393,14 @@ if ! test "x$enable_simple_dmabuf_drm_client" = "xno"; then PKG_CHECK_MODULES(LIBDRM_PLATFORM_INTEL, [libdrm_intel], AC_DEFINE([HAVE_LIBDRM_INTEL], [1], [Build intel dmabuf client]) have_simple_dmabuf_drm_client=yes, [true]) + PKG_CHECK_MODULES(LIBDRM_PLATFORM_ETNAVIV, [libdrm_etnaviv], + AC_DEFINE([HAVE_LIBDRM_ETNAVIV], [1], [Build etnaviv dmabuf client]) have_simple_dmabuf_drm_client=yes, + [have_etnaviv=no]) if test "x$have_simple_dmabuf_drm_client" != "xyes" -o \ "x$have_simple_dmabuf_libs" = "xno" && \ test "x$enable_simple_dmabuf_drm_client" = "xyes"; then -AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but libdrm_intel or libdrm_freedreno not found]) +AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but neither libdrm_intel, libdrm_freedreno or libdrm_etnaviv found]) fi if test "x$have_simple_dmabuf_drm_client" = "xyes" -a "x$have_simple_dmabuf_libs" = "xyes"; then -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 0/3] simple-dmabuf-drm: Support etnaviv (and other cleanups)
Former patches 1-3 where already applied. Thanks! Changes from v2: - Use stride to calculate buffer size (etnaviv) - Use stride to calculate buffer size (freedreno) - Use less generic name for ALIGN macro Changes from v1: - Split up changes - autoconf: - don't define unused have_ variables. Use true instead to prevent abort of PKG_CHECK_MODULES - use && instead of -a in test - properly check variables - use vfunc for drm_device_destroy Guido Günther (3): simple-dmabuf-drm: support etnaviv drm as well simple-dmabuf-drm: use large enough buffer for freedreno simple-dmabuf-drm: name ALIGN FD_ALIGN Makefile.am | 1 + clients/simple-dmabuf-drm.c | 81 +++-- configure.ac| 5 ++- 3 files changed, 83 insertions(+), 4 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 0/3] Allow simple-dmabuf-drm to pass y_inverted flag and cleanups
On Mon, Mar 19, 2018 at 12:12:36PM +0200, Pekka Paalanen wrote: > On Fri, 16 Mar 2018 18:56:47 +0100 > Guido Günther <a...@sigxcpu.org> wrote: > > > Changes from v2 > > > > - Explain OPT_* usage > > - Switch is_immediate to OPT_* > > - use getopt_long > > > > Changes from v1 > > > > - introduce opts as a bitmask of features that can be used to > >manipulate the displayed image > > > > Guido Günther (3): > > Allow simple-dmabuf-drm to pass y_inverted flag > > simple-dmabuf-drm: use opt bitmask instead of is_immediate > > simple-dmabuf-drm: use getopt_long > > > > clients/simple-dmabuf-drm.c | 76 > > - > > 1 file changed, 47 insertions(+), 29 deletions(-) > > > > Hi, > > all three pushed: >63fcad48..60970ec2 master -> master > For review, it would have been easier to convert to getopt_long first > and then add new options, to avoid reviewing code that gets removed > immediately after. Thanks a lot for your review! -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 0/3] Allow simple-dmabuf-drm to pass y_inverted flag and cleanups
Changes from v2 - Explain OPT_* usage - Switch is_immediate to OPT_* - use getopt_long Changes from v1 - introduce opts as a bitmask of features that can be used to manipulate the displayed image Guido Günther (3): Allow simple-dmabuf-drm to pass y_inverted flag simple-dmabuf-drm: use opt bitmask instead of is_immediate simple-dmabuf-drm: use getopt_long clients/simple-dmabuf-drm.c | 76 - 1 file changed, 47 insertions(+), 29 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 3/3] simple-dmabuf-drm: use getopt_long
Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 51 - 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 427597ab..4f26e4a9 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -877,30 +878,32 @@ main(int argc, char **argv) struct window *window; int opts = 0; int import_format = DRM_FORMAT_XRGB; - int ret = 0, i = 0; - - if (argc > 1) { - static const char import_mode[] = "--import-immediate="; - static const char format[] = "--import-format="; - static const char y_inverted[] = "--y-inverted="; - for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], import_mode, -sizeof(import_mode) - 1)) { - if (is_true(argv[i] + sizeof(import_mode) - 1)) - opts |= OPT_IMMEDIATE; - } - else if (!strncmp(argv[i], format, sizeof(format) - 1)) { - import_format = parse_import_format(argv[i] - + sizeof(format) - 1); - } - else if (!strncmp(argv[i], y_inverted, - sizeof(y_inverted) - 1)) { - if (is_true(argv[i] + sizeof(y_inverted) - 1)) - opts |= OPT_Y_INVERTED; - } - else { - print_usage_and_exit(); - } + int c, option_index, ret = 0; + + static struct option long_options[] = { + {"import-format",required_argument, 0, 'f' }, + {"import-immediate", required_argument, 0, 'i' }, + {"y-inverted", required_argument, 0, 'y' }, + {"help", no_argument , 0, 'h' }, + {0, 0, 0, 0} + }; + + while ((c = getopt_long(argc, argv, "hf:i:y:", + long_options, _index)) != -1) { + switch (c) { + case 'f': + import_format = parse_import_format(optarg); + break; + case 'i': + if (is_true(optarg)) + opts |= OPT_IMMEDIATE; + break; + case 'y': + if (is_true(optarg)) + opts |= OPT_Y_INVERTED; + break; + default: + print_usage_and_exit(); } } -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 2/3] simple-dmabuf-drm: use opt bitmask instead of is_immediate
Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 1789db73..427597ab 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -62,6 +62,7 @@ struct buffer; /* Possible options that affect the displayed image */ #define OPT_Y_INVERTED 1 /* contents has y axis inverted */ +#define OPT_IMMEDIATE 2 /* create wl_buffer immediately */ struct display { @@ -756,7 +757,7 @@ static const struct wl_registry_listener registry_listener = { }; static struct display * -create_display(int is_immediate, int format) +create_display(int opts, int format) { struct display *display; const char *extensions; @@ -769,7 +770,7 @@ create_display(int is_immediate, int format) display->display = wl_display_connect(NULL); assert(display->display); - display->req_dmabuf_immediate = is_immediate; + display->req_dmabuf_immediate = opts & OPT_IMMEDIATE; display->req_dmabuf_modifiers = (format == DRM_FORMAT_NV12); /* @@ -874,7 +875,6 @@ main(int argc, char **argv) struct sigaction sigint; struct display *display; struct window *window; - int is_immediate = 0; int opts = 0; int import_format = DRM_FORMAT_XRGB; int ret = 0, i = 0; @@ -886,8 +886,8 @@ main(int argc, char **argv) for (i = 1; i < argc; i++) { if (!strncmp(argv[i], import_mode, sizeof(import_mode) - 1)) { - is_immediate = is_true(argv[i] - + sizeof(import_mode) - 1); + if (is_true(argv[i] + sizeof(import_mode) - 1)) + opts |= OPT_IMMEDIATE; } else if (!strncmp(argv[i], format, sizeof(format) - 1)) { import_format = parse_import_format(argv[i] @@ -904,7 +904,7 @@ main(int argc, char **argv) } } - display = create_display(is_immediate, import_format); + display = create_display(opts, import_format); window = create_window(display, 256, 256, import_format, opts); if (!window) return 1; -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 1/3] Allow simple-dmabuf-drm to pass y_inverted flag
This allows to check if ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT is interpreted correctly by the compositor. We introduce an OPT_* bitmask to hold this flag and possible future command line flags. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- clients/simple-dmabuf-drm.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 492c9667..1789db73 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -60,6 +60,10 @@ extern const unsigned nv12_tiled[]; struct buffer; +/* Possible options that affect the displayed image */ +#define OPT_Y_INVERTED 1 /* contents has y axis inverted */ + + struct display { struct wl_display *display; struct wl_registry *registry; @@ -394,11 +398,11 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = { static int create_dmabuf_buffer(struct display *display, struct buffer *buffer, -int width, int height, int format) +int width, int height, int format, uint32_t opts) { struct zwp_linux_buffer_params_v1 *params; uint64_t modifier = 0; - uint32_t flags; + uint32_t flags = 0; struct drm_device *drm_dev; if (!drm_connect(buffer)) { @@ -449,7 +453,8 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, * correct height to the compositor. */ buffer->height = height; - flags = 0; + if (opts & OPT_Y_INVERTED) + flags |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT; params = zwp_linux_dmabuf_v1_create_params(display->dmabuf); zwp_linux_buffer_params_v1_add(params, @@ -532,7 +537,8 @@ static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = { }; static struct window * -create_window(struct display *display, int width, int height, int format) +create_window(struct display *display, int width, int height, int format, + uint32_t opts) { struct window *window; int i; @@ -581,7 +587,7 @@ create_window(struct display *display, int width, int height, int format) for (i = 0; i < NUM_BUFFERS; ++i) { ret = create_dmabuf_buffer(display, >buffers[i], - width, height, format); + width, height, format, opts); if (ret < 0) return NULL; @@ -829,13 +835,15 @@ print_usage_and_exit(void) printf("usage flags:\n" "\t'--import-immediate=<>'\n\t\t0 to import dmabuf via roundtrip," "\n\t\t1 to enable import without roundtrip\n" + "\t'--y-inverted=<>'\n\t\t0 to not pass Y_INVERTED flag," + "\n\t\t1 to pass Y_INVERTED flag\n" "\t'--import-format=<>'\n\t\tXRGB to import dmabuf as XRGB," "\n\t\tNV12 to import as multi plane NV12 with tiling modifier\n"); exit(0); } static int -is_import_mode_immediate(const char* c) +is_true(const char* c) { if (!strcmp(c, "1")) return 1; @@ -867,22 +875,29 @@ main(int argc, char **argv) struct display *display; struct window *window; int is_immediate = 0; + int opts = 0; int import_format = DRM_FORMAT_XRGB; int ret = 0, i = 0; if (argc > 1) { static const char import_mode[] = "--import-immediate="; static const char format[] = "--import-format="; + static const char y_inverted[] = "--y-inverted="; for (i = 1; i < argc; i++) { if (!strncmp(argv[i], import_mode, sizeof(import_mode) - 1)) { - is_immediate = is_import_mode_immediate(argv[i] + is_immediate = is_true(argv[i] + sizeof(import_mode) - 1); } else if (!strncmp(argv[i], format, sizeof(format) - 1)) { import_format = parse_import_format(argv[i] + sizeof(format) - 1); } + else if (!strncmp(argv[i], y_inverted, + sizeof(y_inverted) - 1)) { + if (is_true(argv[i] + sizeof(y_inverted) - 1)) + opts |= OPT_Y_INVERTED; + } else { print_usage_and_exit(); } @@ -890,7 +905,7 @@ main(int argc, char **ar
[PATCH weston 0/3] Allow simple-dmabuf-drm to pass y_inverted flag and cleanups
Changes from v2 - Explain OPT_* usage - Switch is_immediate to OPT_* - use getopt_long Changes from v1 - introduce opts as a bitmask of features that can be used to manipulate the displayed image Guido Günther (3): Allow simple-dmabuf-drm to pass y_inverted flag simple-dmabuf-drm: use opt bitmask instead of is_immediate simple-dmabuf-drm: use getopt_long clients/simple-dmabuf-drm.c | 76 - 1 file changed, 47 insertions(+), 29 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston v2 1/1] Allow simple-dmabuf-drm to pass y_inverted flag
On Fri, Mar 16, 2018 at 01:55:41PM +0200, Pekka Paalanen wrote: > On Thu, 15 Mar 2018 17:34:55 +0100 > Guido Günther <a...@sigxcpu.org> wrote: > > > This allows to check if ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT is > > interpreted correctly by the compositor. > > --- > > clients/simple-dmabuf-drm.c | 31 +++ > > 1 file changed, 23 insertions(+), 8 deletions(-) > > > > diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c > > index 14d716de..a6e8d870 100644 > > --- a/clients/simple-dmabuf-drm.c > > +++ b/clients/simple-dmabuf-drm.c > > @@ -59,6 +59,10 @@ > > extern const unsigned nv12_tiled[]; > > struct buffer; > > > > +/* Possible options that affect the displayed image */ > > +#define OPT_Y_INVERTED 1 > > Hi, > > why not use ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT directly? I had that first but then decided to use OPT_* so we can do other stuff like changing buffer content via options later on. We could also fold --import-immediate/is_immediate into that. > > @@ -852,22 +860,29 @@ main(int argc, char **argv) > > struct display *display; > > struct window *window; > > int is_immediate = 0; > > + int opts = 0; > > int import_format = DRM_FORMAT_XRGB; > > int ret = 0, i = 0; > > > > if (argc > 1) { > > static const char import_mode[] = "--import-immediate="; > > static const char format[] = "--import-format="; > > + static const char y_inverted[] = "--y-inverted="; > > for (i = 1; i < argc; i++) { > > if (!strncmp(argv[i], import_mode, > > sizeof(import_mode) - 1)) { > > - is_immediate = is_import_mode_immediate(argv[i] > > + is_immediate = is_true(argv[i] > > + sizeof(import_mode) - > > 1); > > } > > else if (!strncmp(argv[i], format, sizeof(format) - 1)) > > { > > import_format = parse_import_format(argv[i] > > + sizeof(format) - 1); > > } > > + else if (!strncmp(argv[i], y_inverted, > > + sizeof(y_inverted) - 1)) { > > + if (is_true(argv[i] + sizeof(y_inverted) - 1)) > > + opts |= OPT_Y_INVERTED; > > + } > > Could I persuade you to change this all to use getopt_long()? :-) Can do. Just let me know if the above OPT_ is o.k. (in this case it would be a follow up). Cheers, -- Guido ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] .gitignore weston-simple-dmabuf-drm
Got renamed in f9dec67990a54afe14d4d2db694bf696ae418bcd Signed-off-by: Guido Günther <a...@sigxcpu.org> --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ac76fd9f..661f4882 100644 --- a/.gitignore +++ b/.gitignore @@ -67,7 +67,7 @@ weston-nested-client weston-presentation-shm weston-resizor weston-scaler -weston-simple-dmabuf-intel +weston-simple-dmabuf-drm weston-simple-dmabuf-v4l weston-simple-egl weston-simple-shm -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 0/1] Allow simple-dmabuf-drm to pass y_inverted flag
Changes from v1 - introduce opts as a bitmask of features that can be used to manipulate the displayed image Guido Günther (1): Allow simple-dmabuf-drm to pass y_inverted flag clients/simple-dmabuf-drm.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 1/1] Allow simple-dmabuf-drm to pass y_inverted flag
This allows to check if ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT is interpreted correctly by the compositor. --- clients/simple-dmabuf-drm.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 14d716de..a6e8d870 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -59,6 +59,10 @@ extern const unsigned nv12_tiled[]; struct buffer; +/* Possible options that affect the displayed image */ +#define OPT_Y_INVERTED 1 + + struct display { struct wl_display *display; struct wl_registry *registry; @@ -379,11 +383,11 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = { static int create_dmabuf_buffer(struct display *display, struct buffer *buffer, -int width, int height, int format) +int width, int height, int format, uint32_t opts) { struct zwp_linux_buffer_params_v1 *params; uint64_t modifier = 0; - uint32_t flags; + uint32_t flags = 0; struct drm_device *drm_dev; if (!drm_connect(buffer)) { @@ -434,7 +438,8 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, * correct height to the compositor. */ buffer->height = height; - flags = 0; + if (opts & OPT_Y_INVERTED) + flags |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT; params = zwp_linux_dmabuf_v1_create_params(display->dmabuf); zwp_linux_buffer_params_v1_add(params, @@ -517,7 +522,8 @@ static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = { }; static struct window * -create_window(struct display *display, int width, int height, int format) +create_window(struct display *display, int width, int height, int format, + uint32_t opts) { struct window *window; int i; @@ -566,7 +572,7 @@ create_window(struct display *display, int width, int height, int format) for (i = 0; i < NUM_BUFFERS; ++i) { ret = create_dmabuf_buffer(display, >buffers[i], - width, height, format); + width, height, format, opts); if (ret < 0) return NULL; @@ -814,13 +820,15 @@ print_usage_and_exit(void) printf("usage flags:\n" "\t'--import-immediate=<>'\n\t\t0 to import dmabuf via roundtrip," "\n\t\t1 to enable import without roundtrip\n" + "\t'--y-inverted=<>'\n\t\t0 to not pass Y_INVERTED flag," + "\n\t\t1 to pass Y_INVERTED flag\n" "\t'--import-format=<>'\n\t\tXRGB to import dmabuf as XRGB," "\n\t\tNV12 to import as multi plane NV12 with tiling modifier\n"); exit(0); } static int -is_import_mode_immediate(const char* c) +is_true(const char* c) { if (!strcmp(c, "1")) return 1; @@ -852,22 +860,29 @@ main(int argc, char **argv) struct display *display; struct window *window; int is_immediate = 0; + int opts = 0; int import_format = DRM_FORMAT_XRGB; int ret = 0, i = 0; if (argc > 1) { static const char import_mode[] = "--import-immediate="; static const char format[] = "--import-format="; + static const char y_inverted[] = "--y-inverted="; for (i = 1; i < argc; i++) { if (!strncmp(argv[i], import_mode, sizeof(import_mode) - 1)) { - is_immediate = is_import_mode_immediate(argv[i] + is_immediate = is_true(argv[i] + sizeof(import_mode) - 1); } else if (!strncmp(argv[i], format, sizeof(format) - 1)) { import_format = parse_import_format(argv[i] + sizeof(format) - 1); } + else if (!strncmp(argv[i], y_inverted, + sizeof(y_inverted) - 1)) { + if (is_true(argv[i] + sizeof(y_inverted) - 1)) + opts |= OPT_Y_INVERTED; + } else { print_usage_and_exit(); } @@ -875,7 +890,7 @@ main(int argc, char **argv) } display = create_display(is_immediate, import_format); - window = create_window(display, 256, 256, import_format); + window = create_window(display, 256, 256, import_format, opts); if (!window) return 1; -- 2.16.1 ___
[PATCH weston v2 4/4] simple-dmabuf-drm: support etnaviv drm as well
--- Makefile.am | 1 + clients/simple-dmabuf-drm.c | 73 + configure.ac| 5 +++- 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c2d448e7..19319fa2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -626,6 +626,7 @@ nodist_weston_simple_dmabuf_drm_SOURCES = \ weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS) weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) \ $(LIBDRM_PLATFORM_FREEDRENO_LIBS) \ + $(LIBDRM_PLATFORM_ETNAVIV_LIBS) \ $(LIBDRM_PLATFORM_INTEL_LIBS) \ libshared.la endif diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 492c9667..a445ffb2 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -48,6 +48,9 @@ #ifdef HAVE_LIBDRM_FREEDRENO #include #endif +#ifdef HAVE_LIBDRM_ETNAVIV +#include +#endif #include #include @@ -101,6 +104,10 @@ struct buffer { struct fd_device *fd_dev; struct fd_bo *fd_bo; #endif /* HAVE_LIBDRM_FREEDRENO */ +#if HAVE_LIBDRM_ETNAVIV + struct etna_device *etna_dev; + struct etna_bo *etna_bo; +#endif /* HAVE_LIBDRM_ETNAVIV */ uint32_t gem_handle; int dmabuf_fd; @@ -264,6 +271,62 @@ fd_device_destroy(struct buffer *buf) fd_device_del(buf->fd_dev); } #endif /* HAVE_LIBDRM_FREEDRENO */ +#ifdef HAVE_LIBDRM_ETNAVIV +#define ROUND_DOWN(v, a) ((v) & ~(a - 1)) + +static int +etna_alloc_bo(struct buffer *buf) +{ + int flags = DRM_ETNA_GEM_CACHE_WC; + int size = buf->width * buf->height * buf->bpp / 8; + buf->etna_dev = etna_device_new(buf->drm_fd); + + buf->etna_bo = etna_bo_new(buf->etna_dev, size, flags); + + if (!buf->etna_bo) + return 0; + buf->stride = ROUND_DOWN(buf->width, 32) * buf->bpp / 8; + return 1; +} + +static void +etna_free_bo(struct buffer *buf) +{ + etna_bo_del(buf->etna_bo); +} + +static int +etna_bo_export_to_prime(struct buffer *buf) +{ + buf->dmabuf_fd = etna_bo_dmabuf(buf->etna_bo); + if (buf->dmabuf_fd > 0) + return 0; + + return 1; +} + +static int +etna_map_bo(struct buffer *buf) +{ + buf->mmap = etna_bo_map(buf->etna_bo); + + if (buf->mmap != NULL) + return 1; + + return 0; +} + +static void +etna_unmap_bo(struct buffer *buf) +{ +} + +static void +etna_device_destroy(struct buffer *buf) +{ + etna_device_del(buf->etna_dev); +} +#endif /* HAVE_LIBDRM_ENTAVIV */ static void fill_content(struct buffer *my_buf) @@ -331,6 +394,16 @@ drm_device_init(struct buffer *buf) dev->unmap_bo = fd_unmap_bo; dev->device_destroy = fd_device_destroy; } +#endif +#ifdef HAVE_LIBDRM_ETNAVIV + else if (!strcmp(dev->name, "etnaviv")) { + dev->alloc_bo = etna_alloc_bo; + dev->free_bo = etna_free_bo; + dev->export_bo_to_prime = etna_bo_export_to_prime; + dev->map_bo = etna_map_bo; + dev->unmap_bo = etna_unmap_bo; + dev->device_destroy = etna_device_destroy; + } #endif else { fprintf(stderr, "Error: drm device %s unsupported.\n", diff --git a/configure.ac b/configure.ac index dc2fbe93..e86c31fa 100644 --- a/configure.ac +++ b/configure.ac @@ -393,11 +393,14 @@ if ! test "x$enable_simple_dmabuf_drm_client" = "xno"; then PKG_CHECK_MODULES(LIBDRM_PLATFORM_INTEL, [libdrm_intel], AC_DEFINE([HAVE_LIBDRM_INTEL], [1], [Build intel dmabuf client]) have_simple_dmabuf_drm_client=yes, [true]) + PKG_CHECK_MODULES(LIBDRM_PLATFORM_ETNAVIV, [libdrm_etnaviv], + AC_DEFINE([HAVE_LIBDRM_ETNAVIV], [1], [Build etnaviv dmabuf client]) have_simple_dmabuf_drm_client=yes, + [have_etnaviv=no]) if test "x$have_simple_dmabuf_drm_client" != "xyes" -o \ "x$have_simple_dmabuf_libs" = "xno" && \ "x$enable_simple_dmabuf_drm_client" = "xyes"; then -AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but libdrm_intel or libdrm_freedreno not found]) +AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but neither libdrm_intel, libdrm_freedreno or libdrm_etnaviv found]) fi if test "x$have_simple_dmabuf_drm_client" = "xyes" -a "x$have_simple_dmabuf_libs"; then -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 0/4] simple-dmabuf-drm: multiple backends and etnaviv support
Changes from v1: - Split up changes - autoconf: - don't define unused have_ variables. Use true instead to prevent abort of PKG_CHECK_MODULES - use && instead of -a in test - properly check variables - use vfunc for drm_device_destroy Guido Günther (4): simple-dmabuf-drm: allow multiple backends simpla-dmabuf-drm: Use more weston like coding style simple-dmabuf-drm: use vfunc for drm_device_destroy simple-dmabuf-drm: support etnaviv drm as well Makefile.am | 6 +- clients/simple-dmabuf-drm.c | 166 +--- configure.ac| 29 +--- 3 files changed, 150 insertions(+), 51 deletions(-) -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 1/4] simple-dmabuf-drm: allow multiple backends
This allows to enable freedreno and intel backends at the same time building the prerequisites for adding further ones. --- Makefile.am | 5 - clients/simple-dmabuf-drm.c | 53 + configure.ac| 24 +++- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/Makefile.am b/Makefile.am index e028a2a1..c2d448e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -624,7 +624,10 @@ nodist_weston_simple_dmabuf_drm_SOURCES = \ protocol/linux-dmabuf-unstable-v1-protocol.c \ 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 +weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) \ + $(LIBDRM_PLATFORM_FREEDRENO_LIBS) \ + $(LIBDRM_PLATFORM_INTEL_LIBS) \ + libshared.la endif if BUILD_SIMPLE_DMABUF_V4L_CLIENT diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 14d716de..51ad51f8 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -44,7 +44,8 @@ #ifdef HAVE_LIBDRM_INTEL #include #include -#elif HAVE_LIBDRM_FREEDRENO +#endif +#ifdef HAVE_LIBDRM_FREEDRENO #include #endif #include @@ -93,10 +94,11 @@ struct buffer { #ifdef HAVE_LIBDRM_INTEL drm_intel_bufmgr *bufmgr; - drm_intel_bo *bo; -#elif HAVE_LIBDRM_FREEDRENO + drm_intel_bo *intel_bo; +#endif /* HAVE_LIBDRM_INTEL */ +#if HAVE_LIBDRM_FREEDRENO struct fd_device *fd_dev; - struct fd_bo *bo; + struct fd_bo *fd_bo; #endif /* HAVE_LIBDRM_FREEDRENO */ uint32_t gem_handle; @@ -152,15 +154,15 @@ intel_alloc_bo(struct buffer *my_buf) assert(my_buf->bufmgr); - my_buf->bo = drm_intel_bo_alloc_tiled(my_buf->bufmgr, "test", - my_buf->width, my_buf->height, - (my_buf->bpp / 8), , - _buf->stride, 0); + my_buf->intel_bo = drm_intel_bo_alloc_tiled(my_buf->bufmgr, "test", + my_buf->width, my_buf->height, + (my_buf->bpp / 8), , + _buf->stride, 0); printf("buffer allocated w %d, h %d, stride %lu, size %lu\n", - my_buf->width, my_buf->height, my_buf->stride, my_buf->bo->size); + my_buf->width, my_buf->height, my_buf->stride, my_buf->intel_bo->size); - if (!my_buf->bo) + if (!my_buf->intel_bo) return 0; if (tiling != I915_TILING_NONE) @@ -172,16 +174,16 @@ intel_alloc_bo(struct buffer *my_buf) static void intel_free_bo(struct buffer *my_buf) { - drm_intel_bo_unreference(my_buf->bo); + drm_intel_bo_unreference(my_buf->intel_bo); } static int intel_map_bo(struct buffer *my_buf) { - if (drm_intel_gem_bo_map_gtt(my_buf->bo) != 0) + if (drm_intel_gem_bo_map_gtt(my_buf->intel_bo) != 0) return 0; - my_buf->mmap = my_buf->bo->virtual; + my_buf->mmap = my_buf->intel_bo->virtual; return 1; } @@ -189,15 +191,16 @@ intel_map_bo(struct buffer *my_buf) static int intel_bo_export_to_prime(struct buffer *buffer) { - return drm_intel_bo_gem_export_to_prime(buffer->bo, >dmabuf_fd); + return drm_intel_bo_gem_export_to_prime(buffer->intel_bo, >dmabuf_fd); } static void intel_unmap_bo(struct buffer *my_buf) { - drm_intel_gem_bo_unmap_gtt(my_buf->bo); + drm_intel_gem_bo_unmap_gtt(my_buf->intel_bo); } -#elif HAVE_LIBDRM_FREEDRENO +#endif /* HAVE_LIBDRM_INTEL */ +#ifdef HAVE_LIBDRM_FREEDRENO #define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) static @@ -207,9 +210,9 @@ int fd_alloc_bo(struct buffer *buf) int size = buf->width * buf->height * buf->bpp / 8; buf->fd_dev = fd_device_new(buf->drm_fd); - buf->bo = fd_bo_new(buf->fd_dev, size, flags); + buf->fd_bo = fd_bo_new(buf->fd_dev, size, flags); - if (!buf->bo) + if (!buf->fd_bo) return 0; buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; return 1; @@ -218,13 +221,13 @@ int fd_alloc_bo(struct buffer *buf) static void fd_free_bo(struct buffer *buf) { - fd_bo_del(buf->bo); + fd_bo_del(buf->fd_bo); } static int fd_bo_export_to_prime(struct buffer *buf) { - buf->dmabuf_fd = fd_bo_dmabuf(buf->bo); + buf->dmabuf_fd = fd_bo_dmabuf(buf->fd_bo); if (buf->dmabuf_fd > 0) return 0; @@ -234,7 +237,7 @@ int fd_bo_export_to_prime(struct buffer *buf) static int fd_map_bo(struct buffer *buf) { - buf->mmap = fd_bo_map(buf->bo); + buf->mmap = fd_bo_map(buf->fd_bo); if (buf->mmap !=
[PATCH weston v2 3/4] simple-dmabuf-drm: use vfunc for drm_device_destroy
Remove ifdef clutter and makes sure it's only called for the active backend. --- clients/simple-dmabuf-drm.c | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index b576ad3a..492c9667 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -83,6 +83,7 @@ struct drm_device { int (*export_bo_to_prime)(struct buffer *buf); int (*map_bo)(struct buffer *buf); void (*unmap_bo)(struct buffer *buf); + void (*device_destroy)(struct buffer *buf); }; struct buffer { @@ -199,6 +200,13 @@ intel_unmap_bo(struct buffer *my_buf) { drm_intel_gem_bo_unmap_gtt(my_buf->intel_bo); } + +static void +intel_device_destroy(struct buffer *my_buf) +{ + drm_intel_bufmgr_destroy(my_buf->bufmgr); +} + #endif /* HAVE_LIBDRM_INTEL */ #ifdef HAVE_LIBDRM_FREEDRENO #define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) @@ -249,6 +257,12 @@ static void fd_unmap_bo(struct buffer *buf) { } + +static void +fd_device_destroy(struct buffer *buf) +{ + fd_device_del(buf->fd_dev); +} #endif /* HAVE_LIBDRM_FREEDRENO */ static void @@ -279,13 +293,7 @@ fill_content(struct buffer *my_buf) static void drm_device_destroy(struct buffer *buf) { -#ifdef HAVE_LIBDRM_INTEL - drm_intel_bufmgr_destroy(buf->bufmgr); -#endif -#ifdef HAVE_LIBDRM_FREEDRENO - fd_device_del(buf->fd_dev); -#endif - + buf->dev->device_destroy(buf); close(buf->drm_fd); } @@ -311,6 +319,7 @@ drm_device_init(struct buffer *buf) dev->export_bo_to_prime = intel_bo_export_to_prime; dev->map_bo = intel_map_bo; dev->unmap_bo = intel_unmap_bo; + dev->device_destroy = intel_device_destroy; } #endif #ifdef HAVE_LIBDRM_FREEDRENO @@ -320,6 +329,7 @@ drm_device_init(struct buffer *buf) dev->export_bo_to_prime = fd_bo_export_to_prime; dev->map_bo = fd_map_bo; dev->unmap_bo = fd_unmap_bo; + dev->device_destroy = fd_device_destroy; } #endif else { -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 2/4] simpla-dmabuf-drm: Use more weston like coding style
--- clients/simple-dmabuf-drm.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 51ad51f8..b576ad3a 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -203,8 +203,8 @@ intel_unmap_bo(struct buffer *my_buf) #ifdef HAVE_LIBDRM_FREEDRENO #define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) -static -int fd_alloc_bo(struct buffer *buf) +static int +fd_alloc_bo(struct buffer *buf) { int flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE; int size = buf->width * buf->height * buf->bpp / 8; @@ -218,14 +218,14 @@ int fd_alloc_bo(struct buffer *buf) return 1; } -static -void fd_free_bo(struct buffer *buf) +static void +fd_free_bo(struct buffer *buf) { fd_bo_del(buf->fd_bo); } -static -int fd_bo_export_to_prime(struct buffer *buf) +static int +fd_bo_export_to_prime(struct buffer *buf) { buf->dmabuf_fd = fd_bo_dmabuf(buf->fd_bo); if (buf->dmabuf_fd > 0) @@ -234,8 +234,8 @@ int fd_bo_export_to_prime(struct buffer *buf) return 1; } -static -int fd_map_bo(struct buffer *buf) +static int +fd_map_bo(struct buffer *buf) { buf->mmap = fd_bo_map(buf->fd_bo); @@ -245,8 +245,8 @@ int fd_map_bo(struct buffer *buf) return 0; } -static -void fd_unmap_bo(struct buffer *buf) +static void +fd_unmap_bo(struct buffer *buf) { } #endif /* HAVE_LIBDRM_FREEDRENO */ -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[weston PATCH] simple-dmabuf-drm: support etnaviv drm as well
Since freedreno and etnaviv can live in parallel allow to build in different DRM backends. --- Makefile.am | 6 ++- clients/simple-dmabuf-drm.c | 122 +++- configure.ac| 29 +++ 3 files changed, 121 insertions(+), 36 deletions(-) diff --git a/Makefile.am b/Makefile.am index e028a2a1..19319fa2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -624,7 +624,11 @@ nodist_weston_simple_dmabuf_drm_SOURCES = \ protocol/linux-dmabuf-unstable-v1-protocol.c \ 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 +weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) \ + $(LIBDRM_PLATFORM_FREEDRENO_LIBS) \ + $(LIBDRM_PLATFORM_ETNAVIV_LIBS) \ + $(LIBDRM_PLATFORM_INTEL_LIBS) \ + libshared.la endif if BUILD_SIMPLE_DMABUF_V4L_CLIENT diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 1073930f..8b7acd39 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -44,9 +44,13 @@ #ifdef HAVE_LIBDRM_INTEL #include #include -#elif HAVE_LIBDRM_FREEDRENO +#endif +#ifdef HAVE_LIBDRM_FREEDRENO #include #endif +#ifdef HAVE_LIBDRM_ETNAVIV +#include +#endif #include #include @@ -93,11 +97,16 @@ struct buffer { #ifdef HAVE_LIBDRM_INTEL drm_intel_bufmgr *bufmgr; - drm_intel_bo *bo; -#elif HAVE_LIBDRM_FREEDRENO + drm_intel_bo *intel_bo; +#endif /* HAVE_LIBDRM_INTEL */ +#if HAVE_LIBDRM_FREEDRENO struct fd_device *fd_dev; - struct fd_bo *bo; + struct fd_bo *fd_bo; #endif /* HAVE_LIBDRM_FREEDRENO */ +#if HAVE_LIBDRM_ETNAVIV + struct etna_device *etna_dev; + struct etna_bo *etna_bo; +#endif /* HAVE_LIBDRM_ETNAVIV */ uint32_t gem_handle; int dmabuf_fd; @@ -152,15 +161,15 @@ intel_alloc_bo(struct buffer *my_buf) assert(my_buf->bufmgr); - my_buf->bo = drm_intel_bo_alloc_tiled(my_buf->bufmgr, "test", - my_buf->width, my_buf->height, - (my_buf->bpp / 8), , - _buf->stride, 0); + my_buf->intel_bo = drm_intel_bo_alloc_tiled(my_buf->bufmgr, "test", + my_buf->width, my_buf->height, + (my_buf->bpp / 8), , + _buf->stride, 0); printf("buffer allocated w %d, h %d, stride %lu, size %lu\n", - my_buf->width, my_buf->height, my_buf->stride, my_buf->bo->size); + my_buf->width, my_buf->height, my_buf->stride, my_buf->intel_bo->size); - if (!my_buf->bo) + if (!my_buf->intel_bo) return 0; if (tiling != I915_TILING_NONE) @@ -172,16 +181,16 @@ intel_alloc_bo(struct buffer *my_buf) static void intel_free_bo(struct buffer *my_buf) { - drm_intel_bo_unreference(my_buf->bo); + drm_intel_bo_unreference(my_buf->intel_bo); } static int intel_map_bo(struct buffer *my_buf) { - if (drm_intel_gem_bo_map_gtt(my_buf->bo) != 0) + if (drm_intel_gem_bo_map_gtt(my_buf->intel_bo) != 0) return 0; - my_buf->mmap = my_buf->bo->virtual; + my_buf->mmap = my_buf->intel_bo->virtual; return 1; } @@ -189,15 +198,16 @@ intel_map_bo(struct buffer *my_buf) static int intel_bo_export_to_prime(struct buffer *buffer) { - return drm_intel_bo_gem_export_to_prime(buffer->bo, >dmabuf_fd); + return drm_intel_bo_gem_export_to_prime(buffer->intel_bo, >dmabuf_fd); } static void intel_unmap_bo(struct buffer *my_buf) { - drm_intel_gem_bo_unmap_gtt(my_buf->bo); + drm_intel_gem_bo_unmap_gtt(my_buf->intel_bo); } -#elif HAVE_LIBDRM_FREEDRENO +#endif /* HAVE_LIBDRM_INTEL */ +#ifdef HAVE_LIBDRM_FREEDRENO #define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) static @@ -207,9 +217,9 @@ int fd_alloc_bo(struct buffer *buf) int size = buf->width * buf->height * buf->bpp / 8; buf->fd_dev = fd_device_new(buf->drm_fd); - buf->bo = fd_bo_new(buf->fd_dev, size, flags); + buf->fd_bo = fd_bo_new(buf->fd_dev, size, flags); - if (!buf->bo) + if (!buf->fd_bo) return 0; buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8; return 1; @@ -218,13 +228,13 @@ int fd_alloc_bo(struct buffer *buf) static void fd_free_bo(struct buffer *buf) { - fd_bo_del(buf->bo); + fd_bo_del(buf->fd_bo); } static int fd_bo_export_to_prime(struct buffer *buf) { - buf->dmabuf_fd = fd_bo_dmabuf(buf->bo); + buf->dmabuf_fd = fd_bo_dmabuf(buf->fd_bo); if (buf->dmabuf_fd > 0) return 0; @@
[weston PATCH] Allow simple-dmabuf-drm to pass y_inverted flag
This allows to check if ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT is interpreted correctly by the compositor. --- clients/simple-dmabuf-drm.c | 27 +++ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c index 14d716de..1073930f 100644 --- a/clients/simple-dmabuf-drm.c +++ b/clients/simple-dmabuf-drm.c @@ -379,11 +379,11 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = { static int create_dmabuf_buffer(struct display *display, struct buffer *buffer, -int width, int height, int format) +int width, int height, int format, int is_y_inverted) { struct zwp_linux_buffer_params_v1 *params; uint64_t modifier = 0; - uint32_t flags; + uint32_t flags = 0; struct drm_device *drm_dev; if (!drm_connect(buffer)) { @@ -434,7 +434,8 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer, * correct height to the compositor. */ buffer->height = height; - flags = 0; + if (is_y_inverted) + flags |= ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT; params = zwp_linux_dmabuf_v1_create_params(display->dmabuf); zwp_linux_buffer_params_v1_add(params, @@ -517,7 +518,8 @@ static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = { }; static struct window * -create_window(struct display *display, int width, int height, int format) +create_window(struct display *display, int width, int height, int format, + int is_y_inverted) { struct window *window; int i; @@ -566,7 +568,7 @@ create_window(struct display *display, int width, int height, int format) for (i = 0; i < NUM_BUFFERS; ++i) { ret = create_dmabuf_buffer(display, >buffers[i], - width, height, format); + width, height, format, is_y_inverted); if (ret < 0) return NULL; @@ -814,13 +816,15 @@ print_usage_and_exit(void) printf("usage flags:\n" "\t'--import-immediate=<>'\n\t\t0 to import dmabuf via roundtrip," "\n\t\t1 to enable import without roundtrip\n" + "\t'--y-inverted=<>'\n\t\t0 to not pass Y_INVERTED flag," + "\n\t\t1 to pass Y_INVERTED flag\n" "\t'--import-format=<>'\n\t\tXRGB to import dmabuf as XRGB," "\n\t\tNV12 to import as multi plane NV12 with tiling modifier\n"); exit(0); } static int -is_import_mode_immediate(const char* c) +is_true(const char* c) { if (!strcmp(c, "1")) return 1; @@ -852,22 +856,29 @@ main(int argc, char **argv) struct display *display; struct window *window; int is_immediate = 0; + int is_y_inverted= 0; int import_format = DRM_FORMAT_XRGB; int ret = 0, i = 0; if (argc > 1) { static const char import_mode[] = "--import-immediate="; static const char format[] = "--import-format="; + static const char y_inverted[] = "--y-inverted="; for (i = 1; i < argc; i++) { if (!strncmp(argv[i], import_mode, sizeof(import_mode) - 1)) { - is_immediate = is_import_mode_immediate(argv[i] + is_immediate = is_true(argv[i] + sizeof(import_mode) - 1); } else if (!strncmp(argv[i], format, sizeof(format) - 1)) { import_format = parse_import_format(argv[i] + sizeof(format) - 1); } + else if (!strncmp(argv[i], y_inverted, +sizeof(y_inverted) - 1)) { + is_y_inverted = is_true(argv[i] + + sizeof(y_inverted) - 1); + } else { print_usage_and_exit(); } @@ -875,7 +886,7 @@ main(int argc, char **argv) } display = create_display(is_immediate, import_format); - window = create_window(display, 256, 256, import_format); + window = create_window(display, 256, 256, import_format, is_y_inverted); if (!window) return 1; -- 2.16.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] configure.ac: drop spurious bracket
Otherwise configure output looks like checking for library containing pam_open_session... -lpam ./configure: line 18064: ]: command not found checking for COLORD... yes Signed-off-by: Guido Günther <a...@sigxcpu.org> --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ed4b94fd..d1b5f471 100644 --- a/configure.ac +++ b/configure.ac @@ -449,7 +449,7 @@ fi AM_CONDITIONAL(HAVE_PANGO, test "x$have_pango" = "xyes") if test "x$have_pango" = "xyes"; then - AC_DEFINE([HAVE_PANGO], [1], [Have pango])] + AC_DEFINE([HAVE_PANGO], [1], [Have pango]) fi AM_CONDITIONAL(HAVE_CAIRO_GLESV2, -- 2.15.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel