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 (*vaQueryImageFormats) (
197 VADriverContextP ctx,
198 VAImageFormat *format_list, /* out */
199 int *num_formats /* out */
202 VAStatus (*vaCreateImage) (
203 VADriverContextP ctx,
204 VAImageFormat *format,
207 VAImage *image /* out */
210 VAStatus (*vaDeriveImage) (
211 VADriverContextP ctx,
213 VAImage *image /* out */
216 VAStatus (*vaDestroyImage) (
217 VADriverContextP ctx,
221 VAStatus (*vaSetImagePalette) (
222 VADriverContextP ctx,
225 * pointer to an array holding the palette data. The size of the array is
226 * num_palette_entries * entry_bytes in size. The order of the components
227 * in the palette is described by the component_order in VAImage struct
229 unsigned char *palette
232 VAStatus (*vaGetImage) (
233 VADriverContextP ctx,
235 int x, /* coordinates of the upper left source pixel */
237 unsigned int width, /* width and height of the region */
242 VAStatus (*vaPutImage) (
243 VADriverContextP ctx,
248 unsigned int src_width,
249 unsigned int src_height,
252 unsigned int dest_width,
253 unsigned int dest_height
256 VAStatus (*vaQuerySubpictureFormats) (
257 VADriverContextP ctx,
258 VAImageFormat *format_list, /* out */
259 unsigned int *flags, /* out */
260 unsigned int *num_formats /* out */
263 VAStatus (*vaCreateSubpicture) (
264 VADriverContextP ctx,
266 VASubpictureID *subpicture /* out */
269 VAStatus (*vaDestroySubpicture) (
270 VADriverContextP ctx,
271 VASubpictureID subpicture
274 VAStatus (*vaSetSubpictureImage) (
275 VADriverContextP ctx,
276 VASubpictureID subpicture,
280 VAStatus (*vaSetSubpictureChromakey) (
281 VADriverContextP ctx,
282 VASubpictureID subpicture,
283 unsigned int chromakey_min,
284 unsigned int chromakey_max,
285 unsigned int chromakey_mask
288 VAStatus (*vaSetSubpictureGlobalAlpha) (
289 VADriverContextP ctx,
290 VASubpictureID subpicture,
294 VAStatus (*vaAssociateSubpicture) (
295 VADriverContextP ctx,
296 VASubpictureID subpicture,
297 VASurfaceID *target_surfaces,
299 short src_x, /* upper left offset in subpicture */
301 unsigned short src_width,
302 unsigned short src_height,
303 short dest_x, /* upper left offset in surface */
305 unsigned short dest_width,
306 unsigned short dest_height,
308 * whether to enable chroma-keying or global-alpha
309 * see VA_SUBPICTURE_XXX values
314 VAStatus (*vaDeassociateSubpicture) (
315 VADriverContextP ctx,
316 VASubpictureID subpicture,
317 VASurfaceID *target_surfaces,
321 VAStatus (*vaQueryDisplayAttributes) (
322 VADriverContextP ctx,
323 VADisplayAttribute *attr_list, /* out */
324 int *num_attributes /* out */
327 VAStatus (*vaGetDisplayAttributes) (
328 VADriverContextP ctx,
329 VADisplayAttribute *attr_list, /* in/out */
333 VAStatus (*vaSetDisplayAttributes) (
334 VADriverContextP ctx,
335 VADisplayAttribute *attr_list,
339 /* device specific */
340 VAStatus (*vaCreateSurfaceFromCIFrame) (
341 VADriverContextP ctx,
342 unsigned long frame_id,
343 VASurfaceID *surface /* out */
347 VAStatus (*vaCreateSurfaceFromV4L2Buf) (
348 VADriverContextP ctx,
349 int v4l2_fd, /* file descriptor of V4L2 device */
350 struct v4l2_format *v4l2_fmt, /* format of V4L2 */
351 struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */
352 VASurfaceID *surface /* out */
355 VAStatus (*vaBufferInfo) (
356 VADriverContextP ctx,
357 VAContextID context, /* in */
358 VABufferID buf_id, /* in */
359 VABufferType *type, /* out */
360 unsigned int *size, /* out */
361 unsigned int *num_elements /* out */
365 VAStatus (*vaCopySurfaceToBuffer) (
366 VADriverContextP ctx,
368 unsigned int *fourcc, /* out for follow argument */
369 unsigned int *luma_stride,
370 unsigned int *chroma_u_stride,
371 unsigned int *chroma_v_stride,
372 unsigned int *luma_offset,
373 unsigned int *chroma_u_offset,
374 unsigned int *chroma_v_offset,
379 struct VADriverContext
382 struct VADriverVTable vtable;
391 int max_image_formats;
392 int max_subpic_formats;
393 int max_display_attributes;
394 const char *str_vendor;
396 void *handle; /* dlopen handle */
401 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
402 struct VADisplayContext
406 VADisplayContextP pNext;
407 VADriverContextP pDriverContext;
410 VADisplayContextP ctx
414 VADisplayContextP ctx
417 VAStatus (*vaGetDriverName) (
418 VADisplayContextP ctx,
423 typedef VAStatus (*VADriverInit) (
424 VADriverContextP driver_context
428 #endif /* _VA_BACKEND_H_ */