query.c revision 725e4ada3062c80623abf51477dfdc73fe294f3f
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 35 36VdpStatus 37vlVdpGetApiVersion(uint32_t *api_version) 38{ 39 if (!api_version) 40 return VDP_STATUS_INVALID_POINTER; 41 42 *api_version = 1; 43 return VDP_STATUS_OK; 44} 45 46VdpStatus 47vlVdpGetInformationString(char const **information_string) 48{ 49 if (!information_string) 50 return VDP_STATUS_INVALID_POINTER; 51 52 *information_string = INFORMATION_STRING; 53 return VDP_STATUS_OK; 54} 55 56VdpStatus 57vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, 58 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) 59{ 60 struct vl_screen *vlscreen; 61 uint32_t max_2d_texture_level; 62 VdpStatus ret; 63 64 if (!(is_supported && max_width && max_height)) 65 return VDP_STATUS_INVALID_POINTER; 66 67 vlVdpDevice *dev = vlGetDataHTAB(device); 68 if (!dev) 69 return VDP_STATUS_INVALID_HANDLE; 70 71 vlscreen = vl_screen_create(dev->display, dev->screen); 72 if (!vlscreen) 73 return VDP_STATUS_RESOURCES; 74 75 /* XXX: Current limits */ 76 *is_supported = true; 77 if (surface_chroma_type != VDP_CHROMA_TYPE_420) { 78 *is_supported = false; 79 goto no_sup; 80 } 81 82 max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS ); 83 if (!max_2d_texture_level) { 84 ret = VDP_STATUS_RESOURCES; 85 goto no_sup; 86 } 87 88 /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */ 89 *max_width = *max_height = pow(2,max_2d_texture_level-1); 90 91 vl_screen_destroy(vlscreen); 92 93 return VDP_STATUS_OK; 94 no_sup: 95 return ret; 96} 97 98VdpStatus 99vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, 100 VdpYCbCrFormat bits_ycbcr_format, 101 VdpBool *is_supported) 102{ 103 struct vl_screen *vlscreen; 104 105 if (!is_supported) 106 return VDP_STATUS_INVALID_POINTER; 107 108 vlVdpDevice *dev = vlGetDataHTAB(device); 109 if (!dev) 110 return VDP_STATUS_INVALID_HANDLE; 111 112 vlscreen = vl_screen_create(dev->display, dev->screen); 113 if (!vlscreen) 114 return VDP_STATUS_RESOURCES; 115 116 if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8) 117 *is_supported = vlscreen->pscreen->is_format_supported(vlscreen->pscreen, 118 FormatToPipe(bits_ycbcr_format), 119 PIPE_TEXTURE_2D, 120 PIPE_BIND_RENDER_TARGET, 121 PIPE_TEXTURE_GEOM_NON_SQUARE ); 122 123 vl_screen_destroy(vlscreen); 124 125 return VDP_STATUS_OK; 126} 127 128VdpStatus 129vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, 130 VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks, 131 uint32_t *max_width, uint32_t *max_height) 132{ 133 enum pipe_video_profile p_profile; 134 uint32_t max_decode_width; 135 uint32_t max_decode_height; 136 uint32_t max_2d_texture_level; 137 struct vl_screen *vlscreen; 138 139 if (!(is_supported && max_level && max_macroblocks && max_width && max_height)) 140 return VDP_STATUS_INVALID_POINTER; 141 142 vlVdpDevice *dev = vlGetDataHTAB(device); 143 if (!dev) 144 return VDP_STATUS_INVALID_HANDLE; 145 146 vlscreen = vl_screen_create(dev->display, dev->screen); 147 if (!vlscreen) 148 return VDP_STATUS_RESOURCES; 149 150 p_profile = ProfileToPipe(profile); 151 if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) { 152 *is_supported = false; 153 return VDP_STATUS_OK; 154 } 155 156 if (p_profile != PIPE_VIDEO_PROFILE_MPEG2_SIMPLE && p_profile != PIPE_VIDEO_PROFILE_MPEG2_MAIN) { 157 *is_supported = false; 158 return VDP_STATUS_OK; 159 } 160 161 /* XXX hack, need to implement something more sane when the decoders have been implemented */ 162 max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS ); 163 max_decode_width = max_decode_height = pow(2,max_2d_texture_level-2); 164 if (!(max_decode_width && max_decode_height)) 165 return VDP_STATUS_RESOURCES; 166 167 *is_supported = true; 168 *max_width = max_decode_width; 169 *max_height = max_decode_height; 170 *max_level = 16; 171 *max_macroblocks = (max_decode_width/16) * (max_decode_height/16); 172 173 vl_screen_destroy(vlscreen); 174 175 return VDP_STATUS_OK; 176} 177 178VdpStatus 179vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 180 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) 181{ 182 if (!(is_supported && max_width && max_height)) 183 return VDP_STATUS_INVALID_POINTER; 184 185 return VDP_STATUS_NO_IMPLEMENTATION; 186} 187 188VdpStatus 189vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 190 VdpBool *is_supported) 191{ 192 if (!is_supported) 193 return VDP_STATUS_INVALID_POINTER; 194 195 return VDP_STATUS_NO_IMPLEMENTATION; 196} 197 198VdpStatus 199vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 200 VdpYCbCrFormat bits_ycbcr_format, 201 VdpBool *is_supported) 202{ 203 if (!is_supported) 204 return VDP_STATUS_INVALID_POINTER; 205 206 return VDP_STATUS_NO_IMPLEMENTATION; 207} 208 209VdpStatus 210vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, 211 VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) 212{ 213 if (!(is_supported && max_width && max_height)) 214 return VDP_STATUS_INVALID_POINTER; 215 216 return VDP_STATUS_NO_IMPLEMENTATION; 217} 218 219VdpStatus 220vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature, 221 VdpBool *is_supported) 222{ 223 if (!is_supported) 224 return VDP_STATUS_INVALID_POINTER; 225 226 return VDP_STATUS_NO_IMPLEMENTATION; 227} 228 229VdpStatus 230vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter, 231 VdpBool *is_supported) 232{ 233 if (!is_supported) 234 return VDP_STATUS_INVALID_POINTER; 235 236 return VDP_STATUS_NO_IMPLEMENTATION; 237} 238 239VdpStatus 240vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter, 241 void *min_value, void *max_value) 242{ 243 if (!(min_value && max_value)) 244 return VDP_STATUS_INVALID_POINTER; 245 246 return VDP_STATUS_NO_IMPLEMENTATION; 247} 248 249VdpStatus 250vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute, 251 VdpBool *is_supported) 252{ 253 if (!is_supported) 254 return VDP_STATUS_INVALID_POINTER; 255 256 return VDP_STATUS_NO_IMPLEMENTATION; 257} 258 259VdpStatus 260vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute, 261 void *min_value, void *max_value) 262{ 263 if (!(min_value && max_value)) 264 return VDP_STATUS_INVALID_POINTER; 265 266 return VDP_STATUS_NO_IMPLEMENTATION; 267} 268