2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
26 * Video Decode Acceleration -Backend API
29 #ifndef _VA_BACKEND_H_
30 #define _VA_BACKEND_H_
34 #include <linux/videodev2.h>
36 typedef struct VADriverContext *VADriverContextP;
37 typedef struct VADisplayContext *VADisplayContextP;
41 VAStatus (*vaTerminate) ( VADriverContextP ctx );
43 VAStatus (*vaQueryConfigProfiles) (
45 VAProfile *profile_list, /* out */
46 int *num_profiles /* out */
49 VAStatus (*vaQueryConfigEntrypoints) (
52 VAEntrypoint *entrypoint_list, /* out */
53 int *num_entrypoints /* out */
56 VAStatus (*vaGetConfigAttributes) (
59 VAEntrypoint entrypoint,
60 VAConfigAttrib *attrib_list, /* in/out */
64 VAStatus (*vaCreateConfig) (
67 VAEntrypoint entrypoint,
68 VAConfigAttrib *attrib_list,
70 VAConfigID *config_id /* out */
73 VAStatus (*vaDestroyConfig) (
78 VAStatus (*vaQueryConfigAttributes) (
81 VAProfile *profile, /* out */
82 VAEntrypoint *entrypoint, /* out */
83 VAConfigAttrib *attrib_list, /* out */
84 int *num_attribs /* out */
87 VAStatus (*vaCreateSurfaces) (
93 VASurfaceID *surfaces /* out */
96 VAStatus (*vaDestroySurfaces) (
98 VASurfaceID *surface_list,
102 VAStatus (*vaCreateContext) (
103 VADriverContextP ctx,
104 VAConfigID config_id,
108 VASurfaceID *render_targets,
109 int num_render_targets,
110 VAContextID *context /* out */
113 VAStatus (*vaDestroyContext) (
114 VADriverContextP ctx,
118 VAStatus (*vaCreateBuffer) (
119 VADriverContextP ctx,
120 VAContextID context, /* in */
121 VABufferType type, /* in */
122 unsigned int size, /* in */
123 unsigned int num_elements, /* in */
125 VABufferID *buf_id /* out */
128 VAStatus (*vaBufferSetNumElements) (
129 VADriverContextP ctx,
130 VABufferID buf_id, /* in */
131 unsigned int num_elements /* in */
134 VAStatus (*vaMapBuffer) (
135 VADriverContextP ctx,
136 VABufferID buf_id, /* in */
137 void **pbuf /* out */
140 VAStatus (*vaUnmapBuffer) (
141 VADriverContextP ctx,
142 VABufferID buf_id /* in */
145 VAStatus (*vaDestroyBuffer) (
146 VADriverContextP ctx,
150 VAStatus (*vaBeginPicture) (
151 VADriverContextP ctx,
153 VASurfaceID render_target
156 VAStatus (*vaRenderPicture) (
157 VADriverContextP ctx,
163 VAStatus (*vaEndPicture) (
164 VADriverContextP ctx,
168 VAStatus (*vaSyncSurface) (
169 VADriverContextP ctx,
170 VASurfaceID render_target
173 VAStatus (*vaQuerySurfaceStatus) (
174 VADriverContextP ctx,
175 VASurfaceID render_target,
176 VASurfaceStatus *status /* out */
179 VAStatus (*vaPutSurface) (
180 VADriverContextP ctx,
182 void* draw, /* X Drawable */
189 unsigned short destw,
190 unsigned short desth,
191 VARectangle *cliprects, /* client supplied clip list */
192 unsigned int number_cliprects, /* number of clip rects in the clip list */
193 unsigned int flags /* de-interlacing flags */
196 VAStatus (*vaPutSurfaceBuf) (
197 VADriverContextP ctx,
199 Drawable draw, /* X Drawable */
208 unsigned short destw,
209 unsigned short desth,
210 VARectangle *cliprects, /* client supplied clip list */
211 unsigned int number_cliprects, /* number of clip rects in the clip list */
212 unsigned int flags /* de-interlacing flags */
215 VAStatus (*vaQueryImageFormats) (
216 VADriverContextP ctx,
217 VAImageFormat *format_list, /* out */
218 int *num_formats /* out */
221 VAStatus (*vaCreateImage) (
222 VADriverContextP ctx,
223 VAImageFormat *format,
226 VAImage *image /* out */
229 VAStatus (*vaDeriveImage) (
230 VADriverContextP ctx,
232 VAImage *image /* out */
235 VAStatus (*vaDestroyImage) (
236 VADriverContextP ctx,
240 VAStatus (*vaSetImagePalette) (
241 VADriverContextP ctx,
244 * pointer to an array holding the palette data. The size of the array is
245 * num_palette_entries * entry_bytes in size. The order of the components
246 * in the palette is described by the component_order in VAImage struct
248 unsigned char *palette
251 VAStatus (*vaGetImage) (
252 VADriverContextP ctx,
254 int x, /* coordinates of the upper left source pixel */
256 unsigned int width, /* width and height of the region */
261 VAStatus (*vaPutImage) (
262 VADriverContextP ctx,
267 unsigned int src_width,
268 unsigned int src_height,
271 unsigned int dest_width,
272 unsigned int dest_height
275 VAStatus (*vaQuerySubpictureFormats) (
276 VADriverContextP ctx,
277 VAImageFormat *format_list, /* out */
278 unsigned int *flags, /* out */
279 unsigned int *num_formats /* out */
282 VAStatus (*vaCreateSubpicture) (
283 VADriverContextP ctx,
285 VASubpictureID *subpicture /* out */
288 VAStatus (*vaDestroySubpicture) (
289 VADriverContextP ctx,
290 VASubpictureID subpicture
293 VAStatus (*vaSetSubpictureImage) (
294 VADriverContextP ctx,
295 VASubpictureID subpicture,
299 VAStatus (*vaSetSubpictureChromakey) (
300 VADriverContextP ctx,
301 VASubpictureID subpicture,
302 unsigned int chromakey_min,
303 unsigned int chromakey_max,
304 unsigned int chromakey_mask
307 VAStatus (*vaSetSubpictureGlobalAlpha) (
308 VADriverContextP ctx,
309 VASubpictureID subpicture,
313 VAStatus (*vaAssociateSubpicture) (
314 VADriverContextP ctx,
315 VASubpictureID subpicture,
316 VASurfaceID *target_surfaces,
318 short src_x, /* upper left offset in subpicture */
320 unsigned short src_width,
321 unsigned short src_height,
322 short dest_x, /* upper left offset in surface */
324 unsigned short dest_width,
325 unsigned short dest_height,
327 * whether to enable chroma-keying or global-alpha
328 * see VA_SUBPICTURE_XXX values
333 VAStatus (*vaDeassociateSubpicture) (
334 VADriverContextP ctx,
335 VASubpictureID subpicture,
336 VASurfaceID *target_surfaces,
340 VAStatus (*vaQueryDisplayAttributes) (
341 VADriverContextP ctx,
342 VADisplayAttribute *attr_list, /* out */
343 int *num_attributes /* out */
346 VAStatus (*vaGetDisplayAttributes) (
347 VADriverContextP ctx,
348 VADisplayAttribute *attr_list, /* in/out */
352 VAStatus (*vaSetDisplayAttributes) (
353 VADriverContextP ctx,
354 VADisplayAttribute *attr_list,
358 /* device specific */
359 VAStatus (*vaCreateSurfaceFromCIFrame) (
360 VADriverContextP ctx,
361 unsigned long frame_id,
362 VASurfaceID *surface /* out */
366 VAStatus (*vaCreateSurfaceFromV4L2Buf) (
367 VADriverContextP ctx,
368 int v4l2_fd, /* file descriptor of V4L2 device */
369 struct v4l2_format *v4l2_fmt, /* format of V4L2 */
370 struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */
371 VASurfaceID *surface /* out */
374 VAStatus (*vaBufferInfo) (
375 VADriverContextP ctx,
376 VAContextID context, /* in */
377 VABufferID buf_id, /* in */
378 VABufferType *type, /* out */
379 unsigned int *size, /* out */
380 unsigned int *num_elements /* out */
384 VAStatus (*vaCopySurfaceToBuffer) (
385 VADriverContextP ctx,
387 unsigned int *fourcc, /* out for follow argument */
388 unsigned int *luma_stride,
389 unsigned int *chroma_u_stride,
390 unsigned int *chroma_v_stride,
391 unsigned int *luma_offset,
392 unsigned int *chroma_u_offset,
393 unsigned int *chroma_v_offset,
398 struct VADriverContext
401 struct VADriverVTable vtable;
410 int max_image_formats;
411 int max_subpic_formats;
412 int max_display_attributes;
413 const char *str_vendor;
415 void *handle; /* dlopen handle */
420 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
421 struct VADisplayContext
425 VADisplayContextP pNext;
426 VADriverContextP pDriverContext;
429 VADisplayContextP ctx
433 VADisplayContextP ctx
436 VAStatus (*vaGetDriverName) (
437 VADisplayContextP ctx,
442 typedef VAStatus (*VADriverInit) (
443 VADriverContextP driver_context
447 #endif /* _VA_BACKEND_H_ */