Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-29 Thread Arnaud Vrac
On Thu, Oct 29, 2015 at 11:28 PM, Emil Velikov 
wrote:

> On 20 October 2015 at 17:40, Arnaud Vrac  wrote:
> > On Tue, Oct 20, 2015 at 6:35 PM, Emil Velikov 
> > wrote:
> >>
> >> On 20 October 2015 at 17:06, Julien Isorce 
> >> wrote:
> >> >
> >> >
> >> > On 19 October 2015 at 17:16, Emil Velikov 
> >> > wrote:
> >> >>
> >> >> On 17 October 2015 at 00:14, Julien Isorce 
> >> >> wrote:
> >> >> > This patch allows to use gallium vaapi without requiring
> >> >> > a X server running for your second graphic card.
> >> >> >
> >> >> I've sent a lengthy series which should mitigate the need of some
> >> >> hunks.
> >> >
> >> >
> >> > Ok I'll wait for your patches to land before going further on this
> >> > patch.
> >> > Should I expect vl_winsy_drm.c in your patches ? Not sure do
> understood
> >> > that
> >> > part. Actually I though about having "vl_screen_create_drm" and
> renames
> >> > vl_screen_create to vl_screen_create_x11 (because it takes XDisplay in
> >> > params) but then I got confused because vl_winsys.h includes Xlib.h.
> >> > Should
> >> > future vl_screen_create_drm be in another header, vl_drm.h ?
> >> >
> >> My series flattens the if GALLIUM_STATIC_TARGETS spaghetti. Although
> >> it's more of a FYI rather than "wait until they land".
> >>
> >> On the winsys_dri vs winsys_drm side - I'm not planning to do any work
> >> there, neither I did notice the Xlib.h dependency in vl_winsys.h.
> >>
> >> What I'm pondering is about having a 'proper' drm backend, although
> >> admittedly I haven't looked exactly what libva{-intel-driver,}'s
> >> definition of that is. I'd assume that moving the non-winsys specifics
> >> (from vl_winsys_dri.c) to vl_winsys.h and adding a
> >> vl_screen_texture_from_drawable() equivalent for drm (amongst others).
> >> As you can tell much of this is guesswork, so if you don't have the
> >> time and others are happy with the approach as is, feel free to
> >> ignore.
> >
> >
> > A wayland backend would be nice too.
> I'm afraid not many of us have the time and/or interest to work on
> that. Patches implementing it will be kindly accepted :-)
>
> > Right now vainfo under wayland just
> > crashes.
> >
> I guess we can separate the VA_DISPLAY_foo switch statement into a
> separate patch which can also go into stable. Personally I don't mind
> either way.
>

Julien added the VA_DISPLAY_WAYLAND in the switch in the latest patches, so
at least an error is now returned instead of crashing.

-- 
Arnaud
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-29 Thread Emil Velikov
On 20 October 2015 at 17:40, Arnaud Vrac  wrote:
> On Tue, Oct 20, 2015 at 6:35 PM, Emil Velikov 
> wrote:
>>
>> On 20 October 2015 at 17:06, Julien Isorce 
>> wrote:
>> >
>> >
>> > On 19 October 2015 at 17:16, Emil Velikov 
>> > wrote:
>> >>
>> >> On 17 October 2015 at 00:14, Julien Isorce 
>> >> wrote:
>> >> > This patch allows to use gallium vaapi without requiring
>> >> > a X server running for your second graphic card.
>> >> >
>> >> I've sent a lengthy series which should mitigate the need of some
>> >> hunks.
>> >
>> >
>> > Ok I'll wait for your patches to land before going further on this
>> > patch.
>> > Should I expect vl_winsy_drm.c in your patches ? Not sure do understood
>> > that
>> > part. Actually I though about having "vl_screen_create_drm" and renames
>> > vl_screen_create to vl_screen_create_x11 (because it takes XDisplay in
>> > params) but then I got confused because vl_winsys.h includes Xlib.h.
>> > Should
>> > future vl_screen_create_drm be in another header, vl_drm.h ?
>> >
>> My series flattens the if GALLIUM_STATIC_TARGETS spaghetti. Although
>> it's more of a FYI rather than "wait until they land".
>>
>> On the winsys_dri vs winsys_drm side - I'm not planning to do any work
>> there, neither I did notice the Xlib.h dependency in vl_winsys.h.
>>
>> What I'm pondering is about having a 'proper' drm backend, although
>> admittedly I haven't looked exactly what libva{-intel-driver,}'s
>> definition of that is. I'd assume that moving the non-winsys specifics
>> (from vl_winsys_dri.c) to vl_winsys.h and adding a
>> vl_screen_texture_from_drawable() equivalent for drm (amongst others).
>> As you can tell much of this is guesswork, so if you don't have the
>> time and others are happy with the approach as is, feel free to
>> ignore.
>
>
> A wayland backend would be nice too.
I'm afraid not many of us have the time and/or interest to work on
that. Patches implementing it will be kindly accepted :-)

> Right now vainfo under wayland just
> crashes.
>
I guess we can separate the VA_DISPLAY_foo switch statement into a
separate patch which can also go into stable. Personally I don't mind
either way.

Cheers,
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-29 Thread Emil Velikov
On 29 October 2015 at 23:04, Arnaud Vrac  wrote:
> On Thu, Oct 29, 2015 at 11:28 PM, Emil Velikov 
> wrote:
>>
>> On 20 October 2015 at 17:40, Arnaud Vrac  wrote:
>> > On Tue, Oct 20, 2015 at 6:35 PM, Emil Velikov 
>> > wrote:
>> >>
>> >> On 20 October 2015 at 17:06, Julien Isorce 
>> >> wrote:
>> >> >
>> >> >
>> >> > On 19 October 2015 at 17:16, Emil Velikov 
>> >> > wrote:
>> >> >>
>> >> >> On 17 October 2015 at 00:14, Julien Isorce 
>> >> >> wrote:
>> >> >> > This patch allows to use gallium vaapi without requiring
>> >> >> > a X server running for your second graphic card.
>> >> >> >
>> >> >> I've sent a lengthy series which should mitigate the need of some
>> >> >> hunks.
>> >> >
>> >> >
>> >> > Ok I'll wait for your patches to land before going further on this
>> >> > patch.
>> >> > Should I expect vl_winsy_drm.c in your patches ? Not sure do
>> >> > understood
>> >> > that
>> >> > part. Actually I though about having "vl_screen_create_drm" and
>> >> > renames
>> >> > vl_screen_create to vl_screen_create_x11 (because it takes XDisplay
>> >> > in
>> >> > params) but then I got confused because vl_winsys.h includes Xlib.h.
>> >> > Should
>> >> > future vl_screen_create_drm be in another header, vl_drm.h ?
>> >> >
>> >> My series flattens the if GALLIUM_STATIC_TARGETS spaghetti. Although
>> >> it's more of a FYI rather than "wait until they land".
>> >>
>> >> On the winsys_dri vs winsys_drm side - I'm not planning to do any work
>> >> there, neither I did notice the Xlib.h dependency in vl_winsys.h.
>> >>
>> >> What I'm pondering is about having a 'proper' drm backend, although
>> >> admittedly I haven't looked exactly what libva{-intel-driver,}'s
>> >> definition of that is. I'd assume that moving the non-winsys specifics
>> >> (from vl_winsys_dri.c) to vl_winsys.h and adding a
>> >> vl_screen_texture_from_drawable() equivalent for drm (amongst others).
>> >> As you can tell much of this is guesswork, so if you don't have the
>> >> time and others are happy with the approach as is, feel free to
>> >> ignore.
>> >
>> >
>> > A wayland backend would be nice too.
>> I'm afraid not many of us have the time and/or interest to work on
>> that. Patches implementing it will be kindly accepted :-)
>>
>> > Right now vainfo under wayland just
>> > crashes.
>> >
>> I guess we can separate the VA_DISPLAY_foo switch statement into a
>> separate patch which can also go into stable. Personally I don't mind
>> either way.
>
>
> Julien added the VA_DISPLAY_WAYLAND in the switch in the latest patches, so
> at least an error is now returned instead of crashing.
>
True. But as is the patch won't end up in stable. Which means that
mesa 11.0.x and earlier(?) will continue crashing.
Although my systems is fine - no wayland no problems :-P

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-20 Thread Julien Isorce
On 19 October 2015 at 17:16, Emil Velikov  wrote:

> On 17 October 2015 at 00:14, Julien Isorce 
> wrote:
> > This patch allows to use gallium vaapi without requiring
> > a X server running for your second graphic card.
> >
> I've sent a lengthy series which should mitigate the need of some hunks.
>

Ok I'll wait for your patches to land before going further on this patch.
Should I expect vl_winsy_drm.c in your patches ? Not sure do understood
that part. Actually I though about having "vl_screen_create_drm" and
renames vl_screen_create to vl_screen_create_x11 (because it takes XDisplay
in params) but then I got confused because vl_winsys.h includes Xlib.h.
Should future vl_screen_create_drm be in another header, vl_drm.h ?

Thx
Julien


> > Signed-off-by: Julien Isorce 
> > ---
> >  src/gallium/state_trackers/va/Makefile.am |  9 ++
> >  src/gallium/state_trackers/va/context.c   | 49
> +++
> >  2 files changed, 53 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/gallium/state_trackers/va/Makefile.am
> b/src/gallium/state_trackers/va/Makefile.am
> > index 2a93a90..348cfe1 100644
> > --- a/src/gallium/state_trackers/va/Makefile.am
> > +++ b/src/gallium/state_trackers/va/Makefile.am
> > @@ -30,6 +30,15 @@ AM_CFLAGS = \
> > $(VA_CFLAGS) \
> > -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)"
> >
> > +AM_CFLAGS += \
> > +   $(GALLIUM_PIPE_LOADER_DEFINES) \
> > +   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
> > +
> > +if HAVE_GALLIUM_STATIC_TARGETS
> > +AM_CFLAGS += \
> > +   -DGALLIUM_STATIC_TARGETS=1
> > +endif
> > +
> Like this one.
>
> >  AM_CPPFLAGS = \
> > -I$(top_srcdir)/include
> >
> > diff --git a/src/gallium/state_trackers/va/context.c
> b/src/gallium/state_trackers/va/context.c
> > index ddc863b..9ab2710 100644
> > --- a/src/gallium/state_trackers/va/context.c
> > +++ b/src/gallium/state_trackers/va/context.c
> > @@ -28,7 +28,8 @@
> >
> >  #include "pipe/p_screen.h"
> >  #include "pipe/p_video_codec.h"
> > -
> > +#include "pipe-loader/pipe_loader.h"
> > +#include "state_tracker/drm_driver.h"
> >  #include "util/u_memory.h"
> >  #include "util/u_handle_table.h"
> >  #include "util/u_video.h"
> > @@ -98,7 +99,7 @@ static struct VADriverVTableVPP vtable_vpp =
> >  PUBLIC VAStatus
> >  VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
> >  {
> > -   vlVaDriver *drv;
> > +   vlVaDriver *drv = NULL;
> Unnecessary change.
>
> >
> > if (!ctx)
> >return VA_STATUS_ERROR_INVALID_CONTEXT;
> > @@ -107,8 +108,40 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
> > if (!drv)
> >return VA_STATUS_ERROR_ALLOCATION_FAILED;
> >
> > -   drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
> > -   if (!drv->vscreen)
> > +   drv->vscreen = NULL;
> DItto.
>
> > +
> > +   switch (ctx->display_type) {
> > +   case VA_DISPLAY_X11:
> > +  drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
> > +  if (!drv->vscreen)
> > + goto error_screen;
> > +  break;
> > +
> > +   case VA_DISPLAY_DRM:
> > +   case VA_DISPLAY_DRM_RENDERNODES: {
> > +  struct drm_state *drm_info = (struct drm_state *) ctx->drm_state;
> > +  if (!drm_info)
> > + goto error_screen;
> > +
> > +  drv->vscreen = CALLOC_STRUCT(vl_screen);
> > +
> > +#if GALLIUM_STATIC_TARGETS
> > +  drv->vscreen->pscreen = dd_create_screen(drm_info->fd);
> > +#else
> > +  int loader_fd = dup(drm_info->fd);
> > +  if (loader_fd == -1)
> > + goto error_screen;
> > +
> > +  if (pipe_loader_drm_probe_fd(>dev, loader_fd))
> > + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev,
> PIPE_SEARCH_DIR);
> > +#endif
> And much of this.
>
> Having this around feels rather abusive. I'm leaning that ideally we
> need vl_winsy_drm.c, but I'll let others decide. At the very least the
> error paths looks quite funky. Please use the same approach as in
> vlVaTerminate()
>
> -Emil
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-20 Thread Emil Velikov
On 20 October 2015 at 17:06, Julien Isorce  wrote:
>
>
> On 19 October 2015 at 17:16, Emil Velikov  wrote:
>>
>> On 17 October 2015 at 00:14, Julien Isorce 
>> wrote:
>> > This patch allows to use gallium vaapi without requiring
>> > a X server running for your second graphic card.
>> >
>> I've sent a lengthy series which should mitigate the need of some hunks.
>
>
> Ok I'll wait for your patches to land before going further on this patch.
> Should I expect vl_winsy_drm.c in your patches ? Not sure do understood that
> part. Actually I though about having "vl_screen_create_drm" and renames
> vl_screen_create to vl_screen_create_x11 (because it takes XDisplay in
> params) but then I got confused because vl_winsys.h includes Xlib.h. Should
> future vl_screen_create_drm be in another header, vl_drm.h ?
>
My series flattens the if GALLIUM_STATIC_TARGETS spaghetti. Although
it's more of a FYI rather than "wait until they land".

On the winsys_dri vs winsys_drm side - I'm not planning to do any work
there, neither I did notice the Xlib.h dependency in vl_winsys.h.

What I'm pondering is about having a 'proper' drm backend, although
admittedly I haven't looked exactly what libva{-intel-driver,}'s
definition of that is. I'd assume that moving the non-winsys specifics
(from vl_winsys_dri.c) to vl_winsys.h and adding a
vl_screen_texture_from_drawable() equivalent for drm (amongst others).
As you can tell much of this is guesswork, so if you don't have the
time and others are happy with the approach as is, feel free to
ignore.

Cheers,
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-20 Thread Arnaud Vrac
On Tue, Oct 20, 2015 at 6:35 PM, Emil Velikov 
wrote:

> On 20 October 2015 at 17:06, Julien Isorce 
> wrote:
> >
> >
> > On 19 October 2015 at 17:16, Emil Velikov 
> wrote:
> >>
> >> On 17 October 2015 at 00:14, Julien Isorce 
> >> wrote:
> >> > This patch allows to use gallium vaapi without requiring
> >> > a X server running for your second graphic card.
> >> >
> >> I've sent a lengthy series which should mitigate the need of some hunks.
> >
> >
> > Ok I'll wait for your patches to land before going further on this patch.
> > Should I expect vl_winsy_drm.c in your patches ? Not sure do understood
> that
> > part. Actually I though about having "vl_screen_create_drm" and renames
> > vl_screen_create to vl_screen_create_x11 (because it takes XDisplay in
> > params) but then I got confused because vl_winsys.h includes Xlib.h.
> Should
> > future vl_screen_create_drm be in another header, vl_drm.h ?
> >
> My series flattens the if GALLIUM_STATIC_TARGETS spaghetti. Although
> it's more of a FYI rather than "wait until they land".
>
> On the winsys_dri vs winsys_drm side - I'm not planning to do any work
> there, neither I did notice the Xlib.h dependency in vl_winsys.h.
>
> What I'm pondering is about having a 'proper' drm backend, although
> admittedly I haven't looked exactly what libva{-intel-driver,}'s
> definition of that is. I'd assume that moving the non-winsys specifics
> (from vl_winsys_dri.c) to vl_winsys.h and adding a
> vl_screen_texture_from_drawable() equivalent for drm (amongst others).
> As you can tell much of this is guesswork, so if you don't have the
> time and others are happy with the approach as is, feel free to
> ignore.
>

A wayland backend would be nice too. Right now vainfo under wayland just
crashes.

-- 
Arnaud
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-19 Thread Emil Velikov
On 17 October 2015 at 00:14, Julien Isorce  wrote:
> This patch allows to use gallium vaapi without requiring
> a X server running for your second graphic card.
>
I've sent a lengthy series which should mitigate the need of some hunks.

> Signed-off-by: Julien Isorce 
> ---
>  src/gallium/state_trackers/va/Makefile.am |  9 ++
>  src/gallium/state_trackers/va/context.c   | 49 
> +++
>  2 files changed, 53 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/state_trackers/va/Makefile.am 
> b/src/gallium/state_trackers/va/Makefile.am
> index 2a93a90..348cfe1 100644
> --- a/src/gallium/state_trackers/va/Makefile.am
> +++ b/src/gallium/state_trackers/va/Makefile.am
> @@ -30,6 +30,15 @@ AM_CFLAGS = \
> $(VA_CFLAGS) \
> -DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)"
>
> +AM_CFLAGS += \
> +   $(GALLIUM_PIPE_LOADER_DEFINES) \
> +   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
> +
> +if HAVE_GALLIUM_STATIC_TARGETS
> +AM_CFLAGS += \
> +   -DGALLIUM_STATIC_TARGETS=1
> +endif
> +
Like this one.

>  AM_CPPFLAGS = \
> -I$(top_srcdir)/include
>
> diff --git a/src/gallium/state_trackers/va/context.c 
> b/src/gallium/state_trackers/va/context.c
> index ddc863b..9ab2710 100644
> --- a/src/gallium/state_trackers/va/context.c
> +++ b/src/gallium/state_trackers/va/context.c
> @@ -28,7 +28,8 @@
>
>  #include "pipe/p_screen.h"
>  #include "pipe/p_video_codec.h"
> -
> +#include "pipe-loader/pipe_loader.h"
> +#include "state_tracker/drm_driver.h"
>  #include "util/u_memory.h"
>  #include "util/u_handle_table.h"
>  #include "util/u_video.h"
> @@ -98,7 +99,7 @@ static struct VADriverVTableVPP vtable_vpp =
>  PUBLIC VAStatus
>  VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
>  {
> -   vlVaDriver *drv;
> +   vlVaDriver *drv = NULL;
Unnecessary change.

>
> if (!ctx)
>return VA_STATUS_ERROR_INVALID_CONTEXT;
> @@ -107,8 +108,40 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
> if (!drv)
>return VA_STATUS_ERROR_ALLOCATION_FAILED;
>
> -   drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
> -   if (!drv->vscreen)
> +   drv->vscreen = NULL;
DItto.

> +
> +   switch (ctx->display_type) {
> +   case VA_DISPLAY_X11:
> +  drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
> +  if (!drv->vscreen)
> + goto error_screen;
> +  break;
> +
> +   case VA_DISPLAY_DRM:
> +   case VA_DISPLAY_DRM_RENDERNODES: {
> +  struct drm_state *drm_info = (struct drm_state *) ctx->drm_state;
> +  if (!drm_info)
> + goto error_screen;
> +
> +  drv->vscreen = CALLOC_STRUCT(vl_screen);
> +
> +#if GALLIUM_STATIC_TARGETS
> +  drv->vscreen->pscreen = dd_create_screen(drm_info->fd);
> +#else
> +  int loader_fd = dup(drm_info->fd);
> +  if (loader_fd == -1)
> + goto error_screen;
> +
> +  if (pipe_loader_drm_probe_fd(>dev, loader_fd))
> + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, 
> PIPE_SEARCH_DIR);
> +#endif
And much of this.

Having this around feels rather abusive. I'm leaning that ideally we
need vl_winsy_drm.c, but I'll let others decide. At the very least the
error paths looks quite funky. Please use the same approach as in
vlVaTerminate()

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 7/7] st/va: add headless support, i.e. VA_DISPLAY_DRM

2015-10-16 Thread Julien Isorce
This patch allows to use gallium vaapi without requiring
a X server running for your second graphic card.

Signed-off-by: Julien Isorce 
---
 src/gallium/state_trackers/va/Makefile.am |  9 ++
 src/gallium/state_trackers/va/context.c   | 49 +++
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/va/Makefile.am 
b/src/gallium/state_trackers/va/Makefile.am
index 2a93a90..348cfe1 100644
--- a/src/gallium/state_trackers/va/Makefile.am
+++ b/src/gallium/state_trackers/va/Makefile.am
@@ -30,6 +30,15 @@ AM_CFLAGS = \
$(VA_CFLAGS) \
-DVA_DRIVER_INIT_FUNC="__vaDriverInit_$(VA_MAJOR)_$(VA_MINOR)"
 
+AM_CFLAGS += \
+   $(GALLIUM_PIPE_LOADER_DEFINES) \
+   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
+
+if HAVE_GALLIUM_STATIC_TARGETS
+AM_CFLAGS += \
+   -DGALLIUM_STATIC_TARGETS=1
+endif
+
 AM_CPPFLAGS = \
-I$(top_srcdir)/include
 
diff --git a/src/gallium/state_trackers/va/context.c 
b/src/gallium/state_trackers/va/context.c
index ddc863b..9ab2710 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -28,7 +28,8 @@
 
 #include "pipe/p_screen.h"
 #include "pipe/p_video_codec.h"
-
+#include "pipe-loader/pipe_loader.h"
+#include "state_tracker/drm_driver.h"
 #include "util/u_memory.h"
 #include "util/u_handle_table.h"
 #include "util/u_video.h"
@@ -98,7 +99,7 @@ static struct VADriverVTableVPP vtable_vpp =
 PUBLIC VAStatus
 VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
 {
-   vlVaDriver *drv;
+   vlVaDriver *drv = NULL;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -107,8 +108,40 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
if (!drv)
   return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
-   drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
-   if (!drv->vscreen)
+   drv->vscreen = NULL;
+
+   switch (ctx->display_type) {
+   case VA_DISPLAY_X11:
+  drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
+  if (!drv->vscreen)
+ goto error_screen;
+  break;
+
+   case VA_DISPLAY_DRM:
+   case VA_DISPLAY_DRM_RENDERNODES: {
+  struct drm_state *drm_info = (struct drm_state *) ctx->drm_state;
+  if (!drm_info)
+ goto error_screen;
+
+  drv->vscreen = CALLOC_STRUCT(vl_screen);
+
+#if GALLIUM_STATIC_TARGETS
+  drv->vscreen->pscreen = dd_create_screen(drm_info->fd);
+#else
+  int loader_fd = dup(drm_info->fd);
+  if (loader_fd == -1)
+ goto error_screen;
+
+  if (pipe_loader_drm_probe_fd(>dev, loader_fd))
+ drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, 
PIPE_SEARCH_DIR);
+#endif
+  }
+  break;
+   default:
+  goto error_screen;
+   }
+
+   if (!drv->vscreen->pscreen)
   goto error_screen;
 
drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen,
@@ -146,8 +179,11 @@ error_htab:
 
 error_pipe:
vl_screen_destroy(drv->vscreen);
+   drv->vscreen = NULL;
 
 error_screen:
+   if (drv->vscreen)
+  FREE(drv->vscreen);
FREE(drv);
return VA_STATUS_ERROR_ALLOCATION_FAILED;
 }
@@ -266,7 +302,10 @@ vlVaTerminate(VADriverContextP ctx)
vl_compositor_cleanup_state(>cstate);
vl_compositor_cleanup(>compositor);
drv->pipe->destroy(drv->pipe);
-   vl_screen_destroy(drv->vscreen);
+   if (ctx->display_type == VA_DISPLAY_X11)
+  vl_screen_destroy(drv->vscreen);
+   else
+   FREE(drv->vscreen);
handle_table_destroy(drv->htab);
FREE(drv);
 
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev