1 /**************************************************************************
3 * Copyright 2010 Younes Manton.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #include "vdpau_private.h"
29 #include <vl_winsys.h>
31 #include <pipe/p_screen.h>
32 #include <pipe/p_defines.h>
34 #include <util/u_debug.h>
38 vlVdpGetApiVersion(uint32_t *api_version
)
41 return VDP_STATUS_INVALID_POINTER
;
48 vlVdpGetInformationString(char const **information_string
)
50 if (!information_string
)
51 return VDP_STATUS_INVALID_POINTER
;
53 *information_string
= INFORMATION_STRING
;
58 vlVdpVideoSurfaceQueryCapabilities(VdpDevice device
, VdpChromaType surface_chroma_type
,
59 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
61 struct vl_screen
*vlscreen
;
62 uint32_t max_2d_texture_level
;
65 debug_printf("[VDPAU] Querying video surfaces\n");
67 if (!(is_supported
&& max_width
&& max_height
))
68 return VDP_STATUS_INVALID_POINTER
;
70 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
72 return VDP_STATUS_INVALID_HANDLE
;
74 vlscreen
= vl_screen_create(dev
->display
, dev
->screen
);
76 return VDP_STATUS_RESOURCES
;
78 /* XXX: Current limits */
80 if (surface_chroma_type
!= VDP_CHROMA_TYPE_420
) {
81 *is_supported
= false;
85 max_2d_texture_level
= vlscreen
->pscreen
->get_param( vlscreen
->pscreen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
);
86 if (!max_2d_texture_level
) {
87 ret
= VDP_STATUS_RESOURCES
;
91 /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
92 *max_width
= *max_height
= pow(2,max_2d_texture_level
-1);
94 vl_screen_destroy(vlscreen
);
102 vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device
, VdpChromaType surface_chroma_type
,
103 VdpYCbCrFormat bits_ycbcr_format
,
104 VdpBool
*is_supported
)
106 struct vl_screen
*vlscreen
;
108 debug_printf("[VDPAU] Querying get put video surfaces\n");
111 return VDP_STATUS_INVALID_POINTER
;
113 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
115 return VDP_STATUS_INVALID_HANDLE
;
117 vlscreen
= vl_screen_create(dev
->display
, dev
->screen
);
119 return VDP_STATUS_RESOURCES
;
121 if (bits_ycbcr_format
!= VDP_YCBCR_FORMAT_Y8U8V8A8
&& bits_ycbcr_format
!= VDP_YCBCR_FORMAT_V8U8Y8A8
)
122 *is_supported
= vlscreen
->pscreen
->is_format_supported(vlscreen
->pscreen
,
123 FormatToPipe(bits_ycbcr_format
),
126 PIPE_BIND_RENDER_TARGET
);
128 vl_screen_destroy(vlscreen
);
130 return VDP_STATUS_OK
;
134 vlVdpDecoderQueryCapabilities(VdpDevice device
, VdpDecoderProfile profile
,
135 VdpBool
*is_supported
, uint32_t *max_level
, uint32_t *max_macroblocks
,
136 uint32_t *max_width
, uint32_t *max_height
)
138 enum pipe_video_profile p_profile
;
139 uint32_t max_decode_width
;
140 uint32_t max_decode_height
;
141 uint32_t max_2d_texture_level
;
142 struct vl_screen
*vlscreen
;
144 debug_printf("[VDPAU] Querying decoder\n");
146 if (!(is_supported
&& max_level
&& max_macroblocks
&& max_width
&& max_height
))
147 return VDP_STATUS_INVALID_POINTER
;
149 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
151 return VDP_STATUS_INVALID_HANDLE
;
153 vlscreen
= vl_screen_create(dev
->display
, dev
->screen
);
155 return VDP_STATUS_RESOURCES
;
157 p_profile
= ProfileToPipe(profile
);
158 if (p_profile
== PIPE_VIDEO_PROFILE_UNKNOWN
) {
159 *is_supported
= false;
160 return VDP_STATUS_OK
;
163 if (p_profile
!= PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
&& p_profile
!= PIPE_VIDEO_PROFILE_MPEG2_MAIN
) {
164 *is_supported
= false;
165 return VDP_STATUS_OK
;
168 /* XXX hack, need to implement something more sane when the decoders have been implemented */
169 max_2d_texture_level
= vlscreen
->pscreen
->get_param( vlscreen
->pscreen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
);
170 max_decode_width
= max_decode_height
= pow(2,max_2d_texture_level
-2);
171 if (!(max_decode_width
&& max_decode_height
))
172 return VDP_STATUS_RESOURCES
;
174 *is_supported
= true;
175 *max_width
= max_decode_width
;
176 *max_height
= max_decode_height
;
178 *max_macroblocks
= (max_decode_width
/16) * (max_decode_height
/16);
180 vl_screen_destroy(vlscreen
);
182 return VDP_STATUS_OK
;
186 vlVdpOutputSurfaceQueryCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
187 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
189 if (!(is_supported
&& max_width
&& max_height
))
190 return VDP_STATUS_INVALID_POINTER
;
192 debug_printf("[VDPAU] Querying ouput surfaces\n");
194 return VDP_STATUS_NO_IMPLEMENTATION
;
198 vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
199 VdpBool
*is_supported
)
201 debug_printf("[VDPAU] Querying output surfaces get put native cap\n");
204 return VDP_STATUS_INVALID_POINTER
;
206 return VDP_STATUS_NO_IMPLEMENTATION
;
210 vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device
,
211 VdpRGBAFormat surface_rgba_format
,
212 VdpIndexedFormat bits_indexed_format
,
213 VdpColorTableFormat color_table_format
,
214 VdpBool
*is_supported
)
216 debug_printf("[VDPAU] Querying output surfaces get put indexed cap\n");
219 return VDP_STATUS_INVALID_POINTER
;
221 return VDP_STATUS_NO_IMPLEMENTATION
;
225 vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
226 VdpYCbCrFormat bits_ycbcr_format
,
227 VdpBool
*is_supported
)
229 debug_printf("[VDPAU] Querying output surfaces put ycrcb cap\n");
231 return VDP_STATUS_INVALID_POINTER
;
233 return VDP_STATUS_NO_IMPLEMENTATION
;
237 vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
238 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
240 debug_printf("[VDPAU] Querying bitmap surfaces\n");
241 if (!(is_supported
&& max_width
&& max_height
))
242 return VDP_STATUS_INVALID_POINTER
;
244 return VDP_STATUS_NO_IMPLEMENTATION
;
248 vlVdpVideoMixerQueryFeatureSupport(VdpDevice device
, VdpVideoMixerFeature feature
,
249 VdpBool
*is_supported
)
251 debug_printf("[VDPAU] Querying mixer feature support\n");
253 return VDP_STATUS_INVALID_POINTER
;
255 return VDP_STATUS_NO_IMPLEMENTATION
;
259 vlVdpVideoMixerQueryParameterSupport(VdpDevice device
, VdpVideoMixerParameter parameter
,
260 VdpBool
*is_supported
)
263 return VDP_STATUS_INVALID_POINTER
;
265 return VDP_STATUS_NO_IMPLEMENTATION
;
269 vlVdpVideoMixerQueryParameterValueRange(VdpDevice device
, VdpVideoMixerParameter parameter
,
270 void *min_value
, void *max_value
)
272 if (!(min_value
&& max_value
))
273 return VDP_STATUS_INVALID_POINTER
;
275 return VDP_STATUS_NO_IMPLEMENTATION
;
279 vlVdpVideoMixerQueryAttributeSupport(VdpDevice device
, VdpVideoMixerAttribute attribute
,
280 VdpBool
*is_supported
)
283 return VDP_STATUS_INVALID_POINTER
;
285 return VDP_STATUS_NO_IMPLEMENTATION
;
289 vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device
, VdpVideoMixerAttribute attribute
,
290 void *min_value
, void *max_value
)
292 if (!(min_value
&& max_value
))
293 return VDP_STATUS_INVALID_POINTER
;
295 return VDP_STATUS_NO_IMPLEMENTATION
;