2 * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #include "va_display.h"
33 extern const VADisplayHooks va_display_hooks_android;
34 extern const VADisplayHooks va_display_hooks_wayland;
35 extern const VADisplayHooks va_display_hooks_x11;
36 extern const VADisplayHooks va_display_hooks_drm;
38 static const VADisplayHooks *g_display_hooks;
39 static const VADisplayHooks *g_display_hooks_available[] = {
41 &va_display_hooks_android,
43 #ifdef HAVE_VA_WAYLAND
44 &va_display_hooks_wayland,
47 &va_display_hooks_x11,
50 &va_display_hooks_drm,
56 static const char *g_display_name;
59 get_display_name(int argc, char *argv[])
61 const char *display_name = NULL;
64 for (i = 1; i < argc; i++) {
65 if (strcmp(argv[i], "--display") != 0)
70 display_name = argv[i];
78 print_display_names(void)
80 const VADisplayHooks **h;
82 printf("Available displays:\n");
83 for (h = g_display_hooks_available; *h != NULL; h++)
84 printf(" %s\n", (*h)->name);
88 sanitize_args(int *argc, char *argv[])
90 char **out_args = argv;
93 for (i = 0; i < n; i++) {
95 *out_args++ = argv[i];
98 *argc = out_args - argv;
102 va_init_display_args(int *argc, char *argv[])
104 const char *display_name;
106 display_name = get_display_name(*argc, argv);
107 if (display_name && strcmp(display_name, "help") == 0) {
108 print_display_names();
111 g_display_name = display_name;
113 sanitize_args(argc, argv);
117 va_open_display(void)
119 VADisplay va_dpy = NULL;
122 for (i = 0; !va_dpy && g_display_hooks_available[i]; i++) {
123 g_display_hooks = g_display_hooks_available[i];
124 if (g_display_name &&
125 strcmp(g_display_name, g_display_hooks->name) != 0)
127 if (!g_display_hooks->open_display)
129 va_dpy = g_display_hooks->open_display();
133 fprintf(stderr, "error: failed to initialize display");
135 fprintf(stderr, " '%s'", g_display_name);
136 fprintf(stderr, "\n");
143 va_close_display(VADisplay va_dpy)
148 if (g_display_hooks && g_display_hooks->close_display)
149 g_display_hooks->close_display(va_dpy);
156 const VARectangle *src_rect,
157 const VARectangle *dst_rect
161 return VA_STATUS_ERROR_INVALID_DISPLAY;
163 if (g_display_hooks && g_display_hooks->put_surface)
164 return g_display_hooks->put_surface(va_dpy, surface, src_rect, dst_rect);
165 return VA_STATUS_ERROR_UNIMPLEMENTED;