query.c revision efc7fda4627919b5355952d955ee4a2c98505e56
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   enum pipe_video_profile p_profile;
132
133   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying decoder\n");
134
135   if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
136      return VDP_STATUS_INVALID_POINTER;
137
138   dev = vlGetDataHTAB(device);
139   if (!dev)
140      return VDP_STATUS_INVALID_HANDLE;
141
142   pscreen = dev->vscreen->pscreen;
143   if (!pscreen)
144      return VDP_STATUS_RESOURCES;
145
146   p_profile = ProfileToPipe(profile);
147   if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN)	{
148      *is_supported = false;
149      return VDP_STATUS_OK;
150   }
151
152   *is_supported = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_SUPPORTED);
153   if (*is_supported) {
154      *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_WIDTH);
155      *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_HEIGHT);
156      *max_level = 16;
157      *max_macroblocks = (*max_width/16)*(*max_height/16);
158   } else {
159      *max_width = 0;
160      *max_height = 0;
161      *max_level = 0;
162      *max_macroblocks = 0;
163   }
164
165   return VDP_STATUS_OK;
166}
167
168VdpStatus
169vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
170                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
171{
172   if (!(is_supported && max_width && max_height))
173      return VDP_STATUS_INVALID_POINTER;
174
175   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying ouput surfaces\n");
176
177   return VDP_STATUS_NO_IMPLEMENTATION;
178}
179
180VdpStatus
181vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
182                                                    VdpBool *is_supported)
183{
184   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put native cap\n");
185
186   if (!is_supported)
187      return VDP_STATUS_INVALID_POINTER;
188
189   return VDP_STATUS_NO_IMPLEMENTATION;
190}
191
192VdpStatus
193vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
194                                                  VdpRGBAFormat surface_rgba_format,
195                                                  VdpIndexedFormat bits_indexed_format,
196                                                  VdpColorTableFormat color_table_format,
197                                                  VdpBool *is_supported)
198{
199   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put indexed cap\n");
200
201   if (!is_supported)
202      return VDP_STATUS_INVALID_POINTER;
203
204   return VDP_STATUS_NO_IMPLEMENTATION;
205}
206
207VdpStatus
208vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
209                                                VdpYCbCrFormat bits_ycbcr_format,
210                                                VdpBool *is_supported)
211{
212   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces put ycrcb cap\n");
213   if (!is_supported)
214      return VDP_STATUS_INVALID_POINTER;
215
216   return VDP_STATUS_NO_IMPLEMENTATION;
217}
218
219VdpStatus
220vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
221                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
222{
223   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying bitmap surfaces\n");
224   if (!(is_supported && max_width && max_height))
225      return VDP_STATUS_INVALID_POINTER;
226
227   return VDP_STATUS_NO_IMPLEMENTATION;
228}
229
230VdpStatus
231vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
232                                   VdpBool *is_supported)
233{
234   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying mixer feature support\n");
235   if (!is_supported)
236      return VDP_STATUS_INVALID_POINTER;
237
238   return VDP_STATUS_NO_IMPLEMENTATION;
239}
240
241VdpStatus
242vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
243                                     VdpBool *is_supported)
244{
245   if (!is_supported)
246      return VDP_STATUS_INVALID_POINTER;
247
248   return VDP_STATUS_NO_IMPLEMENTATION;
249}
250
251VdpStatus
252vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
253                                        void *min_value, void *max_value)
254{
255   if (!(min_value && max_value))
256      return VDP_STATUS_INVALID_POINTER;
257
258   return VDP_STATUS_NO_IMPLEMENTATION;
259}
260
261VdpStatus
262vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
263                                     VdpBool *is_supported)
264{
265   if (!is_supported)
266      return VDP_STATUS_INVALID_POINTER;
267
268   return VDP_STATUS_NO_IMPLEMENTATION;
269}
270
271VdpStatus
272vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
273                                        void *min_value, void *max_value)
274{
275   if (!(min_value && max_value))
276      return VDP_STATUS_INVALID_POINTER;
277
278   return VDP_STATUS_NO_IMPLEMENTATION;
279}
280