Re: [Mesa-dev] [PATCH v3 4/4] st/omx: add headless support

2015-11-09 Thread Emil Velikov
Hi Leo,

I'm glad that you've caught the places where I was day dreaming but
again, please don't just ignore suggestions. If you believe there is
something wrong with them just say so (as you did with
debug_get_options).

On 6 November 2015 at 18:43, Leo Liu  wrote:
> This will allow dec/enc/transcode without X
>
> v2:  -use env override even with X,
>  -use loader_open_device instead of open
> v3:  -cleanup
>
> Signed-off-by: Leo Liu 
> Reviewed-by: Christian König 
> ---
>  src/gallium/state_trackers/omx/entrypoint.c | 45 
> ++---
>  1 file changed, 35 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/state_trackers/omx/entrypoint.c 
> b/src/gallium/state_trackers/omx/entrypoint.c
> index a765666..7df90b1 100644
> --- a/src/gallium/state_trackers/omx/entrypoint.c
> +++ b/src/gallium/state_trackers/omx/entrypoint.c
> @@ -38,6 +38,7 @@
>
>  #include "os/os_thread.h"
>  #include "util/u_memory.h"
> +#include "loader/loader.h"
>
>  #include "entrypoint.h"
>  #include "vid_dec.h"
> @@ -47,6 +48,8 @@ pipe_static_mutex(omx_lock);
>  static Display *omx_display = NULL;
>  static struct vl_screen *omx_screen = NULL;
>  static unsigned omx_usecount = 0;
> +static const char *omx_render_node = NULL;
> +static int drm_fd;
>
>  int omx_component_library_Setup(stLoaderComponentType **stComponents)
>  {
> @@ -73,18 +76,30 @@ struct vl_screen *omx_get_screen(void)
> pipe_mutex_lock(omx_lock);
>
> if (!omx_display) {
> -  omx_display = XOpenDisplay(NULL);
> -  if (!omx_display) {
> - pipe_mutex_unlock(omx_lock);
> - return NULL;
> +  omx_render_node = debug_get_option("OMX_RENDER_NODE", NULL);
> +  if (!omx_render_node) {
> + omx_display = XOpenDisplay(NULL);
> + if (!omx_display)
> +goto error;
>}
> }
>
> if (!omx_screen) {
> -  omx_screen = vl_screen_create(omx_display, 0);
> -  if (!omx_screen) {
> - pipe_mutex_unlock(omx_lock);
> - return NULL;
> +  if (omx_render_node) {
> + drm_fd = loader_open_device(omx_render_node);
> + if (drm_fd < 0)
> +goto error;
> + omx_screen = vl_drm_screen_create(drm_fd);
> + if (!omx_screen) {
> +close(drm_fd);
> +goto error;
> + }
> +  } else {
> + omx_screen = vl_screen_create(omx_display, 0);
> + if (!omx_screen) {
> +XCloseDisplay(omx_display);
> +goto error;
> + }
>}
> }
>
This whole hunk is backwards in so many ways, that I've decided to
respin your patch ... yet you didn't really wait :-\

I'll send the fixes as a separate patch.

-Emil
P.S. Patience is a virtue.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 4/4] st/omx: add headless support

2015-11-06 Thread Leo Liu
This will allow dec/enc/transcode without X

v2:  -use env override even with X,
 -use loader_open_device instead of open
v3:  -cleanup

Signed-off-by: Leo Liu 
Reviewed-by: Christian König 
---
 src/gallium/state_trackers/omx/entrypoint.c | 45 ++---
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/omx/entrypoint.c 
b/src/gallium/state_trackers/omx/entrypoint.c
index a765666..7df90b1 100644
--- a/src/gallium/state_trackers/omx/entrypoint.c
+++ b/src/gallium/state_trackers/omx/entrypoint.c
@@ -38,6 +38,7 @@
 
 #include "os/os_thread.h"
 #include "util/u_memory.h"
+#include "loader/loader.h"
 
 #include "entrypoint.h"
 #include "vid_dec.h"
@@ -47,6 +48,8 @@ pipe_static_mutex(omx_lock);
 static Display *omx_display = NULL;
 static struct vl_screen *omx_screen = NULL;
 static unsigned omx_usecount = 0;
+static const char *omx_render_node = NULL;
+static int drm_fd;
 
 int omx_component_library_Setup(stLoaderComponentType **stComponents)
 {
@@ -73,18 +76,30 @@ struct vl_screen *omx_get_screen(void)
pipe_mutex_lock(omx_lock);
 
if (!omx_display) {
-  omx_display = XOpenDisplay(NULL);
-  if (!omx_display) {
- pipe_mutex_unlock(omx_lock);
- return NULL;
+  omx_render_node = debug_get_option("OMX_RENDER_NODE", NULL);
+  if (!omx_render_node) {
+ omx_display = XOpenDisplay(NULL);
+ if (!omx_display)
+goto error;
   }
}
 
if (!omx_screen) {
-  omx_screen = vl_screen_create(omx_display, 0);
-  if (!omx_screen) {
- pipe_mutex_unlock(omx_lock);
- return NULL;
+  if (omx_render_node) {
+ drm_fd = loader_open_device(omx_render_node);
+ if (drm_fd < 0)
+goto error;
+ omx_screen = vl_drm_screen_create(drm_fd);
+ if (!omx_screen) {
+close(drm_fd);
+goto error;
+ }
+  } else {
+ omx_screen = vl_screen_create(omx_display, 0);
+ if (!omx_screen) {
+XCloseDisplay(omx_display);
+goto error;
+ }
   }
}
 
@@ -92,14 +107,24 @@ struct vl_screen *omx_get_screen(void)
 
pipe_mutex_unlock(omx_lock);
return omx_screen;
+
+error:
+   pipe_mutex_unlock(omx_lock);
+   return NULL;
 }
 
 void omx_put_screen(void)
 {
pipe_mutex_lock(omx_lock);
if ((--omx_usecount) == 0) {
-  vl_screen_destroy(omx_screen);
-  XCloseDisplay(omx_display);
+  if (!omx_render_node) {
+ vl_screen_destroy(omx_screen);
+ if (omx_display)
+XCloseDisplay(omx_display);
+  } else {
+ close(drm_fd);
+ vl_drm_screen_destroy(omx_screen);
+  }
   omx_screen = NULL;
   omx_display = NULL;
}
-- 
1.9.1

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