query.c revision cd4f18089e44872ce9e3c04ac5e808a7204ffc49
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   vlVdpDevice *dev;
62   struct pipe_screen *pscreen;
63   uint32_t max_2d_texture_level;
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   dev = vlGetDataHTAB(device);
71   if (!dev)
72      return VDP_STATUS_INVALID_HANDLE;
73
74   pscreen = dev->vscreen->pscreen;
75   if (!pscreen)
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
83   max_2d_texture_level = pscreen->get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
84   if (!max_2d_texture_level)
85      return VDP_STATUS_RESOURCES;
86
87   /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
88   *max_width = *max_height = pow(2,max_2d_texture_level-1);
89
90   return VDP_STATUS_OK;
91}
92
93VdpStatus
94vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
95                                                  VdpYCbCrFormat bits_ycbcr_format,
96                                                  VdpBool *is_supported)
97{
98   vlVdpDevice *dev;
99   struct pipe_screen *pscreen;
100
101   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying get put video surfaces\n");
102
103   if (!is_supported)
104      return VDP_STATUS_INVALID_POINTER;
105
106   dev = vlGetDataHTAB(device);
107   if (!dev)
108      return VDP_STATUS_INVALID_HANDLE;
109
110   pscreen = dev->vscreen->pscreen;
111   if (!pscreen)
112      return VDP_STATUS_RESOURCES;
113
114   *is_supported = pscreen->is_video_format_supported
115   (
116      pscreen,
117      FormatYCBCRToPipe(bits_ycbcr_format),
118      PIPE_VIDEO_PROFILE_UNKNOWN
119   );
120
121   return VDP_STATUS_OK;
122}
123
124VdpStatus
125vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
126                              VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
127                              uint32_t *max_width, uint32_t *max_height)
128{
129   vlVdpDevice *dev;
130   struct pipe_screen *pscreen;
131
132   enum pipe_video_profile p_profile;
133   uint32_t max_decode_width;
134   uint32_t max_decode_height;
135   uint32_t max_2d_texture_level;
136
137   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying decoder\n");
138
139   if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
140      return VDP_STATUS_INVALID_POINTER;
141
142   dev = vlGetDataHTAB(device);
143   if (!dev)
144      return VDP_STATUS_INVALID_HANDLE;
145
146   pscreen = dev->vscreen->pscreen;
147   if (!pscreen)
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 = pscreen->get_param(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   return VDP_STATUS_OK;
174}
175
176VdpStatus
177vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
178                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
179{
180   if (!(is_supported && max_width && max_height))
181      return VDP_STATUS_INVALID_POINTER;
182
183   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying ouput surfaces\n");
184
185   return VDP_STATUS_NO_IMPLEMENTATION;
186}
187
188VdpStatus
189vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
190                                                    VdpBool *is_supported)
191{
192   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put native cap\n");
193
194   if (!is_supported)
195      return VDP_STATUS_INVALID_POINTER;
196
197   return VDP_STATUS_NO_IMPLEMENTATION;
198}
199
200VdpStatus
201vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
202                                                  VdpRGBAFormat surface_rgba_format,
203                                                  VdpIndexedFormat bits_indexed_format,
204                                                  VdpColorTableFormat color_table_format,
205                                                  VdpBool *is_supported)
206{
207   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put indexed cap\n");
208
209   if (!is_supported)
210      return VDP_STATUS_INVALID_POINTER;
211
212   return VDP_STATUS_NO_IMPLEMENTATION;
213}
214
215VdpStatus
216vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
217                                                VdpYCbCrFormat bits_ycbcr_format,
218                                                VdpBool *is_supported)
219{
220   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces put ycrcb cap\n");
221   if (!is_supported)
222      return VDP_STATUS_INVALID_POINTER;
223
224   return VDP_STATUS_NO_IMPLEMENTATION;
225}
226
227VdpStatus
228vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
229                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
230{
231   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying bitmap surfaces\n");
232   if (!(is_supported && max_width && max_height))
233      return VDP_STATUS_INVALID_POINTER;
234
235   return VDP_STATUS_NO_IMPLEMENTATION;
236}
237
238VdpStatus
239vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
240                                   VdpBool *is_supported)
241{
242   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying mixer feature support\n");
243   if (!is_supported)
244      return VDP_STATUS_INVALID_POINTER;
245
246   return VDP_STATUS_NO_IMPLEMENTATION;
247}
248
249VdpStatus
250vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
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
260vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
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
269VdpStatus
270vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
271                                     VdpBool *is_supported)
272{
273   if (!is_supported)
274      return VDP_STATUS_INVALID_POINTER;
275
276   return VDP_STATUS_NO_IMPLEMENTATION;
277}
278
279VdpStatus
280vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
281                                        void *min_value, void *max_value)
282{
283   if (!(min_value && max_value))
284      return VDP_STATUS_INVALID_POINTER;
285
286   return VDP_STATUS_NO_IMPLEMENTATION;
287}
288