hardware/intel/libva
Revision | 0ea43daae2db5fbfcb4c412853d763f77328414b (tree) |
---|---|
Zeit | 2010-04-16 06:36:59 |
Autor | Austin Yuan <shengquan.yuan@gmai...> |
Commiter | Austin Yuan |
save
Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
@@ -119,6 +119,7 @@ AC_OUTPUT([ | ||
119 | 119 | va/Makefile |
120 | 120 | va/va_version.h |
121 | 121 | va/x11/Makefile |
122 | + va/android/Makefile | |
122 | 123 | dummy_drv_video/Makefile |
123 | 124 | i965_drv_video/Makefile |
124 | 125 | i965_drv_video/shaders/Makefile |
@@ -40,7 +40,7 @@ libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS | ||
40 | 40 | libva_x11_la_LDFLAGS = $(LDADD) |
41 | 41 | libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la |
42 | 42 | |
43 | -SUBDIRS = x11 | |
43 | +SUBDIRS = x11 android | |
44 | 44 | |
45 | 45 | libva_la_SOURCES = va.c va_trace.c |
46 | 46 |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "va.h" |
27 | 27 | #include "va_backend.h" |
28 | 28 | #include "va_android.h" |
29 | +#include "va_dricommon.h" | |
29 | 30 | #include <stdio.h> |
30 | 31 | #include <stdlib.h> |
31 | 32 | #include <stdarg.h> |
@@ -36,6 +37,7 @@ | ||
36 | 37 | #include <fcntl.h> |
37 | 38 | #include <errno.h> |
38 | 39 | |
40 | + | |
39 | 41 | static VADisplayContextP pDisplayContexts = NULL; |
40 | 42 | |
41 | 43 | static int va_DisplayContextIsValid ( |
@@ -70,6 +72,7 @@ static void va_DisplayContextDestroy ( | ||
70 | 72 | } |
71 | 73 | ctx = &((*ctx)->pNext); |
72 | 74 | } |
75 | + free(pDisplayContext->pDriverContext->dri_state); | |
73 | 76 | free(pDisplayContext->pDriverContext); |
74 | 77 | free(pDisplayContext); |
75 | 78 | } |
@@ -79,8 +82,11 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
79 | 82 | VADisplayContextP pDisplayContext, |
80 | 83 | char **driver_name |
81 | 84 | ) |
82 | -{ | |
85 | +{ | |
86 | + VADriverContextP ctx = pDisplayContext->pDriverContext; | |
87 | + struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; | |
83 | 88 | char *driver_name_env; |
89 | + | |
84 | 90 | struct { |
85 | 91 | unsigned int verndor_id; |
86 | 92 | unsigned int device_id; |
@@ -89,17 +95,29 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
89 | 95 | { 0x8086, 0x4100, "pvr" }, |
90 | 96 | }; |
91 | 97 | |
92 | - if (driver_name) | |
93 | - *driver_name = NULL; | |
98 | + memset(dri_state, 0, sizeof(*dri_state)); | |
99 | + dri_state->fd = drm_open_any_master(); | |
100 | + if (dri_state->fd < 0) | |
101 | + return VA_STATUS_ERROR_UNKNOWN; | |
102 | + | |
103 | + if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL | |
104 | + && geteuid() == getuid()) | |
105 | + { | |
106 | + /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ | |
107 | + *driver_name = strdup(driver_name_env); | |
108 | + return VA_STATUS_SUCCESS; | |
109 | + } else /* TBD: other vendor driver names */ | |
110 | + *driver_name = strdup(devices[0].driver_name); | |
94 | 111 | |
95 | - *driver_name = strdup(devices[0].driver_name); | |
112 | + | |
113 | + dri_state->driConnectedFlag = VA_DRI2; | |
96 | 114 | |
97 | 115 | return VA_STATUS_SUCCESS; |
98 | 116 | } |
99 | 117 | |
100 | 118 | |
101 | 119 | VADisplay vaGetDisplay ( |
102 | - Display *native_dpy /* implementation specific */ | |
120 | + void *native_dpy /* implementation specific */ | |
103 | 121 | ) |
104 | 122 | { |
105 | 123 | VADisplay dpy = NULL; |
@@ -123,9 +141,12 @@ VADisplay vaGetDisplay ( | ||
123 | 141 | { |
124 | 142 | /* create new entry */ |
125 | 143 | VADriverContextP pDriverContext; |
144 | + struct dri_state *dri_state; | |
126 | 145 | pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); |
127 | 146 | pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); |
128 | - if (pDisplayContext && pDriverContext) | |
147 | + dri_state = calloc(1, sizeof(*dri_state)); | |
148 | + | |
149 | + if (pDisplayContext && pDriverContext && dri_state) | |
129 | 150 | { |
130 | 151 | pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; |
131 | 152 |
@@ -136,6 +157,7 @@ VADisplay vaGetDisplay ( | ||
136 | 157 | pDisplayContext->vaDestroy = va_DisplayContextDestroy; |
137 | 158 | pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; |
138 | 159 | pDisplayContexts = pDisplayContext; |
160 | + pDriverContext->dri_state = dri_state; | |
139 | 161 | dpy = (VADisplay)pDisplayContext; |
140 | 162 | } |
141 | 163 | else |
@@ -144,6 +166,8 @@ VADisplay vaGetDisplay ( | ||
144 | 166 | free(pDisplayContext); |
145 | 167 | if (pDriverContext) |
146 | 168 | free(pDriverContext); |
169 | + if (dri_state) | |
170 | + free(dri_state); | |
147 | 171 | } |
148 | 172 | } |
149 | 173 |
@@ -160,6 +184,7 @@ static int vaDisplayIsValid(VADisplay dpy) | ||
160 | 184 | return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext); |
161 | 185 | } |
162 | 186 | |
187 | +#ifdef ANDROID | |
163 | 188 | VAStatus vaPutSurface ( |
164 | 189 | VADisplay dpy, |
165 | 190 | VASurfaceID surface, |
@@ -214,3 +239,4 @@ VAStatus vaPutSurfaceBuf ( | ||
214 | 239 | return ctx->vtable.vaPutSurfaceBuf( ctx, surface, draw, data, data_len, srcx, srcy, srcw, srch, |
215 | 240 | destx, desty, destw, desth, cliprects, number_cliprects, flags ); |
216 | 241 | } |
242 | +#endif |
@@ -2,13 +2,13 @@ | ||
2 | 2 | #define _VA_ANDROID_H_ |
3 | 3 | |
4 | 4 | #include <va/va.h> |
5 | -#include <ui/Surface.h> | |
6 | -class Surface; | |
5 | + | |
7 | 6 | |
8 | 7 | #ifdef __cplusplus |
9 | 8 | extern "C" { |
10 | 9 | #endif |
11 | 10 | |
11 | + | |
12 | 12 | /* |
13 | 13 | * Returns a suitable VADisplay for VA API |
14 | 14 | */ |
@@ -16,6 +16,11 @@ VADisplay vaGetDisplay ( | ||
16 | 16 | void *dpy |
17 | 17 | ); |
18 | 18 | |
19 | +#ifdef ANDROID | |
20 | + | |
21 | +#include <ui/Surface.h> | |
22 | +class Surface; | |
23 | + | |
19 | 24 | /* |
20 | 25 | * Output rendering |
21 | 26 | * Following is the rendering interface for X windows, |
@@ -42,23 +47,26 @@ VAStatus vaPutSurface ( | ||
42 | 47 | ); |
43 | 48 | |
44 | 49 | VAStatus vaPutSurfaceBuf ( |
45 | - VADriverContextP ctx, | |
46 | - VASurfaceID surface, | |
47 | - Drawable draw, /* X Drawable */ | |
48 | - unsigned char* data, | |
49 | - int* data_len, | |
50 | - short srcx, | |
51 | - short srcy, | |
52 | - unsigned short srcw, | |
53 | - unsigned short srch, | |
54 | - short destx, | |
55 | - short desty, | |
56 | - unsigned short destw, | |
57 | - unsigned short desth, | |
58 | - VARectangle *cliprects, /* client supplied clip list */ | |
59 | - unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
60 | - unsigned int flags /* de-interlacing flags */ | |
61 | - ); | |
50 | + VADriverContextP ctx, | |
51 | + VASurfaceID surface, | |
52 | + Drawable draw, /* X Drawable */ | |
53 | + unsigned char* data, | |
54 | + int* data_len, | |
55 | + short srcx, | |
56 | + short srcy, | |
57 | + unsigned short srcw, | |
58 | + unsigned short srch, | |
59 | + short destx, | |
60 | + short desty, | |
61 | + unsigned short destw, | |
62 | + unsigned short desth, | |
63 | + VARectangle *cliprects, /* client supplied clip list */ | |
64 | + unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
65 | + unsigned int flags /* de-interlacing flags */ | |
66 | +); | |
67 | + | |
68 | +#endif | |
69 | + | |
62 | 70 | #ifdef __cplusplus |
63 | 71 | } |
64 | 72 | #endif |