query.c revision d64d6f7712e5e8d8f962de3455a71fce8b2a8f78
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   debug_printf("[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	debug_printf("[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                                   FormatToPipe(bits_ycbcr_format),
124                                   PIPE_TEXTURE_2D,
125								   1,
126                                   PIPE_BIND_RENDER_TARGET,
127                                   PIPE_TEXTURE_GEOM_NON_SQUARE );
128
129   vl_screen_destroy(vlscreen);
130
131   return VDP_STATUS_OK;
132}
133
134VdpStatus
135vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
136                              VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
137                              uint32_t *max_width, uint32_t *max_height)
138{
139   enum pipe_video_profile p_profile;
140   uint32_t max_decode_width;
141   uint32_t max_decode_height;
142   uint32_t max_2d_texture_level;
143   struct vl_screen *vlscreen;
144
145   debug_printf("[VDPAU] Querying decoder\n");
146
147   if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
148      return VDP_STATUS_INVALID_POINTER;
149
150   vlVdpDevice *dev = vlGetDataHTAB(device);
151   if (!dev)
152      return VDP_STATUS_INVALID_HANDLE;
153
154   vlscreen = vl_screen_create(dev->display, dev->screen);
155   if (!vlscreen)
156      return VDP_STATUS_RESOURCES;
157
158   p_profile = ProfileToPipe(profile);
159   if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN)	{
160	   *is_supported = false;
161	   return VDP_STATUS_OK;
162   }
163
164   if (p_profile != PIPE_VIDEO_PROFILE_MPEG2_SIMPLE && p_profile != PIPE_VIDEO_PROFILE_MPEG2_MAIN)  {
165	   *is_supported = false;
166	   return VDP_STATUS_OK;
167   }
168
169   /* XXX hack, need to implement something more sane when the decoders have been implemented */
170   max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS );
171   max_decode_width = max_decode_height = pow(2,max_2d_texture_level-2);
172   if (!(max_decode_width && max_decode_height))
173      return VDP_STATUS_RESOURCES;
174
175   *is_supported = true;
176   *max_width = max_decode_width;
177   *max_height = max_decode_height;
178   *max_level = 16;
179   *max_macroblocks = (max_decode_width/16) * (max_decode_height/16);
180
181   vl_screen_destroy(vlscreen);
182
183   return VDP_STATUS_OK;
184}
185
186VdpStatus
187vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
188                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
189{
190   if (!(is_supported && max_width && max_height))
191      return VDP_STATUS_INVALID_POINTER;
192
193   debug_printf("[VDPAU] Querying ouput surfaces\n");
194
195   return VDP_STATUS_NO_IMPLEMENTATION;
196}
197
198VdpStatus
199vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
200                                                    VdpBool *is_supported)
201{
202   debug_printf("[VDPAU] Querying output surfaces get put native cap\n");
203
204   if (!is_supported)
205      return VDP_STATUS_INVALID_POINTER;
206
207   return VDP_STATUS_NO_IMPLEMENTATION;
208}
209
210VdpStatus
211vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
212                                                VdpYCbCrFormat bits_ycbcr_format,
213                                                VdpBool *is_supported)
214{
215   debug_printf("[VDPAU] Querying output surfaces put ycrcb cap\n");
216   if (!is_supported)
217      return VDP_STATUS_INVALID_POINTER;
218
219   return VDP_STATUS_NO_IMPLEMENTATION;
220}
221
222VdpStatus
223vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
224                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
225{
226   debug_printf("[VDPAU] Querying bitmap surfaces\n");
227   if (!(is_supported && max_width && max_height))
228      return VDP_STATUS_INVALID_POINTER;
229
230   return VDP_STATUS_NO_IMPLEMENTATION;
231}
232
233VdpStatus
234vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
235                                   VdpBool *is_supported)
236{
237   debug_printf("[VDPAU] Querying mixer feature support\n");
238   if (!is_supported)
239      return VDP_STATUS_INVALID_POINTER;
240
241   return VDP_STATUS_NO_IMPLEMENTATION;
242}
243
244VdpStatus
245vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
246                                     VdpBool *is_supported)
247{
248   if (!is_supported)
249      return VDP_STATUS_INVALID_POINTER;
250
251   return VDP_STATUS_NO_IMPLEMENTATION;
252}
253
254VdpStatus
255vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
256                                        void *min_value, void *max_value)
257{
258   if (!(min_value && max_value))
259      return VDP_STATUS_INVALID_POINTER;
260
261   return VDP_STATUS_NO_IMPLEMENTATION;
262}
263
264VdpStatus
265vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
266                                     VdpBool *is_supported)
267{
268   if (!is_supported)
269      return VDP_STATUS_INVALID_POINTER;
270
271   return VDP_STATUS_NO_IMPLEMENTATION;
272}
273
274VdpStatus
275vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
276                                        void *min_value, void *max_value)
277{
278   if (!(min_value && max_value))
279      return VDP_STATUS_INVALID_POINTER;
280
281   return VDP_STATUS_NO_IMPLEMENTATION;
282}
283