<div dir="ltr">Hi Gurkirpal,<div><br></div><div><div>> Before refactoring process both the state trackers were in independent directories.</div><div>> During earlier refactoring effort we decided to keep that directory structure so it made</div><div>> sense to move them to auxiliary code. After that I moved them both under st/omx.</div><div>> Since there could be a chance of it being useful out of st/omx, I left the decision to</div><div>> keep it or move it back to st/omx to the mailing list.</div></div><div><br></div><div>Yes please move it back to st/omx for the reasons you said, i.e. there will now 2</div><div>sub directories, st/omx/bellagio and st/omx/tizonia and common code in st/omx.</div><div><br></div><div>Another reason is that the env var <span style="font-size:12.8px">"OMX_RENDER_</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">NODE" mentions OMX.</span></div><div><br></div><div>Thx!</div><div>Julien</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 November 2017 at 04:02, Gurkirpal Singh <span dir="ltr"><<a href="mailto:gurkirpal204@gmail.com" target="_blank">gurkirpal204@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
src/gallium/auxiliary/<wbr>Makefile.sources | 2 +<br>
src/gallium/auxiliary/vl/vl_<wbr>screen.c | 107 +++++++++++++++++++++<br>
src/gallium/auxiliary/vl/vl_<wbr>screen.h | 33 +++++++<br>
.../state_trackers/omx_<wbr>bellagio/entrypoint.c | 83 ----------------<br>
.../state_trackers/omx_<wbr>bellagio/entrypoint.h | 3 -<br>
src/gallium/state_trackers/<wbr>omx_bellagio/vid_dec.c | 5 +-<br>
src/gallium/state_trackers/<wbr>omx_bellagio/vid_enc.c | 5 +-<br>
7 files changed, 148 insertions(+), 90 deletions(-)<br>
create mode 100644 src/gallium/auxiliary/vl/vl_<wbr>screen.c<br>
create mode 100644 src/gallium/auxiliary/vl/vl_<wbr>screen.h<br>
<br>
diff --git a/src/gallium/auxiliary/<wbr>Makefile.sources b/src/gallium/auxiliary/<wbr>Makefile.sources<br>
index f40c472..35e89f9 100644<br>
--- a/src/gallium/auxiliary/<wbr>Makefile.sources<br>
+++ b/src/gallium/auxiliary/<wbr>Makefile.sources<br>
@@ -343,6 +343,8 @@ VL_SOURCES := \<br>
vl/vl_mpeg12_decoder.c \<br>
vl/vl_mpeg12_decoder.h \<br>
vl/vl_rbsp.h \<br>
+ vl/vl_screen.c \<br>
+ vl/vl_screen.h \<br>
vl/vl_types.h \<br>
vl/vl_vertex_buffers.c \<br>
vl/vl_vertex_buffers.h \<br>
diff --git a/src/gallium/auxiliary/vl/vl_<wbr>screen.c b/src/gallium/auxiliary/vl/vl_<wbr>screen.c<br>
new file mode 100644<br>
index 0000000..7192802<br>
--- /dev/null<br>
+++ b/src/gallium/auxiliary/vl/vl_<wbr>screen.c<br>
@@ -0,0 +1,107 @@<br>
+/****************************<wbr>******************************<wbr>****************<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the<br>
+ * "Software"), to deal in the Software without restriction, including<br>
+ * without limitation the rights to use, copy, modify, merge, publish,<br>
+ * distribute, sub license, and/or sell copies of the Software, and to<br>
+ * permit persons to whom the Software is furnished to do so, subject to<br>
+ * the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the<br>
+ * next paragraph) shall be included in all copies or substantial portions<br>
+ * of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.<br>
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR<br>
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ ******************************<wbr>******************************<wbr>**************/<br>
+<br>
+#include <assert.h><br>
+#include <string.h><br>
+#include <stdbool.h><br>
+<br>
+#include "os/os_thread.h"<br>
+#include "util/u_memory.h"<br>
+#include "loader/loader.h"<br>
+#include "vl_screen.h"<br>
+<br>
+#if defined(HAVE_X11_PLATFORM)<br>
+#include <X11/Xlib.h><br>
+#else<br>
+#define XOpenDisplay(x) NULL<br>
+#define XCloseDisplay(x)<br>
+#define Display void<br>
+#endif<br>
+<br>
+static mtx_t st_lock = _MTX_INITIALIZER_NP;<br>
+static Display *st_display = NULL;<br>
+static struct vl_screen *st_screen = NULL;<br>
+static unsigned st_usecount = 0;<br>
+static const char *st_render_node = NULL;<br>
+static int drm_fd;<br>
+<br>
+struct vl_screen *vl_get_screen(const char* render_node)<br>
+{<br>
+ static bool first_time = true;<br>
+ mtx_lock(&st_lock);<br>
+<br>
+ if (!st_screen) {<br>
+ if (first_time) {<br>
+ st_render_node = debug_get_option(render_node, NULL);<br>
+ first_time = false;<br>
+ }<br>
+ if (st_render_node) {<br>
+ drm_fd = loader_open_device(st_render_<wbr>node);<br>
+ if (drm_fd < 0)<br>
+ goto error;<br>
+<br>
+ st_screen = vl_drm_screen_create(drm_fd);<br>
+ if (!st_screen) {<br>
+ close(drm_fd);<br>
+ goto error;<br>
+ }<br>
+ } else {<br>
+ st_display = XOpenDisplay(NULL);<br>
+ if (!st_display)<br>
+ goto error;<br>
+<br>
+ st_screen = vl_dri3_screen_create(st_<wbr>display, 0);<br>
+ if (!st_screen)<br>
+ st_screen = vl_dri2_screen_create(st_<wbr>display, 0);<br>
+ if (!st_screen) {<br>
+ XCloseDisplay(st_display);<br>
+ goto error;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ ++st_usecount;<br>
+<br>
+ mtx_unlock(&st_lock);<br>
+ return st_screen;<br>
+<br>
+error:<br>
+ mtx_unlock(&st_lock);<br>
+ return NULL;<br>
+}<br>
+<br>
+void vl_put_screen(void)<br>
+{<br>
+ mtx_lock(&st_lock);<br>
+ if ((--st_usecount) == 0) {<br>
+ st_screen->destroy(st_screen);<br>
+ st_screen = NULL;<br>
+<br>
+ if (st_render_node)<br>
+ close(drm_fd);<br>
+ else<br>
+ XCloseDisplay(st_display);<br>
+ }<br>
+ mtx_unlock(&st_lock);<br>
+}<br>
diff --git a/src/gallium/auxiliary/vl/vl_<wbr>screen.h b/src/gallium/auxiliary/vl/vl_<wbr>screen.h<br>
new file mode 100644<br>
index 0000000..1e14775<br>
--- /dev/null<br>
+++ b/src/gallium/auxiliary/vl/vl_<wbr>screen.h<br>
@@ -0,0 +1,33 @@<br>
+/****************************<wbr>******************************<wbr>****************<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the<br>
+ * "Software"), to deal in the Software without restriction, including<br>
+ * without limitation the rights to use, copy, modify, merge, publish,<br>
+ * distribute, sub license, and/or sell copies of the Software, and to<br>
+ * permit persons to whom the Software is furnished to do so, subject to<br>
+ * the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the<br>
+ * next paragraph) shall be included in all copies or substantial portions<br>
+ * of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.<br>
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR<br>
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ ******************************<wbr>******************************<wbr>**************/<br>
+<br>
+#ifndef VL_VL_SCREEN_H<br>
+#define VL_VL_SCREEN_H<br>
+<br>
+#include "vl_winsys.h"<br>
+<br>
+struct vl_screen *vl_get_screen(const char* render_node);<br>
+void vl_put_screen(void);<br>
+<br>
+#endif<br>
diff --git a/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.c b/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.c<br>
index 251cc7d..5c75e8d 100644<br>
--- a/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.c<br>
+++ b/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.c<br>
@@ -31,33 +31,10 @@<br>
*<br>
*/<br>
<br>
-#include <assert.h><br>
-#include <string.h><br>
-#include <stdbool.h><br>
-<br>
-#if defined(HAVE_X11_PLATFORM)<br>
-#include <X11/Xlib.h><br>
-#else<br>
-#define XOpenDisplay(x) NULL<br>
-#define XCloseDisplay(x)<br>
-#define Display void<br>
-#endif<br>
-<br>
-#include "os/os_thread.h"<br>
-#include "util/u_memory.h"<br>
-#include "loader/loader.h"<br>
-<br>
#include "entrypoint.h"<br>
#include "vid_dec.h"<br>
#include "vid_enc.h"<br>
<br>
-static mtx_t omx_lock = _MTX_INITIALIZER_NP;<br>
-static Display *omx_display = NULL;<br>
-static struct vl_screen *omx_screen = NULL;<br>
-static unsigned omx_usecount = 0;<br>
-static const char *omx_render_node = NULL;<br>
-static int drm_fd;<br>
-<br>
int omx_component_library_Setup(<wbr>stLoaderComponentType **stComponents)<br>
{<br>
OMX_ERRORTYPE r;<br>
@@ -78,66 +55,6 @@ int omx_component_library_Setup(<wbr>stLoaderComponentType **stComponents)<br>
return 2;<br>
}<br>
<br>
-struct vl_screen *omx_get_screen(void)<br>
-{<br>
- static bool first_time = true;<br>
- mtx_lock(&omx_lock);<br>
-<br>
- if (!omx_screen) {<br>
- if (first_time) {<br>
- omx_render_node = debug_get_option("OMX_RENDER_<wbr>NODE", NULL);<br>
- first_time = false;<br>
- }<br>
- if (omx_render_node) {<br>
- drm_fd = loader_open_device(omx_render_<wbr>node);<br>
- if (drm_fd < 0)<br>
- goto error;<br>
-<br>
- omx_screen = vl_drm_screen_create(drm_fd);<br>
- if (!omx_screen) {<br>
- close(drm_fd);<br>
- goto error;<br>
- }<br>
- } else {<br>
- omx_display = XOpenDisplay(NULL);<br>
- if (!omx_display)<br>
- goto error;<br>
-<br>
- omx_screen = vl_dri3_screen_create(omx_<wbr>display, 0);<br>
- if (!omx_screen)<br>
- omx_screen = vl_dri2_screen_create(omx_<wbr>display, 0);<br>
- if (!omx_screen) {<br>
- XCloseDisplay(omx_display);<br>
- goto error;<br>
- }<br>
- }<br>
- }<br>
-<br>
- ++omx_usecount;<br>
-<br>
- mtx_unlock(&omx_lock);<br>
- return omx_screen;<br>
-<br>
-error:<br>
- mtx_unlock(&omx_lock);<br>
- return NULL;<br>
-}<br>
-<br>
-void omx_put_screen(void)<br>
-{<br>
- mtx_lock(&omx_lock);<br>
- if ((--omx_usecount) == 0) {<br>
- omx_screen->destroy(omx_<wbr>screen);<br>
- omx_screen = NULL;<br>
-<br>
- if (omx_render_node)<br>
- close(drm_fd);<br>
- else<br>
- XCloseDisplay(omx_display);<br>
- }<br>
- mtx_unlock(&omx_lock);<br>
-}<br>
-<br>
OMX_ERRORTYPE omx_workaround_Destructor(OMX_<wbr>COMPONENTTYPE *comp)<br>
{<br>
omx_base_component_<wbr>PrivateType* priv = (omx_base_component_<wbr>PrivateType*)comp-><wbr>pComponentPrivate;<br>
diff --git a/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.h b/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.h<br>
index 7625d7a..d566d1e 100644<br>
--- a/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.h<br>
+++ b/src/gallium/state_trackers/<wbr>omx_bellagio/entrypoint.h<br>
@@ -40,9 +40,6 @@<br>
<br>
PUBLIC extern int omx_component_library_Setup(<wbr>stLoaderComponentType **stComponents);<br>
<br>
-struct vl_screen *omx_get_screen(void);<br>
-void omx_put_screen(void);<br>
-<br>
OMX_ERRORTYPE omx_workaround_Destructor(OMX_<wbr>COMPONENTTYPE *comp);<br>
<br>
#endif<br>
diff --git a/src/gallium/state_trackers/<wbr>omx_bellagio/vid_dec.c b/src/gallium/state_trackers/<wbr>omx_bellagio/vid_dec.c<br>
index f9fe19f..b62c705 100644<br>
--- a/src/gallium/state_trackers/<wbr>omx_bellagio/vid_dec.c<br>
+++ b/src/gallium/state_trackers/<wbr>omx_bellagio/vid_dec.c<br>
@@ -50,6 +50,7 @@<br>
#include "util/u_surface.h"<br>
#include "vl/vl_video_buffer.h"<br>
#include "vl/vl_vlc.h"<br>
+#include "vl/vl_screen.h"<br>
<br>
#include "entrypoint.h"<br>
#include "vid_dec.h"<br>
@@ -173,7 +174,7 @@ static OMX_ERRORTYPE vid_dec_Constructor(OMX_<wbr>COMPONENTTYPE *comp, OMX_STRING nam<br>
comp->SetParameter = vid_dec_SetParameter;<br>
comp->GetParameter = vid_dec_GetParameter;<br>
<br>
- priv->screen = omx_get_screen();<br>
+ priv->screen = vl_get_screen("OMX_RENDER_<wbr>NODE");<br>
if (!priv->screen)<br>
return OMX_<wbr>ErrorInsufficientResources;<br>
<br>
@@ -253,7 +254,7 @@ static OMX_ERRORTYPE vid_dec_Destructor(OMX_<wbr>COMPONENTTYPE *comp)<br>
}<br>
<br>
if (priv->screen)<br>
- omx_put_screen();<br>
+ vl_put_screen();<br>
<br>
return omx_workaround_Destructor(<wbr>comp);<br>
}<br>
diff --git a/src/gallium/state_trackers/<wbr>omx_bellagio/vid_enc.c b/src/gallium/state_trackers/<wbr>omx_bellagio/vid_enc.c<br>
index 1a4fb62..40e7a0f 100644<br>
--- a/src/gallium/state_trackers/<wbr>omx_bellagio/vid_enc.c<br>
+++ b/src/gallium/state_trackers/<wbr>omx_bellagio/vid_enc.c<br>
@@ -50,6 +50,7 @@<br>
#include "pipe/p_video_codec.h"<br>
#include "util/u_memory.h"<br>
#include "vl/vl_video_buffer.h"<br>
+#include "vl/vl_screen.h"<br>
<br>
#include "entrypoint.h"<br>
#include "vid_enc.h"<br>
@@ -170,7 +171,7 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_<wbr>COMPONENTTYPE *comp, OMX_STRING nam<br>
comp->GetConfig = vid_enc_GetConfig;<br>
comp->SetConfig = vid_enc_SetConfig;<br>
<br>
- priv->screen = omx_get_screen();<br>
+ priv->screen = vl_get_screen("OMX_RENDER_<wbr>NODE");<br>
if (!priv->screen)<br>
return OMX_<wbr>ErrorInsufficientResources;<br>
<br>
@@ -296,7 +297,7 @@ static OMX_ERRORTYPE vid_enc_Destructor(OMX_<wbr>COMPONENTTYPE *comp)<br>
priv->t_pipe->destroy(priv->t_<wbr>pipe);<br>
<br>
if (priv->screen)<br>
- omx_put_screen();<br>
+ vl_put_screen();<br>
<br>
return omx_workaround_Destructor(<wbr>comp);<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>