36ef124c13d484906a4020e3ac20d107cdf9797d
[mesa.git] / src / gallium / state_trackers / vdpau / vdpau_private.h
1 /**************************************************************************
2 *
3 * Copyright 2010 Younes Manton.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef VDPAU_PRIVATE_H
29 #define VDPAU_PRIVATE_H
30
31
32 #include <vdpau/vdpau.h>
33 #include <vdpau/vdpau_x11.h>
34 #include <pipe/p_compiler.h>
35 #include <pipe/p_video_context.h>
36 #include <vl_winsys.h>
37 #include <assert.h>
38
39 #define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
40 #define QUOTEME(x) #x
41 #define TOSTRING(x) QUOTEME(x)
42 #define INFORMATION_STRING TOSTRING(INFORMATION)
43 #define VL_HANDLES
44
45 static enum pipe_video_chroma_format TypeToPipe(VdpChromaType vdpau_type)
46 {
47 switch (vdpau_type) {
48 case VDP_CHROMA_TYPE_420:
49 return PIPE_VIDEO_CHROMA_FORMAT_420;
50 case VDP_CHROMA_TYPE_422:
51 return PIPE_VIDEO_CHROMA_FORMAT_422;
52 case VDP_CHROMA_TYPE_444:
53 return PIPE_VIDEO_CHROMA_FORMAT_444;
54 default:
55 assert(0);
56 }
57
58 return -1;
59 }
60
61 static VdpChromaType PipeToType(enum pipe_video_chroma_format pipe_type)
62 {
63 switch (pipe_type) {
64 case PIPE_VIDEO_CHROMA_FORMAT_420:
65 return VDP_CHROMA_TYPE_420;
66 case PIPE_VIDEO_CHROMA_FORMAT_422:
67 return VDP_CHROMA_TYPE_422;
68 case PIPE_VIDEO_CHROMA_FORMAT_444:
69 return VDP_CHROMA_TYPE_444;
70 default:
71 assert(0);
72 }
73
74 return -1;
75 }
76
77
78 static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format)
79 {
80 switch (vdpau_format) {
81 case VDP_YCBCR_FORMAT_NV12:
82 return PIPE_FORMAT_NV12;
83 case VDP_YCBCR_FORMAT_YV12:
84 return PIPE_FORMAT_YV12;
85 case VDP_YCBCR_FORMAT_UYVY:
86 return PIPE_FORMAT_UYVY;
87 case VDP_YCBCR_FORMAT_YUYV:
88 return PIPE_FORMAT_YUYV;
89 case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */
90 return 0;
91 case VDP_YCBCR_FORMAT_V8U8Y8A8:
92 return PIPE_FORMAT_VUYA;
93 default:
94 assert(0);
95 }
96
97 return -1;
98 }
99
100 static enum pipe_format FormatRGBAToPipe(VdpRGBAFormat vdpau_format)
101 {
102 switch (vdpau_format) {
103 case VDP_RGBA_FORMAT_A8:
104 return PIPE_FORMAT_A8_UNORM;
105 case VDP_RGBA_FORMAT_B10G10R10A2:
106 return PIPE_FORMAT_B10G10R10A2_UNORM;
107 case VDP_RGBA_FORMAT_B8G8R8A8:
108 return PIPE_FORMAT_B8G8R8A8_UNORM;
109 case VDP_RGBA_FORMAT_R10G10B10A2:
110 return PIPE_FORMAT_R10G10B10A2_UNORM;
111 case VDP_RGBA_FORMAT_R8G8B8A8:
112 return PIPE_FORMAT_R8G8B8A8_UNORM;
113 default:
114 assert(0);
115 }
116
117 return -1;
118 }
119
120 static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format)
121 {
122 switch (p_format) {
123 case PIPE_FORMAT_NV12:
124 return VDP_YCBCR_FORMAT_NV12;
125 case PIPE_FORMAT_YV12:
126 return VDP_YCBCR_FORMAT_YV12;
127 case PIPE_FORMAT_UYVY:
128 return VDP_YCBCR_FORMAT_UYVY;
129 case PIPE_FORMAT_YUYV:
130 return VDP_YCBCR_FORMAT_YUYV;
131 //case PIPE_FORMAT_YUVA:
132 // return VDP_YCBCR_FORMAT_Y8U8V8A8;
133 case PIPE_FORMAT_VUYA:
134 return VDP_YCBCR_FORMAT_V8U8Y8A8;
135 default:
136 assert(0);
137 }
138
139 return -1;
140 }
141
142 static enum pipe_video_profile ProfileToPipe(VdpDecoderProfile vdpau_profile)
143 {
144 switch (vdpau_profile) {
145 case VDP_DECODER_PROFILE_MPEG1:
146 return PIPE_VIDEO_PROFILE_MPEG1;
147 case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
148 return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
149 case VDP_DECODER_PROFILE_MPEG2_MAIN:
150 return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
151 case VDP_DECODER_PROFILE_H264_BASELINE:
152 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
153 case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */
154 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
155 case VDP_DECODER_PROFILE_H264_HIGH:
156 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
157 default:
158 PIPE_VIDEO_PROFILE_UNKNOWN;
159 }
160
161 return -1;
162 }
163
164 typedef struct
165 {
166 void *display;
167 int screen;
168 } vlVdpDevice;
169
170 typedef struct
171 {
172 vlVdpDevice *device;
173 Drawable drawable;
174 } vlVdpPresentationQueueTarget;
175
176 typedef struct
177 {
178 vlVdpDevice *device;
179 Drawable drawable;
180 } vlVdpPresentationQueue;
181
182 typedef struct
183 {
184 vlVdpDevice *device;
185 } vlVdpVideoMixer;
186
187 typedef struct
188 {
189 vlVdpDevice *device;
190 uint32_t width;
191 uint32_t height;
192 uint32_t pitch;
193 struct pipe_surface *psurface;
194 enum pipe_format format;
195 enum pipe_video_chroma_format chroma_format;
196 uint8_t *data;
197 } vlVdpSurface;
198
199 typedef struct
200 {
201 vlVdpDevice *device;
202 uint32_t width;
203 uint32_t height;
204 enum pipe_format format;
205 } vlVdpOutputSurface;
206
207 typedef struct
208 {
209 vlVdpDevice *device;
210 struct vl_screen *vlscreen;
211 struct vl_context *vctx;
212 enum pipe_video_chroma_format chroma_format;
213 enum pipe_video_profile profile;
214 } vlVdpDecoder;
215
216 typedef uint32_t vlHandle;
217
218 boolean vlCreateHTAB(void);
219 void vlDestroyHTAB(void);
220 vlHandle vlAddDataHTAB(void *data);
221 void* vlGetDataHTAB(vlHandle handle);
222 boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
223
224 /* Public functions */
225 VdpDeviceCreateX11 vdp_imp_device_create_x11;
226 VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
227
228 /* Internal function pointers */
229 VdpGetErrorString vlVdpGetErrorString;
230 VdpDeviceDestroy vlVdpDeviceDestroy;
231 VdpGetProcAddress vlVdpGetProcAddress;
232 VdpGetApiVersion vlVdpGetApiVersion;
233 VdpGetInformationString vlVdpGetInformationString;
234 VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;
235 VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
236 VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;
237 VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;
238 VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
239 VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
240 VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
241 VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
242 VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
243 VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
244 VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
245 VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
246 VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
247 VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
248 VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
249 VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
250 VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
251 VdpDecoderCreate vlVdpDecoderCreate;
252 VdpDecoderDestroy vlVdpDecoderDestroy;
253 VdpDecoderRender vlVdpDecoderRender;
254 VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
255 VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
256 VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
257 VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
258 VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
259 VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
260 VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
261 VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
262 VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
263 VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
264 VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
265 VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
266 VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
267 VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
268 VdpPreemptionCallback vlVdpPreemptionCallback;
269 VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
270 VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
271 VdpVideoMixerCreate vlVdpVideoMixerCreate;
272 VdpVideoMixerRender vlVdpVideoMixerRender;
273 VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
274 VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
275
276
277 #endif // VDPAU_PRIVATE_H