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