hardware/intel/libva
修订版 | 5bc5efa30ce3a53b69c2560ab50e1a3d9367fdac (tree) |
---|---|
时间 | 2010-05-05 17:19:39 |
作者 | Ren Zhaohan <zhaohan.ren@inte...> |
Commiter | Ren Zhaohan |
add new va_DisplayContextGetDriverName, remove 'x11/XX' include folder name
@@ -17,6 +17,7 @@ LOCAL_CFLAGS += -DHAVE_CONFIG_H \ | ||
17 | 17 | LOCAL_C_INCLUDES += \ |
18 | 18 | $(TOPDIR)kernel/include \ |
19 | 19 | $(TARGET_OUT_HEADERS)/libva \ |
20 | + $(LOCAL_PATH)/x11 \ | |
20 | 21 | $(TOPDIR)kernel/include/drm |
21 | 22 | |
22 | 23 | LOCAL_COPY_HEADERS_TO := libva/va |
@@ -26,7 +26,7 @@ | ||
26 | 26 | #include "va.h" |
27 | 27 | #include "va_backend.h" |
28 | 28 | #include "va_android.h" |
29 | -#include "x11/va_dricommon.h" /* needs some helper functions from this file */ | |
29 | +#include "va_dricommon.h" /* needs some helper functions from this file */ | |
30 | 30 | #include <stdio.h> |
31 | 31 | #include <stdlib.h> |
32 | 32 | #include <stdarg.h> |
@@ -37,6 +37,10 @@ | ||
37 | 37 | #include <fcntl.h> |
38 | 38 | #include <dlfcn.h> |
39 | 39 | #include <errno.h> |
40 | +#ifndef ANDROID | |
41 | +#include <libudev.h> | |
42 | +#include "drm_test.h" | |
43 | +#endif | |
40 | 44 | |
41 | 45 | #define CHECK_SYMBOL(func) { if (!func) printf("func %s not found\n", #func); return VA_STATUS_ERROR_UNKNOWN; } |
42 | 46 | #define DEVICE_NAME "/dev/dri/card0" |
@@ -110,7 +114,7 @@ static void va_DisplayContextDestroy ( | ||
110 | 114 | free(pDisplayContext); |
111 | 115 | } |
112 | 116 | |
113 | - | |
117 | +#ifdef ANDROID | |
114 | 118 | static VAStatus va_DisplayContextGetDriverName ( |
115 | 119 | VADisplayContextP pDisplayContext, |
116 | 120 | char **driver_name |
@@ -154,7 +158,51 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
154 | 158 | |
155 | 159 | return VA_STATUS_SUCCESS; |
156 | 160 | } |
161 | +#else | |
162 | +static VAStatus va_DisplayContextGetDriverName ( | |
163 | + VADisplayContextP pDisplayContext, | |
164 | + char **driver_name | |
165 | +) | |
166 | +{ | |
167 | + VADriverContextP ctx = pDisplayContext->pDriverContext; | |
168 | + struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; | |
169 | + char *driver_name_env; | |
170 | + | |
171 | + struct { | |
172 | + unsigned int vendor_id; | |
173 | + unsigned int device_id; | |
174 | + char driver_name[64]; | |
175 | + } devices[] = { | |
176 | + { 0x8086, 0x4100, "pvr" }, | |
177 | + }; | |
157 | 178 | |
179 | + memset(dri_state, 0, sizeof(*dri_state)); | |
180 | + dri_state->fd = drm_open_any_master(); | |
181 | + if (dri_state->fd < 0) { | |
182 | + fprintf(stderr, "open DRM device by udev failed, try /dev/dri/card0\n"); | |
183 | + dri_state->fd = open("/dev/dri/card0", O_RDWR); | |
184 | + } | |
185 | + | |
186 | + if (dri_state->fd < 0) { | |
187 | + fprintf(stderr,"can't open DRM devices\n"); | |
188 | + return VA_STATUS_ERROR_UNKNOWN; | |
189 | + } | |
190 | + | |
191 | + if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL | |
192 | + && geteuid() == getuid()) | |
193 | + { | |
194 | + /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ | |
195 | + *driver_name = strdup(driver_name_env); | |
196 | + return VA_STATUS_SUCCESS; | |
197 | + } else /* TBD: other vendor driver names */ | |
198 | + *driver_name = strdup(devices[0].driver_name); | |
199 | + | |
200 | + | |
201 | + dri_state->driConnectedFlag = VA_DUMMY; | |
202 | + | |
203 | + return VA_STATUS_SUCCESS; | |
204 | +} | |
205 | +#endif | |
158 | 206 | |
159 | 207 | VADisplay vaGetDisplay ( |
160 | 208 | void *native_dpy /* implementation specific */ |
@@ -245,7 +293,6 @@ VAStatus vaPutSurface ( | ||
245 | 293 | |
246 | 294 | CHECK_DISPLAY(dpy); |
247 | 295 | ctx = CTX(dpy); |
248 | - | |
249 | 296 | return ctx->vtable.vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch, |
250 | 297 | destx, desty, destw, desth, |
251 | 298 | cliprects, number_cliprects, flags ); |
@@ -5,7 +5,6 @@ | ||
5 | 5 | #ifdef __cplusplus |
6 | 6 | extern "C" { |
7 | 7 | #endif |
8 | - | |
9 | 8 | /* |
10 | 9 | * Returns a suitable VADisplay for VA API |
11 | 10 | */ |
@@ -16,7 +15,7 @@ VADisplay vaGetDisplay ( | ||
16 | 15 | #if ANDROID |
17 | 16 | //#include <ui/Surface.h> |
18 | 17 | //class Surface; |
19 | - | |
18 | + | |
20 | 19 | /* |
21 | 20 | * Output rendering |
22 | 21 | * Following is the rendering interface for X windows, |
@@ -185,7 +185,11 @@ struct VADriverVTable | ||
185 | 185 | VAStatus (*vaPutSurface) ( |
186 | 186 | VADriverContextP ctx, |
187 | 187 | VASurfaceID surface, |
188 | - void * draw, /* Drawable of window system */ | |
188 | +#ifdef ANDROID | |
189 | + Surface* draw, /* Drawable of window system */ | |
190 | +#else | |
191 | + Drawable draw, | |
192 | +#endif | |
189 | 193 | short srcx, |
190 | 194 | short srcy, |
191 | 195 | unsigned short srcw, |
@@ -199,25 +203,6 @@ struct VADriverVTable | ||
199 | 203 | unsigned int flags /* de-interlacing flags */ |
200 | 204 | ); |
201 | 205 | |
202 | - VAStatus (*vaPutSurfaceBuf) ( | |
203 | - VADriverContextP ctx, | |
204 | - VASurfaceID surface, | |
205 | - Drawable draw, /* X Drawable */ | |
206 | - unsigned char* data, | |
207 | - int* data_len, | |
208 | - short srcx, | |
209 | - short srcy, | |
210 | - unsigned short srcw, | |
211 | - unsigned short srch, | |
212 | - short destx, | |
213 | - short desty, | |
214 | - unsigned short destw, | |
215 | - unsigned short desth, | |
216 | - VARectangle *cliprects, /* client supplied clip list */ | |
217 | - unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
218 | - unsigned int flags /* de-interlacing flags */ | |
219 | - ); | |
220 | - | |
221 | 206 | VAStatus (*vaQueryImageFormats) ( |
222 | 207 | VADriverContextP ctx, |
223 | 208 | VAImageFormat *format_list, /* out */ |