hardware/intel/libva
リビジョン | 943686a94957337b6a6fadcc316d6dee0e0f56d4 (tree) |
---|---|
日時 | 2010-06-04 15:29:01 |
作者 | Austin Yuan <shengquan.yuan@gmai...> |
コミッター | Austin Yuan |
Follow up the change of "LIBVA_DRIVER_NAME", remove it from va_android.cpp
Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
@@ -47,45 +47,39 @@ | ||
47 | 47 | |
48 | 48 | static VADisplayContextP pDisplayContexts = NULL; |
49 | 49 | |
50 | -static int vaDisplayIsValid (VADisplay dpy) | |
51 | -{ | |
52 | - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; | |
53 | - return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext); | |
54 | -} | |
55 | - | |
56 | 50 | static int open_device (char *dev_name) |
57 | 51 | { |
58 | - struct stat st; | |
59 | - int fd; | |
52 | + struct stat st; | |
53 | + int fd; | |
60 | 54 | |
61 | - if (-1 == stat (dev_name, &st)) | |
55 | + if (-1 == stat (dev_name, &st)) | |
62 | 56 | { |
63 | - printf ("Cannot identify '%s': %d, %s\n", | |
64 | - dev_name, errno, strerror (errno)); | |
65 | - return -1; | |
57 | + printf ("Cannot identify '%s': %d, %s\n", | |
58 | + dev_name, errno, strerror (errno)); | |
59 | + return -1; | |
66 | 60 | } |
67 | 61 | |
68 | - if (!S_ISCHR (st.st_mode)) | |
62 | + if (!S_ISCHR (st.st_mode)) | |
69 | 63 | { |
70 | - printf ("%s is no device\n", dev_name); | |
71 | - return -1; | |
64 | + printf ("%s is no device\n", dev_name); | |
65 | + return -1; | |
72 | 66 | } |
73 | 67 | |
74 | - fd = open (dev_name, O_RDWR); | |
68 | + fd = open (dev_name, O_RDWR); | |
75 | 69 | |
76 | - if (-1 == fd) | |
70 | + if (-1 == fd) | |
77 | 71 | { |
78 | - fprintf (stderr, "Cannot open '%s': %d, %s\n", | |
79 | - dev_name, errno, strerror (errno)); | |
80 | - return -1; | |
72 | + fprintf (stderr, "Cannot open '%s': %d, %s\n", | |
73 | + dev_name, errno, strerror (errno)); | |
74 | + return -1; | |
81 | 75 | } |
82 | 76 | |
83 | - return fd; | |
77 | + return fd; | |
84 | 78 | } |
85 | 79 | |
86 | 80 | static int va_DisplayContextIsValid ( |
87 | 81 | VADisplayContextP pDisplayContext |
88 | -) | |
82 | + ) | |
89 | 83 | { |
90 | 84 | VADisplayContextP ctx = pDisplayContexts; |
91 | 85 |
@@ -149,17 +143,11 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
149 | 143 | return VA_STATUS_ERROR_UNKNOWN; |
150 | 144 | } |
151 | 145 | |
152 | - if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL | |
153 | - && geteuid() == getuid()) { | |
154 | - /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ | |
155 | - *driver_name = strdup(driver_name_env); | |
156 | - return VA_STATUS_SUCCESS; | |
157 | - } else { /* TBD: other vendor driver names */ | |
158 | - vendor_id = devices[0].vendor_id; | |
159 | - device_id = devices[0].device_id; | |
160 | - *driver_name = strdup(devices[0].driver_name); | |
161 | - } | |
162 | - | |
146 | + /* TBD: other vendor driver names */ | |
147 | + vendor_id = devices[0].vendor_id; | |
148 | + device_id = devices[0].device_id; | |
149 | + *driver_name = strdup(devices[0].driver_name); | |
150 | + | |
163 | 151 | dri_state->driConnectedFlag = VA_DUMMY; |
164 | 152 | |
165 | 153 | return VA_STATUS_SUCCESS; |
@@ -174,6 +162,7 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
174 | 162 | struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; |
175 | 163 | char *driver_name_env; |
176 | 164 | int vendor_id, device_id; |
165 | + int i = 0; | |
177 | 166 | |
178 | 167 | struct { |
179 | 168 | int vendor_id; |
@@ -193,31 +182,24 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
193 | 182 | return VA_STATUS_ERROR_UNKNOWN; |
194 | 183 | } |
195 | 184 | |
196 | - if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL | |
197 | - && geteuid() == getuid()) { | |
198 | - /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ | |
199 | - *driver_name = strdup(driver_name_env); | |
200 | - return VA_STATUS_SUCCESS; | |
201 | - } else { /* TBD: other vendor driver names */ | |
202 | - int i = 0; | |
203 | - | |
204 | - while (devices[i].device_id != 0) { | |
205 | - if ((devices[i].vendor_id == vendor_id) && | |
206 | - (devices[i].device_id == device_id)) | |
207 | - break; | |
208 | - i++; | |
209 | - } | |
185 | + /* TBD: other vendor driver names */ | |
210 | 186 | |
211 | - if (devices[i].device_id != 0) | |
212 | - *driver_name = strdup(devices[i].driver_name); | |
213 | - else { | |
214 | - fprintf(stderr,"device (0x%04x:0x%04x) is not supported\n", | |
215 | - vendor_id, device_id); | |
216 | - | |
217 | - return VA_STATUS_ERROR_UNKNOWN; | |
218 | - } | |
187 | + while (devices[i].device_id != 0) { | |
188 | + if ((devices[i].vendor_id == vendor_id) && | |
189 | + (devices[i].device_id == device_id)) | |
190 | + break; | |
191 | + i++; | |
219 | 192 | } |
220 | 193 | |
194 | + if (devices[i].device_id != 0) | |
195 | + *driver_name = strdup(devices[i].driver_name); | |
196 | + else { | |
197 | + fprintf(stderr,"device (0x%04x:0x%04x) is not supported\n", | |
198 | + vendor_id, device_id); | |
199 | + | |
200 | + return VA_STATUS_ERROR_UNKNOWN; | |
201 | + } | |
202 | + | |
221 | 203 | printf("DRM device is opened, loading driver %s for device 0x%04x:0x%04x\n", |
222 | 204 | driver_name, vendor_id, device_id); |
223 | 205 |
@@ -231,58 +213,58 @@ VADisplay vaGetDisplay ( | ||
231 | 213 | void *native_dpy /* implementation specific */ |
232 | 214 | ) |
233 | 215 | { |
234 | - VADisplay dpy = NULL; | |
235 | - VADisplayContextP pDisplayContext = pDisplayContexts; | |
236 | - | |
237 | - if (!native_dpy) | |
238 | - return NULL; | |
216 | + VADisplay dpy = NULL; | |
217 | + VADisplayContextP pDisplayContext = pDisplayContexts; | |
239 | 218 | |
240 | - while (pDisplayContext) | |
241 | - { | |
242 | - if (pDisplayContext->pDriverContext && | |
243 | - pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy) | |
244 | - { | |
245 | - dpy = (VADisplay)pDisplayContext; | |
246 | - break; | |
247 | - } | |
248 | - pDisplayContext = pDisplayContext->pNext; | |
249 | - } | |
219 | + if (!native_dpy) | |
220 | + return NULL; | |
250 | 221 | |
222 | + while (pDisplayContext) | |
223 | + { | |
224 | + if (pDisplayContext->pDriverContext && | |
225 | + pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy) | |
226 | + { | |
227 | + dpy = (VADisplay)pDisplayContext; | |
228 | + break; | |
229 | + } | |
230 | + pDisplayContext = pDisplayContext->pNext; | |
231 | + } | |
251 | 232 | |
252 | - if (!dpy) | |
253 | - { | |
254 | - /* create new entry */ | |
255 | - VADriverContextP pDriverContext; | |
256 | - struct dri_state *dri_state; | |
257 | - pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); | |
258 | - pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); | |
259 | - dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state)); | |
260 | - if (pDisplayContext && pDriverContext && dri_state) | |
261 | - { | |
262 | - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; | |
263 | 233 | |
264 | - pDriverContext->native_dpy = (void *)native_dpy; | |
265 | - pDisplayContext->pNext = pDisplayContexts; | |
266 | - pDisplayContext->pDriverContext = pDriverContext; | |
267 | - pDisplayContext->vaIsValid = va_DisplayContextIsValid; | |
268 | - pDisplayContext->vaDestroy = va_DisplayContextDestroy; | |
269 | - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; | |
270 | - pDisplayContexts = pDisplayContext; | |
271 | - pDriverContext->dri_state = dri_state; | |
272 | - dpy = (VADisplay)pDisplayContext; | |
273 | - } | |
274 | - else | |
275 | - { | |
276 | - if (pDisplayContext) | |
277 | - free(pDisplayContext); | |
278 | - if (pDriverContext) | |
279 | - free(pDriverContext); | |
280 | - if (dri_state) | |
281 | - free(dri_state); | |
282 | - } | |
283 | - } | |
234 | + if (!dpy) | |
235 | + { | |
236 | + /* create new entry */ | |
237 | + VADriverContextP pDriverContext; | |
238 | + struct dri_state *dri_state; | |
239 | + pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); | |
240 | + pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); | |
241 | + dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state)); | |
242 | + if (pDisplayContext && pDriverContext && dri_state) | |
243 | + { | |
244 | + pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; | |
245 | + | |
246 | + pDriverContext->native_dpy = (void *)native_dpy; | |
247 | + pDisplayContext->pNext = pDisplayContexts; | |
248 | + pDisplayContext->pDriverContext = pDriverContext; | |
249 | + pDisplayContext->vaIsValid = va_DisplayContextIsValid; | |
250 | + pDisplayContext->vaDestroy = va_DisplayContextDestroy; | |
251 | + pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; | |
252 | + pDisplayContexts = pDisplayContext; | |
253 | + pDriverContext->dri_state = dri_state; | |
254 | + dpy = (VADisplay)pDisplayContext; | |
255 | + } | |
256 | + else | |
257 | + { | |
258 | + if (pDisplayContext) | |
259 | + free(pDisplayContext); | |
260 | + if (pDriverContext) | |
261 | + free(pDriverContext); | |
262 | + if (dri_state) | |
263 | + free(dri_state); | |
264 | + } | |
265 | + } | |
284 | 266 | |
285 | - return dpy; | |
267 | + return dpy; | |
286 | 268 | } |
287 | 269 | |
288 | 270 | #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) |
@@ -307,12 +289,12 @@ VAStatus vaPutSurface ( | ||
307 | 289 | unsigned int flags /* de-interlacing flags */ |
308 | 290 | ) |
309 | 291 | { |
310 | - VADriverContextP ctx; | |
292 | + VADriverContextP ctx; | |
311 | 293 | |
312 | - CHECK_DISPLAY(dpy); | |
313 | - ctx = CTX(dpy); | |
314 | - return ctx->vtable.vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch, | |
315 | - destx, desty, destw, desth, | |
316 | - cliprects, number_cliprects, flags ); | |
294 | + CHECK_DISPLAY(dpy); | |
295 | + ctx = CTX(dpy); | |
296 | + return ctx->vtable.vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch, | |
297 | + destx, desty, destw, desth, | |
298 | + cliprects, number_cliprects, flags ); | |
317 | 299 | } |
318 | 300 | #endif |
@@ -47,8 +47,6 @@ | ||
47 | 47 | status = vtable->va##func##GLX args; \ |
48 | 48 | } while (0) |
49 | 49 | |
50 | -// Check VADisplay is valid (from libva.so.*) | |
51 | -int vaDisplayIsValid(VADisplay dpy); | |
52 | 50 | |
53 | 51 | // Destroy VA/GLX display context |
54 | 52 | static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) |
@@ -159,6 +159,8 @@ const char *vaErrorStr(VAStatus error_status); | ||
159 | 159 | */ |
160 | 160 | typedef void* NativeDisplay; /* window system dependent */ |
161 | 161 | |
162 | +int vaDisplayIsValid(VADisplay dpy); | |
163 | + | |
162 | 164 | /* |
163 | 165 | * Initialize the library |
164 | 166 | */ |