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 **************************************************************************/
31 #include "vdpau_private.h"
32 #include "vl_winsys.h"
33 #include "pipe/p_screen.h"
34 #include "pipe/p_defines.h"
35 #include "util/u_debug.h"
38 * Retrieve the VDPAU version implemented by the backend.
41 vlVdpGetApiVersion(uint32_t *api_version
)
44 return VDP_STATUS_INVALID_POINTER
;
51 * Retrieve an implementation-specific string description of the implementation.
52 * This typically includes detailed version information.
55 vlVdpGetInformationString(char const **information_string
)
57 if (!information_string
)
58 return VDP_STATUS_INVALID_POINTER
;
60 *information_string
= INFORMATION_STRING
;
65 * Query the implementation's VdpVideoSurface capabilities.
68 vlVdpVideoSurfaceQueryCapabilities(VdpDevice device
, VdpChromaType surface_chroma_type
,
69 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
72 struct pipe_screen
*pscreen
;
73 uint32_t max_2d_texture_level
;
75 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpVideoSurface capabilities\n");
77 if (!(is_supported
&& max_width
&& max_height
))
78 return VDP_STATUS_INVALID_POINTER
;
80 dev
= vlGetDataHTAB(device
);
82 return VDP_STATUS_INVALID_HANDLE
;
84 pscreen
= dev
->vscreen
->pscreen
;
86 return VDP_STATUS_RESOURCES
;
88 /* XXX: Current limits */
90 if (surface_chroma_type
!= VDP_CHROMA_TYPE_420
)
91 *is_supported
= false;
93 max_2d_texture_level
= pscreen
->get_param(pscreen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
);
94 if (!max_2d_texture_level
)
95 return VDP_STATUS_RESOURCES
;
97 /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
98 *max_width
= *max_height
= pow(2,max_2d_texture_level
-1);
100 return VDP_STATUS_OK
;
104 * Query the implementation's VdpVideoSurface GetBits/PutBits capabilities.
107 vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device
, VdpChromaType surface_chroma_type
,
108 VdpYCbCrFormat bits_ycbcr_format
,
109 VdpBool
*is_supported
)
112 struct pipe_screen
*pscreen
;
114 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpVideoSurface get/put bits YCbCr capabilities\n");
117 return VDP_STATUS_INVALID_POINTER
;
119 dev
= vlGetDataHTAB(device
);
121 return VDP_STATUS_INVALID_HANDLE
;
123 pscreen
= dev
->vscreen
->pscreen
;
125 return VDP_STATUS_RESOURCES
;
127 *is_supported
= pscreen
->is_video_format_supported
130 FormatYCBCRToPipe(bits_ycbcr_format
),
131 PIPE_VIDEO_PROFILE_UNKNOWN
134 return VDP_STATUS_OK
;
138 * Query the implementation's VdpDecoder capabilities.
141 vlVdpDecoderQueryCapabilities(VdpDevice device
, VdpDecoderProfile profile
,
142 VdpBool
*is_supported
, uint32_t *max_level
, uint32_t *max_macroblocks
,
143 uint32_t *max_width
, uint32_t *max_height
)
146 struct pipe_screen
*pscreen
;
147 enum pipe_video_profile p_profile
;
149 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpDecoder capabilities\n");
151 if (!(is_supported
&& max_level
&& max_macroblocks
&& max_width
&& max_height
))
152 return VDP_STATUS_INVALID_POINTER
;
154 dev
= vlGetDataHTAB(device
);
156 return VDP_STATUS_INVALID_HANDLE
;
158 pscreen
= dev
->vscreen
->pscreen
;
160 return VDP_STATUS_RESOURCES
;
162 p_profile
= ProfileToPipe(profile
);
163 if (p_profile
== PIPE_VIDEO_PROFILE_UNKNOWN
) {
164 *is_supported
= false;
165 return VDP_STATUS_OK
;
168 *is_supported
= pscreen
->get_video_param(pscreen
, p_profile
, PIPE_VIDEO_CAP_SUPPORTED
);
170 *max_width
= pscreen
->get_video_param(pscreen
, p_profile
, PIPE_VIDEO_CAP_MAX_WIDTH
);
171 *max_height
= pscreen
->get_video_param(pscreen
, p_profile
, PIPE_VIDEO_CAP_MAX_HEIGHT
);
173 *max_macroblocks
= (*max_width
/16)*(*max_height
/16);
178 *max_macroblocks
= 0;
181 return VDP_STATUS_OK
;
185 * Query the implementation's VdpOutputSurface capabilities.
188 vlVdpOutputSurfaceQueryCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
189 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
192 struct pipe_screen
*pscreen
;
193 enum pipe_format format
;
195 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpOutputSurface capabilities\n");
197 dev
= vlGetDataHTAB(device
);
199 return VDP_STATUS_INVALID_HANDLE
;
201 pscreen
= dev
->vscreen
->pscreen
;
203 return VDP_STATUS_RESOURCES
;
205 format
= FormatRGBAToPipe(surface_rgba_format
);
206 if (format
== PIPE_FORMAT_NONE
|| format
== PIPE_FORMAT_A8_UNORM
)
207 return VDP_STATUS_INVALID_RGBA_FORMAT
;
209 if (!(is_supported
&& max_width
&& max_height
))
210 return VDP_STATUS_INVALID_POINTER
;
212 *is_supported
= pscreen
->is_format_supported
214 pscreen
, format
, PIPE_TEXTURE_3D
, 1,
215 PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
218 uint32_t max_2d_texture_level
= pscreen
->get_param(
219 pscreen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
);
221 if (!max_2d_texture_level
)
222 return VDP_STATUS_ERROR
;
224 *max_width
= *max_height
= pow(2, max_2d_texture_level
- 1);
230 return VDP_STATUS_OK
;
234 * Query the implementation's capability to perform a PutBits operation using
235 * application data matching the surface's format.
238 vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
239 VdpBool
*is_supported
)
241 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpOutputSurface get/put bits native capabilities\n");
244 return VDP_STATUS_INVALID_POINTER
;
246 return VDP_STATUS_NO_IMPLEMENTATION
;
250 * Query the implementation's capability to perform a PutBits operation using
251 * application data in a specific indexed format.
254 vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device
,
255 VdpRGBAFormat surface_rgba_format
,
256 VdpIndexedFormat bits_indexed_format
,
257 VdpColorTableFormat color_table_format
,
258 VdpBool
*is_supported
)
260 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpOutputSurface put bits indexed capabilities\n");
263 return VDP_STATUS_INVALID_POINTER
;
265 return VDP_STATUS_NO_IMPLEMENTATION
;
269 * Query the implementation's capability to perform a PutBits operation using
270 * application data in a specific YCbCr/YUB format.
273 vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
274 VdpYCbCrFormat bits_ycbcr_format
,
275 VdpBool
*is_supported
)
277 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpOutputSurface put bits YCbCr capabilities\n");
280 return VDP_STATUS_INVALID_POINTER
;
282 return VDP_STATUS_NO_IMPLEMENTATION
;
286 * Query the implementation's VdpBitmapSurface capabilities.
289 vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device
, VdpRGBAFormat surface_rgba_format
,
290 VdpBool
*is_supported
, uint32_t *max_width
, uint32_t *max_height
)
292 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Querying VdpBitmapSurface capabilities\n");
294 if (!(is_supported
&& max_width
&& max_height
))
295 return VDP_STATUS_INVALID_POINTER
;
297 return VDP_STATUS_NO_IMPLEMENTATION
;
301 * Query the implementation's support for a specific feature.
304 vlVdpVideoMixerQueryFeatureSupport(VdpDevice device
, VdpVideoMixerFeature feature
,
305 VdpBool
*is_supported
)
308 return VDP_STATUS_INVALID_POINTER
;
311 case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION
:
312 *is_supported
= VDP_TRUE
;
315 *is_supported
= VDP_FALSE
;
318 return VDP_STATUS_OK
;
322 * Query the implementation's support for a specific parameter.
325 vlVdpVideoMixerQueryParameterSupport(VdpDevice device
, VdpVideoMixerParameter parameter
,
326 VdpBool
*is_supported
)
329 return VDP_STATUS_INVALID_POINTER
;
332 case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH
:
333 case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT
:
334 case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE
:
335 case VDP_VIDEO_MIXER_PARAMETER_LAYERS
:
336 *is_supported
= VDP_TRUE
;
339 *is_supported
= VDP_FALSE
;
342 return VDP_STATUS_OK
;
346 * Query the implementation's supported for a specific parameter.
349 vlVdpVideoMixerQueryParameterValueRange(VdpDevice device
, VdpVideoMixerParameter parameter
,
350 void *min_value
, void *max_value
)
352 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
353 struct pipe_screen
*screen
;
354 enum pipe_video_profile prof
= PIPE_VIDEO_PROFILE_UNKNOWN
;
356 return VDP_STATUS_INVALID_HANDLE
;
357 if (!(min_value
&& max_value
))
358 return VDP_STATUS_INVALID_POINTER
;
359 screen
= dev
->vscreen
->pscreen
;
361 case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH
:
362 *(uint32_t*)min_value
= 48;
363 *(uint32_t*)max_value
= screen
->get_video_param(screen
, prof
, PIPE_VIDEO_CAP_MAX_WIDTH
);
365 case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT
:
366 *(uint32_t*)min_value
= 48;
367 *(uint32_t*)max_value
= screen
->get_video_param(screen
, prof
, PIPE_VIDEO_CAP_MAX_HEIGHT
);
370 case VDP_VIDEO_MIXER_PARAMETER_LAYERS
:
371 *(uint32_t*)min_value
= 0;
372 *(uint32_t*)max_value
= 4;
375 case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE
:
377 return VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER
;
379 return VDP_STATUS_OK
;
383 * Query the implementation's support for a specific attribute.
386 vlVdpVideoMixerQueryAttributeSupport(VdpDevice device
, VdpVideoMixerAttribute attribute
,
387 VdpBool
*is_supported
)
390 return VDP_STATUS_INVALID_POINTER
;
393 case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR
:
394 case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX
:
395 case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL
:
396 case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL
:
397 case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA
:
398 case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA
:
399 case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE
:
400 *is_supported
= VDP_TRUE
;
403 *is_supported
= VDP_FALSE
;
405 return VDP_STATUS_OK
;
409 * Query the implementation's supported for a specific attribute.
412 vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device
, VdpVideoMixerAttribute attribute
,
413 void *min_value
, void *max_value
)
415 if (!(min_value
&& max_value
))
416 return VDP_STATUS_INVALID_POINTER
;
419 case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL
:
420 case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA
:
421 case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA
:
422 *(float*)min_value
= 0.f
;
423 *(float*)max_value
= 1.f
;
425 case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL
:
426 *(float*)min_value
= -1.f
;
427 *(float*)max_value
= 1.f
;
429 case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE
:
430 *(uint8_t*)min_value
= 0;
431 *(uint8_t*)max_value
= 1;
433 case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR
:
434 case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX
:
436 return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE
;
438 return VDP_STATUS_OK
;