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_
33 #include <va/va_x11.h>
36 #include <linux/videodev2.h>
39 typedef struct VADriverContext *VADriverContextP;
40 typedef struct VADisplayContext *VADisplayContextP;
44 VAStatus (*vaTerminate) ( VADriverContextP ctx );
46 VAStatus (*vaQueryConfigProfiles) (
48 VAProfile *profile_list, /* out */
49 int *num_profiles /* out */
52 VAStatus (*vaQueryConfigEntrypoints) (
55 VAEntrypoint *entrypoint_list, /* out */
56 int *num_entrypoints /* out */
59 VAStatus (*vaGetConfigAttributes) (
62 VAEntrypoint entrypoint,
63 VAConfigAttrib *attrib_list, /* in/out */
67 VAStatus (*vaCreateConfig) (
70 VAEntrypoint entrypoint,
71 VAConfigAttrib *attrib_list,
73 VAConfigID *config_id /* out */
76 VAStatus (*vaDestroyConfig) (
81 VAStatus (*vaQueryConfigAttributes) (
84 VAProfile *profile, /* out */
85 VAEntrypoint *entrypoint, /* out */
86 VAConfigAttrib *attrib_list, /* out */
87 int *num_attribs /* out */
90 VAStatus (*vaCreateSurfaces) (
96 VASurfaceID *surfaces /* out */
99 VAStatus (*vaDestroySurfaces) (
100 VADriverContextP ctx,
101 VASurfaceID *surface_list,
105 VAStatus (*vaCreateContext) (
106 VADriverContextP ctx,
107 VAConfigID config_id,
111 VASurfaceID *render_targets,
112 int num_render_targets,
113 VAContextID *context /* out */
116 VAStatus (*vaDestroyContext) (
117 VADriverContextP ctx,
121 VAStatus (*vaCreateBuffer) (
122 VADriverContextP ctx,
123 VAContextID context, /* in */
124 VABufferType type, /* in */
125 unsigned int size, /* in */
126 unsigned int num_elements, /* in */
128 VABufferID *buf_id /* out */
131 VAStatus (*vaBufferSetNumElements) (
132 VADriverContextP ctx,
133 VABufferID buf_id, /* in */
134 unsigned int num_elements /* in */
137 VAStatus (*vaMapBuffer) (
138 VADriverContextP ctx,
139 VABufferID buf_id, /* in */
140 void **pbuf /* out */
143 VAStatus (*vaUnmapBuffer) (
144 VADriverContextP ctx,
145 VABufferID buf_id /* in */
148 VAStatus (*vaDestroyBuffer) (
149 VADriverContextP ctx,
153 VAStatus (*vaBeginPicture) (
154 VADriverContextP ctx,
156 VASurfaceID render_target
159 VAStatus (*vaRenderPicture) (
160 VADriverContextP ctx,
166 VAStatus (*vaEndPicture) (
167 VADriverContextP ctx,
171 VAStatus (*vaSyncSurface) (
172 VADriverContextP ctx,
173 VASurfaceID render_target
176 VAStatus (*vaQuerySurfaceStatus) (
177 VADriverContextP ctx,
178 VASurfaceID render_target,
179 VASurfaceStatus *status /* out */
182 VAStatus (*vaPutSurface) (
183 VADriverContextP ctx,
185 Drawable draw, /* X Drawable */
192 unsigned short destw,
193 unsigned short desth,
194 VARectangle *cliprects, /* client supplied clip list */
195 unsigned int number_cliprects, /* number of clip rects in the clip list */
196 unsigned int flags /* de-interlacing flags */
199 VAStatus (*vaQueryImageFormats) (
200 VADriverContextP ctx,
201 VAImageFormat *format_list, /* out */
202 int *num_formats /* out */
205 VAStatus (*vaCreateImage) (
206 VADriverContextP ctx,
207 VAImageFormat *format,
210 VAImage *image /* out */
213 VAStatus (*vaDeriveImage) (
214 VADriverContextP ctx,
216 VAImage *image /* out */
219 VAStatus (*vaDestroyImage) (
220 VADriverContextP ctx,
224 VAStatus (*vaSetImagePalette) (
225 VADriverContextP ctx,
228 * pointer to an array holding the palette data. The size of the array is
229 * num_palette_entries * entry_bytes in size. The order of the components
230 * in the palette is described by the component_order in VAImage struct
232 unsigned char *palette
235 VAStatus (*vaGetImage) (
236 VADriverContextP ctx,
238 int x, /* coordinates of the upper left source pixel */
240 unsigned int width, /* width and height of the region */
245 VAStatus (*vaPutImage) (
246 VADriverContextP ctx,
251 unsigned int src_width,
252 unsigned int src_height,
255 unsigned int dest_width,
256 unsigned int dest_height
259 VAStatus (*vaQuerySubpictureFormats) (
260 VADriverContextP ctx,
261 VAImageFormat *format_list, /* out */
262 unsigned int *flags, /* out */
263 unsigned int *num_formats /* out */
266 VAStatus (*vaCreateSubpicture) (
267 VADriverContextP ctx,
269 VASubpictureID *subpicture /* out */
272 VAStatus (*vaDestroySubpicture) (
273 VADriverContextP ctx,
274 VASubpictureID subpicture
277 VAStatus (*vaSetSubpictureImage) (
278 VADriverContextP ctx,
279 VASubpictureID subpicture,
283 VAStatus (*vaSetSubpictureChromakey) (
284 VADriverContextP ctx,
285 VASubpictureID subpicture,
286 unsigned int chromakey_min,
287 unsigned int chromakey_max,
288 unsigned int chromakey_mask
291 VAStatus (*vaSetSubpictureGlobalAlpha) (
292 VADriverContextP ctx,
293 VASubpictureID subpicture,
297 VAStatus (*vaAssociateSubpicture) (
298 VADriverContextP ctx,
299 VASubpictureID subpicture,
300 VASurfaceID *target_surfaces,
302 short src_x, /* upper left offset in subpicture */
304 unsigned short src_width,
305 unsigned short src_height,
306 short dest_x, /* upper left offset in surface */
308 unsigned short dest_width,
309 unsigned short dest_height,
311 * whether to enable chroma-keying or global-alpha
312 * see VA_SUBPICTURE_XXX values
317 VAStatus (*vaDeassociateSubpicture) (
318 VADriverContextP ctx,
319 VASubpictureID subpicture,
320 VASurfaceID *target_surfaces,
324 VAStatus (*vaQueryDisplayAttributes) (
325 VADriverContextP ctx,
326 VADisplayAttribute *attr_list, /* out */
327 int *num_attributes /* out */
330 VAStatus (*vaGetDisplayAttributes) (
331 VADriverContextP ctx,
332 VADisplayAttribute *attr_list, /* in/out */
336 VAStatus (*vaSetDisplayAttributes) (
337 VADriverContextP ctx,
338 VADisplayAttribute *attr_list,
342 /* device specific */
343 VAStatus (*vaCreateSurfaceFromCIFrame) (
344 VADriverContextP ctx,
345 unsigned long frame_id,
346 VASurfaceID *surface /* out */
350 VAStatus (*vaCreateSurfaceFromV4L2Buf) (
351 VADriverContextP ctx,
352 int v4l2_fd, /* file descriptor of V4L2 device */
353 struct v4l2_format *v4l2_fmt, /* format of V4L2 */
354 struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */
355 VASurfaceID *surface /* out */
358 VAStatus (*vaCopySurfaceToBuffer) (
359 VADriverContextP ctx,
361 unsigned int *fourcc, /* out for follow argument */
362 unsigned int *luma_stride,
363 unsigned int *chroma_u_stride,
364 unsigned int *chroma_v_stride,
365 unsigned int *luma_offset,
366 unsigned int *chroma_u_offset,
367 unsigned int *chroma_v_offset,
372 struct VADriverContext
375 struct VADriverVTable vtable;
384 int max_image_formats;
385 int max_subpic_formats;
386 int max_display_attributes;
387 const char *str_vendor;
389 void *handle; /* dlopen handle */
394 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
395 struct VADisplayContext
399 VADisplayContextP pNext;
400 VADriverContextP pDriverContext;
403 VADisplayContextP ctx
407 VADisplayContextP ctx
410 VAStatus (*vaGetDriverName) (
411 VADisplayContextP ctx,
416 typedef VAStatus (*VADriverInit) (
417 VADriverContextP driver_context
421 #endif /* _VA_BACKEND_H_ */