1 /*
2  *  vdpau_driver_template.h - VDPAU driver initialization template
3  *
4  *  libva-vdpau-driver (C) 2009-2011 Splitted-Desktop Systems
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19  */
20 
21 #undef  CONCAT_
22 #define CONCAT_(x, y)   x##y
23 #undef  CONCAT
24 #define CONCAT(x, y)    CONCAT_(x, y)
25 #undef  FUNC
26 #define FUNC(name)      CONCAT(CONCAT(CONCAT(vdpau_,name),_),VA_INIT_SUFFIX)
27 
28 #undef  VA_INIT_CHECK_VERSION
29 #define VA_INIT_CHECK_VERSION(major, minor, micro)      \
30     (VA_INIT_VERSION_MAJOR > (major) ||                 \
31      (VA_INIT_VERSION_MAJOR == (major) &&               \
32       VA_INIT_VERSION_MINOR > (minor)) ||               \
33      (VA_INIT_VERSION_MAJOR == (major) &&               \
34       VA_INIT_VERSION_MINOR == (minor) &&               \
35       VA_INIT_VERSION_MICRO >= (micro)))
36 
37 #undef  VA_INIT_CHECK_VERSION_SDS
38 #define VA_INIT_CHECK_VERSION_SDS(major, minor, micro, sds)             \
39     (VA_INIT_CHECK_VERSION(major, minor, (micro)+1) ||                  \
40      (VA_INIT_CHECK_VERSION(major, minor, micro) &&                     \
41       VA_INIT_VERSION_SDS >= (sds)))
42 
43 #ifndef VA_INIT_SUFFIX
44 #define VA_INIT_SUFFIX  Current
45 #define VA_INIT_CURRENT 1
46 #else
47 #define VA_INIT_CURRENT 0
48 #endif
49 
50 #ifndef VA_INIT_VERSION_SDS
51 #define VA_INIT_VERSION_SDS 0
52 #endif
53 
54 #ifndef VA_INIT_GLX
55 #define VA_INIT_GLX     0
56 #endif
57 
58 #if VA_INIT_CURRENT
59 #define VA_DRIVER_VTABLE        VADriverVTable
60 #define VA_DRIVER_CONTEXT       VADriverContext
61 #define VA_DRIVER_CONTEXT_P     VADriverContextP
62 #else
63 #define VA_DRIVER_VTABLE        CONCAT(VADriverVTable_,VA_INIT_SUFFIX)
64 #define VA_DRIVER_VTABLE_GLX_P  CONCAT(VADriverVTableGLX_,VA_INIT_SUFFIX)
65 #define VA_DRIVER_CONTEXT       CONCAT(VADriverContext_,VA_INIT_SUFFIX)
66 #define VA_DRIVER_CONTEXT_P     CONCAT(VADriverContextP_,VA_INIT_SUFFIX)
67 
68 typedef struct VA_DRIVER_CONTEXT *VA_DRIVER_CONTEXT_P;
69 
70 /* Driver VTable */
71 struct VA_DRIVER_VTABLE {
72 	VAStatus (*vaTerminate) ( VA_DRIVER_CONTEXT_P ctx );
73 
74 	VAStatus (*vaQueryConfigProfiles) (
75 		VADriverContextP ctx,
76 		VAProfile *profile_list,	/* out */
77 		int *num_profiles			/* out */
78 	);
79 
80 	VAStatus (*vaQueryConfigEntrypoints) (
81 		VADriverContextP ctx,
82 		VAProfile profile,
83 		VAEntrypoint  *entrypoint_list,	/* out */
84 		int *num_entrypoints			/* out */
85 	);
86 
87 	VAStatus (*vaGetConfigAttributes) (
88 		VADriverContextP ctx,
89 		VAProfile profile,
90 		VAEntrypoint entrypoint,
91 		VAConfigAttrib *attrib_list,	/* in/out */
92 		int num_attribs
93 	);
94 
95 	VAStatus (*vaCreateConfig) (
96 		VADriverContextP ctx,
97 		VAProfile profile,
98 		VAEntrypoint entrypoint,
99 		VAConfigAttrib *attrib_list,
100 		int num_attribs,
101 		VAConfigID *config_id		/* out */
102 	);
103 
104 	VAStatus (*vaDestroyConfig) (
105 		VADriverContextP ctx,
106 		VAConfigID config_id
107 	);
108 
109 	VAStatus (*vaQueryConfigAttributes) (
110 		VADriverContextP ctx,
111 		VAConfigID config_id,
112 		VAProfile *profile,		/* out */
113 		VAEntrypoint *entrypoint, 	/* out */
114 		VAConfigAttrib *attrib_list,	/* out */
115 		int *num_attribs		/* out */
116 	);
117 
118 	VAStatus (*vaCreateSurfaces) (
119 		VADriverContextP ctx,
120 		int width,
121 		int height,
122 		int format,
123 		int num_surfaces,
124 		VASurfaceID *surfaces		/* out */
125 	);
126 
127 	VAStatus (*vaDestroySurfaces) (
128 		VADriverContextP ctx,
129 		VASurfaceID *surface_list,
130 		int num_surfaces
131 	);
132 
133 	VAStatus (*vaCreateContext) (
134 		VADriverContextP ctx,
135 		VAConfigID config_id,
136 		int picture_width,
137 		int picture_height,
138 		int flag,
139 		VASurfaceID *render_targets,
140 		int num_render_targets,
141 		VAContextID *context		/* out */
142 	);
143 
144 	VAStatus (*vaDestroyContext) (
145 		VADriverContextP ctx,
146 		VAContextID context
147 	);
148 
149 	VAStatus (*vaCreateBuffer) (
150 		VADriverContextP ctx,
151 		VAContextID context,		/* in */
152 		VABufferType type,		/* in */
153 		unsigned int size,		/* in */
154 		unsigned int num_elements,	/* in */
155 		void *data,			/* in */
156 		VABufferID *buf_id		/* out */
157 	);
158 
159 	VAStatus (*vaBufferSetNumElements) (
160 		VADriverContextP ctx,
161 		VABufferID buf_id,	/* in */
162 		unsigned int num_elements	/* in */
163 	);
164 
165 	VAStatus (*vaMapBuffer) (
166 		VADriverContextP ctx,
167 		VABufferID buf_id,	/* in */
168 		void **pbuf         /* out */
169 	);
170 
171 	VAStatus (*vaUnmapBuffer) (
172 		VADriverContextP ctx,
173 		VABufferID buf_id	/* in */
174 	);
175 
176 	VAStatus (*vaDestroyBuffer) (
177 		VADriverContextP ctx,
178 		VABufferID buffer_id
179 	);
180 
181 	VAStatus (*vaBeginPicture) (
182 		VADriverContextP ctx,
183 		VAContextID context,
184 		VASurfaceID render_target
185 	);
186 
187 	VAStatus (*vaRenderPicture) (
188 		VADriverContextP ctx,
189 		VAContextID context,
190 		VABufferID *buffers,
191 		int num_buffers
192 	);
193 
194 	VAStatus (*vaEndPicture) (
195 		VADriverContextP ctx,
196 		VAContextID context
197 	);
198 
199 	VAStatus (*vaSyncSurface) (
200 		VADriverContextP ctx,
201 		VASurfaceID render_target
202 	);
203 
204 	VAStatus (*vaQuerySurfaceStatus) (
205 		VADriverContextP ctx,
206 		VASurfaceID render_target,
207 		VASurfaceStatus *status	/* out */
208 	);
209 
210 #if VA_INIT_CHECK_VERSION(0,31,2)
211         VAStatus (*vaQuerySurfaceError) (
212                 VADriverContextP ctx,
213                 VASurfaceID render_target,
214                 VAStatus error_status,
215                 void **error_info /*out*/
216         );
217 #endif
218 
219 	VAStatus (*vaPutSurface) (
220     		VADriverContextP ctx,
221 		VASurfaceID surface,
222 		VADrawable draw, /* X Drawable */
223 		short srcx,
224 		short srcy,
225 		unsigned short srcw,
226 		unsigned short srch,
227 		short destx,
228 		short desty,
229 		unsigned short destw,
230 		unsigned short desth,
231 		VARectangle *cliprects, /* client supplied clip list */
232 		unsigned int number_cliprects, /* number of clip rects in the clip list */
233 		unsigned int flags /* de-interlacing flags */
234 	);
235 
236 	VAStatus (*vaQueryImageFormats) (
237 		VADriverContextP ctx,
238 		VAImageFormat *format_list,        /* out */
239 		int *num_formats           /* out */
240 	);
241 
242 	VAStatus (*vaCreateImage) (
243 		VADriverContextP ctx,
244 		VAImageFormat *format,
245 		int width,
246 		int height,
247 		VAImage *image     /* out */
248 	);
249 
250 	VAStatus (*vaDeriveImage) (
251 		VADriverContextP ctx,
252 		VASurfaceID surface,
253 		VAImage *image     /* out */
254 	);
255 
256 	VAStatus (*vaDestroyImage) (
257 		VADriverContextP ctx,
258 		VAImageID image
259 	);
260 
261 	VAStatus (*vaSetImagePalette) (
262 	        VADriverContextP ctx,
263 	        VAImageID image,
264 	        /*
265                  * pointer to an array holding the palette data.  The size of the array is
266                  * num_palette_entries * entry_bytes in size.  The order of the components
267                  * in the palette is described by the component_order in VAImage struct
268                  */
269                 unsigned char *palette
270 	);
271 
272 	VAStatus (*vaGetImage) (
273 		VADriverContextP ctx,
274 		VASurfaceID surface,
275 		int x,     /* coordinates of the upper left source pixel */
276 		int y,
277 		unsigned int width, /* width and height of the region */
278 		unsigned int height,
279 		VAImageID image
280 	);
281 
282 	VAStatus (*vaPutImage) (
283 		VADriverContextP ctx,
284 		VASurfaceID surface,
285 		VAImageID image,
286 		int src_x,
287 		int src_y,
288 		unsigned int src_width,
289 		unsigned int src_height,
290 		int dest_x,
291 		int dest_y,
292 		unsigned int dest_width,
293 		unsigned int dest_height
294 	);
295 
296 	VAStatus (*vaQuerySubpictureFormats) (
297 		VADriverContextP ctx,
298 		VAImageFormat *format_list,        /* out */
299 		unsigned int *flags,       /* out */
300 		unsigned int *num_formats  /* out */
301 	);
302 
303 	VAStatus (*vaCreateSubpicture) (
304 		VADriverContextP ctx,
305 		VAImageID image,
306 		VASubpictureID *subpicture   /* out */
307 	);
308 
309 	VAStatus (*vaDestroySubpicture) (
310 		VADriverContextP ctx,
311 		VASubpictureID subpicture
312 	);
313 
314         VAStatus (*vaSetSubpictureImage) (
315                 VADriverContextP ctx,
316                 VASubpictureID subpicture,
317                 VAImageID image
318         );
319 
320 	VAStatus (*vaSetSubpictureChromakey) (
321 		VADriverContextP ctx,
322 		VASubpictureID subpicture,
323 		unsigned int chromakey_min,
324 		unsigned int chromakey_max,
325 		unsigned int chromakey_mask
326 	);
327 
328 	VAStatus (*vaSetSubpictureGlobalAlpha) (
329 		VADriverContextP ctx,
330 		VASubpictureID subpicture,
331 		float global_alpha
332 	);
333 
334 	VAStatus (*vaAssociateSubpicture) (
335 		VADriverContextP ctx,
336 		VASubpictureID subpicture,
337 		VASurfaceID *target_surfaces,
338 		int num_surfaces,
339 		short src_x, /* upper left offset in subpicture */
340 		short src_y,
341 		unsigned short src_width,
342 		unsigned short src_height,
343 		short dest_x, /* upper left offset in surface */
344 		short dest_y,
345 		unsigned short dest_width,
346 		unsigned short dest_height,
347 		/*
348 		 * whether to enable chroma-keying or global-alpha
349 		 * see VA_SUBPICTURE_XXX values
350 		 */
351 		unsigned int flags
352 	);
353 
354 	VAStatus (*vaDeassociateSubpicture) (
355 		VADriverContextP ctx,
356 		VASubpictureID subpicture,
357 		VASurfaceID *target_surfaces,
358 		int num_surfaces
359 	);
360 
361 	VAStatus (*vaQueryDisplayAttributes) (
362 		VADriverContextP ctx,
363 		VADisplayAttribute *attr_list,	/* out */
364 		int *num_attributes		/* out */
365         );
366 
367 	VAStatus (*vaGetDisplayAttributes) (
368 		VADriverContextP ctx,
369 		VADisplayAttribute *attr_list,	/* in/out */
370 		int num_attributes
371         );
372 
373         VAStatus (*vaSetDisplayAttributes) (
374 		VADriverContextP ctx,
375                 VADisplayAttribute *attr_list,
376                 int num_attributes
377         );
378 
379 #if VA_INIT_CHECK_VERSION(0,31,1)
380         /* used by va trace */
381         VAStatus (*vaBufferInfo) (
382                 VADriverContextP ctx,
383                 VAContextID context, /* in */
384                 VABufferID buf_id, /* in */
385                 VABufferType *type,    /* out */
386                 unsigned int *size,    /* out */
387                 unsigned int *num_elements /* out */
388         );
389 
390         /* lock/unlock surface for external access */
391         VAStatus (*vaLockSurface) (
392 		VADriverContextP ctx,
393                 VASurfaceID surface,
394                 unsigned int *fourcc, /* out  for follow argument */
395                 unsigned int *luma_stride,
396                 unsigned int *chroma_u_stride,
397                 unsigned int *chroma_v_stride,
398                 unsigned int *luma_offset,
399                 unsigned int *chroma_u_offset,
400                 unsigned int *chroma_v_offset,
401                 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
402                                             * surface buffer name
403                                             */
404                 void **buffer /* if it is not NULL, map the surface buffer for
405                                 * CPU access
406                                 */
407         );
408 
409         VAStatus (*vaUnlockSurface) (
410 		VADriverContextP ctx,
411                 VASurfaceID surface
412         );
413 
414 #if !VA_INIT_CHECK_VERSION(0,32,0)
415         /* Optional: GLX support hooks */
416         struct VADriverVTableGLX *glx;
417 #endif
418 #else
419         /* device specific */
420 	VAStatus (*vaCreateSurfaceFromCIFrame) (
421 		VADriverContextP ctx,
422 		unsigned long frame_id,
423 		VASurfaceID *surface		/* out */
424 	);
425 
426 
427         VAStatus (*vaCreateSurfaceFromV4L2Buf) (
428 		VADriverContextP ctx,
429                 int v4l2_fd,         /* file descriptor of V4L2 device */
430                 struct v4l2_format *v4l2_fmt,       /* format of V4L2 */
431                 struct v4l2_buffer *v4l2_buf,       /* V4L2 buffer */
432                 VASurfaceID *surface	           /* out */
433         );
434 
435         VAStatus (*vaCopySurfaceToBuffer) (
436 		VADriverContextP ctx,
437                 VASurfaceID surface,
438                 unsigned int *fourcc, /* out  for follow argument */
439                 unsigned int *luma_stride,
440                 unsigned int *chroma_u_stride,
441                 unsigned int *chroma_v_stride,
442                 unsigned int *luma_offset,
443                 unsigned int *chroma_u_offset,
444                 unsigned int *chroma_v_offset,
445                 void **buffer
446         );
447 #endif
448 };
449 
450 /* Driver context */
451 struct VA_DRIVER_CONTEXT {
452     void *pDriverData;
453 #if VA_INIT_CHECK_VERSION(0,32,0)
454     struct VA_DRIVER_VTABLE *vtable;
455     struct VADriverVTableGLX *vtable_glx;
456     struct VADriverVTableEGL *vtable_egl;
457 #else
458     struct VA_DRIVER_VTABLE vtable;
459 #endif
460 #if VA_INIT_CHECK_VERSION(0,31,1)
461     void *vtable_tpi; /* the structure is malloc-ed */
462 #endif
463 
464     Display *native_dpy;
465     int x11_screen;
466     int version_major;
467     int version_minor;
468     int max_profiles;
469     int max_entrypoints;
470     int max_attributes;
471     int max_image_formats;
472     int max_subpic_formats;
473     int max_display_attributes;
474     const char *str_vendor;
475 
476     void *handle;			/* dlopen handle */
477 
478     void *dri_state;
479 #if VA_INIT_CHECK_VERSION(0,31,1)
480     void *glx;                         /* opaque for GLX code */
481 #endif
482 };
483 #endif
484 
485 // Check for VA/GLX changes from libVA API >= 0.31.0-sds2
486 #if VA_INIT_GLX
487 #if VA_INIT_CHECK_VERSION_SDS(0,31,0,2)
488 typedef struct VADriverVTableGLX *VA_DRIVER_VTABLE_GLX_P;
489 #else
490 typedef struct VA_DRIVER_VTABLE  *VA_DRIVER_VTABLE_GLX_P;
491 #endif
492 
FUNC(GetVTableGLX)493 static inline VA_DRIVER_VTABLE_GLX_P FUNC(GetVTableGLX)(VA_DRIVER_CONTEXT_P ctx)
494 {
495 #if VA_INIT_CHECK_VERSION_SDS(0,31,0,6)
496 #if VA_INIT_CHECK_VERSION(0,32,0)
497     /* Upstream VA-API 0.32 */
498     VA_DRIVER_VTABLE_GLX_P *p_vtable_glx = &ctx->vtable_glx;
499 #else
500     /* Upstream VA-API 0.31.1 or SDS >= 0.31.0-sds6 */
501     VA_DRIVER_VTABLE_GLX_P *p_vtable_glx = &ctx->vtable.glx;
502 #endif
503     VA_DRIVER_VTABLE_GLX_P vtable_glx = *p_vtable_glx;
504 
505     if (!vtable_glx) {
506         vtable_glx = calloc(1, sizeof(*vtable_glx));
507         if (!vtable_glx)
508             return NULL;
509         *p_vtable_glx = vtable_glx;
510     }
511     return vtable_glx;
512 #elif VA_INIT_CHECK_VERSION_SDS(0,31,0,2)
513     /* SDS >= 0.31.0-sds2 */
514     return &ctx->vtable.glx;
515 #else
516     /* Any other VA-API version 0.31.0 or lower */
517     return &ctx->vtable;
518 #endif
519 }
520 
FUNC(ReleaseVTableGLX)521 static inline void FUNC(ReleaseVTableGLX)(VA_DRIVER_CONTEXT_P ctx)
522 {
523 #if VA_INIT_CHECK_VERSION(0,32,0)
524     free(ctx->vtable_glx);
525     ctx->vtable_glx = NULL;
526 #elif VA_INIT_CHECK_VERSION_SDS(0,31,0,6)
527     free(ctx->vtable.glx);
528     ctx->vtable.glx = NULL;
529 #endif
530 }
531 #endif
532 
FUNC(Terminate)533 static VAStatus FUNC(Terminate)(VA_DRIVER_CONTEXT_P ctx)
534 {
535     VDPAU_DRIVER_DATA_INIT;
536 
537     vdpau_common_Terminate(driver_data);
538 
539 #if VA_INIT_GLX
540     FUNC(ReleaseVTableGLX)(ctx);
541 #endif
542 
543     free(ctx->pDriverData);
544     ctx->pDriverData = NULL;
545 
546     return VA_STATUS_SUCCESS;
547 }
548 
FUNC(Initialize)549 static VAStatus FUNC(Initialize)(VA_DRIVER_CONTEXT_P ctx)
550 {
551     struct vdpau_driver_data *driver_data;
552 
553     driver_data = calloc(1, sizeof(*driver_data));
554     if (!driver_data)
555         return VA_STATUS_ERROR_ALLOCATION_FAILED;
556 
557     ctx->pDriverData            = driver_data;
558     driver_data->x11_dpy        = ctx->native_dpy;
559     driver_data->x11_screen     = ctx->x11_screen;
560 
561     VAStatus va_status = vdpau_common_Initialize(driver_data);
562     if (va_status != VA_STATUS_SUCCESS) {
563         FUNC(Terminate)(ctx);
564         return va_status;
565     }
566 
567     ctx->version_major          = VA_INIT_VERSION_MAJOR;
568     ctx->version_minor          = VA_INIT_VERSION_MINOR;
569     ctx->max_profiles           = VDPAU_MAX_PROFILES;
570     ctx->max_entrypoints        = VDPAU_MAX_ENTRYPOINTS;
571     ctx->max_attributes         = VDPAU_MAX_CONFIG_ATTRIBUTES;
572     ctx->max_image_formats      = VDPAU_MAX_IMAGE_FORMATS;
573     ctx->max_subpic_formats     = VDPAU_MAX_SUBPICTURE_FORMATS;
574     ctx->max_display_attributes = VDPAU_MAX_DISPLAY_ATTRIBUTES;
575     ctx->str_vendor             = driver_data->va_vendor;
576 
577     struct VA_DRIVER_VTABLE *vtable;
578 #if VA_INIT_CHECK_VERSION(0,32,0)
579     vtable = ctx->vtable;
580 #else
581     vtable = &ctx->vtable;
582 #endif
583     memset(vtable, 0, sizeof(*vtable));
584     vtable->vaTerminate                     = FUNC(Terminate);
585     vtable->vaQueryConfigEntrypoints        = vdpau_QueryConfigEntrypoints;
586     vtable->vaQueryConfigProfiles           = vdpau_QueryConfigProfiles;
587     vtable->vaQueryConfigEntrypoints        = vdpau_QueryConfigEntrypoints;
588     vtable->vaQueryConfigAttributes         = vdpau_QueryConfigAttributes;
589     vtable->vaCreateConfig                  = vdpau_CreateConfig;
590     vtable->vaDestroyConfig                 = vdpau_DestroyConfig;
591     vtable->vaGetConfigAttributes           = vdpau_GetConfigAttributes;
592     vtable->vaCreateSurfaces                = vdpau_CreateSurfaces;
593     vtable->vaDestroySurfaces               = vdpau_DestroySurfaces;
594     vtable->vaCreateContext                 = vdpau_CreateContext;
595     vtable->vaDestroyContext                = vdpau_DestroyContext;
596     vtable->vaCreateBuffer                  = vdpau_CreateBuffer;
597     vtable->vaBufferSetNumElements          = vdpau_BufferSetNumElements;
598     vtable->vaMapBuffer                     = vdpau_MapBuffer;
599     vtable->vaUnmapBuffer                   = vdpau_UnmapBuffer;
600     vtable->vaDestroyBuffer                 = vdpau_DestroyBuffer;
601     vtable->vaBeginPicture                  = vdpau_BeginPicture;
602     vtable->vaRenderPicture                 = vdpau_RenderPicture;
603     vtable->vaEndPicture                    = vdpau_EndPicture;
604 #if VA_INIT_CHECK_VERSION(0,31,0)
605     vtable->vaSyncSurface                   = vdpau_SyncSurface2;
606 #else
607     vtable->vaSyncSurface                   = vdpau_SyncSurface3;
608 #endif
609     vtable->vaQuerySurfaceStatus            = vdpau_QuerySurfaceStatus;
610     vtable->vaPutSurface                    = vdpau_PutSurface;
611     vtable->vaQueryImageFormats             = vdpau_QueryImageFormats;
612     vtable->vaCreateImage                   = vdpau_CreateImage;
613     vtable->vaDeriveImage                   = vdpau_DeriveImage;
614     vtable->vaDestroyImage                  = vdpau_DestroyImage;
615     vtable->vaSetImagePalette               = vdpau_SetImagePalette;
616     vtable->vaGetImage                      = vdpau_GetImage;
617 #if VA_INIT_CHECK_VERSION(0,31,0)
618     vtable->vaPutImage                      = vdpau_PutImage_full;
619 #else
620     vtable->vaPutImage                      = vdpau_PutImage;
621     vtable->vaPutImage2                     = vdpau_PutImage_full;
622 #endif
623     vtable->vaQuerySubpictureFormats        = vdpau_QuerySubpictureFormats;
624     vtable->vaCreateSubpicture              = vdpau_CreateSubpicture;
625     vtable->vaDestroySubpicture             = vdpau_DestroySubpicture;
626     vtable->vaSetSubpictureImage            = vdpau_SetSubpictureImage;
627     vtable->vaSetSubpictureChromakey        = vdpau_SetSubpictureChromakey;
628     vtable->vaSetSubpictureGlobalAlpha      = vdpau_SetSubpictureGlobalAlpha;
629 #if VA_INIT_CHECK_VERSION(0,31,0)
630     vtable->vaAssociateSubpicture           = vdpau_AssociateSubpicture_full;
631 #else
632     vtable->vaAssociateSubpicture           = vdpau_AssociateSubpicture;
633     vtable->vaAssociateSubpicture2          = vdpau_AssociateSubpicture_full;
634 #endif
635     vtable->vaDeassociateSubpicture         = vdpau_DeassociateSubpicture;
636     vtable->vaQueryDisplayAttributes        = vdpau_QueryDisplayAttributes;
637     vtable->vaGetDisplayAttributes          = vdpau_GetDisplayAttributes;
638     vtable->vaSetDisplayAttributes          = vdpau_SetDisplayAttributes;
639 #if VA_INIT_CHECK_VERSION(0,31,1)
640 #if VA_INIT_CHECK_VERSION(0,32,0)
641     vtable->vaBufferInfo                    = vdpau_BufferInfo;
642 #else
643     vtable->vaBufferInfo                    = vdpau_BufferInfo_0_31_1;
644 #endif
645     vtable->vaLockSurface                   = vdpau_LockSurface;
646     vtable->vaUnlockSurface                 = vdpau_UnlockSurface;
647 #else
648 #if VA_INIT_CHECK_VERSION(0,30,0)
649     vtable->vaCreateSurfaceFromCIFrame      = vdpau_CreateSurfaceFromCIFrame;
650     vtable->vaCreateSurfaceFromV4L2Buf      = vdpau_CreateSurfaceFromV4L2Buf;
651     vtable->vaCopySurfaceToBuffer           = vdpau_CopySurfaceToBuffer;
652 #else
653     vtable->vaSetSubpicturePalette          = vdpau_SetSubpicturePalette;
654     vtable->vaDbgCopySurfaceToBuffer        = vdpau_DbgCopySurfaceToBuffer;
655 #endif
656 #endif
657 
658 #if VA_INIT_GLX
659     VA_DRIVER_VTABLE_GLX_P const glx_vtable = FUNC(GetVTableGLX)(ctx);
660     if (!glx_vtable)
661         return VA_STATUS_ERROR_ALLOCATION_FAILED;
662     glx_vtable->vaCreateSurfaceGLX          = vdpau_CreateSurfaceGLX;
663     glx_vtable->vaDestroySurfaceGLX         = vdpau_DestroySurfaceGLX;
664     glx_vtable->vaCopySurfaceGLX            = vdpau_CopySurfaceGLX;
665 #endif
666     return VA_STATUS_SUCCESS;
667 }
668 
669 #undef VA_INIT_CURRENT
670 #undef VA_INIT_VERSION_MAJOR
671 #undef VA_INIT_VERSION_MINOR
672 #undef VA_INIT_VERSION_MICRO
673 #undef VA_INIT_VERSION_SDS
674 #undef VA_INIT_SUFFIX
675 #undef VA_INIT_GLX
676 
677 #undef VA_DRIVER_VTABLE
678 #undef VA_DRIVER_VTABLE_GLX_P
679 #undef VA_DRIVER_CONTEXT
680 #undef VA_DRIVER_CONTEXT_P
681