aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/omx/entrypoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/omx/entrypoint.c')
-rw-r--r--src/gallium/state_trackers/omx/entrypoint.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/gallium/state_trackers/omx/entrypoint.c b/src/gallium/state_trackers/omx/entrypoint.c
index 7df90b16a84..da9ca104d93 100644
--- a/src/gallium/state_trackers/omx/entrypoint.c
+++ b/src/gallium/state_trackers/omx/entrypoint.c
@@ -33,6 +33,7 @@
#include <assert.h>
#include <string.h>
+#include <stdbool.h>
#include <X11/Xlib.h>
@@ -73,29 +74,30 @@ int omx_component_library_Setup(stLoaderComponentType **stComponents)
struct vl_screen *omx_get_screen(void)
{
+ static bool first_time = true;
pipe_mutex_lock(omx_lock);
- if (!omx_display) {
- 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) {
+ if (first_time) {
+ omx_render_node = debug_get_option("OMX_RENDER_NODE", NULL);
+ first_time = false;
+ }
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);
+ omx_display = XOpenDisplay(NULL);
+ if (!omx_display)
+ goto error;
+
+ omx_screen = vl_dri2_screen_create(omx_display, 0);
if (!omx_screen) {
XCloseDisplay(omx_display);
goto error;
@@ -117,16 +119,13 @@ void omx_put_screen(void)
{
pipe_mutex_lock(omx_lock);
if ((--omx_usecount) == 0) {
- 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->destroy(omx_screen);
omx_screen = NULL;
- omx_display = NULL;
+
+ if (omx_render_node)
+ close(drm_fd);
+ else
+ XCloseDisplay(omx_display);
}
pipe_mutex_unlock(omx_lock);
}