query.c revision 3d769619e2937cb4f2a036e82b396d9e53d65ba8
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#include "vdpau_private.h" 29#include <vl_winsys.h> 30#include <assert.h> 31#include <pipe/p_screen.h> 32#include <pipe/p_defines.h> 33#include <math.h> 34#include <util/u_debug.h> 35 36 37VdpStatus 38vlVdpGetApiVersion(uint32_t *api_version) 39{ 40 if (!api_version) 41 return VDP_STATUS_INVALID_POINTER; 42 43 *api_version = 1; 44 return VDP_STATUS_OK; 45} 46 47VdpStatus 48vlVdpGetInformationString(char const **information_string) 49{ 50 if (!information_string) 51 return VDP_STATUS_INVALID_POINTER; 52 53 *information_string = INFORMATION_STRING; 54 return VDP_STATUS_OK; 55} 56 57VdpStatus 58vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, 59 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) 60{ 61 struct vl_screen *vlscreen; 62 uint32_t max_2d_texture_level; 63 VdpStatus ret; 64 65 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying video surfaces\n"); 66 67 if (!(is_supported && max_width && max_height)) 68 return VDP_STATUS_INVALID_POINTER; 69 70 vlVdpDevice *dev = vlGetDataHTAB(device); 71 if (!dev) 72 return VDP_STATUS_INVALID_HANDLE; 73 74 vlscreen = vl_screen_create(dev->display, dev->screen); 75 if (!vlscreen) 76 return VDP_STATUS_RESOURCES; 77 78 /* XXX: Current limits */ 79 *is_supported = true; 80 if (surface_chroma_type != VDP_CHROMA_TYPE_420) { 81 *is_supported = false; 82 goto no_sup; 83 } 84 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; 88 goto no_sup; 89 } 90 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); 93 94 vl_screen_destroy(vlscreen); 95 96 return VDP_STATUS_OK; 97 no_sup: 98 return ret; 99} 100 101VdpStatus 102vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, 103 VdpYCbCrFormat bits_ycbcr_format, 104 VdpBool *is_supported) 105{ 106 struct vl_screen *vlscreen; 107 108 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying get put video surfaces\n"); 109 110 if (!is_supported) 111 return VDP_STATUS_INVALID_POINTER; 112 113 vlVdpDevice *dev = vlGetDataHTAB(device); 114 if (!dev) 115 return VDP_STATUS_INVALID_HANDLE; 116 117 vlscreen = vl_screen_create(dev->display, dev->screen); 118 if (!vlscreen) 119 return VDP_STATUS_RESOURCES; 120 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 FormatYCBCRToPipe(bits_ycbcr_format), 124 PIPE_TEXTURE_2D, 125 1, 126 PIPE_BIND_RENDER_TARGET); 127 128 vl_screen_destroy(vlscreen); 129 130 return VDP_STATUS_OK; 131} 132 133VdpStatus 134vlVdpDecoderQueryCapabilities(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) 137{ 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; 143 144 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying decoder\n"); 145 146 if (!(is_supported && max_level && max_macroblocks && max_width && max_height)) 147 return VDP_STATUS_INVALID_POINTER; 148 149 vlVdpDevice *dev = vlGetDataHTAB(device); 150 if (!dev) 151 return VDP_STATUS_INVALID_HANDLE; 152 153 vlscreen = vl_screen_create(dev->display, dev->screen); 154 if (!vlscreen) 155 return VDP_STATUS_RESOURCES; 156 157 p_profile = ProfileToPipe(profile); 158 if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) { 159 *is_supported = false; 160 return VDP_STATUS_OK; 161 } 162 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; 166 } 167 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; 173 174 *is_supported = true; 175 *max_width = max_decode_width; 176 *max_height = max_decode_height; 177 *max_level = 16; 178 *max_macroblocks = (max_decode_width/16) * (max_decode_height/16); 179 180 vl_screen_destroy(vlscreen); 181 182 return VDP_STATUS_OK; 183} 184 185VdpStatus 186vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 187 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) 188{ 189 if (!(is_supported && max_width && max_height)) 190 return VDP_STATUS_INVALID_POINTER; 191 192 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying ouput surfaces\n"); 193 194 return VDP_STATUS_NO_IMPLEMENTATION; 195} 196 197VdpStatus 198vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 199 VdpBool *is_supported) 200{ 201 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put native cap\n"); 202 203 if (!is_supported) 204 return VDP_STATUS_INVALID_POINTER; 205 206 return VDP_STATUS_NO_IMPLEMENTATION; 207} 208 209VdpStatus 210vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device, 211 VdpRGBAFormat surface_rgba_format, 212 VdpIndexedFormat bits_indexed_format, 213 VdpColorTableFormat color_table_format, 214 VdpBool *is_supported) 215{ 216 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put indexed cap\n"); 217 218 if (!is_supported) 219 return VDP_STATUS_INVALID_POINTER; 220 221 return VDP_STATUS_NO_IMPLEMENTATION; 222} 223 224VdpStatus 225vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 226 VdpYCbCrFormat bits_ycbcr_format, 227 VdpBool *is_supported) 228{ 229 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces put ycrcb cap\n"); 230 if (!is_supported) 231 return VDP_STATUS_INVALID_POINTER; 232 233 return VDP_STATUS_NO_IMPLEMENTATION; 234} 235 236VdpStatus 237vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 238 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) 239{ 240 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying bitmap surfaces\n"); 241 if (!(is_supported && max_width && max_height)) 242 return VDP_STATUS_INVALID_POINTER; 243 244 return VDP_STATUS_NO_IMPLEMENTATION; 245} 246 247VdpStatus 248vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature, 249 VdpBool *is_supported) 250{ 251 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying mixer feature support\n"); 252 if (!is_supported) 253 return VDP_STATUS_INVALID_POINTER; 254 255 return VDP_STATUS_NO_IMPLEMENTATION; 256} 257 258VdpStatus 259vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter, 260 VdpBool *is_supported) 261{ 262 if (!is_supported) 263 return VDP_STATUS_INVALID_POINTER; 264 265 return VDP_STATUS_NO_IMPLEMENTATION; 266} 267 268VdpStatus 269vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter, 270 void *min_value, void *max_value) 271{ 272 if (!(min_value && max_value)) 273 return VDP_STATUS_INVALID_POINTER; 274 275 return VDP_STATUS_NO_IMPLEMENTATION; 276} 277 278VdpStatus 279vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute, 280 VdpBool *is_supported) 281{ 282 if (!is_supported) 283 return VDP_STATUS_INVALID_POINTER; 284 285 return VDP_STATUS_NO_IMPLEMENTATION; 286} 287 288VdpStatus 289vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute, 290 void *min_value, void *max_value) 291{ 292 if (!(min_value && max_value)) 293 return VDP_STATUS_INVALID_POINTER; 294 295 return VDP_STATUS_NO_IMPLEMENTATION; 296} 297