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>
37 typedef struct VADriverContext *VADriverContextP;
38 typedef struct VADisplayContext *VADisplayContextP;
42 VAStatus (*vaTerminate) ( VADriverContextP ctx );
44 VAStatus (*vaQueryConfigProfiles) (
46 VAProfile *profile_list, /* out */
47 int *num_profiles /* out */
50 VAStatus (*vaQueryConfigEntrypoints) (
53 VAEntrypoint *entrypoint_list, /* out */
54 int *num_entrypoints /* out */
57 VAStatus (*vaGetConfigAttributes) (
60 VAEntrypoint entrypoint,
61 VAConfigAttrib *attrib_list, /* in/out */
65 VAStatus (*vaCreateConfig) (
68 VAEntrypoint entrypoint,
69 VAConfigAttrib *attrib_list,
71 VAConfigID *config_id /* out */
74 VAStatus (*vaDestroyConfig) (
79 VAStatus (*vaQueryConfigAttributes) (
82 VAProfile *profile, /* out */
83 VAEntrypoint *entrypoint, /* out */
84 VAConfigAttrib *attrib_list, /* out */
85 int *num_attribs /* out */
88 VAStatus (*vaCreateSurfaces) (
94 VASurfaceID *surfaces /* out */
97 VAStatus (*vaDestroySurfaces) (
99 VASurfaceID *surface_list,
103 VAStatus (*vaCreateContext) (
104 VADriverContextP ctx,
105 VAConfigID config_id,
109 VASurfaceID *render_targets,
110 int num_render_targets,
111 VAContextID *context /* out */
114 VAStatus (*vaDestroyContext) (
115 VADriverContextP ctx,
119 VAStatus (*vaCreateBuffer) (
120 VADriverContextP ctx,
121 VAContextID context, /* in */
122 VABufferType type, /* in */
123 unsigned int size, /* in */
124 unsigned int num_elements, /* in */
126 VABufferID *buf_id /* out */
129 VAStatus (*vaBufferSetNumElements) (
130 VADriverContextP ctx,
131 VABufferID buf_id, /* in */
132 unsigned int num_elements /* in */
135 VAStatus (*vaMapBuffer) (
136 VADriverContextP ctx,
137 VABufferID buf_id, /* in */
138 void **pbuf /* out */
141 VAStatus (*vaUnmapBuffer) (
142 VADriverContextP ctx,
143 VABufferID buf_id /* in */
146 VAStatus (*vaDestroyBuffer) (
147 VADriverContextP ctx,
151 VAStatus (*vaBeginPicture) (
152 VADriverContextP ctx,
154 VASurfaceID render_target
157 VAStatus (*vaRenderPicture) (
158 VADriverContextP ctx,
164 VAStatus (*vaEndPicture) (
165 VADriverContextP ctx,
169 VAStatus (*vaSyncSurface) (
170 VADriverContextP ctx,
171 VASurfaceID render_target
174 VAStatus (*vaQuerySurfaceStatus) (
175 VADriverContextP ctx,
176 VASurfaceID render_target,
177 VASurfaceStatus *status /* out */
180 VAStatus (*vaPutSurface) (
181 VADriverContextP ctx,
183 Drawable draw, /* X Drawable */
190 unsigned short destw,
191 unsigned short desth,
192 VARectangle *cliprects, /* client supplied clip list */
193 unsigned int number_cliprects, /* number of clip rects in the clip list */
194 unsigned int flags /* de-interlacing flags */
197 VAStatus (*vaQueryImageFormats) (
198 VADriverContextP ctx,
199 VAImageFormat *format_list, /* out */
200 int *num_formats /* out */
203 VAStatus (*vaCreateImage) (
204 VADriverContextP ctx,
205 VAImageFormat *format,
208 VAImage *image /* out */
211 VAStatus (*vaDeriveImage) (
212 VADriverContextP ctx,
214 VAImage *image /* out */
217 VAStatus (*vaDestroyImage) (
218 VADriverContextP ctx,
222 VAStatus (*vaSetImagePalette) (
223 VADriverContextP ctx,
226 * pointer to an array holding the palette data. The size of the array is
227 * num_palette_entries * entry_bytes in size. The order of the components
228 * in the palette is described by the component_order in VAImage struct
230 unsigned char *palette
233 VAStatus (*vaGetImage) (
234 VADriverContextP ctx,
236 int x, /* coordinates of the upper left source pixel */
238 unsigned int width, /* width and height of the region */
243 VAStatus (*vaPutImage) (
244 VADriverContextP ctx,
249 unsigned int src_width,
250 unsigned int src_height,
253 unsigned int dest_width,
254 unsigned int dest_height
257 VAStatus (*vaQuerySubpictureFormats) (
258 VADriverContextP ctx,
259 VAImageFormat *format_list, /* out */
260 unsigned int *flags, /* out */
261 unsigned int *num_formats /* out */
264 VAStatus (*vaCreateSubpicture) (
265 VADriverContextP ctx,
267 VASubpictureID *subpicture /* out */
270 VAStatus (*vaDestroySubpicture) (
271 VADriverContextP ctx,
272 VASubpictureID subpicture
275 VAStatus (*vaSetSubpictureImage) (
276 VADriverContextP ctx,
277 VASubpictureID subpicture,
281 VAStatus (*vaSetSubpictureChromakey) (
282 VADriverContextP ctx,
283 VASubpictureID subpicture,
284 unsigned int chromakey_min,
285 unsigned int chromakey_max,
286 unsigned int chromakey_mask
289 VAStatus (*vaSetSubpictureGlobalAlpha) (
290 VADriverContextP ctx,
291 VASubpictureID subpicture,
295 VAStatus (*vaAssociateSubpicture) (
296 VADriverContextP ctx,
297 VASubpictureID subpicture,
298 VASurfaceID *target_surfaces,
300 short src_x, /* upper left offset in subpicture */
302 unsigned short src_width,
303 unsigned short src_height,
304 short dest_x, /* upper left offset in surface */
306 unsigned short dest_width,
307 unsigned short dest_height,
309 * whether to enable chroma-keying or global-alpha
310 * see VA_SUBPICTURE_XXX values
315 VAStatus (*vaDeassociateSubpicture) (
316 VADriverContextP ctx,
317 VASubpictureID subpicture,
318 VASurfaceID *target_surfaces,
322 VAStatus (*vaQueryDisplayAttributes) (
323 VADriverContextP ctx,
324 VADisplayAttribute *attr_list, /* out */
325 int *num_attributes /* out */
328 VAStatus (*vaGetDisplayAttributes) (
329 VADriverContextP ctx,
330 VADisplayAttribute *attr_list, /* in/out */
334 VAStatus (*vaSetDisplayAttributes) (
335 VADriverContextP ctx,
336 VADisplayAttribute *attr_list,
340 /* device specific */
341 VAStatus (*vaCreateSurfaceFromCIFrame) (
342 VADriverContextP ctx,
343 unsigned long frame_id,
344 VASurfaceID *surface /* out */
348 VAStatus (*vaCreateSurfaceFromV4L2Buf) (
349 VADriverContextP ctx,
350 int v4l2_fd, /* file descriptor of V4L2 device */
351 struct v4l2_format *v4l2_fmt, /* format of V4L2 */
352 struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */
353 VASurfaceID *surface /* out */
356 VAStatus (*vaBufferInfo) (
357 VADriverContextP ctx,
358 VAContextID context, /* in */
359 VABufferID buf_id, /* in */
360 VABufferType *type, /* out */
361 unsigned int *size, /* out */
362 unsigned int *num_elements /* out */
366 VAStatus (*vaCopySurfaceToBuffer) (
367 VADriverContextP ctx,
369 unsigned int *fourcc, /* out for follow argument */
370 unsigned int *luma_stride,
371 unsigned int *chroma_u_stride,
372 unsigned int *chroma_v_stride,
373 unsigned int *luma_offset,
374 unsigned int *chroma_u_offset,
375 unsigned int *chroma_v_offset,
380 struct VADriverContext
383 struct VADriverVTable vtable;
392 int max_image_formats;
393 int max_subpic_formats;
394 int max_display_attributes;
395 const char *str_vendor;
397 void *handle; /* dlopen handle */
402 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
403 struct VADisplayContext
407 VADisplayContextP pNext;
408 VADriverContextP pDriverContext;
411 VADisplayContextP ctx
415 VADisplayContextP ctx
418 VAStatus (*vaGetDriverName) (
419 VADisplayContextP ctx,
424 typedef VAStatus (*VADriverInit) (
425 VADriverContextP driver_context
429 #endif /* _VA_BACKEND_H_ */