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
,
127 PIPE_TEXTURE_GEOM_NON_SQUARE
);
129 vl_screen_destroy(vlscreen
);
131 return VDP_STATUS_OK
;
135 vlVdpDecoderQueryCapabilities(VdpDevice device
, VdpDecoderProfile profile
,
136 VdpBool
*is_supported
, uint32_t *max_level
, uint32_t *max_macroblocks
,
137 uint32_t *max_width
, uint32_t *max_height
)
139 enum pipe_video_profile p_profile
;
140 uint32_t max_decode_width
;
141 uint32_t max_decode_height
;
142 uint32_t max_2d_texture_level
;
143 struct vl_screen
*vlscreen
;
145 debug_printf("[VDPAU] Querying decoder\n");
147 if (!(is_supported
&& max_level
&& max_macroblocks
&& max_width
&& max_height
))
148 return VDP_STATUS_INVALID_POINTER
;
150 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
152 return VDP_STATUS_INVALID_HANDLE
;
154 vlscreen
= vl_screen_create(dev
->display
, dev
->screen
);
156 return VDP_STATUS_RESOURCES
;
158 p_profile
= ProfileToPipe(profile
);
159 if (p_profile
== PIPE_VIDEO_PROFILE_UNKNOWN
) {
160 *is_supported
= false;
161 return VDP_STATUS_OK
;
164 if (p_profile
!= PIPE_VIDEO_PROFILE_MPEG2_SIMPLE
&& p_profile
!= PIPE_VIDEO_PROFILE_MPEG2_MAIN
) {
165 *is_supported
= false;
166 return VDP_STATUS_OK
;
169 /* XXX hack, need to implement something more sane when the decoders have been implemented */
170 max_2d_texture_level
= vlscreen
->pscreen
->get_param( vlscreen
->pscreen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
);
171 max_decode_width
= max_decode_height
= pow(2,max_2d_texture_level
-2);
172 if (!(max_decode_width
&& max_decode_height
))
173 return VDP_STATUS_RESOURCES
;
175 *is_supported
= true;
176 *max_width
= max_decode_width
;
177 *max_height
= max_decode_height
;
179 *max_macroblocks
= (max_decode_width
/16) * (max_decode_height
/16);
181 vl_screen_destroy(vlscreen
);
183 return VDP_STATUS_OK
;
187 vlVdpOutputSurfaceQueryCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
188 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
190 if (!(is_supported
&& max_width
&& max_height
))
191 return VDP_STATUS_INVALID_POINTER
;
193 debug_printf("[VDPAU] Querying ouput surfaces\n");
195 return VDP_STATUS_NO_IMPLEMENTATION
;
199 vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
200 VdpBool
*is_supported
)
202 debug_printf("[VDPAU] Querying output surfaces get put native cap\n");
205 return VDP_STATUS_INVALID_POINTER
;
207 return VDP_STATUS_NO_IMPLEMENTATION
;
211 vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
212 VdpYCbCrFormat bits_ycbcr_format
,
213 VdpBool
*is_supported
)
215 debug_printf("[VDPAU] Querying output surfaces put ycrcb cap\n");
217 return VDP_STATUS_INVALID_POINTER
;
219 return VDP_STATUS_NO_IMPLEMENTATION
;
223 vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
224 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
226 debug_printf("[VDPAU] Querying bitmap surfaces\n");
227 if (!(is_supported
&& max_width
&& max_height
))
228 return VDP_STATUS_INVALID_POINTER
;
230 return VDP_STATUS_NO_IMPLEMENTATION
;
234 vlVdpVideoMixerQueryFeatureSupport(VdpDevice device
, VdpVideoMixerFeature feature
,
235 VdpBool
*is_supported
)
237 debug_printf("[VDPAU] Querying mixer feature support\n");
239 return VDP_STATUS_INVALID_POINTER
;
241 return VDP_STATUS_NO_IMPLEMENTATION
;
245 vlVdpVideoMixerQueryParameterSupport(VdpDevice device
, VdpVideoMixerParameter parameter
,
246 VdpBool
*is_supported
)
249 return VDP_STATUS_INVALID_POINTER
;
251 return VDP_STATUS_NO_IMPLEMENTATION
;
255 vlVdpVideoMixerQueryParameterValueRange(VdpDevice device
, VdpVideoMixerParameter parameter
,
256 void *min_value
, void *max_value
)
258 if (!(min_value
&& max_value
))
259 return VDP_STATUS_INVALID_POINTER
;
261 return VDP_STATUS_NO_IMPLEMENTATION
;
265 vlVdpVideoMixerQueryAttributeSupport(VdpDevice device
, VdpVideoMixerAttribute attribute
,
266 VdpBool
*is_supported
)
269 return VDP_STATUS_INVALID_POINTER
;
271 return VDP_STATUS_NO_IMPLEMENTATION
;
275 vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device
, VdpVideoMixerAttribute attribute
,
276 void *min_value
, void *max_value
)
278 if (!(min_value
&& max_value
))
279 return VDP_STATUS_INVALID_POINTER
;
281 return VDP_STATUS_NO_IMPLEMENTATION
;