st/va: implement vlVa(Create|Destroy|Query|Get)Config
[mesa.git] / src / gallium / state_trackers / va / va_private.h
1 /**************************************************************************
2 *
3 * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
4 * Copyright 2014 Advanced Micro Devices, Inc.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 **************************************************************************/
28
29 #ifndef VA_PRIVATE_H
30 #define VA_PRIVATE_H
31
32 #include <assert.h>
33
34 #include <va/va.h>
35 #include <va/va_backend.h>
36
37 #include "pipe/p_video_enums.h"
38
39 #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
40 #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
41
42 static inline VAProfile
43 PipeToProfile(enum pipe_video_profile profile)
44 {
45 switch (profile) {
46 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
47 return VAProfileMPEG2Simple;
48 case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
49 return VAProfileMPEG2Main;
50 case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
51 return VAProfileMPEG4Simple;
52 case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
53 return VAProfileMPEG4AdvancedSimple;
54 case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
55 return VAProfileVC1Simple;
56 case PIPE_VIDEO_PROFILE_VC1_MAIN:
57 return VAProfileVC1Main;
58 case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
59 return VAProfileVC1Advanced;
60 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
61 return VAProfileH264Baseline;
62 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
63 return VAProfileH264Main;
64 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
65 return VAProfileH264High;
66 case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED:
67 return VAProfileNone;
68 default:
69 assert(0);
70 return -1;
71 }
72 }
73
74 static inline enum pipe_video_profile
75 ProfileToPipe(VAProfile profile)
76 {
77 switch (profile) {
78 case VAProfileMPEG2Simple:
79 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
80 case VAProfileMPEG2Main:
81 return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
82 case VAProfileMPEG4Simple:
83 return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;
84 case VAProfileMPEG4AdvancedSimple:
85 return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;
86 case VAProfileVC1Simple:
87 return PIPE_VIDEO_PROFILE_VC1_SIMPLE;
88 case VAProfileVC1Main:
89 return PIPE_VIDEO_PROFILE_VC1_MAIN;
90 case VAProfileVC1Advanced:
91 return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
92 case VAProfileH264Baseline:
93 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
94 case VAProfileH264Main:
95 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
96 case VAProfileH264High:
97 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
98 default:
99 return PIPE_VIDEO_PROFILE_UNKNOWN;
100 }
101 }
102
103 typedef struct {
104 struct vl_screen *vscreen;
105 } vlVaDriver;
106
107 // Public functions:
108 VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx);
109
110 // vtable functions:
111 VAStatus vlVaTerminate(VADriverContextP ctx);
112 VAStatus vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list,int *num_profiles);
113 VAStatus vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile,
114 VAEntrypoint *entrypoint_list, int *num_entrypoints);
115 VAStatus vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
116 VAConfigAttrib *attrib_list, int num_attribs);
117 VAStatus vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
118 VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id);
119 VAStatus vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id);
120 VAStatus vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile *profile,
121 VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs);
122 VAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format,
123 int num_surfaces, VASurfaceID *surfaces);
124 VAStatus vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces);
125 VAStatus vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, int picture_height,
126 int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context);
127 VAStatus vlVaDestroyContext(VADriverContextP ctx, VAContextID context);
128 VAStatus vlVaCreateBuffer(VADriverContextP ctx, VAContextID context, VABufferType type, unsigned int size,
129 unsigned int num_elements, void *data, VABufferID *buf_id);
130 VAStatus vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, unsigned int num_elements);
131 VAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuf);
132 VAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id);
133 VAStatus vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buffer_id);
134 VAStatus vlVaBeginPicture(VADriverContextP ctx, VAContextID context, VASurfaceID render_target);
135 VAStatus vlVaRenderPicture(VADriverContextP ctx, VAContextID context, VABufferID *buffers, int num_buffers);
136 VAStatus vlVaEndPicture(VADriverContextP ctx, VAContextID context);
137 VAStatus vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target);
138 VAStatus vlVaQuerySurfaceStatus(VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status);
139 VAStatus vlVaQuerySurfaceError(VADriverContextP ctx, VASurfaceID render_target,
140 VAStatus error_status, void **error_info);
141 VAStatus vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, short srcy,
142 unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw,
143 unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects,
144 unsigned int flags);
145 VAStatus vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num_formats);
146 VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list,
147 unsigned int *flags, unsigned int *num_formats);
148 VAStatus vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int height, VAImage *image);
149 VAStatus vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image);
150 VAStatus vlVaDestroyImage(VADriverContextP ctx, VAImageID image);
151 VAStatus vlVaSetImagePalette(VADriverContextP ctx, VAImageID image, unsigned char *palette);
152 VAStatus vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y,
153 unsigned int width, unsigned int height, VAImageID image);
154 VAStatus vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, int src_x, int src_y,
155 unsigned int src_width, unsigned int src_height, int dest_x, int dest_y,
156 unsigned int dest_width, unsigned int dest_height);
157 VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list,
158 unsigned int *flags, unsigned int *num_formats);
159 VAStatus vlVaCreateSubpicture(VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture);
160 VAStatus vlVaDestroySubpicture(VADriverContextP ctx, VASubpictureID subpicture);
161 VAStatus vlVaSubpictureImage(VADriverContextP ctx, VASubpictureID subpicture, VAImageID image);
162 VAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx, VASubpictureID subpicture,
163 unsigned int chromakey_min, unsigned int chromakey_max,
164 unsigned int chromakey_mask);
165 VAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx, VASubpictureID subpicture, float global_alpha);
166 VAStatus vlVaAssociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture, VASurfaceID *target_surfaces,
167 int num_surfaces, short src_x, short src_y,
168 unsigned short src_width, unsigned short src_height,
169 short dest_x, short dest_y, unsigned short dest_width, unsigned short dest_height,
170 unsigned int flags);
171 VAStatus vlVaDeassociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture,
172 VASurfaceID *target_surfaces, int num_surfaces);
173 VAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes);
174 VAStatus vlVaGetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes);
175 VAStatus vlVaSetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes);
176 VAStatus vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type,
177 unsigned int *size, unsigned int *num_elements);
178 VAStatus vlVaLockSurface(VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc,
179 unsigned int *luma_stride, unsigned int *chroma_u_stride, unsigned int *chroma_v_stride,
180 unsigned int *luma_offset, unsigned int *chroma_u_offset, unsigned int *chroma_v_offset,
181 unsigned int *buffer_name, void **buffer);
182 VAStatus vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface);
183
184 #endif //VA_PRIVATE_H