hardware/intel/libva
修訂 | 98ed754fa7ecf5848f9aeb56a6237ef415ff0a4d (tree) |
---|---|
時間 | 2009-08-25 01:35:05 |
作者 | Austin Yuan <shengquan.yuan@inte...> |
Commiter | Austin Yuan |
Merge branch 'test'
@@ -21,9 +21,21 @@ | ||
21 | 21 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | 22 | |
23 | 23 | AUTOMAKE_OPTIONS = foreign |
24 | -SUBDIRS = src dummy_drv_video i965_drv_video test | |
24 | + | |
25 | +SUBDIRS = src test | |
26 | +if BUILD_DUMMY_DRIVER | |
27 | +SUBDIRS += dummy_drv_video | |
28 | +endif | |
29 | +if BUILD_I965_DRIVER | |
30 | +SUBDIRS += i965_drv_video | |
31 | +endif | |
32 | + | |
33 | +pcfiles = \ | |
34 | + libva.pc | |
25 | 35 | |
26 | 36 | pkgconfigdir = @pkgconfigdir@ |
27 | -pkgconfig_DATA = libva.pc | |
37 | +pkgconfig_DATA = $(pcfiles) | |
28 | 38 | |
29 | 39 | EXTRA_DIST = libva.pc.in |
40 | + | |
41 | +CLEANFILES = $(pcfiles) |
@@ -20,13 +20,70 @@ | ||
20 | 20 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
21 | 21 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | 22 | |
23 | +# libva package version number, (as distinct from shared library version) | |
24 | +m4_define([libva_major_version], [0]) | |
25 | +m4_define([libva_minor_version], [30]) | |
26 | +m4_define([libva_micro_version], [4]) | |
27 | + | |
28 | +m4_define([libva_version], | |
29 | + [libva_major_version.libva_minor_version.libva_micro_version]) | |
30 | + | |
31 | +# increase this number for each API change | |
32 | +m4_define([libva_sds_version], [2]) | |
33 | + | |
34 | +# if the library source code has changed, increment revision | |
35 | +m4_define([libva_lt_revision], [1]) | |
36 | +# if any interface was added/removed/changed, then inc current, reset revision | |
37 | +m4_define([libva_lt_current], [0]) | |
38 | +# if any interface was added since last public release, then increment age | |
39 | +# if any interface was removed since last public release, then set age to 0 | |
40 | +m4_define([libva_lt_age], [0]) | |
41 | + | |
23 | 42 | AC_PREREQ(2.57) |
24 | -AC_INIT([libva], 0.30.4, [waldo.bastian@intel.com], libva) | |
43 | +AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva) | |
25 | 44 | AC_CONFIG_SRCDIR([Makefile.am]) |
26 | 45 | AM_INIT_AUTOMAKE([dist-bzip2]) |
27 | 46 | |
28 | 47 | AM_CONFIG_HEADER([config.h]) |
29 | 48 | |
49 | +LIBVA_MAJOR_VERSION=libva_major_version | |
50 | +LIBVA_MINOR_VERSION=libva_minor_version | |
51 | +LIBVA_MICRO_VERSION=libva_micro_version | |
52 | +LIBVA_VERSION=libva_version | |
53 | +AC_SUBST(LIBVA_MAJOR_VERSION) | |
54 | +AC_SUBST(LIBVA_MINOR_VERSION) | |
55 | +AC_SUBST(LIBVA_MICRO_VERSION) | |
56 | +AC_SUBST(LIBVA_VERSION) | |
57 | + | |
58 | +LIBVA_SDS_VERSION=libva_sds_version | |
59 | +AC_SUBST(LIBVA_SDS_VERSION) | |
60 | + | |
61 | +LIBVA_LT_CURRENT=libva_lt_current | |
62 | +LIBVA_LT_REV=libva_lt_revision | |
63 | +LIBVA_LT_AGE=libva_lt_age | |
64 | +LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" | |
65 | +LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" | |
66 | +AC_SUBST(LIBVA_LT_VERSION) | |
67 | +AC_SUBST(LIBVA_LT_LDFLAGS) | |
68 | + | |
69 | +AC_ARG_ENABLE(dummy-driver, | |
70 | + [AC_HELP_STRING([--enable-dummy-driver], | |
71 | + [build dummy video driver])], | |
72 | + [], [enable_dummy_driver=yes]) | |
73 | +AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) | |
74 | + | |
75 | +AC_ARG_ENABLE(i965-driver, | |
76 | + [AC_HELP_STRING([--enable-i965-driver], | |
77 | + [build i965 video driver])], | |
78 | + [], [enable_i965_driver=no]) | |
79 | + | |
80 | +AC_ARG_WITH(drivers-path, | |
81 | + [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, | |
82 | + [with_drivers_path="$libdir/dri"]) | |
83 | + | |
84 | +LIBVA_DRIVERS_PATH="$with_drivers_path" | |
85 | +AC_SUBST(LIBVA_DRIVERS_PATH) | |
86 | + | |
30 | 87 | AC_DISABLE_STATIC |
31 | 88 | AC_PROG_LIBTOOL |
32 | 89 | AC_PROG_CC |
@@ -36,23 +93,34 @@ AC_SYS_LARGEFILE | ||
36 | 93 | |
37 | 94 | PKG_CHECK_MODULES([X11], [x11]) |
38 | 95 | PKG_CHECK_MODULES([XEXT],[xext]) |
96 | +PKG_CHECK_MODULES([XFIXES], [xfixes]) | |
39 | 97 | PKG_CHECK_MODULES([DRM], [libdrm]) |
40 | -PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm]) | |
41 | 98 | |
42 | 99 | PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no]) |
43 | 100 | AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes) |
44 | 101 | |
102 | +# Check for libdrm >= 2.4 (needed for i965_drv_video.so) | |
103 | +if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdrm; then | |
104 | + AC_MSG_WARN([libdrm < 2.4 found, disabling build of i965 video driver]) | |
105 | + enable_i965_driver=no | |
106 | +fi | |
107 | +AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) | |
108 | + | |
45 | 109 | # We only need the headers, we don't link against the DRM libraries |
46 | -LIBVA_CFLAGS="$LIBDRM_DEPS_CFLAGS" | |
110 | +LIBVA_CFLAGS="$DRM_CFLAGS" | |
47 | 111 | AC_SUBST(LIBVA_CFLAGS) |
48 | 112 | AC_SUBST(LIBVA_LIBS) |
49 | 113 | |
50 | 114 | pkgconfigdir=${libdir}/pkgconfig |
51 | 115 | AC_SUBST(pkgconfigdir) |
52 | 116 | |
117 | +libvabackendlib=libva.la | |
118 | +AC_SUBST([libvabackendlib]) | |
119 | + | |
53 | 120 | AC_OUTPUT([ |
54 | 121 | Makefile |
55 | 122 | src/Makefile |
123 | + src/va_version.h | |
56 | 124 | src/x11/Makefile |
57 | 125 | dummy_drv_video/Makefile |
58 | 126 | i965_drv_video/Makefile |
@@ -21,9 +21,10 @@ | ||
21 | 21 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | 22 | |
23 | 23 | dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la |
24 | -dummy_drv_video_ladir = /usr/lib/dri | |
24 | +dummy_drv_video_ladir = @LIBVA_DRIVERS_PATH@ | |
25 | 25 | dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined |
26 | -dummy_drv_video_la_LIBADD = ../src/libva.la | |
26 | +dummy_drv_video_la_LIBADD = $(top_srcdir)/src/$(libvabackendlib) | |
27 | +dummy_drv_video_la_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib) | |
27 | 28 | |
28 | 29 | AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/../../include/kmd -DIN_LIBVA |
29 | 30 | dummy_drv_video_la_SOURCES = dummy_drv_video.c object_heap.c |
@@ -1211,15 +1211,15 @@ VAStatus dummy_Terminate( VADriverContextP ctx ) | ||
1211 | 1211 | return VA_STATUS_SUCCESS; |
1212 | 1212 | } |
1213 | 1213 | |
1214 | -VAStatus __vaDriverInit_0_29( VADriverContextP ctx ) | |
1214 | +VAStatus __vaDriverInit_0_30( VADriverContextP ctx ) | |
1215 | 1215 | { |
1216 | 1216 | object_base_p obj; |
1217 | 1217 | int result; |
1218 | 1218 | struct dummy_driver_data *driver_data; |
1219 | 1219 | int i; |
1220 | 1220 | |
1221 | - ctx->version_major = 0; | |
1222 | - ctx->version_minor = 29; | |
1221 | + ctx->version_major = VA_MAJOR_VERSION; | |
1222 | + ctx->version_minor = VA_MINOR_VERSION; | |
1223 | 1223 | ctx->max_profiles = DUMMY_MAX_PROFILES; |
1224 | 1224 | ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS; |
1225 | 1225 | ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES; |
@@ -25,7 +25,7 @@ SUBDIRS = shaders | ||
25 | 25 | AM_CFLAGS = -Wall -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 @DRM_CFLAGS@ -DIN_LIBVA |
26 | 26 | |
27 | 27 | i965_drv_video_la_LTLIBRARIES = i965_drv_video.la |
28 | -i965_drv_video_ladir = $(libdir)/dri | |
28 | +i965_drv_video_ladir = @LIBVA_DRIVERS_PATH@ | |
29 | 29 | i965_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined @DRM_LIBS@ -ldrm_intel |
30 | 30 | i965_drv_video_la_LIBADD = ../src/libva.la -lpthread |
31 | 31 |
@@ -2,6 +2,7 @@ prefix=@prefix@ | ||
2 | 2 | exec_prefix=@exec_prefix@ |
3 | 3 | libdir=@libdir@ |
4 | 4 | includedir=@includedir@ |
5 | +driverdir=@LIBVA_DRIVERS_PATH@ | |
5 | 6 | |
6 | 7 | Name: libva |
7 | 8 | Description: Userspace Video Acceleration (VA) core interface |
@@ -22,25 +22,26 @@ | ||
22 | 22 | |
23 | 23 | INCLUDES = \ |
24 | 24 | $(LIBVA_CFLAGS) -I$(top_srcdir)/src/x11 \ |
25 | - -DIN_LIBVA | |
25 | + -DIN_LIBVA \ | |
26 | + -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" | |
27 | + | |
28 | +LDADD = \ | |
29 | + $(LIBVA_LT_LDFLAGS) | |
26 | 30 | |
27 | 31 | libva_la_LTLIBRARIES = libva.la |
28 | 32 | libva_ladir = $(libdir) |
29 | -libva_la_LDFLAGS = -version-number 0:30:4 -no-undefined | |
33 | +libva_la_LDFLAGS = $(LDADD) -no-undefined | |
30 | 34 | libva_la_LIBADD = $(LIBVA_LIBS) -ldl -lX11 -lXext x11/libva_x11.la -ldrm -lXfixes |
31 | 35 | |
32 | -nodist_libva_la_SOURCES = va_version.h | |
33 | -BUILT_SOURCES = va_version.h | |
34 | - | |
35 | -CLEANFILES = va_version.h | |
36 | - | |
37 | -va_version.h: Makefile | |
38 | - echo "#define VA_BUILD_DATE \"$(shell date +'%Y%m%d') $(shell date +'1%H%M%S') \"" > va_version.h | |
39 | - echo "#define VA_BUILD_GIT \"($(shell git log | head -n1 | cut -f2 -d' ')) \" " >> va_version.h | |
40 | - | |
41 | 36 | SUBDIRS = x11 |
42 | 37 | |
43 | 38 | libva_la_SOURCES = va.c |
44 | 39 | |
45 | 40 | libvaincludedir = ${includedir}/va |
46 | -libvainclude_HEADERS = va.h va_backend.h | |
41 | +libvainclude_HEADERS = va.h va_backend.h va_version.h | |
42 | + | |
43 | +DISTCLEANFILES = \ | |
44 | + va_version.h | |
45 | + | |
46 | +EXTRA_DIST = \ | |
47 | + va_version.h.in |
@@ -22,11 +22,10 @@ | ||
22 | 22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
23 | 23 | */ |
24 | 24 | |
25 | +#define _GNU_SOURCE 1 | |
25 | 26 | #include "va.h" |
26 | 27 | #include "va_backend.h" |
27 | 28 | |
28 | -#include "va_version.h" | |
29 | - | |
30 | 29 | #include <assert.h> |
31 | 30 | #include <stdarg.h> |
32 | 31 | #include <stdio.h> |
@@ -40,13 +39,9 @@ | ||
40 | 39 | #include "va_dricommon.h" |
41 | 40 | |
42 | 41 | |
43 | -#define VA_STR_VERSION VA_BUILD_DATE VA_BUILD_GIT | |
44 | - | |
45 | -#define VA_MAJOR_VERSION 0 | |
46 | -#define VA_MINOR_VERSION 30 | |
47 | 42 | #define DRIVER_INIT_FUNC "__vaDriverInit_0_30" |
43 | +#define DRIVER_INIT_FUNC_SDS "__vaDriverInit_0_30_sds" | |
48 | 44 | |
49 | -#define DEFAULT_DRIVER_DIR "/usr/lib/dri/" | |
50 | 45 | #define DRIVER_EXTENSION "_drv_video.so" |
51 | 46 | |
52 | 47 | #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) |
@@ -116,21 +111,8 @@ static Bool va_checkString(const char* value, char *variable) | ||
116 | 111 | static VAStatus va_getDriverName(VADisplay dpy, char **driver_name) |
117 | 112 | { |
118 | 113 | VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; |
119 | - VADriverContextP ctx = CTX(dpy); | |
120 | 114 | |
121 | - VAStatus ret; | |
122 | - ret = pDisplayContext->vaGetDriverName(pDisplayContext, driver_name); | |
123 | - if (ret == VA_STATUS_SUCCESS) | |
124 | - { | |
125 | - if (isDRI2Connected(ctx, driver_name)) | |
126 | - { | |
127 | - ret = VA_STATUS_SUCCESS; | |
128 | - } else if (isDRI1Connected(ctx, driver_name)) | |
129 | - { | |
130 | - ret = VA_STATUS_SUCCESS; | |
131 | - } | |
132 | - } | |
133 | - return ret; | |
115 | + return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name); | |
134 | 116 | } |
135 | 117 | |
136 | 118 | static VAStatus va_openDriver(VADisplay dpy, char *driver_name) |
@@ -152,7 +134,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
152 | 134 | } |
153 | 135 | if (!search_path) |
154 | 136 | { |
155 | - search_path = DEFAULT_DRIVER_DIR; | |
137 | + search_path = VA_DRIVERS_PATH; | |
156 | 138 | } |
157 | 139 | |
158 | 140 | search_path = strdup((const char *)search_path); |
@@ -185,6 +167,11 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
185 | 167 | init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); |
186 | 168 | if (!init_func) |
187 | 169 | { |
170 | + /* Then try SDS extensions (VDPAU and XvBA backends) */ | |
171 | + init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_SDS); | |
172 | + } | |
173 | + if (!init_func) | |
174 | + { | |
188 | 175 | va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC); |
189 | 176 | dlclose(handle); |
190 | 177 | } |
@@ -347,7 +334,7 @@ VAStatus vaInitialize ( | ||
347 | 334 | |
348 | 335 | va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); |
349 | 336 | |
350 | - va_infoMessage("libva build on %s\n", VA_STR_VERSION); | |
337 | + va_infoMessage("libva version %s\n", VA_VERSION_S); | |
351 | 338 | |
352 | 339 | vaStatus = va_getDriverName(dpy, &driver_name); |
353 | 340 | va_infoMessage("va_getDriverName() returns %d\n", vaStatus); |
@@ -63,6 +63,12 @@ | ||
63 | 63 | #ifndef _VA_H_ |
64 | 64 | #define _VA_H_ |
65 | 65 | |
66 | +#ifdef IN_LIBVA | |
67 | +#include "va_version.h" | |
68 | +#else | |
69 | +#include <va/va_version.h> | |
70 | +#endif | |
71 | + | |
66 | 72 | #ifdef __cplusplus |
67 | 73 | extern "C" { |
68 | 74 | #endif |
@@ -364,7 +370,8 @@ typedef VAGenericID VAContextID; | ||
364 | 370 | |
365 | 371 | typedef VAGenericID VASurfaceID; |
366 | 372 | |
367 | -#define VA_INVALID_SURFACE -1 | |
373 | +#define VA_INVALID_ID 0xffffffff | |
374 | +#define VA_INVALID_SURFACE VA_INVALID_ID | |
368 | 375 | |
369 | 376 | /* |
370 | 377 | * vaCreateSurfaces - Create an array of surfaces used for decode and display |
@@ -465,6 +472,27 @@ typedef enum | ||
465 | 472 | } VABufferType; |
466 | 473 | |
467 | 474 | |
475 | +/* | |
476 | + * There will be cases where the bitstream buffer will not have enough room to hold | |
477 | + * the data for the entire slice, and the following flags will be used in the slice | |
478 | + * parameter to signal to the server for the possible cases. | |
479 | + * If a slice parameter buffer and slice data buffer pair is sent to the server with | |
480 | + * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below), | |
481 | + * then a slice parameter and data buffer needs to be sent again to complete this slice. | |
482 | + */ | |
483 | +#define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */ | |
484 | +#define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */ | |
485 | +#define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */ | |
486 | +#define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */ | |
487 | + | |
488 | +/* Codec-independent Slice Parameter Buffer base */ | |
489 | +typedef struct _VASliceParameterBufferBase | |
490 | +{ | |
491 | + unsigned int slice_data_size; /* number of bytes in the slice data buffer for this slice */ | |
492 | + unsigned int slice_data_offset; /* the offset to the first byte of slice data */ | |
493 | + unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */ | |
494 | +} VASliceParameterBufferBase; | |
495 | + | |
468 | 496 | /**************************** |
469 | 497 | * MPEG-2 data structures |
470 | 498 | ****************************/ |
@@ -516,19 +544,6 @@ typedef struct _VAIQMatrixBufferMPEG2 | ||
516 | 544 | unsigned char chroma_non_intra_quantiser_matrix[64]; |
517 | 545 | } VAIQMatrixBufferMPEG2; |
518 | 546 | |
519 | -/* | |
520 | - * There will be cases where the bitstream buffer will not have enough room to hold | |
521 | - * the data for the entire slice, and the following flags will be used in the slice | |
522 | - * parameter to signal to the server for the possible cases. | |
523 | - * If a slice parameter buffer and slice data buffer pair is sent to the server with | |
524 | - * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below), | |
525 | - * then a slice parameter and data buffer needs to be sent again to complete this slice. | |
526 | - */ | |
527 | -#define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */ | |
528 | -#define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */ | |
529 | -#define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */ | |
530 | -#define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */ | |
531 | - | |
532 | 547 | /* MPEG-2 Slice Parameter Buffer */ |
533 | 548 | typedef struct _VASliceParameterBufferMPEG2 |
534 | 549 | { |
@@ -407,14 +407,11 @@ struct VADriverVTable | ||
407 | 407 | |
408 | 408 | struct VADriverContext |
409 | 409 | { |
410 | - void *old_pNext; /* preserved for binary compatibility */ | |
411 | - | |
412 | 410 | void *pDriverData; |
413 | 411 | struct VADriverVTable vtable; |
414 | 412 | |
415 | 413 | Display *x11_dpy; |
416 | 414 | int x11_screen; |
417 | - int dri2; | |
418 | 415 | int version_major; |
419 | 416 | int version_minor; |
420 | 417 | int max_profiles; |
@@ -0,0 +1,94 @@ | ||
1 | +/* | |
2 | + * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. | |
3 | + * | |
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: | |
11 | + * | |
12 | + * The above copyright notice and this permission notice (including the | |
13 | + * next paragraph) shall be included in all copies or substantial portions | |
14 | + * of the Software. | |
15 | + * | |
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. | |
23 | + */ | |
24 | + | |
25 | +#ifndef VA_VERSION_H | |
26 | +#define VA_VERSION_H | |
27 | + | |
28 | +/** | |
29 | + * VA_MAJOR_VERSION: | |
30 | + * | |
31 | + * The major version of the VA library (1, if %VA_VERSION is 1.2.3) | |
32 | + */ | |
33 | +#define VA_MAJOR_VERSION (@LIBVA_MAJOR_VERSION@) | |
34 | + | |
35 | +/** | |
36 | + * VA_MINOR_VERSION: | |
37 | + * | |
38 | + * The minor version of the VA library (2, if %VA_VERSION is 1.2.3) | |
39 | + */ | |
40 | +#define VA_MINOR_VERSION (@LIBVA_MINOR_VERSION@) | |
41 | + | |
42 | +/** | |
43 | + * VA_MICRO_VERSION: | |
44 | + * | |
45 | + * The micro version of the VA library (3, if %VA_VERSION is 1.2.3) | |
46 | + */ | |
47 | +#define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@) | |
48 | + | |
49 | +/** | |
50 | + * VA_SDS_VERSION: | |
51 | + * | |
52 | + * The version of the SDS API extensions to the VA library | |
53 | + */ | |
54 | +#define VA_SDS_VERSION (@LIBVA_SDS_VERSION@) | |
55 | + | |
56 | +/** | |
57 | + * VA_VERSION: | |
58 | + * | |
59 | + * The full version of the VA library, like 1.2.3 | |
60 | + */ | |
61 | +#define VA_VERSION @LIBVA_VERSION@ | |
62 | + | |
63 | +/** | |
64 | + * VA_VERSION_S: | |
65 | + * | |
66 | + * The full version of the VA library, in string form (suited for | |
67 | + * string concatenation) | |
68 | + */ | |
69 | +#define VA_VERSION_S "@LIBVA_VERSION@-sds@LIBVA_SDS_VERSION@" | |
70 | + | |
71 | +/** | |
72 | + * VA_VERSION_HEX: | |
73 | + * | |
74 | + * Numerically encoded version of the VA library, like 0x010203 | |
75 | + */ | |
76 | +#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \ | |
77 | + (VA_MINOR_VERSION << 16) | \ | |
78 | + (VA_MICRO_VERSION << 8)) | |
79 | + | |
80 | +/** | |
81 | + * VA_CHECK_VERSION: | |
82 | + * @major: major version, like 1 in 1.2.3 | |
83 | + * @minor: minor version, like 2 in 1.2.3 | |
84 | + * @micro: micro version, like 3 in 1.2.3 | |
85 | + * | |
86 | + * Evaluates to %TRUE if the version of the VA library is greater | |
87 | + * than @major, @minor and @micro | |
88 | + */ | |
89 | +#define VA_CHECK_VERSION(major,minor,micro) \ | |
90 | + (VA_MAJOR_VERSION > (major) || \ | |
91 | + (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \ | |
92 | + (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro))) | |
93 | + | |
94 | +#endif /* VA_VERSION_H */ |
@@ -22,9 +22,9 @@ AM_CFLAGS = -DLINUX -DIN_LIBVA -I$(top_srcdir)/src $(DRM_CFLAGS) | ||
22 | 22 | |
23 | 23 | noinst_LTLIBRARIES = libva_x11.la |
24 | 24 | |
25 | -libva_x11includedir = ${includedir}/va | |
25 | +libva_x11includedir = ${includedir}/va | |
26 | 26 | libva_x11include_HEADERS = va_x11.h va_dri.h va_dri2.h va_dricommon.h |
27 | 27 | |
28 | -libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c | |
28 | +libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c | |
29 | 29 | |
30 | -EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h | |
30 | +EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h |
@@ -5,7 +5,8 @@ | ||
5 | 5 | |
6 | 6 | #include <xf86drm.h> |
7 | 7 | |
8 | -#include "X11/Xlib.h" | |
8 | +#include <X11/Xlibint.h> | |
9 | +#include <X11/Xlib.h> | |
9 | 10 | #include "va.h" |
10 | 11 | #include "va_backend.h" |
11 | 12 |
@@ -0,0 +1,392 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2008 NVIDIA, Corporation | |
3 | + * | |
4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | + * of this software and associated documentation files (the "Software"), to deal | |
6 | + * in the Software without restriction, including without limitation the rights | |
7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | + * copies of the Software, and to permit persons to whom the Software is | |
9 | + * furnished to do so, subject to the following conditions: | |
10 | + * | |
11 | + * The above copyright notice and this permission notice (including the next | |
12 | + * paragraph) shall be included in all copies or substantial portions of the | |
13 | + * Software. | |
14 | + * | |
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
21 | + * SOFTWARE. | |
22 | + */ | |
23 | + | |
24 | +#define _GNU_SOURCE 1 | |
25 | +#include <string.h> | |
26 | + | |
27 | +#define NEED_REPLIES | |
28 | +#include <stdlib.h> | |
29 | +#include <X11/Xlibint.h> | |
30 | +#include <X11/Xutil.h> | |
31 | +#include <X11/extensions/Xext.h> | |
32 | +#include <X11/extensions/extutil.h> | |
33 | +#include "va_nvctrl.h" | |
34 | + | |
35 | +#define NV_CONTROL_ERRORS 0 | |
36 | +#define NV_CONTROL_EVENTS 5 | |
37 | +#define NV_CONTROL_NAME "NV-CONTROL" | |
38 | + | |
39 | +#define NV_CTRL_TARGET_TYPE_X_SCREEN 0 | |
40 | +#define NV_CTRL_TARGET_TYPE_GPU 1 | |
41 | +#define NV_CTRL_TARGET_TYPE_FRAMELOCK 2 | |
42 | +#define NV_CTRL_TARGET_TYPE_VCSC 3 /* Visual Computing System */ | |
43 | + | |
44 | +#define NV_CTRL_STRING_NVIDIA_DRIVER_VERSION 3 /* R--G */ | |
45 | + | |
46 | +#define X_nvCtrlQueryExtension 0 | |
47 | +#define X_nvCtrlIsNv 1 | |
48 | +#define X_nvCtrlQueryStringAttribute 4 | |
49 | + | |
50 | +typedef struct { | |
51 | + CARD8 reqType; | |
52 | + CARD8 nvReqType; | |
53 | + CARD16 length B16; | |
54 | +} xnvCtrlQueryExtensionReq; | |
55 | +#define sz_xnvCtrlQueryExtensionReq 4 | |
56 | + | |
57 | +typedef struct { | |
58 | + BYTE type; /* X_Reply */ | |
59 | + CARD8 padb1; | |
60 | + CARD16 sequenceNumber B16; | |
61 | + CARD32 length B32; | |
62 | + CARD16 major B16; | |
63 | + CARD16 minor B16; | |
64 | + CARD32 padl4 B32; | |
65 | + CARD32 padl5 B32; | |
66 | + CARD32 padl6 B32; | |
67 | + CARD32 padl7 B32; | |
68 | + CARD32 padl8 B32; | |
69 | +} xnvCtrlQueryExtensionReply; | |
70 | +#define sz_xnvCtrlQueryExtensionReply 32 | |
71 | + | |
72 | +typedef struct { | |
73 | + CARD8 reqType; | |
74 | + CARD8 nvReqType; | |
75 | + CARD16 length B16; | |
76 | + CARD32 screen B32; | |
77 | +} xnvCtrlIsNvReq; | |
78 | +#define sz_xnvCtrlIsNvReq 8 | |
79 | + | |
80 | +typedef struct { | |
81 | + BYTE type; /* X_Reply */ | |
82 | + CARD8 padb1; | |
83 | + CARD16 sequenceNumber B16; | |
84 | + CARD32 length B32; | |
85 | + CARD32 isnv B32; | |
86 | + CARD32 padl4 B32; | |
87 | + CARD32 padl5 B32; | |
88 | + CARD32 padl6 B32; | |
89 | + CARD32 padl7 B32; | |
90 | + CARD32 padl8 B32; | |
91 | +} xnvCtrlIsNvReply; | |
92 | +#define sz_xnvCtrlIsNvReply 32 | |
93 | + | |
94 | +typedef struct { | |
95 | + CARD8 reqType; | |
96 | + CARD8 nvReqType; | |
97 | + CARD16 length B16; | |
98 | + CARD16 target_id B16; /* X screen number or GPU number */ | |
99 | + CARD16 target_type B16; /* X screen or GPU */ | |
100 | + CARD32 display_mask B32; | |
101 | + CARD32 attribute B32; | |
102 | +} xnvCtrlQueryStringAttributeReq; | |
103 | +#define sz_xnvCtrlQueryStringAttributeReq 16 | |
104 | + | |
105 | +typedef struct { | |
106 | + BYTE type; | |
107 | + BYTE pad0; | |
108 | + CARD16 sequenceNumber B16; | |
109 | + CARD32 length B32; | |
110 | + CARD32 flags B32; | |
111 | + CARD32 n B32; /* Length of string */ | |
112 | + CARD32 pad4 B32; | |
113 | + CARD32 pad5 B32; | |
114 | + CARD32 pad6 B32; | |
115 | + CARD32 pad7 B32; | |
116 | +} xnvCtrlQueryStringAttributeReply; | |
117 | +#define sz_xnvCtrlQueryStringAttributeReply 32 | |
118 | + | |
119 | +#define NVCTRL_EXT_NEED_CHECK (XPointer)(~0) | |
120 | +#define NVCTRL_EXT_NEED_NOTHING (XPointer)(0) | |
121 | +#define NVCTRL_EXT_NEED_TARGET_SWAP (XPointer)(1) | |
122 | + | |
123 | +static XExtensionInfo _nvctrl_ext_info_data; | |
124 | +static XExtensionInfo *nvctrl_ext_info = &_nvctrl_ext_info_data; | |
125 | +static /* const */ char *nvctrl_extension_name = NV_CONTROL_NAME; | |
126 | + | |
127 | +#define XNVCTRLCheckExtension(dpy,i,val) \ | |
128 | + XextCheckExtension (dpy, i, nvctrl_extension_name, val) | |
129 | +#define XNVCTRLSimpleCheckExtension(dpy,i) \ | |
130 | + XextSimpleCheckExtension (dpy, i, nvctrl_extension_name) | |
131 | + | |
132 | +static int close_display(); | |
133 | +static /* const */ XExtensionHooks nvctrl_extension_hooks = { | |
134 | + NULL, /* create_gc */ | |
135 | + NULL, /* copy_gc */ | |
136 | + NULL, /* flush_gc */ | |
137 | + NULL, /* free_gc */ | |
138 | + NULL, /* create_font */ | |
139 | + NULL, /* free_font */ | |
140 | + close_display, /* close_display */ | |
141 | + NULL, /* wire_to_event */ | |
142 | + NULL, /* event_to_wire */ | |
143 | + NULL, /* error */ | |
144 | + NULL, /* error_string */ | |
145 | +}; | |
146 | + | |
147 | +static XEXT_GENERATE_FIND_DISPLAY (find_display, nvctrl_ext_info, | |
148 | + nvctrl_extension_name, | |
149 | + &nvctrl_extension_hooks, | |
150 | + NV_CONTROL_EVENTS, NVCTRL_EXT_NEED_CHECK) | |
151 | + | |
152 | +static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info) | |
153 | + | |
154 | +static Bool XNVCTRLQueryVersion (Display *dpy, int *major, int *minor); | |
155 | + | |
156 | +/* | |
157 | + * NV-CONTROL versions 1.8 and 1.9 pack the target_type and target_id | |
158 | + * fields in reversed order. In order to talk to one of these servers, | |
159 | + * we need to swap these fields. | |
160 | + */ | |
161 | +static void XNVCTRLCheckTargetData(Display *dpy, XExtDisplayInfo *info, | |
162 | + int *target_type, int *target_id) | |
163 | +{ | |
164 | + /* Find out what the server's NV-CONTROL version is and | |
165 | + * setup for swapping if we need to. | |
166 | + */ | |
167 | + if (info->data == NVCTRL_EXT_NEED_CHECK) { | |
168 | + int major, minor; | |
169 | + | |
170 | + if (XNVCTRLQueryVersion(dpy, &major, &minor)) { | |
171 | + if (major == 1 && | |
172 | + (minor == 8 || minor == 9)) { | |
173 | + info->data = NVCTRL_EXT_NEED_TARGET_SWAP; | |
174 | + } else { | |
175 | + info->data = NVCTRL_EXT_NEED_NOTHING; | |
176 | + } | |
177 | + } else { | |
178 | + info->data = NVCTRL_EXT_NEED_NOTHING; | |
179 | + } | |
180 | + } | |
181 | + | |
182 | + /* We need to swap the target_type and target_id */ | |
183 | + if (info->data == NVCTRL_EXT_NEED_TARGET_SWAP) { | |
184 | + int tmp; | |
185 | + tmp = *target_type; | |
186 | + *target_type = *target_id; | |
187 | + *target_id = tmp; | |
188 | + } | |
189 | +} | |
190 | + | |
191 | + | |
192 | +static Bool XNVCTRLQueryExtension ( | |
193 | + Display *dpy, | |
194 | + int *event_basep, | |
195 | + int *error_basep | |
196 | +){ | |
197 | + XExtDisplayInfo *info = find_display (dpy); | |
198 | + | |
199 | + if (XextHasExtension(info)) { | |
200 | + if (event_basep) *event_basep = info->codes->first_event; | |
201 | + if (error_basep) *error_basep = info->codes->first_error; | |
202 | + return True; | |
203 | + } else { | |
204 | + return False; | |
205 | + } | |
206 | +} | |
207 | + | |
208 | + | |
209 | +static Bool XNVCTRLQueryVersion ( | |
210 | + Display *dpy, | |
211 | + int *major, | |
212 | + int *minor | |
213 | +){ | |
214 | + XExtDisplayInfo *info = find_display (dpy); | |
215 | + xnvCtrlQueryExtensionReply rep; | |
216 | + xnvCtrlQueryExtensionReq *req; | |
217 | + | |
218 | + if(!XextHasExtension(info)) | |
219 | + return False; | |
220 | + | |
221 | + XNVCTRLCheckExtension (dpy, info, False); | |
222 | + | |
223 | + LockDisplay (dpy); | |
224 | + GetReq (nvCtrlQueryExtension, req); | |
225 | + req->reqType = info->codes->major_opcode; | |
226 | + req->nvReqType = X_nvCtrlQueryExtension; | |
227 | + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { | |
228 | + UnlockDisplay (dpy); | |
229 | + SyncHandle (); | |
230 | + return False; | |
231 | + } | |
232 | + if (major) *major = rep.major; | |
233 | + if (minor) *minor = rep.minor; | |
234 | + UnlockDisplay (dpy); | |
235 | + SyncHandle (); | |
236 | + return True; | |
237 | +} | |
238 | + | |
239 | + | |
240 | +static Bool XNVCTRLIsNvScreen ( | |
241 | + Display *dpy, | |
242 | + int screen | |
243 | +){ | |
244 | + XExtDisplayInfo *info = find_display (dpy); | |
245 | + xnvCtrlIsNvReply rep; | |
246 | + xnvCtrlIsNvReq *req; | |
247 | + Bool isnv; | |
248 | + | |
249 | + if(!XextHasExtension(info)) | |
250 | + return False; | |
251 | + | |
252 | + XNVCTRLCheckExtension (dpy, info, False); | |
253 | + | |
254 | + LockDisplay (dpy); | |
255 | + GetReq (nvCtrlIsNv, req); | |
256 | + req->reqType = info->codes->major_opcode; | |
257 | + req->nvReqType = X_nvCtrlIsNv; | |
258 | + req->screen = screen; | |
259 | + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { | |
260 | + UnlockDisplay (dpy); | |
261 | + SyncHandle (); | |
262 | + return False; | |
263 | + } | |
264 | + isnv = rep.isnv; | |
265 | + UnlockDisplay (dpy); | |
266 | + SyncHandle (); | |
267 | + return isnv; | |
268 | +} | |
269 | + | |
270 | + | |
271 | +static Bool XNVCTRLQueryTargetStringAttribute ( | |
272 | + Display *dpy, | |
273 | + int target_type, | |
274 | + int target_id, | |
275 | + unsigned int display_mask, | |
276 | + unsigned int attribute, | |
277 | + char **ptr | |
278 | +){ | |
279 | + XExtDisplayInfo *info = find_display (dpy); | |
280 | + xnvCtrlQueryStringAttributeReply rep; | |
281 | + xnvCtrlQueryStringAttributeReq *req; | |
282 | + Bool exists; | |
283 | + int length, numbytes, slop; | |
284 | + | |
285 | + if (!ptr) return False; | |
286 | + | |
287 | + if(!XextHasExtension(info)) | |
288 | + return False; | |
289 | + | |
290 | + XNVCTRLCheckExtension (dpy, info, False); | |
291 | + XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); | |
292 | + | |
293 | + LockDisplay (dpy); | |
294 | + GetReq (nvCtrlQueryStringAttribute, req); | |
295 | + req->reqType = info->codes->major_opcode; | |
296 | + req->nvReqType = X_nvCtrlQueryStringAttribute; | |
297 | + req->target_type = target_type; | |
298 | + req->target_id = target_id; | |
299 | + req->display_mask = display_mask; | |
300 | + req->attribute = attribute; | |
301 | + if (!_XReply (dpy, (xReply *) &rep, 0, False)) { | |
302 | + UnlockDisplay (dpy); | |
303 | + SyncHandle (); | |
304 | + return False; | |
305 | + } | |
306 | + length = rep.length; | |
307 | + numbytes = rep.n; | |
308 | + slop = numbytes & 3; | |
309 | + *ptr = (char *) Xmalloc(numbytes); | |
310 | + if (! *ptr) { | |
311 | + _XEatData(dpy, length); | |
312 | + UnlockDisplay (dpy); | |
313 | + SyncHandle (); | |
314 | + return False; | |
315 | + } else { | |
316 | + _XRead(dpy, (char *) *ptr, numbytes); | |
317 | + if (slop) _XEatData(dpy, 4-slop); | |
318 | + } | |
319 | + exists = rep.flags; | |
320 | + UnlockDisplay (dpy); | |
321 | + SyncHandle (); | |
322 | + return exists; | |
323 | +} | |
324 | + | |
325 | +static Bool XNVCTRLQueryStringAttribute ( | |
326 | + Display *dpy, | |
327 | + int screen, | |
328 | + unsigned int display_mask, | |
329 | + unsigned int attribute, | |
330 | + char **ptr | |
331 | +){ | |
332 | + return XNVCTRLQueryTargetStringAttribute(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN, | |
333 | + screen, display_mask, | |
334 | + attribute, ptr); | |
335 | +} | |
336 | + | |
337 | + | |
338 | +Bool VA_NVCTRLQueryDirectRenderingCapable( Display *dpy, int screen, | |
339 | + Bool *isCapable ) | |
340 | +{ | |
341 | + int event_base; | |
342 | + int error_base; | |
343 | + | |
344 | + if (isCapable) | |
345 | + *isCapable = False; | |
346 | + | |
347 | + if (!XNVCTRLQueryExtension(dpy, &event_base, &error_base)) | |
348 | + return False; | |
349 | + | |
350 | + if (isCapable && XNVCTRLIsNvScreen(dpy, screen)) | |
351 | + *isCapable = True; | |
352 | + | |
353 | + return True; | |
354 | +} | |
355 | + | |
356 | +Bool VA_NVCTRLGetClientDriverName( Display *dpy, int screen, | |
357 | + int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, | |
358 | + int *ddxDriverPatchVersion, char **clientDriverName ) | |
359 | +{ | |
360 | + if (ddxDriverMajorVersion) | |
361 | + *ddxDriverMajorVersion = 0; | |
362 | + if (ddxDriverMinorVersion) | |
363 | + *ddxDriverMinorVersion = 0; | |
364 | + if (ddxDriverPatchVersion) | |
365 | + *ddxDriverPatchVersion = 0; | |
366 | + if (clientDriverName) | |
367 | + *clientDriverName = NULL; | |
368 | + | |
369 | + char *nvidia_driver_version = NULL; | |
370 | + if (!XNVCTRLQueryStringAttribute(dpy, screen, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, &nvidia_driver_version)) | |
371 | + return False; | |
372 | + | |
373 | + char *end, *str = nvidia_driver_version; | |
374 | + unsigned long v = strtoul(str, &end, 10); | |
375 | + if (end && end != str) { | |
376 | + if (ddxDriverMajorVersion) | |
377 | + *ddxDriverMajorVersion = v; | |
378 | + if (*(str = end) == '.') { | |
379 | + v = strtoul(str + 1, &end, 10); | |
380 | + if (end && end != str && *end == '\0') { | |
381 | + if (ddxDriverMinorVersion) | |
382 | + *ddxDriverMinorVersion = v; | |
383 | + } | |
384 | + } | |
385 | + } | |
386 | + Xfree(nvidia_driver_version); | |
387 | + | |
388 | + if (clientDriverName) | |
389 | + *clientDriverName = strdup("nvidia"); | |
390 | + | |
391 | + return True; | |
392 | +} |
@@ -0,0 +1,36 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2008 NVIDIA, Corporation | |
3 | + * | |
4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | + * of this software and associated documentation files (the "Software"), to deal | |
6 | + * in the Software without restriction, including without limitation the rights | |
7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | + * copies of the Software, and to permit persons to whom the Software is | |
9 | + * furnished to do so, subject to the following conditions: | |
10 | + * | |
11 | + * The above copyright notice and this permission notice (including the next | |
12 | + * paragraph) shall be included in all copies or substantial portions of the | |
13 | + * Software. | |
14 | + * | |
15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
21 | + * SOFTWARE. | |
22 | + */ | |
23 | + | |
24 | +#ifndef VA_NVCTRLLIB_H | |
25 | +#define VA_NVCTRLLIB_H | |
26 | + | |
27 | +#include <X11/Xlib.h> | |
28 | + | |
29 | +Bool VA_NVCTRLQueryDirectRenderingCapable( Display *dpy, int screen, | |
30 | + Bool *isCapable ); | |
31 | + | |
32 | +Bool VA_NVCTRLGetClientDriverName( Display *dpy, int screen, | |
33 | + int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, | |
34 | + int *ddxDriverPatchVersion, char **clientDriverName ); | |
35 | + | |
36 | +#endif /* VA_NVCTRLLIB_H */ |
@@ -22,6 +22,7 @@ | ||
22 | 22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
23 | 23 | */ |
24 | 24 | |
25 | +#define _GNU_SOURCE 1 | |
25 | 26 | #include "config.h" |
26 | 27 | #include "va.h" |
27 | 28 | #include "va_backend.h" |
@@ -29,9 +30,11 @@ | ||
29 | 30 | #include "va_dri.h" |
30 | 31 | #include "va_dri2.h" |
31 | 32 | #include "va_dricommon.h" |
33 | +#include "va_nvctrl.h" | |
32 | 34 | #include <stdio.h> |
33 | 35 | #include <stdarg.h> |
34 | 36 | #include <string.h> |
37 | +#include <unistd.h> | |
35 | 38 | #include <sys/types.h> |
36 | 39 | #include <sys/stat.h> |
37 | 40 | #include <fcntl.h> |
@@ -91,6 +94,7 @@ static void va_DisplayContextDestroy ( | ||
91 | 94 | } |
92 | 95 | ctx = &((*ctx)->pNext); |
93 | 96 | } |
97 | + free(pDisplayContext->pDriverContext->dri_state); | |
94 | 98 | free(pDisplayContext->pDriverContext); |
95 | 99 | free(pDisplayContext); |
96 | 100 | } |
@@ -102,63 +106,46 @@ static VAStatus va_DRI2GetDriverName ( | ||
102 | 106 | ) |
103 | 107 | { |
104 | 108 | VADriverContextP ctx = pDisplayContext->pDriverContext; |
105 | - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; | |
106 | - int eventBase, errorBase; | |
107 | - char *device_name; | |
108 | - int driver_major; | |
109 | - int driver_minor; | |
110 | - int driver_patch; | |
111 | - Bool result = True; | |
112 | 109 | |
113 | - if (!VA_DRI2QueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) { | |
114 | - va_infoMessage("DRI2 extension isn't present\n"); | |
110 | + if (!isDRI2Connected(ctx, driver_name)) | |
115 | 111 | return VA_STATUS_ERROR_UNKNOWN; |
116 | - } | |
117 | 112 | |
118 | - if (!VA_DRI2QueryVersion(ctx->x11_dpy, &driver_major, &driver_minor)) { | |
119 | - va_errorMessage("VA_DRI2QueryVersion failed\n"); | |
120 | - return VA_STATUS_ERROR_UNKNOWN; | |
121 | - } | |
122 | - | |
123 | - if (!VA_DRI2Connect(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), | |
124 | - driver_name, &device_name)) { | |
125 | - va_infoMessage("DRI2 isn't enabled, fallback to DRI1\n"); | |
113 | + return VA_STATUS_SUCCESS; | |
114 | +} | |
115 | + | |
116 | +static VAStatus va_DRIGetDriverName ( | |
117 | + VADisplayContextP pDisplayContext, | |
118 | + char **driver_name | |
119 | +) | |
120 | +{ | |
121 | + VADriverContextP ctx = pDisplayContext->pDriverContext; | |
122 | + | |
123 | + if (!isDRI1Connected(ctx, driver_name)) | |
126 | 124 | return VA_STATUS_ERROR_UNKNOWN; |
127 | - } | |
128 | 125 | |
129 | - va_infoMessage("VA_DRI2Connect: %d.%d.%d %s (screen %d)\n", | |
130 | - driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen); | |
131 | - ctx->dri2 = 1; | |
132 | - | |
133 | 126 | return VA_STATUS_SUCCESS; |
134 | 127 | } |
135 | 128 | |
136 | -static VAStatus va_DRIGetDriverName ( | |
129 | +static VAStatus va_NVCTRL_GetDriverName ( | |
137 | 130 | VADisplayContextP pDisplayContext, |
138 | 131 | char **driver_name |
139 | 132 | ) |
140 | 133 | { |
141 | 134 | VADriverContextP ctx = pDisplayContext->pDriverContext; |
142 | 135 | VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; |
143 | - int eventBase, errorBase; | |
144 | 136 | int direct_capable; |
145 | 137 | int driver_major; |
146 | 138 | int driver_minor; |
147 | 139 | int driver_patch; |
148 | 140 | Bool result = True; |
149 | - char *x_driver_name = NULL; | |
141 | + char *nvidia_driver_name = NULL; | |
150 | 142 | |
151 | - if (!VA_DRIQueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) { | |
152 | - va_errorMessage("VA_DRIQueryExtension failed\n"); | |
153 | - return VA_STATUS_ERROR_UNKNOWN; | |
154 | - } | |
155 | - | |
156 | 143 | if (result) |
157 | 144 | { |
158 | - result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable); | |
145 | + result = VA_NVCTRLQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable); | |
159 | 146 | if (!result) |
160 | 147 | { |
161 | - va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n"); | |
148 | + va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable failed\n"); | |
162 | 149 | } |
163 | 150 | } |
164 | 151 | if (result) |
@@ -166,29 +153,27 @@ static VAStatus va_DRIGetDriverName ( | ||
166 | 153 | result = direct_capable; |
167 | 154 | if (!result) |
168 | 155 | { |
169 | - va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n"); | |
156 | + va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable returned false\n"); | |
170 | 157 | } |
171 | 158 | } |
172 | 159 | if (result) |
173 | 160 | { |
174 | - result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor, | |
175 | - &driver_patch, &x_driver_name); | |
161 | + result = VA_NVCTRLGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor, | |
162 | + &driver_patch, &nvidia_driver_name); | |
176 | 163 | if (!result) |
177 | 164 | { |
178 | - va_errorMessage("VA_DRIGetClientDriverName returned false\n"); | |
165 | + va_errorMessage("VA_NVCTRLGetClientDriverName returned false\n"); | |
179 | 166 | } |
180 | 167 | } |
181 | 168 | if (result) |
182 | 169 | { |
183 | 170 | vaStatus = VA_STATUS_SUCCESS; |
184 | - va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", | |
185 | - driver_major, driver_minor, driver_patch, x_driver_name, ctx->x11_screen); | |
186 | - if (driver_name) | |
187 | - *driver_name = strdup(x_driver_name); | |
171 | + va_infoMessage("va_NVCTRL_GetDriverName: %d.%d.%d %s (screen %d)\n", | |
172 | + driver_major, driver_minor, driver_patch, | |
173 | + nvidia_driver_name, ctx->x11_screen); | |
174 | + if (driver_name) | |
175 | + *driver_name = nvidia_driver_name; | |
188 | 176 | } |
189 | - if (x_driver_name) | |
190 | - XFree(x_driver_name); | |
191 | - | |
192 | 177 | return vaStatus; |
193 | 178 | } |
194 | 179 |
@@ -197,37 +182,26 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
197 | 182 | char **driver_name |
198 | 183 | ) |
199 | 184 | { |
200 | - VADriverContextP ctx = pDisplayContext->pDriverContext; | |
201 | - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; | |
202 | - int direct_capable; | |
203 | - int driver_major; | |
204 | - int driver_minor; | |
205 | - int driver_patch; | |
206 | - Bool result = True; | |
207 | - char *x_driver_name = NULL; | |
185 | + VAStatus vaStatus; | |
186 | + char *driver_name_env; | |
208 | 187 | |
209 | 188 | if (driver_name) |
210 | 189 | *driver_name = NULL; |
211 | - | |
212 | - vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); | |
213 | - if (vaStatus != VA_STATUS_SUCCESS) | |
214 | - vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); | |
215 | 190 | |
216 | - if ((vaStatus == VA_STATUS_SUCCESS) | |
191 | + if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL | |
217 | 192 | && geteuid() == getuid()) |
218 | 193 | { |
219 | 194 | /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ |
220 | - if (getenv("LIBVA_DRIVER_NAME")) | |
221 | - { | |
222 | - /* For easier debugging */ | |
223 | - if (*driver_name) | |
224 | - XFree(*driver_name); | |
225 | - | |
226 | - *driver_name = strdup(getenv("LIBVA_DRIVER_NAME")); | |
227 | - return VA_STATUS_SUCCESS; | |
228 | - } | |
195 | + *driver_name = strdup(driver_name_env); | |
196 | + return VA_STATUS_SUCCESS; | |
229 | 197 | } |
230 | - | |
198 | + | |
199 | + vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); | |
200 | + if (vaStatus != VA_STATUS_SUCCESS) | |
201 | + vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); | |
202 | + if (vaStatus != VA_STATUS_SUCCESS) | |
203 | + vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name); | |
204 | + | |
231 | 205 | return vaStatus; |
232 | 206 | } |
233 | 207 |
@@ -278,11 +252,12 @@ VADisplay vaGetDisplay ( | ||
278 | 252 | { |
279 | 253 | /* create new entry */ |
280 | 254 | VADriverContextP pDriverContext; |
255 | + struct dri_state *dri_state; | |
281 | 256 | pDisplayContext = calloc(1, sizeof(*pDisplayContext)); |
282 | 257 | pDriverContext = calloc(1, sizeof(*pDriverContext)); |
283 | - if (pDisplayContext && pDriverContext) | |
258 | + dri_state = calloc(1, sizeof(*dri_state)); | |
259 | + if (pDisplayContext && pDriverContext && dri_state) | |
284 | 260 | { |
285 | - pDriverContext->old_pNext = (void *)(unsigned long)0xdeadbeef; | |
286 | 261 | pDriverContext->x11_dpy = native_dpy; |
287 | 262 | pDisplayContext->pNext = pDisplayContexts; |
288 | 263 | pDisplayContext->pDriverContext = pDriverContext; |
@@ -290,7 +265,7 @@ VADisplay vaGetDisplay ( | ||
290 | 265 | pDisplayContext->vaDestroy = va_DisplayContextDestroy; |
291 | 266 | pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; |
292 | 267 | pDisplayContexts = pDisplayContext; |
293 | - pDriverContext->dri_state = calloc(1, sizeof(struct dri_state)); | |
268 | + pDriverContext->dri_state = dri_state; | |
294 | 269 | dpy = (VADisplay)pDisplayContext; |
295 | 270 | } |
296 | 271 | else |
@@ -299,6 +274,8 @@ VADisplay vaGetDisplay ( | ||
299 | 274 | free(pDisplayContext); |
300 | 275 | if (pDriverContext) |
301 | 276 | free(pDriverContext); |
277 | + if (dri_state) | |
278 | + free(dri_state); | |
302 | 279 | } |
303 | 280 | } |
304 | 281 |
@@ -31,9 +31,10 @@ AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src -I$(top_ | ||
31 | 31 | |
32 | 32 | TESTS = $(check_PROGRAMS) |
33 | 33 | |
34 | -TEST_LIBS = ../src/libva.la | |
34 | +TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib) | |
35 | 35 | |
36 | -vainfo_LDADD = ../src/libva.la | |
36 | +vainfo_LDADD = $(top_srcdir)/src/$(libvabackendlib) | |
37 | +vainfo_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib) | |
37 | 38 | vainfo_SOURCES = vainfo.c |
38 | 39 | |
39 | 40 | test_01_LDADD = $(TEST_LIBS) |
@@ -63,7 +63,7 @@ void status(const char *msg, ...) | ||
63 | 63 | |
64 | 64 | int main(int argc, const char* argv[]) |
65 | 65 | { |
66 | - const char *name = rindex(argv[0], '/'); | |
66 | + const char *name = strrchr(argv[0], '/'); | |
67 | 67 | if (name) |
68 | 68 | name++; |
69 | 69 | else |