Re: [PATCH xserver v3] xwayland: add glamor Xv adaptor
On Tue, 2016-03-08 at 10:15 -0500, Olivier Fourdan wrote: > Hi Adam, > > I had posted a revisited version using GL_MAX_TEXTURE_SIZE to > determine the encoder size as per your review last week, is there > anything else that needs rework? This adds a warning, but I don't think that's your fault: xwayland-glamor-xv.c: In function ‘xwl_glamor_xv_add_adaptors’: xwayland-glamor-xv.c:339:16: warning: large integer implicitly truncated to unsigned type [-Woverflow] pa->type = XvWindowMask | XvInputMask | XvImageMask;; ^ % grep Xv.*put /usr/include/X11/extensions/*h /usr/include/X11/extensions/Xv.h:#define XvInput 0 /usr/include/X11/extensions/Xv.h:#define XvOutput 1 /usr/include/X11/extensions/Xv.h:#define XvInputMask (1L<
Re: [PATCH xserver v3] xwayland: add glamor Xv adaptor
Hi Adam, I had posted a revisited version using GL_MAX_TEXTURE_SIZE to determine the encoder size as per your review last week, is there anything else that needs rework? Cheers, Olivier - Original Message - > This adds an Xv adaptor using glamor. > > Signed-off-by: Olivier Fourdan> --- > v2: Plug leak of Xv adaptor and glamor private ports array on closure > v3: Get the adaptor size from the GL_MAX_TEXTURE_SIZE > > hw/xwayland/Makefile.am | 4 +- > hw/xwayland/xwayland-glamor-xv.c | 413 > +++ > hw/xwayland/xwayland-glamor.c| 3 + > hw/xwayland/xwayland.h | 2 + > 4 files changed, 421 insertions(+), 1 deletion(-) > create mode 100644 hw/xwayland/xwayland-glamor-xv.c > > diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am > index 0905082..26fdba7 100644 > --- a/hw/xwayland/Makefile.am > +++ b/hw/xwayland/Makefile.am > @@ -32,7 +32,9 @@ Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) > > > if GLAMOR_EGL > -Xwayland_SOURCES += xwayland-glamor.c > +Xwayland_SOURCES += \ > + xwayland-glamor.c \ > + xwayland-glamor-xv.c > > nodist_Xwayland_SOURCES =\ > drm-client-protocol.h \ > diff --git a/hw/xwayland/xwayland-glamor-xv.c > b/hw/xwayland/xwayland-glamor-xv.c > new file mode 100644 > index 000..5fa1c69 > --- /dev/null > +++ b/hw/xwayland/xwayland-glamor-xv.c > @@ -0,0 +1,413 @@ > +/* > + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. > + * Copyright © 2013 Red Hat > + * Copyright © 2014 Intel Corporation > + * Copyright © 2016 Red Hat > + * > + * 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. > + * > + * Authors: > + * Olivier Fourdan > + * > + * Derived from the glamor_xf86_xv, ephyr_glamor_xv and xf86xv > + * implementations > + */ > + > +#include "xwayland.h" > +#include "glamor_priv.h" > + > +#include > + > +#define NUM_FORMATS3 > +#define NUM_PORTS 16 > +#define ADAPTOR_NAME "glamor textured video" > +#define ENCODER_NAME "XV_IMAGE" > + > +static DevPrivateKeyRec xwlXvScreenPrivateKeyRec; > +#define xwlXvScreenPrivateKey () > + > +typedef struct { > +XvAdaptorPtr glxv_adaptor; /* We have only one adaptor, glamor Xv */ > +glamor_port_private *port_privates; > + > +CloseScreenProcPtr CloseScreen; > +} xwlXvScreenRec, *xwlXvScreenPtr; > + > +typedef struct { > +char depth; > +short class; > +} xwlVideoFormatRec, *xwlVideoFormatPtr; > + > +static xwlVideoFormatRec Formats[NUM_FORMATS] = { > +{15, TrueColor}, > +{16, TrueColor}, > +{24, TrueColor} > +}; > + > +static int > +xwl_glamor_xv_stop_video(XvPortPtr pPort, > + DrawablePtr pDraw) > +{ > +glamor_port_private *gpp = (glamor_port_private *) (pPort->devPriv.ptr); > + > +if (pDraw->type != DRAWABLE_WINDOW) > +return BadAlloc; > + > +glamor_xv_stop_video(gpp); > + > +return Success; > +} > + > +static int > +xwl_glamor_xv_set_port_attribute(XvPortPtr pPort, > + Atom attribute, > + INT32 value) > +{ > +glamor_port_private *gpp = (glamor_port_private *) (pPort->devPriv.ptr); > + > +return glamor_xv_set_port_attribute(gpp, attribute, value); > +} > + > +static int > +xwl_glamor_xv_get_port_attribute(XvPortPtr pPort, > + Atom attribute, > + INT32*pValue) > +{ > +glamor_port_private *gpp = (glamor_port_private *) (pPort->devPriv.ptr); > + > +return glamor_xv_get_port_attribute(gpp, attribute, pValue); > +} > + > +static int > +xwl_glamor_xv_query_best_size(XvPortPtr pPort, > + CARD8 motion, > +
[PATCH xserver v3] xwayland: add glamor Xv adaptor
This adds an Xv adaptor using glamor. Signed-off-by: Olivier Fourdan--- v2: Plug leak of Xv adaptor and glamor private ports array on closure v3: Get the adaptor size from the GL_MAX_TEXTURE_SIZE hw/xwayland/Makefile.am | 4 +- hw/xwayland/xwayland-glamor-xv.c | 413 +++ hw/xwayland/xwayland-glamor.c| 3 + hw/xwayland/xwayland.h | 2 + 4 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 hw/xwayland/xwayland-glamor-xv.c diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am index 0905082..26fdba7 100644 --- a/hw/xwayland/Makefile.am +++ b/hw/xwayland/Makefile.am @@ -32,7 +32,9 @@ Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) if GLAMOR_EGL -Xwayland_SOURCES += xwayland-glamor.c +Xwayland_SOURCES +=\ + xwayland-glamor.c \ + xwayland-glamor-xv.c nodist_Xwayland_SOURCES = \ drm-client-protocol.h \ diff --git a/hw/xwayland/xwayland-glamor-xv.c b/hw/xwayland/xwayland-glamor-xv.c new file mode 100644 index 000..5fa1c69 --- /dev/null +++ b/hw/xwayland/xwayland-glamor-xv.c @@ -0,0 +1,413 @@ +/* + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. + * Copyright © 2013 Red Hat + * Copyright © 2014 Intel Corporation + * Copyright © 2016 Red Hat + * + * 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. + * + * Authors: + * Olivier Fourdan + * + * Derived from the glamor_xf86_xv, ephyr_glamor_xv and xf86xv + * implementations + */ + +#include "xwayland.h" +#include "glamor_priv.h" + +#include + +#define NUM_FORMATS3 +#define NUM_PORTS 16 +#define ADAPTOR_NAME "glamor textured video" +#define ENCODER_NAME "XV_IMAGE" + +static DevPrivateKeyRec xwlXvScreenPrivateKeyRec; +#define xwlXvScreenPrivateKey () + +typedef struct { +XvAdaptorPtr glxv_adaptor; /* We have only one adaptor, glamor Xv */ +glamor_port_private *port_privates; + +CloseScreenProcPtr CloseScreen; +} xwlXvScreenRec, *xwlXvScreenPtr; + +typedef struct { +char depth; +short class; +} xwlVideoFormatRec, *xwlVideoFormatPtr; + +static xwlVideoFormatRec Formats[NUM_FORMATS] = { +{15, TrueColor}, +{16, TrueColor}, +{24, TrueColor} +}; + +static int +xwl_glamor_xv_stop_video(XvPortPtr pPort, + DrawablePtr pDraw) +{ +glamor_port_private *gpp = (glamor_port_private *) (pPort->devPriv.ptr); + +if (pDraw->type != DRAWABLE_WINDOW) +return BadAlloc; + +glamor_xv_stop_video(gpp); + +return Success; +} + +static int +xwl_glamor_xv_set_port_attribute(XvPortPtr pPort, + Atom attribute, + INT32 value) +{ +glamor_port_private *gpp = (glamor_port_private *) (pPort->devPriv.ptr); + +return glamor_xv_set_port_attribute(gpp, attribute, value); +} + +static int +xwl_glamor_xv_get_port_attribute(XvPortPtr pPort, + Atom attribute, + INT32*pValue) +{ +glamor_port_private *gpp = (glamor_port_private *) (pPort->devPriv.ptr); + +return glamor_xv_get_port_attribute(gpp, attribute, pValue); +} + +static int +xwl_glamor_xv_query_best_size(XvPortPtr pPort, + CARD8 motion, + CARD16vid_w, + CARD16vid_h, + CARD16drw_w, + CARD16drw_h, + unsigned int *p_w, + unsigned int *p_h) +{ +*p_w = drw_w; +*p_h = drw_h; + +return Success; +} + +static int +xwl_glamor_xv_query_image_attributes(XvPortPtr pPort, + XvImagePtr format, +