~misterc/libva/Trunk

« back to all changes in this revision

Viewing changes to src/va.c

  • Committer: Austin Yuan
  • Date: 2009-06-13 01:17:46 UTC
  • Revision ID: git-v1:527643827e6589645df6fe2232c2d397f9fe76e9
Fix the issue that all files are moved into a sub-directory libva.

Signed-off-by: Austin Yuan <shengquan.yuan@intel.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2007 Intel Corporation. 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
#include "va.h"
 
26
#include "va_backend.h"
 
27
 
 
28
#include "va_version.h"
 
29
 
 
30
#include <assert.h>
 
31
#include <stdarg.h>
 
32
#include <stdio.h>
 
33
#include <string.h>
 
34
#include <dlfcn.h>
 
35
#include <unistd.h>
 
36
 
 
37
#define VA_STR_VERSION          VA_BUILD_DATE VA_BUILD_GIT
 
38
 
 
39
#define VA_MAJOR_VERSION        0
 
40
#define VA_MINOR_VERSION        30
 
41
#define DRIVER_INIT_FUNC        "__vaDriverInit_0_30"
 
42
 
 
43
#define DEFAULT_DRIVER_DIR      "/usr/lib/dri/"
 
44
#define DRIVER_EXTENSION        "_drv_video.so"
 
45
 
 
46
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
 
47
#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
 
48
 
 
49
#define ASSERT          assert
 
50
#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
 
51
#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
 
52
#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
 
53
 
 
54
#define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
 
55
 
 
56
static int va_debug_trace = 0;
 
57
 
 
58
int vaDisplayIsValid(VADisplay dpy);
 
59
 
 
60
static void va_errorMessage(const char *msg, ...)
 
61
{
 
62
    va_list args;
 
63
 
 
64
    fprintf(stderr, "libva error: ");
 
65
    va_start(args, msg);
 
66
    vfprintf(stderr, msg, args);
 
67
    va_end(args);
 
68
}
 
69
 
 
70
static void va_infoMessage(const char *msg, ...)
 
71
{
 
72
    va_list args;
 
73
 
 
74
    fprintf(stderr, "libva: ");
 
75
    va_start(args, msg);
 
76
    vfprintf(stderr, msg, args);
 
77
    va_end(args);
 
78
}
 
79
 
 
80
static Bool va_checkVtable(void *ptr, char *function)
 
81
{
 
82
    if (!ptr)
 
83
    {
 
84
        va_errorMessage("No valid vtable entry for va%s\n", function);
 
85
        return False;
 
86
    }
 
87
    return True;
 
88
}
 
89
 
 
90
static Bool va_checkMaximum(int value, char *variable)
 
91
{
 
92
    if (!value)
 
93
    {
 
94
        va_errorMessage("Failed to define max_%s in init\n", variable);
 
95
        return False;
 
96
    }
 
97
    return True;
 
98
}
 
99
 
 
100
static Bool va_checkString(const char* value, char *variable)
 
101
{
 
102
    if (!value)
 
103
    {
 
104
        va_errorMessage("Failed to define str_%s in init\n", variable);
 
105
        return False;
 
106
    }
 
107
    return True;
 
108
}
 
109
 
 
110
static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
 
111
{
 
112
    VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
 
113
    return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
 
114
}
 
115
 
 
116
static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
 
117
{
 
118
    VADriverContextP ctx = CTX(dpy);
 
119
    VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
 
120
    char *search_path = NULL;
 
121
    char *saveptr;
 
122
    char *driver_dir;
 
123
    
 
124
    if (geteuid() == getuid())
 
125
    {
 
126
        /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
 
127
        search_path = getenv("LIBVA_DRIVERS_PATH");
 
128
        if (!search_path)
 
129
        {
 
130
            search_path = getenv("LIBGL_DRIVERS_PATH");
 
131
        }
 
132
    }
 
133
    if (!search_path)
 
134
    {
 
135
        search_path = DEFAULT_DRIVER_DIR;
 
136
    }
 
137
 
 
138
    search_path = strdup(search_path);
 
139
    driver_dir = strtok_r(search_path, ":", &saveptr);
 
140
    while(driver_dir)
 
141
    {
 
142
        void *handle = NULL;
 
143
        char *driver_path = (char *) malloc( strlen(driver_dir) +
 
144
                                             strlen(driver_name) +
 
145
                                             strlen(DRIVER_EXTENSION) + 2 );
 
146
        strncpy( driver_path, driver_dir, strlen(driver_dir) + 1);
 
147
        strncat( driver_path, "/", strlen("/") );
 
148
        strncat( driver_path, driver_name, strlen(driver_name) );
 
149
        strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
 
150
        
 
151
        va_infoMessage("Trying to open %s\n", driver_path);
 
152
 
 
153
        handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
 
154
        if (!handle)
 
155
        {
 
156
            /* Don't give errors for non-existing files */
 
157
            if (0 == access( driver_path, F_OK))
 
158
            {   
 
159
                va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
 
160
            }
 
161
        }
 
162
        else
 
163
        {
 
164
            VADriverInit init_func;
 
165
            init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
 
166
            if (!init_func)
 
167
            {
 
168
                va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
 
169
                dlclose(handle);
 
170
            }
 
171
            else
 
172
            {
 
173
                vaStatus = (*init_func)(ctx);
 
174
 
 
175
                if (VA_STATUS_SUCCESS == vaStatus)
 
176
                {
 
177
                    CHECK_MAXIMUM(vaStatus, ctx, profiles);
 
178
                    CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
 
179
                    CHECK_MAXIMUM(vaStatus, ctx, attributes);
 
180
                    CHECK_MAXIMUM(vaStatus, ctx, image_formats);
 
181
                    CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
 
182
                    CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
 
183
                    CHECK_STRING(vaStatus, ctx, vendor);
 
184
                    CHECK_VTABLE(vaStatus, ctx, Terminate);
 
185
                    CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
 
186
                    CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
 
187
                    CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
 
188
                    CHECK_VTABLE(vaStatus, ctx, CreateConfig);
 
189
                    CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
 
190
                    CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
 
191
                    CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
 
192
                    CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
 
193
                    CHECK_VTABLE(vaStatus, ctx, CreateContext);
 
194
                    CHECK_VTABLE(vaStatus, ctx, DestroyContext);
 
195
                    CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
 
196
                    CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
 
197
                    CHECK_VTABLE(vaStatus, ctx, MapBuffer);
 
198
                    CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
 
199
                    CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
 
200
                    CHECK_VTABLE(vaStatus, ctx, BeginPicture);
 
201
                    CHECK_VTABLE(vaStatus, ctx, RenderPicture);
 
202
                    CHECK_VTABLE(vaStatus, ctx, EndPicture);
 
203
                    CHECK_VTABLE(vaStatus, ctx, SyncSurface);
 
204
                    CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
 
205
                    CHECK_VTABLE(vaStatus, ctx, PutSurface);
 
206
                    CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
 
207
                    CHECK_VTABLE(vaStatus, ctx, CreateImage);
 
208
                    CHECK_VTABLE(vaStatus, ctx, DeriveImage);
 
209
                    CHECK_VTABLE(vaStatus, ctx, DestroyImage);
 
210
                    CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
 
211
                    CHECK_VTABLE(vaStatus, ctx, GetImage);
 
212
                    CHECK_VTABLE(vaStatus, ctx, PutImage);
 
213
                    CHECK_VTABLE(vaStatus, ctx, PutImage2);
 
214
                    CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
 
215
                    CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
 
216
                    CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
 
217
                    CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
 
218
                    CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
 
219
                    CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
 
220
                    CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
 
221
                    CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture2);
 
222
                    CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
 
223
                    CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
 
224
                    CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
 
225
                    CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
 
226
                    CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
 
227
                }
 
228
                if (VA_STATUS_SUCCESS != vaStatus)
 
229
                {
 
230
                    va_errorMessage("%s init failed\n", driver_path);
 
231
                    dlclose(handle);
 
232
                }
 
233
                if (VA_STATUS_SUCCESS == vaStatus)
 
234
                {
 
235
                    ctx->handle = handle;
 
236
                }
 
237
                free(driver_path);
 
238
                break;
 
239
            }
 
240
        }
 
241
        free(driver_path);
 
242
        
 
243
        driver_dir = strtok_r(NULL, ":", &saveptr);
 
244
    }
 
245
    
 
246
    free(search_path);    
 
247
    
 
248
    return vaStatus;
 
249
}
 
250
 
 
251
VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
 
252
{
 
253
    VADriverContextP ctx;
 
254
    if( !vaDisplayIsValid(dpy) )
 
255
        return NULL;
 
256
    ctx = CTX(dpy);
 
257
 
 
258
    if (NULL == ctx->handle)
 
259
        return NULL;
 
260
        
 
261
    return (VAPrivFunc) dlsym(ctx->handle, func);
 
262
}
 
263
 
 
264
 
 
265
/*
 
266
 * Returns a short english description of error_status
 
267
 */
 
268
const char *vaErrorStr(VAStatus error_status)
 
269
{
 
270
    switch(error_status)
 
271
    {
 
272
        case VA_STATUS_SUCCESS:
 
273
            return "success (no error)";
 
274
        case VA_STATUS_ERROR_OPERATION_FAILED:
 
275
            return "operation failed";
 
276
        case VA_STATUS_ERROR_ALLOCATION_FAILED:
 
277
            return "resource allocation failed";
 
278
        case VA_STATUS_ERROR_INVALID_DISPLAY:
 
279
            return "invalid VADisplay";
 
280
        case VA_STATUS_ERROR_INVALID_CONFIG:
 
281
            return "invalid VAConfigID";
 
282
        case VA_STATUS_ERROR_INVALID_CONTEXT:
 
283
            return "invalid VAContextID";
 
284
        case VA_STATUS_ERROR_INVALID_SURFACE:
 
285
            return "invalid VASurfaceID";
 
286
        case VA_STATUS_ERROR_INVALID_BUFFER:
 
287
            return "invalid VABufferID";
 
288
        case VA_STATUS_ERROR_INVALID_IMAGE:
 
289
            return "invalid VAImageID";
 
290
        case VA_STATUS_ERROR_INVALID_SUBPICTURE:
 
291
            return "invalid VASubpictureID";
 
292
        case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
 
293
            return "attribute not supported";
 
294
        case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
 
295
            return "list argument exceeds maximum number";
 
296
        case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
 
297
            return "the requested VAProfile is not supported";
 
298
        case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
 
299
            return "the requested VAEntryPoint is not supported";
 
300
        case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
 
301
            return "the requested RT Format is not supported";
 
302
        case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
 
303
            return "the requested VABufferType is not supported";
 
304
        case VA_STATUS_ERROR_SURFACE_BUSY:
 
305
            return "surface is in use";
 
306
        case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
 
307
            return "flag not supported";
 
308
        case VA_STATUS_ERROR_INVALID_PARAMETER:
 
309
            return "invalid parameter";
 
310
        case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
 
311
            return "resolution not supported";
 
312
        case VA_STATUS_ERROR_UNKNOWN:
 
313
            return "unknown libva error";
 
314
    }
 
315
    return "unknown libva error / description missing";
 
316
}
 
317
      
 
318
VAStatus vaInitialize (
 
319
    VADisplay dpy,
 
320
    int *major_version,  /* out */
 
321
    int *minor_version   /* out */
 
322
)
 
323
{
 
324
  char *driver_name = NULL;
 
325
  VAStatus vaStatus;
 
326
  
 
327
  CHECK_DISPLAY(dpy);
 
328
 
 
329
  va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
 
330
 
 
331
  va_infoMessage("libva build on %s\n", VA_STR_VERSION);
 
332
 
 
333
  vaStatus = va_getDriverName(dpy, &driver_name);
 
334
  va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
 
335
  
 
336
  if (VA_STATUS_SUCCESS == vaStatus)
 
337
  {
 
338
      vaStatus = va_openDriver(dpy, driver_name);
 
339
      va_infoMessage("va_openDriver() returns %d\n", vaStatus);
 
340
      
 
341
      *major_version = VA_MAJOR_VERSION;
 
342
      *minor_version = VA_MINOR_VERSION;
 
343
  }
 
344
 
 
345
  if (driver_name)
 
346
      free(driver_name);
 
347
  return vaStatus;
 
348
}
 
349
 
 
350
 
 
351
/*
 
352
 * After this call, all library internal resources will be cleaned up
 
353
 */ 
 
354
VAStatus vaTerminate (
 
355
    VADisplay dpy
 
356
)
 
357
{
 
358
  VAStatus vaStatus = VA_STATUS_SUCCESS;
 
359
  VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
 
360
  VADriverContextP old_ctx;
 
361
 
 
362
  CHECK_DISPLAY(dpy);
 
363
  old_ctx = CTX(dpy);
 
364
 
 
365
  if (old_ctx->handle)
 
366
  {
 
367
      vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
 
368
      dlclose(old_ctx->handle);
 
369
      old_ctx->handle = NULL;
 
370
  }
 
371
 
 
372
  if (VA_STATUS_SUCCESS == vaStatus)
 
373
      pDisplayContext->vaDestroy(pDisplayContext);
 
374
  return vaStatus;
 
375
}
 
376
 
 
377
/*
 
378
 * vaQueryVendorString returns a pointer to a zero-terminated string
 
379
 * describing some aspects of the VA implemenation on a specific
 
380
 * hardware accelerator. The format of the returned string is:
 
381
 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
 
382
 * e.g. for the Intel GMA500 implementation, an example would be:
 
383
 * "IntelGMA500-1.0-0.2-patch3
 
384
 */
 
385
const char *vaQueryVendorString (
 
386
    VADisplay dpy
 
387
)
 
388
{
 
389
  if( !vaDisplayIsValid(dpy) )
 
390
      return NULL;
 
391
  
 
392
  return CTX(dpy)->str_vendor;
 
393
}
 
394
 
 
395
 
 
396
/* Get maximum number of profiles supported by the implementation */
 
397
int vaMaxNumProfiles (
 
398
    VADisplay dpy
 
399
)
 
400
{
 
401
  if( !vaDisplayIsValid(dpy) )
 
402
      return 0;
 
403
  
 
404
  return CTX(dpy)->max_profiles;
 
405
}
 
406
 
 
407
/* Get maximum number of entrypoints supported by the implementation */
 
408
int vaMaxNumEntrypoints (
 
409
    VADisplay dpy
 
410
)
 
411
{
 
412
  if( !vaDisplayIsValid(dpy) )
 
413
      return 0;
 
414
  
 
415
  return CTX(dpy)->max_entrypoints;
 
416
}
 
417
 
 
418
 
 
419
/* Get maximum number of attributs supported by the implementation */
 
420
int vaMaxNumConfigAttributes (
 
421
    VADisplay dpy
 
422
)
 
423
{
 
424
  if( !vaDisplayIsValid(dpy) )
 
425
      return 0;
 
426
  
 
427
  return CTX(dpy)->max_attributes;
 
428
}
 
429
 
 
430
VAStatus vaQueryConfigEntrypoints (
 
431
    VADisplay dpy,
 
432
    VAProfile profile,
 
433
    VAEntrypoint *entrypoints,  /* out */
 
434
    int *num_entrypoints        /* out */
 
435
)
 
436
{
 
437
  VADriverContextP ctx;
 
438
  CHECK_DISPLAY(dpy);
 
439
  ctx = CTX(dpy);
 
440
 
 
441
  TRACE(vaQueryConfigEntrypoints);
 
442
  return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
 
443
}
 
444
 
 
445
VAStatus vaGetConfigAttributes (
 
446
    VADisplay dpy,
 
447
    VAProfile profile,
 
448
    VAEntrypoint entrypoint,
 
449
    VAConfigAttrib *attrib_list, /* in/out */
 
450
    int num_attribs
 
451
)
 
452
{
 
453
  VADriverContextP ctx;
 
454
  CHECK_DISPLAY(dpy);
 
455
  ctx = CTX(dpy);
 
456
 
 
457
  TRACE(vaGetConfigAttributes);
 
458
  return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
 
459
}
 
460
 
 
461
VAStatus vaQueryConfigProfiles (
 
462
    VADisplay dpy,
 
463
    VAProfile *profile_list,    /* out */
 
464
    int *num_profiles           /* out */
 
465
)
 
466
{
 
467
  VADriverContextP ctx;
 
468
  CHECK_DISPLAY(dpy);
 
469
  ctx = CTX(dpy);
 
470
 
 
471
  TRACE(vaQueryConfigProfiles);
 
472
  return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
 
473
}
 
474
 
 
475
VAStatus vaCreateConfig (
 
476
    VADisplay dpy,
 
477
    VAProfile profile, 
 
478
    VAEntrypoint entrypoint, 
 
479
    VAConfigAttrib *attrib_list,
 
480
    int num_attribs,
 
481
    VAConfigID *config_id /* out */
 
482
)
 
483
{
 
484
  VADriverContextP ctx;
 
485
  CHECK_DISPLAY(dpy);
 
486
  ctx = CTX(dpy);
 
487
 
 
488
  TRACE(vaCreateConfig);
 
489
  return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
 
490
}
 
491
 
 
492
VAStatus vaDestroyConfig (
 
493
    VADisplay dpy,
 
494
    VAConfigID config_id
 
495
)
 
496
{
 
497
  VADriverContextP ctx;
 
498
  CHECK_DISPLAY(dpy);
 
499
  ctx = CTX(dpy);
 
500
 
 
501
  TRACE(vaDestroyConfig);
 
502
  return ctx->vtable.vaDestroyConfig ( ctx, config_id );
 
503
}
 
504
 
 
505
VAStatus vaQueryConfigAttributes (
 
506
    VADisplay dpy,
 
507
    VAConfigID config_id, 
 
508
    VAProfile *profile,         /* out */
 
509
    VAEntrypoint *entrypoint,   /* out */
 
510
    VAConfigAttrib *attrib_list,/* out */
 
511
    int *num_attribs            /* out */
 
512
)
 
513
{
 
514
  VADriverContextP ctx;
 
515
  CHECK_DISPLAY(dpy);
 
516
  ctx = CTX(dpy);
 
517
 
 
518
  TRACE(vaQueryConfigAttributes);
 
519
  return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
 
520
}
 
521
 
 
522
VAStatus vaCreateSurfaces (
 
523
    VADisplay dpy,
 
524
    int width,
 
525
    int height,
 
526
    int format,
 
527
    int num_surfaces,
 
528
    VASurfaceID *surfaces       /* out */
 
529
)
 
530
{
 
531
  VADriverContextP ctx;
 
532
  CHECK_DISPLAY(dpy);
 
533
  ctx = CTX(dpy);
 
534
 
 
535
  TRACE(vaCreateSurfaces);
 
536
  return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
 
537
}
 
538
 
 
539
 
 
540
VAStatus vaCreateSurfaceFromCIFrame (
 
541
    VADisplay dpy,
 
542
    unsigned long frame_id,
 
543
    VASurfaceID *surface        /* out */
 
544
)
 
545
{
 
546
  VADriverContextP ctx;
 
547
  CHECK_DISPLAY(dpy);
 
548
  ctx = CTX(dpy);
 
549
 
 
550
  TRACE(vaCreateSurfacesFromCIFrame);
 
551
  return ctx->vtable.vaCreateSurfaceFromCIFrame( ctx, frame_id, surface );
 
552
}
 
553
 
 
554
VAStatus vaDestroySurfaces (
 
555
    VADisplay dpy,
 
556
    VASurfaceID *surface_list,
 
557
    int num_surfaces
 
558
)
 
559
{
 
560
  VADriverContextP ctx;
 
561
  CHECK_DISPLAY(dpy);
 
562
  ctx = CTX(dpy);
 
563
 
 
564
  TRACE(vaDestroySurfaces);
 
565
  return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
 
566
}
 
567
 
 
568
VAStatus vaCreateContext (
 
569
    VADisplay dpy,
 
570
    VAConfigID config_id,
 
571
    int picture_width,
 
572
    int picture_height,
 
573
    int flag,
 
574
    VASurfaceID *render_targets,
 
575
    int num_render_targets,
 
576
    VAContextID *context                /* out */
 
577
)
 
578
{
 
579
  VADriverContextP ctx;
 
580
  CHECK_DISPLAY(dpy);
 
581
  ctx = CTX(dpy);
 
582
 
 
583
  TRACE(vaCreateContext);
 
584
  return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
 
585
                                      flag, render_targets, num_render_targets, context );
 
586
}
 
587
 
 
588
VAStatus vaDestroyContext (
 
589
    VADisplay dpy,
 
590
    VAContextID context
 
591
)
 
592
{
 
593
  VADriverContextP ctx;
 
594
  CHECK_DISPLAY(dpy);
 
595
  ctx = CTX(dpy);
 
596
 
 
597
  TRACE(vaDestroyContext);
 
598
  return ctx->vtable.vaDestroyContext( ctx, context );
 
599
}
 
600
 
 
601
VAStatus vaCreateBuffer (
 
602
    VADisplay dpy,
 
603
    VAContextID context,        /* in */
 
604
    VABufferType type,          /* in */
 
605
    unsigned int size,          /* in */
 
606
    unsigned int num_elements,  /* in */
 
607
    void *data,                 /* in */
 
608
    VABufferID *buf_id          /* out */
 
609
)
 
610
{
 
611
  VADriverContextP ctx;
 
612
  CHECK_DISPLAY(dpy);
 
613
  ctx = CTX(dpy);
 
614
 
 
615
  TRACE(vaCreateBuffer);
 
616
  return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
 
617
}
 
618
 
 
619
VAStatus vaBufferSetNumElements (
 
620
    VADisplay dpy,
 
621
    VABufferID buf_id,  /* in */
 
622
    unsigned int num_elements /* in */
 
623
)
 
624
{
 
625
  VADriverContextP ctx;
 
626
  CHECK_DISPLAY(dpy);
 
627
  ctx = CTX(dpy);
 
628
 
 
629
  TRACE(vaBufferSetNumElements);
 
630
  return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
 
631
}
 
632
 
 
633
 
 
634
VAStatus vaMapBuffer (
 
635
    VADisplay dpy,
 
636
    VABufferID buf_id,  /* in */
 
637
    void **pbuf         /* out */
 
638
)
 
639
{
 
640
  VADriverContextP ctx;
 
641
  CHECK_DISPLAY(dpy);
 
642
  ctx = CTX(dpy);
 
643
 
 
644
  TRACE(vaMapBuffer);
 
645
  return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
 
646
}
 
647
 
 
648
VAStatus vaUnmapBuffer (
 
649
    VADisplay dpy,
 
650
    VABufferID buf_id   /* in */
 
651
)
 
652
{
 
653
  VADriverContextP ctx;
 
654
  CHECK_DISPLAY(dpy);
 
655
  ctx = CTX(dpy);
 
656
 
 
657
  TRACE(vaUnmapBuffer);
 
658
  return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
 
659
}
 
660
 
 
661
VAStatus vaDestroyBuffer (
 
662
    VADisplay dpy,
 
663
    VABufferID buffer_id
 
664
)
 
665
{
 
666
  VADriverContextP ctx;
 
667
  CHECK_DISPLAY(dpy);
 
668
  ctx = CTX(dpy);
 
669
 
 
670
  TRACE(vaDestroyBuffer);
 
671
  return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
 
672
}
 
673
 
 
674
VAStatus vaBeginPicture (
 
675
    VADisplay dpy,
 
676
    VAContextID context,
 
677
    VASurfaceID render_target
 
678
)
 
679
{
 
680
  VADriverContextP ctx;
 
681
  CHECK_DISPLAY(dpy);
 
682
  ctx = CTX(dpy);
 
683
 
 
684
  TRACE(vaBeginPicture);
 
685
  return ctx->vtable.vaBeginPicture( ctx, context, render_target );
 
686
}
 
687
 
 
688
VAStatus vaRenderPicture (
 
689
    VADisplay dpy,
 
690
    VAContextID context,
 
691
    VABufferID *buffers,
 
692
    int num_buffers
 
693
)
 
694
{
 
695
  VADriverContextP ctx;
 
696
  CHECK_DISPLAY(dpy);
 
697
  ctx = CTX(dpy);
 
698
 
 
699
  TRACE(vaRenderPicture);
 
700
  return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
 
701
}
 
702
 
 
703
VAStatus vaEndPicture (
 
704
    VADisplay dpy,
 
705
    VAContextID context
 
706
)
 
707
{
 
708
  VADriverContextP ctx;
 
709
  CHECK_DISPLAY(dpy);
 
710
  ctx = CTX(dpy);
 
711
 
 
712
  TRACE(vaEndPicture);
 
713
  return ctx->vtable.vaEndPicture( ctx, context );
 
714
}
 
715
 
 
716
VAStatus vaSyncSurface (
 
717
    VADisplay dpy,
 
718
    VAContextID context,
 
719
    VASurfaceID render_target
 
720
)
 
721
{
 
722
  VADriverContextP ctx;
 
723
  CHECK_DISPLAY(dpy);
 
724
  ctx = CTX(dpy);
 
725
 
 
726
  TRACE(vaSyncSurface);
 
727
  return ctx->vtable.vaSyncSurface( ctx, context, render_target );
 
728
}
 
729
 
 
730
VAStatus vaQuerySurfaceStatus (
 
731
    VADisplay dpy,
 
732
    VASurfaceID render_target,
 
733
    VASurfaceStatus *status     /* out */
 
734
)
 
735
{
 
736
  VADriverContextP ctx;
 
737
  CHECK_DISPLAY(dpy);
 
738
  ctx = CTX(dpy);
 
739
 
 
740
  TRACE(vaQuerySurfaceStatus);
 
741
  return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
 
742
}
 
743
 
 
744
VAStatus vaPutSurface (
 
745
    VADisplay dpy,
 
746
    VASurfaceID surface,
 
747
    Drawable draw, /* X Drawable */
 
748
    short srcx,
 
749
    short srcy,
 
750
    unsigned short srcw,
 
751
    unsigned short srch,
 
752
    short destx,
 
753
    short desty,
 
754
    unsigned short destw,
 
755
    unsigned short desth,
 
756
    VARectangle *cliprects, /* client supplied clip list */
 
757
    unsigned int number_cliprects, /* number of clip rects in the clip list */
 
758
    unsigned int flags /* de-interlacing flags */
 
759
)
 
760
{
 
761
  VADriverContextP ctx;
 
762
  CHECK_DISPLAY(dpy);
 
763
  ctx = CTX(dpy);
 
764
 
 
765
  TRACE(vaPutSurface);
 
766
  return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
 
767
                                   destx, desty, destw, desth,
 
768
                                   cliprects, number_cliprects, flags );
 
769
}
 
770
 
 
771
/* Get maximum number of image formats supported by the implementation */
 
772
int vaMaxNumImageFormats (
 
773
    VADisplay dpy
 
774
)
 
775
{
 
776
  if( !vaDisplayIsValid(dpy) )
 
777
      return 0;
 
778
  
 
779
  return CTX(dpy)->max_image_formats;
 
780
}
 
781
 
 
782
VAStatus vaQueryImageFormats (
 
783
    VADisplay dpy,
 
784
    VAImageFormat *format_list, /* out */
 
785
    int *num_formats            /* out */
 
786
)
 
787
{
 
788
  VADriverContextP ctx;
 
789
  CHECK_DISPLAY(dpy);
 
790
  ctx = CTX(dpy);
 
791
 
 
792
  TRACE(vaQueryImageFormats);
 
793
  return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
 
794
}
 
795
 
 
796
/* 
 
797
 * The width and height fields returned in the VAImage structure may get 
 
798
 * enlarged for some YUV formats. The size of the data buffer that needs
 
799
 * to be allocated will be given in the "data_size" field in VAImage.
 
800
 * Image data is not allocated by this function.  The client should
 
801
 * allocate the memory and fill in the VAImage structure's data field
 
802
 * after looking at "data_size" returned from the library.
 
803
 */
 
804
VAStatus vaCreateImage (
 
805
    VADisplay dpy,
 
806
    VAImageFormat *format,
 
807
    int width,
 
808
    int height,
 
809
    VAImage *image      /* out */
 
810
)
 
811
{
 
812
  VADriverContextP ctx;
 
813
  CHECK_DISPLAY(dpy);
 
814
  ctx = CTX(dpy);
 
815
 
 
816
  TRACE(vaCreateImage);
 
817
  return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
 
818
}
 
819
 
 
820
/*
 
821
 * Should call DestroyImage before destroying the surface it is bound to
 
822
 */
 
823
VAStatus vaDestroyImage (
 
824
    VADisplay dpy,
 
825
    VAImageID image
 
826
)
 
827
{
 
828
  VADriverContextP ctx;
 
829
  CHECK_DISPLAY(dpy);
 
830
  ctx = CTX(dpy);
 
831
 
 
832
  TRACE(vaDestroyImage);
 
833
  return ctx->vtable.vaDestroyImage ( ctx, image);
 
834
}
 
835
 
 
836
VAStatus vaSetImagePalette (
 
837
    VADisplay dpy,
 
838
    VAImageID image,
 
839
    unsigned char *palette
 
840
)
 
841
{
 
842
  VADriverContextP ctx;
 
843
  CHECK_DISPLAY(dpy);
 
844
  ctx = CTX(dpy);
 
845
 
 
846
  TRACE(vaSetImagePalette);
 
847
  return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
 
848
}
 
849
 
 
850
/*
 
851
 * Retrieve surface data into a VAImage
 
852
 * Image must be in a format supported by the implementation
 
853
 */
 
854
VAStatus vaGetImage (
 
855
    VADisplay dpy,
 
856
    VASurfaceID surface,
 
857
    int x,      /* coordinates of the upper left source pixel */
 
858
    int y,
 
859
    unsigned int width, /* width and height of the region */
 
860
    unsigned int height,
 
861
    VAImageID image
 
862
)
 
863
{
 
864
  VADriverContextP ctx;
 
865
  CHECK_DISPLAY(dpy);
 
866
  ctx = CTX(dpy);
 
867
 
 
868
  TRACE(vaGetImage);
 
869
  return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
 
870
}
 
871
 
 
872
/*
 
873
 * Copy data from a VAImage to a surface
 
874
 * Image must be in a format supported by the implementation
 
875
 */
 
876
VAStatus vaPutImage (
 
877
    VADisplay dpy,
 
878
    VASurfaceID surface,
 
879
    VAImageID image,
 
880
    int src_x,
 
881
    int src_y,
 
882
    unsigned int width,
 
883
    unsigned int height,
 
884
    int dest_x,
 
885
    int dest_y
 
886
)
 
887
{
 
888
  VADriverContextP ctx;
 
889
  CHECK_DISPLAY(dpy);
 
890
  ctx = CTX(dpy);
 
891
 
 
892
  TRACE(vaPutImage);
 
893
  return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
 
894
}
 
895
 
 
896
/*
 
897
 * Similar to vaPutImage but with additional destination width
 
898
 * and height arguments to enable scaling
 
899
 */
 
900
VAStatus vaPutImage2 (
 
901
    VADisplay dpy,
 
902
    VASurfaceID surface,
 
903
    VAImageID image,
 
904
    int src_x,
 
905
    int src_y,
 
906
    unsigned int src_width,
 
907
    unsigned int src_height,
 
908
    int dest_x,
 
909
    int dest_y,
 
910
    unsigned int dest_width,
 
911
    unsigned int dest_height
 
912
)
 
913
{
 
914
  VADriverContextP ctx;
 
915
  CHECK_DISPLAY(dpy);
 
916
  ctx = CTX(dpy);
 
917
 
 
918
  TRACE(vaPutImage2);
 
919
  return ctx->vtable.vaPutImage2 ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
 
920
}
 
921
 
 
922
/*
 
923
 * Derive an VAImage from an existing surface.
 
924
 * This interface will derive a VAImage and corresponding image buffer from
 
925
 * an existing VA Surface. The image buffer can then be mapped/unmapped for
 
926
 * direct CPU access. This operation is only possible on implementations with
 
927
 * direct rendering capabilities and internal surface formats that can be
 
928
 * represented with a VAImage. When the operation is not possible this interface
 
929
 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
 
930
 * to using vaCreateImage + vaPutImage to accomplish the same task in an
 
931
 * indirect manner.
 
932
 *
 
933
 * Implementations should only return success when the resulting image buffer
 
934
 * would be useable with vaMap/Unmap.
 
935
 *
 
936
 * When directly accessing a surface special care must be taken to insure
 
937
 * proper synchronization with the graphics hardware. Clients should call
 
938
 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
 
939
 * rendering or currently being displayed by an overlay.
 
940
 *
 
941
 * Additionally nothing about the contents of a surface should be assumed
 
942
 * following a vaPutSurface. Implementations are free to modify the surface for
 
943
 * scaling or subpicture blending within a call to vaPutImage.
 
944
 *
 
945
 * Calls to vaPutImage or vaGetImage using the same surface from which the image
 
946
 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
 
947
 * vaGetImage with other surfaces is supported.
 
948
 *
 
949
 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
 
950
 * image and image buffer structures will be destroyed; however, the underlying
 
951
 * surface will remain unchanged until freed with vaDestroySurfaces.
 
952
 */
 
953
VAStatus vaDeriveImage (
 
954
    VADisplay dpy,
 
955
    VASurfaceID surface,
 
956
    VAImage *image      /* out */
 
957
)
 
958
{
 
959
  VADriverContextP ctx;
 
960
  CHECK_DISPLAY(dpy);
 
961
  ctx = CTX(dpy);
 
962
 
 
963
  TRACE(vaDeriveImage);
 
964
  return ctx->vtable.vaDeriveImage ( ctx, surface, image );
 
965
}
 
966
 
 
967
 
 
968
/* Get maximum number of subpicture formats supported by the implementation */
 
969
int vaMaxNumSubpictureFormats (
 
970
    VADisplay dpy
 
971
)
 
972
{
 
973
  if( !vaDisplayIsValid(dpy) )
 
974
      return 0;
 
975
  
 
976
  return CTX(dpy)->max_subpic_formats;
 
977
}
 
978
 
 
979
/* 
 
980
 * Query supported subpicture formats 
 
981
 * The caller must provide a "format_list" array that can hold at
 
982
 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag 
 
983
 * for each format to indicate additional capabilities for that format. The actual 
 
984
 * number of formats returned in "format_list" is returned in "num_formats".
 
985
 */
 
986
VAStatus vaQuerySubpictureFormats (
 
987
    VADisplay dpy,
 
988
    VAImageFormat *format_list, /* out */
 
989
    unsigned int *flags,        /* out */
 
990
    unsigned int *num_formats   /* out */
 
991
)
 
992
{
 
993
  VADriverContextP ctx;
 
994
  CHECK_DISPLAY(dpy);
 
995
  ctx = CTX(dpy);
 
996
 
 
997
  TRACE(vaQuerySubpictureFormats);
 
998
  return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
 
999
}
 
1000
 
 
1001
/* 
 
1002
 * Subpictures are created with an image associated. 
 
1003
 */
 
1004
VAStatus vaCreateSubpicture (
 
1005
    VADisplay dpy,
 
1006
    VAImageID image,
 
1007
    VASubpictureID *subpicture  /* out */
 
1008
)
 
1009
{
 
1010
  VADriverContextP ctx;
 
1011
  CHECK_DISPLAY(dpy);
 
1012
  ctx = CTX(dpy);
 
1013
 
 
1014
  TRACE(vaCreateSubpicture);
 
1015
  return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
 
1016
}
 
1017
 
 
1018
/*
 
1019
 * Destroy the subpicture before destroying the image it is assocated to
 
1020
 */
 
1021
VAStatus vaDestroySubpicture (
 
1022
    VADisplay dpy,
 
1023
    VASubpictureID subpicture
 
1024
)
 
1025
{
 
1026
  VADriverContextP ctx;
 
1027
  CHECK_DISPLAY(dpy);
 
1028
  ctx = CTX(dpy);
 
1029
 
 
1030
  TRACE(vaDestroySubpicture);
 
1031
  return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
 
1032
}
 
1033
 
 
1034
VAStatus vaSetSubpictureImage (
 
1035
    VADisplay dpy,
 
1036
    VASubpictureID subpicture,
 
1037
    VAImageID image
 
1038
)
 
1039
{
 
1040
  VADriverContextP ctx;
 
1041
  CHECK_DISPLAY(dpy);
 
1042
  ctx = CTX(dpy);
 
1043
 
 
1044
  TRACE(vaSetSubpictureImage);
 
1045
  return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
 
1046
}
 
1047
 
 
1048
 
 
1049
/*
 
1050
 * If chromakey is enabled, then the area where the source value falls within
 
1051
 * the chromakey [min, max] range is transparent
 
1052
 */
 
1053
VAStatus vaSetSubpictureChromakey (
 
1054
    VADisplay dpy,
 
1055
    VASubpictureID subpicture,
 
1056
    unsigned int chromakey_min,
 
1057
    unsigned int chromakey_max,
 
1058
    unsigned int chromakey_mask
 
1059
)
 
1060
{
 
1061
  VADriverContextP ctx;
 
1062
  CHECK_DISPLAY(dpy);
 
1063
  ctx = CTX(dpy);
 
1064
 
 
1065
  TRACE(vaSetSubpictureChromakey);
 
1066
  return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
 
1067
}
 
1068
 
 
1069
 
 
1070
/*
 
1071
 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and 
 
1072
 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
 
1073
 * the overall alpha is per-pixel alpha multiplied by the global alpha
 
1074
 */
 
1075
VAStatus vaSetSubpictureGlobalAlpha (
 
1076
    VADisplay dpy,
 
1077
    VASubpictureID subpicture,
 
1078
    float global_alpha 
 
1079
)
 
1080
{
 
1081
  VADriverContextP ctx;
 
1082
  CHECK_DISPLAY(dpy);
 
1083
  ctx = CTX(dpy);
 
1084
 
 
1085
  TRACE(vaSetSubpictureGlobalAlpha);
 
1086
  return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
 
1087
}
 
1088
 
 
1089
/*
 
1090
  vaAssociateSubpicture associates the subpicture with the target_surface.
 
1091
  It defines the region mapping between the subpicture and the target 
 
1092
  surface through source and destination rectangles (with the same width and height).
 
1093
  Both will be displayed at the next call to vaPutSurface.  Additional
 
1094
  associations before the call to vaPutSurface simply overrides the association.
 
1095
*/
 
1096
VAStatus vaAssociateSubpicture (
 
1097
    VADisplay dpy,
 
1098
    VASubpictureID subpicture,
 
1099
    VASurfaceID *target_surfaces,
 
1100
    int num_surfaces,
 
1101
    short src_x, /* upper left offset in subpicture */
 
1102
    short src_y,
 
1103
    short dest_x, /* upper left offset in surface */
 
1104
    short dest_y,
 
1105
    unsigned short width,
 
1106
    unsigned short height,
 
1107
    /*
 
1108
     * whether to enable chroma-keying or global-alpha
 
1109
     * see VA_SUBPICTURE_XXX values
 
1110
     */
 
1111
    unsigned int flags
 
1112
)
 
1113
{
 
1114
  VADriverContextP ctx;
 
1115
  CHECK_DISPLAY(dpy);
 
1116
  ctx = CTX(dpy);
 
1117
 
 
1118
  TRACE(vaAssociateSubpicture);
 
1119
  return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
 
1120
}
 
1121
 
 
1122
VAStatus vaAssociateSubpicture2 (
 
1123
    VADisplay dpy,
 
1124
    VASubpictureID subpicture,
 
1125
    VASurfaceID *target_surfaces,
 
1126
    int num_surfaces,
 
1127
    short src_x, /* upper left offset in subpicture */
 
1128
    short src_y,
 
1129
    unsigned short src_width,
 
1130
    unsigned short src_height,
 
1131
    short dest_x, /* upper left offset in surface */
 
1132
    short dest_y,
 
1133
    unsigned short dest_width,
 
1134
    unsigned short dest_height,
 
1135
    /*
 
1136
     * whether to enable chroma-keying or global-alpha
 
1137
     * see VA_SUBPICTURE_XXX values
 
1138
     */
 
1139
    unsigned int flags
 
1140
)
 
1141
{
 
1142
  VADriverContextP ctx;
 
1143
  CHECK_DISPLAY(dpy);
 
1144
  ctx = CTX(dpy);
 
1145
 
 
1146
  TRACE(vaAssociateSubpicture2);
 
1147
  return ctx->vtable.vaAssociateSubpicture2 ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags );
 
1148
}
 
1149
 
 
1150
/*
 
1151
 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
 
1152
 */
 
1153
VAStatus vaDeassociateSubpicture (
 
1154
    VADisplay dpy,
 
1155
    VASubpictureID subpicture,
 
1156
    VASurfaceID *target_surfaces,
 
1157
    int num_surfaces
 
1158
)
 
1159
{
 
1160
  VADriverContextP ctx;
 
1161
  CHECK_DISPLAY(dpy);
 
1162
  ctx = CTX(dpy);
 
1163
 
 
1164
  TRACE(vaDeassociateSubpicture);
 
1165
  return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
 
1166
}
 
1167
 
 
1168
 
 
1169
/* Get maximum number of display attributes supported by the implementation */
 
1170
int vaMaxNumDisplayAttributes (
 
1171
    VADisplay dpy
 
1172
)
 
1173
{
 
1174
  if( !vaDisplayIsValid(dpy) )
 
1175
      return 0;
 
1176
  
 
1177
  return CTX(dpy)->max_display_attributes;
 
1178
}
 
1179
 
 
1180
/* 
 
1181
 * Query display attributes 
 
1182
 * The caller must provide a "attr_list" array that can hold at
 
1183
 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
 
1184
 * returned in "attr_list" is returned in "num_attributes".
 
1185
 */
 
1186
VAStatus vaQueryDisplayAttributes (
 
1187
    VADisplay dpy,
 
1188
    VADisplayAttribute *attr_list,      /* out */
 
1189
    int *num_attributes                 /* out */
 
1190
)
 
1191
{
 
1192
  VADriverContextP ctx;
 
1193
  CHECK_DISPLAY(dpy);
 
1194
  ctx = CTX(dpy);
 
1195
 
 
1196
  TRACE(vaQueryDisplayAttributes);
 
1197
  return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
 
1198
}
 
1199
 
 
1200
/* 
 
1201
 * Get display attributes 
 
1202
 * This function returns the current attribute values in "attr_list".
 
1203
 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
 
1204
 * from vaQueryDisplayAttributes() can have their values retrieved.  
 
1205
 */
 
1206
VAStatus vaGetDisplayAttributes (
 
1207
    VADisplay dpy,
 
1208
    VADisplayAttribute *attr_list,      /* in/out */
 
1209
    int num_attributes
 
1210
)
 
1211
{
 
1212
  VADriverContextP ctx;
 
1213
  CHECK_DISPLAY(dpy);
 
1214
  ctx = CTX(dpy);
 
1215
 
 
1216
  TRACE(vaGetDisplayAttributes);
 
1217
  return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
 
1218
}
 
1219
 
 
1220
/* 
 
1221
 * Set display attributes 
 
1222
 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
 
1223
 * from vaQueryDisplayAttributes() can be set.  If the attribute is not settable or 
 
1224
 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
 
1225
 */
 
1226
VAStatus vaSetDisplayAttributes (
 
1227
    VADisplay dpy,
 
1228
    VADisplayAttribute *attr_list,
 
1229
    int num_attributes
 
1230
)
 
1231
{
 
1232
  VADriverContextP ctx;
 
1233
  CHECK_DISPLAY(dpy);
 
1234
  ctx = CTX(dpy);
 
1235
 
 
1236
  TRACE(vaSetDisplayAttributes);
 
1237
  return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
 
1238
}
 
1239
 
 
1240
 
 
1241
#warning TODO: Remove vaDbgCopySurfaceToBuffer in rev 0.29
 
1242
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
 
1243
    VASurfaceID surface,
 
1244
    void **buffer, /* out */
 
1245
    unsigned int *stride /* out */
 
1246
)
 
1247
{
 
1248
  VADriverContextP ctx;
 
1249
  CHECK_DISPLAY(dpy);
 
1250
  ctx = CTX(dpy);
 
1251
 
 
1252
  TRACE(vaDbgCopySurfaceToBuffer);
 
1253
  return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );
 
1254
}
 
1255
 
 
1256
#warning TODO: Remove vaDbgCreateSurfaceFromMrstV4L2Buf in rev 0.29
 
1257
VAStatus vaDbgCreateSurfaceFromMrstV4L2Buf(
 
1258
    VADisplay dpy,
 
1259
    unsigned int width,
 
1260
    unsigned int height,
 
1261
    unsigned int size,
 
1262
    unsigned int fourcc,
 
1263
    unsigned int luma_stride,
 
1264
    unsigned int chroma_u_stride,
 
1265
    unsigned int chroma_v_stride,
 
1266
    unsigned int luma_offset,
 
1267
    unsigned int chroma_u_offset,
 
1268
    unsigned int chroma_v_offset,
 
1269
    VASurfaceID *surface        /* out */
 
1270
)
 
1271
{
 
1272
  VADriverContextP ctx;
 
1273
  CHECK_DISPLAY(dpy);
 
1274
  ctx = CTX(dpy);
 
1275
 
 
1276
  TRACE(vtable.vaDbgCreateSurfaceFromMrstV4L2Buf);
 
1277
  return ctx->vtable.vaDbgCreateSurfaceFromMrstV4L2Buf( ctx, width, height, size, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, surface );
 
1278
}
 
1279