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

2015-10-30 Thread Daniel Stone
Hi,
I know this isn't your fault, but I really really don't see any reason
why the vl winsys bits should continue to exist. We already have a
winsys/presentation layer in Mesa ...

Cheers,
Daniel

On 29 October 2015 at 17:40, Julien Isorce  wrote:
> 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   | 70 
> ---
>  2 files changed, 73 insertions(+), 6 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 a107cc4..bd533c4 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"
> @@ -36,6 +37,8 @@
>
>  #include "va_private.h"
>
> +#include 
> +
>  static struct VADriverVTable vtable =
>  {
> ,
> @@ -99,6 +102,8 @@ PUBLIC VAStatus
>  VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
>  {
> vlVaDriver *drv;
> +   int drm_fd;
> +   struct drm_state *drm_info;
>
> if (!ctx)
>return VA_STATUS_ERROR_INVALID_CONTEXT;
> @@ -107,9 +112,56 @@ 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)
> -  goto error_screen;
> +   switch (ctx->display_type) {
> +   case VA_DISPLAY_ANDROID:
> +   case VA_DISPLAY_WAYLAND:
> +  FREE(drv);
> +  return VA_STATUS_ERROR_UNIMPLEMENTED;
> +   case VA_DISPLAY_GLX:
> +   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: {
> +  drm_info = (struct drm_state *) ctx->drm_state;
> +  if (!drm_info) {
> + FREE(drv);
> + return VA_STATUS_ERROR_INVALID_PARAMETER;
> +  }
> +
> +#if GALLIUM_STATIC_TARGETS
> +  drm_fd = drm_info->fd;
> +#else
> +  drm_fd = dup(drm_info->fd);
> +#endif
> +
> +  if (drm_fd < 0) {
> + FREE(drv);
> + return VA_STATUS_ERROR_INVALID_PARAMETER;
> +  }
> +
> +  drv->vscreen = CALLOC_STRUCT(vl_screen);
> +  if (!drv->vscreen)
> + goto error_screen;
> +
> +#if GALLIUM_STATIC_TARGETS
> +  drv->vscreen->pscreen = dd_create_screen(drm_fd);
> +#else
> +  if (pipe_loader_drm_probe_fd(>dev, drm_fd))
> + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, 
> PIPE_SEARCH_DIR);
> +#endif
> +
> +  if (!drv->vscreen->pscreen)
> + goto error_pipe;
> +
> +  }
> +  break;
> +   default:
> +  FREE(drv);
> +  return VA_STATUS_ERROR_INVALID_DISPLAY;
> +   }
>
> drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen,
>   drv->vscreen, 0);
> @@ -145,7 +197,10 @@ error_htab:
> drv->pipe->destroy(drv->pipe);
>
>  error_pipe:
> -   vl_screen_destroy(drv->vscreen);
> +   if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == 
> VA_DISPLAY_X11)
> +  vl_screen_destroy(drv->vscreen);
> +   else
> +  FREE(drv->vscreen);
>
>  error_screen:
> FREE(drv);
> @@ -282,7 +337,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_GLX || 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
___
mesa-dev mailing list

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

2015-10-30 Thread Christian König

On 29.10.2015 18:40, Julien Isorce wrote:

This patch allows to use gallium vaapi without requiring
a X server running for your second graphic card.

Signed-off-by: Julien Isorce 


Reviewed-by: Christian König 


---
  src/gallium/state_trackers/va/Makefile.am |  9 
  src/gallium/state_trackers/va/context.c   | 70 ---
  2 files changed, 73 insertions(+), 6 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 a107cc4..bd533c4 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"
@@ -36,6 +37,8 @@
  
  #include "va_private.h"
  
+#include 

+
  static struct VADriverVTable vtable =
  {
 ,
@@ -99,6 +102,8 @@ PUBLIC VAStatus
  VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
  {
 vlVaDriver *drv;
+   int drm_fd;
+   struct drm_state *drm_info;
  
 if (!ctx)

return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -107,9 +112,56 @@ 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)
-  goto error_screen;
+   switch (ctx->display_type) {
+   case VA_DISPLAY_ANDROID:
+   case VA_DISPLAY_WAYLAND:
+  FREE(drv);
+  return VA_STATUS_ERROR_UNIMPLEMENTED;
+   case VA_DISPLAY_GLX:
+   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: {
+  drm_info = (struct drm_state *) ctx->drm_state;
+  if (!drm_info) {
+ FREE(drv);
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+  }
+
+#if GALLIUM_STATIC_TARGETS
+  drm_fd = drm_info->fd;
+#else
+  drm_fd = dup(drm_info->fd);
+#endif
+
+  if (drm_fd < 0) {
+ FREE(drv);
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+  }
+
+  drv->vscreen = CALLOC_STRUCT(vl_screen);
+  if (!drv->vscreen)
+ goto error_screen;
+
+#if GALLIUM_STATIC_TARGETS
+  drv->vscreen->pscreen = dd_create_screen(drm_fd);
+#else
+  if (pipe_loader_drm_probe_fd(>dev, drm_fd))
+ drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, 
PIPE_SEARCH_DIR);
+#endif
+
+  if (!drv->vscreen->pscreen)
+ goto error_pipe;
+
+  }
+  break;
+   default:
+  FREE(drv);
+  return VA_STATUS_ERROR_INVALID_DISPLAY;
+   }
  
 drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen,

   drv->vscreen, 0);
@@ -145,7 +197,10 @@ error_htab:
 drv->pipe->destroy(drv->pipe);
  
  error_pipe:

-   vl_screen_destroy(drv->vscreen);
+   if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == 
VA_DISPLAY_X11)
+  vl_screen_destroy(drv->vscreen);
+   else
+  FREE(drv->vscreen);
  
  error_screen:

 FREE(drv);
@@ -282,7 +337,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_GLX || ctx->display_type == 
VA_DISPLAY_X11)
+  vl_screen_destroy(drv->vscreen);
+   else
+  FREE(drv->vscreen);
 handle_table_destroy(drv->htab);
 FREE(drv);
  


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


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

2015-10-30 Thread Julien Isorce
Hi Daniel,

Thx for pointing this out. Where are the files related to
winsys/presentation :) ?

Is your remark a blocker for landing the patches I submitted ? Maybe we can
still land them and then if you could guide me what I should change to use
newer api that would be great.

Cheers
Julien

On 30 October 2015 at 08:47, Daniel Stone  wrote:

> Hi,
> I know this isn't your fault, but I really really don't see any reason
> why the vl winsys bits should continue to exist. We already have a
> winsys/presentation layer in Mesa ...
>
> Cheers,
> Daniel
>
> On 29 October 2015 at 17:40, Julien Isorce  wrote:
> > 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   | 70
> ---
> >  2 files changed, 73 insertions(+), 6 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 a107cc4..bd533c4 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"
> > @@ -36,6 +37,8 @@
> >
> >  #include "va_private.h"
> >
> > +#include 
> > +
> >  static struct VADriverVTable vtable =
> >  {
> > ,
> > @@ -99,6 +102,8 @@ PUBLIC VAStatus
> >  VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
> >  {
> > vlVaDriver *drv;
> > +   int drm_fd;
> > +   struct drm_state *drm_info;
> >
> > if (!ctx)
> >return VA_STATUS_ERROR_INVALID_CONTEXT;
> > @@ -107,9 +112,56 @@ 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)
> > -  goto error_screen;
> > +   switch (ctx->display_type) {
> > +   case VA_DISPLAY_ANDROID:
> > +   case VA_DISPLAY_WAYLAND:
> > +  FREE(drv);
> > +  return VA_STATUS_ERROR_UNIMPLEMENTED;
> > +   case VA_DISPLAY_GLX:
> > +   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: {
> > +  drm_info = (struct drm_state *) ctx->drm_state;
> > +  if (!drm_info) {
> > + FREE(drv);
> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
> > +  }
> > +
> > +#if GALLIUM_STATIC_TARGETS
> > +  drm_fd = drm_info->fd;
> > +#else
> > +  drm_fd = dup(drm_info->fd);
> > +#endif
> > +
> > +  if (drm_fd < 0) {
> > + FREE(drv);
> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
> > +  }
> > +
> > +  drv->vscreen = CALLOC_STRUCT(vl_screen);
> > +  if (!drv->vscreen)
> > + goto error_screen;
> > +
> > +#if GALLIUM_STATIC_TARGETS
> > +  drv->vscreen->pscreen = dd_create_screen(drm_fd);
> > +#else
> > +  if (pipe_loader_drm_probe_fd(>dev, drm_fd))
> > + drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev,
> PIPE_SEARCH_DIR);
> > +#endif
> > +
> > +  if (!drv->vscreen->pscreen)
> > + goto error_pipe;
> > +
> > +  }
> > +  break;
> > +   default:
> > +  FREE(drv);
> > +  return VA_STATUS_ERROR_INVALID_DISPLAY;
> > +   }
> >
> > drv->pipe =
> drv->vscreen->pscreen->context_create(drv->vscreen->pscreen,
> >   drv->vscreen, 0);
> > @@ -145,7 +197,10 @@ error_htab:
> > drv->pipe->destroy(drv->pipe);
> >
> >  error_pipe:
> > -   vl_screen_destroy(drv->vscreen);
> > +   if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type ==
> VA_DISPLAY_X11)
> > +  vl_screen_destroy(drv->vscreen);
> > +   else
> > +  FREE(drv->vscreen);
> >
> >  error_screen:
> > FREE(drv);
> > @@ -282,7 +337,10 @@ vlVaTerminate(VADriverContextP 

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

2015-10-30 Thread Daniel Stone
Hi Julien,

On 30 October 2015 at 11:32, Julien Isorce  wrote:
> Thx for pointing this out. Where are the files related to
> winsys/presentation :) ?

The one you're changing. ;)

src/gbm already has a great deal of infrastructure for handling direct
connections to DRM/KMS devices, buffer allocation, et al.
src/egl/drivers/dri2/platform_x11.c already has the support for
connecting to the X server, displaying buffers inside a window using
DRI2/DRI3, etc etc. src/egl/drivers/dri2/platform_wayland.c implements
everything you need to do the same with Wayland.

It would be really great if it were possible to reuse all that
infrastructure rather than reinventing it inside the VA-API code.

> Is your remark a blocker for landing the patches I submitted ? Maybe we can
> still land them and then if you could guide me what I should change to use
> newer api that would be great.

Right, as I said it's certainly not your fault! I'd be happy to see
this series land if there were an aspiration towards unifying the
codepaths.

At the moment, the winsys support in src/egl is, unsurprisingly,
pretty closely tied to EGL. So I guess it would be a matter of
modifying the existing internal EGL platform API to be able to use it
from vl_*, rather than straight reuse. DItto for gbm if there's
anything useful in there that could use the same codepaths.

Cheers,
Daniel

> Cheers
> Julien
>
>
> On 30 October 2015 at 08:47, Daniel Stone  wrote:
>>
>> Hi,
>> I know this isn't your fault, but I really really don't see any reason
>> why the vl winsys bits should continue to exist. We already have a
>> winsys/presentation layer in Mesa ...
>>
>> Cheers,
>> Daniel
>>
>> On 29 October 2015 at 17:40, Julien Isorce  wrote:
>> > 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   | 70
>> > ---
>> >  2 files changed, 73 insertions(+), 6 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 a107cc4..bd533c4 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"
>> > @@ -36,6 +37,8 @@
>> >
>> >  #include "va_private.h"
>> >
>> > +#include 
>> > +
>> >  static struct VADriverVTable vtable =
>> >  {
>> > ,
>> > @@ -99,6 +102,8 @@ PUBLIC VAStatus
>> >  VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
>> >  {
>> > vlVaDriver *drv;
>> > +   int drm_fd;
>> > +   struct drm_state *drm_info;
>> >
>> > if (!ctx)
>> >return VA_STATUS_ERROR_INVALID_CONTEXT;
>> > @@ -107,9 +112,56 @@ 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)
>> > -  goto error_screen;
>> > +   switch (ctx->display_type) {
>> > +   case VA_DISPLAY_ANDROID:
>> > +   case VA_DISPLAY_WAYLAND:
>> > +  FREE(drv);
>> > +  return VA_STATUS_ERROR_UNIMPLEMENTED;
>> > +   case VA_DISPLAY_GLX:
>> > +   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: {
>> > +  drm_info = (struct drm_state *) ctx->drm_state;
>> > +  if (!drm_info) {
>> > + FREE(drv);
>> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
>> > +  }
>> > +
>> > +#if GALLIUM_STATIC_TARGETS
>> > +  drm_fd = drm_info->fd;
>> > +#else
>> > +  drm_fd = dup(drm_info->fd);
>> > +#endif
>> > +
>> > +  if (drm_fd < 0) {
>> > + FREE(drv);
>> > +  

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

2015-10-30 Thread Emil Velikov
On 30 October 2015 at 14:48, Daniel Stone  wrote:
> Hi Julien,
>
> On 30 October 2015 at 11:32, Julien Isorce  wrote:
>> Thx for pointing this out. Where are the files related to
>> winsys/presentation :) ?
>
> The one you're changing. ;)
>
> src/gbm already has a great deal of infrastructure for handling direct
> connections to DRM/KMS devices, buffer allocation, et al.
> src/egl/drivers/dri2/platform_x11.c already has the support for
> connecting to the X server, displaying buffers inside a window using
> DRI2/DRI3, etc etc. src/egl/drivers/dri2/platform_wayland.c implements
> everything you need to do the same with Wayland.
>
> It would be really great if it were possible to reuse all that
> infrastructure rather than reinventing it inside the VA-API code.
>
>> Is your remark a blocker for landing the patches I submitted ? Maybe we can
>> still land them and then if you could guide me what I should change to use
>> newer api that would be great.
>
> Right, as I said it's certainly not your fault! I'd be happy to see
> this series land if there were an aspiration towards unifying the
> codepaths.
>
> At the moment, the winsys support in src/egl is, unsurprisingly,
> pretty closely tied to EGL. So I guess it would be a matter of
> modifying the existing internal EGL platform API to be able to use it
> from vl_*, rather than straight reuse. DItto for gbm if there's
> anything useful in there that could use the same codepaths.
>
Bth, I'm not sure if one can share much with the dri backed loaders
(libgl/libegl/libgbm) - on the drm/gbm side from we (vl) don't require
anything special.
In theory the idea is great, in practise I think that things will end
up quite ugly pretty quickly.

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


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

2015-10-29 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   | 70 ---
 2 files changed, 73 insertions(+), 6 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 a107cc4..bd533c4 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"
@@ -36,6 +37,8 @@
 
 #include "va_private.h"
 
+#include 
+
 static struct VADriverVTable vtable =
 {
,
@@ -99,6 +102,8 @@ PUBLIC VAStatus
 VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
 {
vlVaDriver *drv;
+   int drm_fd;
+   struct drm_state *drm_info;
 
if (!ctx)
   return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -107,9 +112,56 @@ 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)
-  goto error_screen;
+   switch (ctx->display_type) {
+   case VA_DISPLAY_ANDROID:
+   case VA_DISPLAY_WAYLAND:
+  FREE(drv);
+  return VA_STATUS_ERROR_UNIMPLEMENTED;
+   case VA_DISPLAY_GLX:
+   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: {
+  drm_info = (struct drm_state *) ctx->drm_state;
+  if (!drm_info) {
+ FREE(drv);
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+  }
+
+#if GALLIUM_STATIC_TARGETS
+  drm_fd = drm_info->fd;
+#else
+  drm_fd = dup(drm_info->fd);
+#endif
+
+  if (drm_fd < 0) {
+ FREE(drv);
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+  }
+
+  drv->vscreen = CALLOC_STRUCT(vl_screen);
+  if (!drv->vscreen)
+ goto error_screen;
+
+#if GALLIUM_STATIC_TARGETS
+  drv->vscreen->pscreen = dd_create_screen(drm_fd);
+#else
+  if (pipe_loader_drm_probe_fd(>dev, drm_fd))
+ drv->vscreen->pscreen = pipe_loader_create_screen(drv->dev, 
PIPE_SEARCH_DIR);
+#endif
+
+  if (!drv->vscreen->pscreen)
+ goto error_pipe;
+
+  }
+  break;
+   default:
+  FREE(drv);
+  return VA_STATUS_ERROR_INVALID_DISPLAY;
+   }
 
drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen,
  drv->vscreen, 0);
@@ -145,7 +197,10 @@ error_htab:
drv->pipe->destroy(drv->pipe);
 
 error_pipe:
-   vl_screen_destroy(drv->vscreen);
+   if (ctx->display_type == VA_DISPLAY_GLX || ctx->display_type == 
VA_DISPLAY_X11)
+  vl_screen_destroy(drv->vscreen);
+   else
+  FREE(drv->vscreen);
 
 error_screen:
FREE(drv);
@@ -282,7 +337,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_GLX || 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