hardware/intel/common/libva
修訂 | 61785ae8eead50bfe785b5cbaacf42a49e1d0fd3 (tree) |
---|---|
時間 | 2017-06-05 17:52:23 |
作者 | Xiang, Haihao <haihao.xiang@inte...> |
Commiter | Xiang, Haihao |
Remove the dummy driver
No one is interested in this dummy driver and it is not maintained.
This fixes https://github.com/01org/libva/issues/28
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
@@ -24,7 +24,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} | ||
24 | 24 | |
25 | 25 | AUTOMAKE_OPTIONS = foreign |
26 | 26 | |
27 | -SUBDIRS = va dummy_drv_video pkgconfig doc | |
27 | +SUBDIRS = va pkgconfig doc | |
28 | 28 | |
29 | 29 | # Extra clean files so that maintainer-clean removes *everything* |
30 | 30 | MAINTAINERCLEANFILES = \ |
@@ -158,12 +158,6 @@ AC_ARG_ENABLE([va-messaging], | ||
158 | 158 | [build with va info and error messaging @<:@default=yes@:>@])], |
159 | 159 | [], [enable_va_messaging="yes"]) |
160 | 160 | |
161 | -AC_ARG_ENABLE(dummy-driver, | |
162 | - [AC_HELP_STRING([--enable-dummy-driver], | |
163 | - [build dummy video driver @<:@default=yes@:>@])], | |
164 | - [], [enable_dummy_driver="yes"]) | |
165 | -AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) | |
166 | - | |
167 | 161 | AC_ARG_WITH(drivers-path, |
168 | 162 | [AC_HELP_STRING([--with-drivers-path=[[path]]], |
169 | 163 | [drivers path])], |
@@ -311,15 +305,9 @@ if test "$USE_DRM:$USE_X11:$USE_WAYLAND" = "no:no:no"; then | ||
311 | 305 | AC_MSG_ERROR([Please select at least one backend (DRM, X11, Wayland)]) |
312 | 306 | fi |
313 | 307 | |
314 | -# Define __vaDriverInit*() function name for dummy backend | |
315 | -VA_DRIVER_INIT_FUNC="__vaDriverInit_${VA_API_MAJOR_VERSION}_${VA_API_MINOR_VERSION}" | |
316 | -AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC], [$VA_DRIVER_INIT_FUNC], | |
317 | - [Defined to the versioned __vaDriverInit function name]) | |
318 | - | |
319 | 308 | AC_OUTPUT([ |
320 | 309 | Makefile |
321 | 310 | doc/Makefile |
322 | - dummy_drv_video/Makefile | |
323 | 311 | pkgconfig/Makefile |
324 | 312 | pkgconfig/libva-drm.pc |
325 | 313 | pkgconfig/libva-egl.pc |
@@ -351,7 +339,6 @@ echo | ||
351 | 339 | echo Installation prefix .............. : $prefix |
352 | 340 | echo Default driver path .............. : $LIBVA_DRIVERS_PATH |
353 | 341 | echo Extra window systems ............. : $BACKENDS |
354 | -echo Build dummy driver ............... : $enable_dummy_driver | |
355 | 342 | echo Build documentation .............. : $enable_docs |
356 | 343 | echo Build with messaging ............. : $enable_va_messaging |
357 | 344 | echo |
@@ -1,33 +0,0 @@ | ||
1 | -# Copyright (c) 2007 Intel Corporation. All Rights Reserved. | |
2 | -# | |
3 | -# Permission is hereby granted, free of charge, to any person obtaining a | |
4 | -# copy of this software and associated documentation files (the | |
5 | -# "Software"), to deal in the Software without restriction, including | |
6 | -# without limitation the rights to use, copy, modify, merge, publish, | |
7 | -# distribute, sub license, and/or sell copies of the Software, and to | |
8 | -# permit persons to whom the Software is furnished to do so, subject to | |
9 | -# the following conditions: | |
10 | -# | |
11 | -# The above copyright notice and this permission notice (including the | |
12 | -# next paragraph) shall be included in all copies or substantial portions | |
13 | -# of the Software. | |
14 | -# | |
15 | -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 | -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
17 | -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | |
18 | -# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR | |
19 | -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
20 | -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
21 | -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
22 | - | |
23 | -AM_CPPFLAGS = -I$(top_srcdir) | |
24 | - | |
25 | -if BUILD_DUMMY_DRIVER | |
26 | -dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la | |
27 | -dummy_drv_video_ladir = $(LIBVA_DRIVERS_PATH) | |
28 | -dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined | |
29 | -dummy_drv_video_la_LIBADD = | |
30 | -dummy_drv_video_la_DEPENDENCIES = | |
31 | -dummy_drv_video_la_SOURCES = dummy_drv_video.c object_heap.c | |
32 | -noinst_HEADERS = dummy_drv_video.h object_heap.h | |
33 | -endif |
@@ -1,1232 +0,0 @@ | ||
1 | -/* | |
2 | - * Copyright (c) 2007 Intel Corporation. All Rights Reserved. | |
3 | - * | |
4 | - * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | - * copy of this software and associated documentation files (the | |
6 | - * "Software"), to deal in the Software without restriction, including | |
7 | - * without limitation the rights to use, copy, modify, merge, publish, | |
8 | - * distribute, sub license, and/or sell copies of the Software, and to | |
9 | - * permit persons to whom the Software is furnished to do so, subject to | |
10 | - * the following conditions: | |
11 | - * | |
12 | - * The above copyright notice and this permission notice (including the | |
13 | - * next paragraph) shall be included in all copies or substantial portions | |
14 | - * of the Software. | |
15 | - * | |
16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
17 | - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | |
19 | - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR | |
20 | - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
21 | - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
22 | - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | - */ | |
24 | - | |
25 | -#include "config.h" | |
26 | -#include <va/va_backend.h> | |
27 | - | |
28 | -#include "dummy_drv_video.h" | |
29 | - | |
30 | -#include "assert.h" | |
31 | -#include <stdio.h> | |
32 | -#include <stdlib.h> | |
33 | -#include <string.h> | |
34 | -#include <stdarg.h> | |
35 | - | |
36 | -#define ASSERT assert | |
37 | - | |
38 | -#define INIT_DRIVER_DATA struct dummy_driver_data * const driver_data = (struct dummy_driver_data *) ctx->pDriverData; | |
39 | - | |
40 | -#define CONFIG(id) ((object_config_p) object_heap_lookup( &driver_data->config_heap, id )) | |
41 | -#define CONTEXT(id) ((object_context_p) object_heap_lookup( &driver_data->context_heap, id )) | |
42 | -#define SURFACE(id) ((object_surface_p) object_heap_lookup( &driver_data->surface_heap, id )) | |
43 | -#define BUFFER(id) ((object_buffer_p) object_heap_lookup( &driver_data->buffer_heap, id )) | |
44 | - | |
45 | -#define CONFIG_ID_OFFSET 0x01000000 | |
46 | -#define CONTEXT_ID_OFFSET 0x02000000 | |
47 | -#define SURFACE_ID_OFFSET 0x04000000 | |
48 | -#define BUFFER_ID_OFFSET 0x08000000 | |
49 | - | |
50 | -static void dummy__error_message(const char *msg, ...) | |
51 | -{ | |
52 | - va_list args; | |
53 | - | |
54 | - fprintf(stderr, "dummy_drv_video error: "); | |
55 | - va_start(args, msg); | |
56 | - vfprintf(stderr, msg, args); | |
57 | - va_end(args); | |
58 | -} | |
59 | - | |
60 | -static void dummy__information_message(const char *msg, ...) | |
61 | -{ | |
62 | - va_list args; | |
63 | - | |
64 | - fprintf(stderr, "dummy_drv_video: "); | |
65 | - va_start(args, msg); | |
66 | - vfprintf(stderr, msg, args); | |
67 | - va_end(args); | |
68 | -} | |
69 | - | |
70 | -VAStatus dummy_QueryConfigProfiles( | |
71 | - VADriverContextP ctx, | |
72 | - VAProfile *profile_list, /* out */ | |
73 | - int *num_profiles /* out */ | |
74 | - ) | |
75 | -{ | |
76 | - int i = 0; | |
77 | - | |
78 | - profile_list[i++] = VAProfileMPEG2Simple; | |
79 | - profile_list[i++] = VAProfileMPEG2Main; | |
80 | - profile_list[i++] = VAProfileMPEG4Simple; | |
81 | - profile_list[i++] = VAProfileMPEG4AdvancedSimple; | |
82 | - profile_list[i++] = VAProfileMPEG4Main; | |
83 | - profile_list[i++] = VAProfileH264Baseline; | |
84 | - profile_list[i++] = VAProfileH264Main; | |
85 | - profile_list[i++] = VAProfileH264High; | |
86 | - profile_list[i++] = VAProfileVC1Simple; | |
87 | - profile_list[i++] = VAProfileVC1Main; | |
88 | - profile_list[i++] = VAProfileVC1Advanced; | |
89 | - | |
90 | - /* If the assert fails then DUMMY_MAX_PROFILES needs to be bigger */ | |
91 | - ASSERT(i <= DUMMY_MAX_PROFILES); | |
92 | - *num_profiles = i; | |
93 | - | |
94 | - return VA_STATUS_SUCCESS; | |
95 | -} | |
96 | - | |
97 | -VAStatus dummy_QueryConfigEntrypoints( | |
98 | - VADriverContextP ctx, | |
99 | - VAProfile profile, | |
100 | - VAEntrypoint *entrypoint_list, /* out */ | |
101 | - int *num_entrypoints /* out */ | |
102 | - ) | |
103 | -{ | |
104 | - switch (profile) { | |
105 | - case VAProfileMPEG2Simple: | |
106 | - case VAProfileMPEG2Main: | |
107 | - *num_entrypoints = 2; | |
108 | - entrypoint_list[0] = VAEntrypointVLD; | |
109 | - entrypoint_list[1] = VAEntrypointMoComp; | |
110 | - break; | |
111 | - | |
112 | - case VAProfileMPEG4Simple: | |
113 | - case VAProfileMPEG4AdvancedSimple: | |
114 | - case VAProfileMPEG4Main: | |
115 | - *num_entrypoints = 1; | |
116 | - entrypoint_list[0] = VAEntrypointVLD; | |
117 | - break; | |
118 | - | |
119 | - case VAProfileH264Baseline: | |
120 | - case VAProfileH264Main: | |
121 | - case VAProfileH264High: | |
122 | - *num_entrypoints = 1; | |
123 | - entrypoint_list[0] = VAEntrypointVLD; | |
124 | - break; | |
125 | - | |
126 | - case VAProfileVC1Simple: | |
127 | - case VAProfileVC1Main: | |
128 | - case VAProfileVC1Advanced: | |
129 | - *num_entrypoints = 1; | |
130 | - entrypoint_list[0] = VAEntrypointVLD; | |
131 | - break; | |
132 | - | |
133 | - default: | |
134 | - *num_entrypoints = 0; | |
135 | - break; | |
136 | - } | |
137 | - | |
138 | - /* If the assert fails then DUMMY_MAX_ENTRYPOINTS needs to be bigger */ | |
139 | - ASSERT(*num_entrypoints <= DUMMY_MAX_ENTRYPOINTS); | |
140 | - return VA_STATUS_SUCCESS; | |
141 | -} | |
142 | - | |
143 | -VAStatus dummy_GetConfigAttributes( | |
144 | - VADriverContextP ctx, | |
145 | - VAProfile profile, | |
146 | - VAEntrypoint entrypoint, | |
147 | - VAConfigAttrib *attrib_list, /* in/out */ | |
148 | - int num_attribs | |
149 | - ) | |
150 | -{ | |
151 | - int i; | |
152 | - | |
153 | - /* Other attributes don't seem to be defined */ | |
154 | - /* What to do if we don't know the attribute? */ | |
155 | - for (i = 0; i < num_attribs; i++) | |
156 | - { | |
157 | - switch (attrib_list[i].type) | |
158 | - { | |
159 | - case VAConfigAttribRTFormat: | |
160 | - attrib_list[i].value = VA_RT_FORMAT_YUV420; | |
161 | - break; | |
162 | - | |
163 | - default: | |
164 | - /* Do nothing */ | |
165 | - attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; | |
166 | - break; | |
167 | - } | |
168 | - } | |
169 | - | |
170 | - return VA_STATUS_SUCCESS; | |
171 | -} | |
172 | - | |
173 | -static VAStatus dummy__update_attribute(object_config_p obj_config, VAConfigAttrib *attrib) | |
174 | -{ | |
175 | - int i; | |
176 | - /* Check existing attrbiutes */ | |
177 | - for(i = 0; obj_config->attrib_count < i; i++) | |
178 | - { | |
179 | - if (obj_config->attrib_list[i].type == attrib->type) | |
180 | - { | |
181 | - /* Update existing attribute */ | |
182 | - obj_config->attrib_list[i].value = attrib->value; | |
183 | - return VA_STATUS_SUCCESS; | |
184 | - } | |
185 | - } | |
186 | - if (obj_config->attrib_count < DUMMY_MAX_CONFIG_ATTRIBUTES) | |
187 | - { | |
188 | - i = obj_config->attrib_count; | |
189 | - obj_config->attrib_list[i].type = attrib->type; | |
190 | - obj_config->attrib_list[i].value = attrib->value; | |
191 | - obj_config->attrib_count++; | |
192 | - return VA_STATUS_SUCCESS; | |
193 | - } | |
194 | - return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; | |
195 | -} | |
196 | - | |
197 | -VAStatus dummy_CreateConfig( | |
198 | - VADriverContextP ctx, | |
199 | - VAProfile profile, | |
200 | - VAEntrypoint entrypoint, | |
201 | - VAConfigAttrib *attrib_list, | |
202 | - int num_attribs, | |
203 | - VAConfigID *config_id /* out */ | |
204 | - ) | |
205 | -{ | |
206 | - INIT_DRIVER_DATA | |
207 | - VAStatus vaStatus; | |
208 | - int configID; | |
209 | - object_config_p obj_config; | |
210 | - int i; | |
211 | - | |
212 | - /* Validate profile & entrypoint */ | |
213 | - switch (profile) { | |
214 | - case VAProfileMPEG2Simple: | |
215 | - case VAProfileMPEG2Main: | |
216 | - if ((VAEntrypointVLD == entrypoint) || | |
217 | - (VAEntrypointMoComp == entrypoint)) | |
218 | - { | |
219 | - vaStatus = VA_STATUS_SUCCESS; | |
220 | - } | |
221 | - else | |
222 | - { | |
223 | - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; | |
224 | - } | |
225 | - break; | |
226 | - | |
227 | - case VAProfileMPEG4Simple: | |
228 | - case VAProfileMPEG4AdvancedSimple: | |
229 | - case VAProfileMPEG4Main: | |
230 | - if (VAEntrypointVLD == entrypoint) | |
231 | - { | |
232 | - vaStatus = VA_STATUS_SUCCESS; | |
233 | - } | |
234 | - else | |
235 | - { | |
236 | - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; | |
237 | - } | |
238 | - break; | |
239 | - | |
240 | - case VAProfileH264Baseline: | |
241 | - case VAProfileH264Main: | |
242 | - case VAProfileH264High: | |
243 | - if (VAEntrypointVLD == entrypoint) | |
244 | - { | |
245 | - vaStatus = VA_STATUS_SUCCESS; | |
246 | - } | |
247 | - else | |
248 | - { | |
249 | - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; | |
250 | - } | |
251 | - break; | |
252 | - | |
253 | - case VAProfileVC1Simple: | |
254 | - case VAProfileVC1Main: | |
255 | - case VAProfileVC1Advanced: | |
256 | - if (VAEntrypointVLD == entrypoint) | |
257 | - { | |
258 | - vaStatus = VA_STATUS_SUCCESS; | |
259 | - } | |
260 | - else | |
261 | - { | |
262 | - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; | |
263 | - } | |
264 | - break; | |
265 | - | |
266 | - default: | |
267 | - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; | |
268 | - break; | |
269 | - } | |
270 | - | |
271 | - if (VA_STATUS_SUCCESS != vaStatus) | |
272 | - { | |
273 | - return vaStatus; | |
274 | - } | |
275 | - | |
276 | - configID = object_heap_allocate( &driver_data->config_heap ); | |
277 | - obj_config = CONFIG(configID); | |
278 | - if (NULL == obj_config) | |
279 | - { | |
280 | - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
281 | - return vaStatus; | |
282 | - } | |
283 | - | |
284 | - obj_config->profile = profile; | |
285 | - obj_config->entrypoint = entrypoint; | |
286 | - obj_config->attrib_list[0].type = VAConfigAttribRTFormat; | |
287 | - obj_config->attrib_list[0].value = VA_RT_FORMAT_YUV420; | |
288 | - obj_config->attrib_count = 1; | |
289 | - | |
290 | - for(i = 0; i < num_attribs; i++) | |
291 | - { | |
292 | - vaStatus = dummy__update_attribute(obj_config, &(attrib_list[i])); | |
293 | - if (VA_STATUS_SUCCESS != vaStatus) | |
294 | - { | |
295 | - break; | |
296 | - } | |
297 | - } | |
298 | - | |
299 | - /* Error recovery */ | |
300 | - if (VA_STATUS_SUCCESS != vaStatus) | |
301 | - { | |
302 | - object_heap_free( &driver_data->config_heap, (object_base_p) obj_config); | |
303 | - } | |
304 | - else | |
305 | - { | |
306 | - *config_id = configID; | |
307 | - } | |
308 | - | |
309 | - return vaStatus; | |
310 | -} | |
311 | - | |
312 | -VAStatus dummy_DestroyConfig( | |
313 | - VADriverContextP ctx, | |
314 | - VAConfigID config_id | |
315 | - ) | |
316 | -{ | |
317 | - INIT_DRIVER_DATA | |
318 | - VAStatus vaStatus; | |
319 | - object_config_p obj_config; | |
320 | - | |
321 | - obj_config = CONFIG(config_id); | |
322 | - if (NULL == obj_config) | |
323 | - { | |
324 | - vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; | |
325 | - return vaStatus; | |
326 | - } | |
327 | - | |
328 | - object_heap_free( &driver_data->config_heap, (object_base_p) obj_config); | |
329 | - return VA_STATUS_SUCCESS; | |
330 | -} | |
331 | - | |
332 | -VAStatus dummy_QueryConfigAttributes( | |
333 | - VADriverContextP ctx, | |
334 | - VAConfigID config_id, | |
335 | - VAProfile *profile, /* out */ | |
336 | - VAEntrypoint *entrypoint, /* out */ | |
337 | - VAConfigAttrib *attrib_list, /* out */ | |
338 | - int *num_attribs /* out */ | |
339 | - ) | |
340 | -{ | |
341 | - INIT_DRIVER_DATA | |
342 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
343 | - object_config_p obj_config; | |
344 | - int i; | |
345 | - | |
346 | - obj_config = CONFIG(config_id); | |
347 | - ASSERT(obj_config); | |
348 | - | |
349 | - *profile = obj_config->profile; | |
350 | - *entrypoint = obj_config->entrypoint; | |
351 | - *num_attribs = obj_config->attrib_count; | |
352 | - for(i = 0; i < obj_config->attrib_count; i++) | |
353 | - { | |
354 | - attrib_list[i] = obj_config->attrib_list[i]; | |
355 | - } | |
356 | - | |
357 | - return vaStatus; | |
358 | -} | |
359 | - | |
360 | -VAStatus dummy_CreateSurfaces( | |
361 | - VADriverContextP ctx, | |
362 | - int width, | |
363 | - int height, | |
364 | - int format, | |
365 | - int num_surfaces, | |
366 | - VASurfaceID *surfaces /* out */ | |
367 | - ) | |
368 | -{ | |
369 | - INIT_DRIVER_DATA | |
370 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
371 | - int i; | |
372 | - | |
373 | - /* We only support one format */ | |
374 | - if (VA_RT_FORMAT_YUV420 != format) | |
375 | - { | |
376 | - return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; | |
377 | - } | |
378 | - | |
379 | - for (i = 0; i < num_surfaces; i++) | |
380 | - { | |
381 | - int surfaceID = object_heap_allocate( &driver_data->surface_heap ); | |
382 | - object_surface_p obj_surface = SURFACE(surfaceID); | |
383 | - if (NULL == obj_surface) | |
384 | - { | |
385 | - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
386 | - break; | |
387 | - } | |
388 | - obj_surface->surface_id = surfaceID; | |
389 | - surfaces[i] = surfaceID; | |
390 | - } | |
391 | - | |
392 | - /* Error recovery */ | |
393 | - if (VA_STATUS_SUCCESS != vaStatus) | |
394 | - { | |
395 | - /* surfaces[i-1] was the last successful allocation */ | |
396 | - for(; i--; ) | |
397 | - { | |
398 | - object_surface_p obj_surface = SURFACE(surfaces[i]); | |
399 | - surfaces[i] = VA_INVALID_SURFACE; | |
400 | - ASSERT(obj_surface); | |
401 | - object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); | |
402 | - } | |
403 | - } | |
404 | - | |
405 | - return vaStatus; | |
406 | -} | |
407 | - | |
408 | -VAStatus dummy_DestroySurfaces( | |
409 | - VADriverContextP ctx, | |
410 | - VASurfaceID *surface_list, | |
411 | - int num_surfaces | |
412 | - ) | |
413 | -{ | |
414 | - INIT_DRIVER_DATA | |
415 | - int i; | |
416 | - for(i = num_surfaces; i--; ) | |
417 | - { | |
418 | - object_surface_p obj_surface = SURFACE(surface_list[i]); | |
419 | - ASSERT(obj_surface); | |
420 | - object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); | |
421 | - } | |
422 | - return VA_STATUS_SUCCESS; | |
423 | -} | |
424 | - | |
425 | -VAStatus dummy_QueryImageFormats( | |
426 | - VADriverContextP ctx, | |
427 | - VAImageFormat *format_list, /* out */ | |
428 | - int *num_formats /* out */ | |
429 | -) | |
430 | -{ | |
431 | - /* TODO */ | |
432 | - return VA_STATUS_SUCCESS; | |
433 | -} | |
434 | - | |
435 | -VAStatus dummy_CreateImage( | |
436 | - VADriverContextP ctx, | |
437 | - VAImageFormat *format, | |
438 | - int width, | |
439 | - int height, | |
440 | - VAImage *image /* out */ | |
441 | -) | |
442 | -{ | |
443 | - /* TODO */ | |
444 | - return VA_STATUS_SUCCESS; | |
445 | -} | |
446 | - | |
447 | -VAStatus dummy_DeriveImage( | |
448 | - VADriverContextP ctx, | |
449 | - VASurfaceID surface, | |
450 | - VAImage *image /* out */ | |
451 | -) | |
452 | -{ | |
453 | - /* TODO */ | |
454 | - return VA_STATUS_SUCCESS; | |
455 | -} | |
456 | - | |
457 | -VAStatus dummy_DestroyImage( | |
458 | - VADriverContextP ctx, | |
459 | - VAImageID image | |
460 | -) | |
461 | -{ | |
462 | - /* TODO */ | |
463 | - return VA_STATUS_SUCCESS; | |
464 | -} | |
465 | - | |
466 | -VAStatus dummy_SetImagePalette( | |
467 | - VADriverContextP ctx, | |
468 | - VAImageID image, | |
469 | - unsigned char *palette | |
470 | -) | |
471 | -{ | |
472 | - /* TODO */ | |
473 | - return VA_STATUS_SUCCESS; | |
474 | -} | |
475 | - | |
476 | -VAStatus dummy_GetImage( | |
477 | - VADriverContextP ctx, | |
478 | - VASurfaceID surface, | |
479 | - int x, /* coordinates of the upper left source pixel */ | |
480 | - int y, | |
481 | - unsigned int width, /* width and height of the region */ | |
482 | - unsigned int height, | |
483 | - VAImageID image | |
484 | -) | |
485 | -{ | |
486 | - /* TODO */ | |
487 | - return VA_STATUS_SUCCESS; | |
488 | -} | |
489 | - | |
490 | - | |
491 | -VAStatus dummy_PutImage( | |
492 | - VADriverContextP ctx, | |
493 | - VASurfaceID surface, | |
494 | - VAImageID image, | |
495 | - int src_x, | |
496 | - int src_y, | |
497 | - unsigned int src_width, | |
498 | - unsigned int src_height, | |
499 | - int dest_x, | |
500 | - int dest_y, | |
501 | - unsigned int dest_width, | |
502 | - unsigned int dest_height | |
503 | -) | |
504 | -{ | |
505 | - /* TODO */ | |
506 | - return VA_STATUS_SUCCESS; | |
507 | -} | |
508 | - | |
509 | -VAStatus dummy_QuerySubpictureFormats( | |
510 | - VADriverContextP ctx, | |
511 | - VAImageFormat *format_list, /* out */ | |
512 | - unsigned int *flags, /* out */ | |
513 | - unsigned int *num_formats /* out */ | |
514 | -) | |
515 | -{ | |
516 | - /* TODO */ | |
517 | - return VA_STATUS_SUCCESS; | |
518 | -} | |
519 | - | |
520 | -VAStatus dummy_CreateSubpicture( | |
521 | - VADriverContextP ctx, | |
522 | - VAImageID image, | |
523 | - VASubpictureID *subpicture /* out */ | |
524 | -) | |
525 | -{ | |
526 | - /* TODO */ | |
527 | - return VA_STATUS_SUCCESS; | |
528 | -} | |
529 | - | |
530 | -VAStatus dummy_DestroySubpicture( | |
531 | - VADriverContextP ctx, | |
532 | - VASubpictureID subpicture | |
533 | -) | |
534 | -{ | |
535 | - /* TODO */ | |
536 | - return VA_STATUS_SUCCESS; | |
537 | -} | |
538 | - | |
539 | -VAStatus dummy_SetSubpictureImage( | |
540 | - VADriverContextP ctx, | |
541 | - VASubpictureID subpicture, | |
542 | - VAImageID image | |
543 | -) | |
544 | -{ | |
545 | - /* TODO */ | |
546 | - return VA_STATUS_SUCCESS; | |
547 | -} | |
548 | - | |
549 | -VAStatus dummy_SetSubpicturePalette( | |
550 | - VADriverContextP ctx, | |
551 | - VASubpictureID subpicture, | |
552 | - /* | |
553 | - * pointer to an array holding the palette data. The size of the array is | |
554 | - * num_palette_entries * entry_bytes in size. The order of the components | |
555 | - * in the palette is described by the component_order in VASubpicture struct | |
556 | - */ | |
557 | - unsigned char *palette | |
558 | -) | |
559 | -{ | |
560 | - /* TODO */ | |
561 | - return VA_STATUS_SUCCESS; | |
562 | -} | |
563 | - | |
564 | -VAStatus dummy_SetSubpictureChromakey( | |
565 | - VADriverContextP ctx, | |
566 | - VASubpictureID subpicture, | |
567 | - unsigned int chromakey_min, | |
568 | - unsigned int chromakey_max, | |
569 | - unsigned int chromakey_mask | |
570 | -) | |
571 | -{ | |
572 | - /* TODO */ | |
573 | - return VA_STATUS_SUCCESS; | |
574 | -} | |
575 | - | |
576 | -VAStatus dummy_SetSubpictureGlobalAlpha( | |
577 | - VADriverContextP ctx, | |
578 | - VASubpictureID subpicture, | |
579 | - float global_alpha | |
580 | -) | |
581 | -{ | |
582 | - /* TODO */ | |
583 | - return VA_STATUS_SUCCESS; | |
584 | -} | |
585 | - | |
586 | - | |
587 | -VAStatus dummy_AssociateSubpicture( | |
588 | - VADriverContextP ctx, | |
589 | - VASubpictureID subpicture, | |
590 | - VASurfaceID *target_surfaces, | |
591 | - int num_surfaces, | |
592 | - short src_x, /* upper left offset in subpicture */ | |
593 | - short src_y, | |
594 | - unsigned short src_width, | |
595 | - unsigned short src_height, | |
596 | - short dest_x, /* upper left offset in surface */ | |
597 | - short dest_y, | |
598 | - unsigned short dest_width, | |
599 | - unsigned short dest_height, | |
600 | - /* | |
601 | - * whether to enable chroma-keying or global-alpha | |
602 | - * see VA_SUBPICTURE_XXX values | |
603 | - */ | |
604 | - unsigned int flags | |
605 | -) | |
606 | -{ | |
607 | - /* TODO */ | |
608 | - return VA_STATUS_SUCCESS; | |
609 | -} | |
610 | - | |
611 | -VAStatus dummy_DeassociateSubpicture( | |
612 | - VADriverContextP ctx, | |
613 | - VASubpictureID subpicture, | |
614 | - VASurfaceID *target_surfaces, | |
615 | - int num_surfaces | |
616 | -) | |
617 | -{ | |
618 | - /* TODO */ | |
619 | - return VA_STATUS_SUCCESS; | |
620 | -} | |
621 | - | |
622 | -VAStatus dummy_CreateContext( | |
623 | - VADriverContextP ctx, | |
624 | - VAConfigID config_id, | |
625 | - int picture_width, | |
626 | - int picture_height, | |
627 | - int flag, | |
628 | - VASurfaceID *render_targets, | |
629 | - int num_render_targets, | |
630 | - VAContextID *context /* out */ | |
631 | - ) | |
632 | -{ | |
633 | - INIT_DRIVER_DATA | |
634 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
635 | - object_config_p obj_config; | |
636 | - int i; | |
637 | - | |
638 | - obj_config = CONFIG(config_id); | |
639 | - if (NULL == obj_config) | |
640 | - { | |
641 | - vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; | |
642 | - return vaStatus; | |
643 | - } | |
644 | - | |
645 | - /* Validate flag */ | |
646 | - /* Validate picture dimensions */ | |
647 | - | |
648 | - int contextID = object_heap_allocate( &driver_data->context_heap ); | |
649 | - object_context_p obj_context = CONTEXT(contextID); | |
650 | - if (NULL == obj_context) | |
651 | - { | |
652 | - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
653 | - return vaStatus; | |
654 | - } | |
655 | - | |
656 | - obj_context->context_id = contextID; | |
657 | - *context = contextID; | |
658 | - obj_context->current_render_target = -1; | |
659 | - obj_context->config_id = config_id; | |
660 | - obj_context->picture_width = picture_width; | |
661 | - obj_context->picture_height = picture_height; | |
662 | - obj_context->num_render_targets = num_render_targets; | |
663 | - obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID)); | |
664 | - if (obj_context->render_targets == NULL) | |
665 | - { | |
666 | - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
667 | - return vaStatus; | |
668 | - } | |
669 | - | |
670 | - for(i = 0; i < num_render_targets; i++) | |
671 | - { | |
672 | - if (NULL == SURFACE(render_targets[i])) | |
673 | - { | |
674 | - vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; | |
675 | - break; | |
676 | - } | |
677 | - obj_context->render_targets[i] = render_targets[i]; | |
678 | - } | |
679 | - obj_context->flags = flag; | |
680 | - | |
681 | - /* Error recovery */ | |
682 | - if (VA_STATUS_SUCCESS != vaStatus) | |
683 | - { | |
684 | - obj_context->context_id = -1; | |
685 | - obj_context->config_id = -1; | |
686 | - free(obj_context->render_targets); | |
687 | - obj_context->render_targets = NULL; | |
688 | - obj_context->num_render_targets = 0; | |
689 | - obj_context->flags = 0; | |
690 | - object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); | |
691 | - } | |
692 | - | |
693 | - return vaStatus; | |
694 | -} | |
695 | - | |
696 | - | |
697 | -VAStatus dummy_DestroyContext( | |
698 | - VADriverContextP ctx, | |
699 | - VAContextID context | |
700 | - ) | |
701 | -{ | |
702 | - INIT_DRIVER_DATA | |
703 | - object_context_p obj_context = CONTEXT(context); | |
704 | - ASSERT(obj_context); | |
705 | - | |
706 | - obj_context->context_id = -1; | |
707 | - obj_context->config_id = -1; | |
708 | - obj_context->picture_width = 0; | |
709 | - obj_context->picture_height = 0; | |
710 | - if (obj_context->render_targets) | |
711 | - { | |
712 | - free(obj_context->render_targets); | |
713 | - } | |
714 | - obj_context->render_targets = NULL; | |
715 | - obj_context->num_render_targets = 0; | |
716 | - obj_context->flags = 0; | |
717 | - | |
718 | - obj_context->current_render_target = -1; | |
719 | - | |
720 | - object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); | |
721 | - | |
722 | - return VA_STATUS_SUCCESS; | |
723 | -} | |
724 | - | |
725 | - | |
726 | - | |
727 | -static VAStatus dummy__allocate_buffer(object_buffer_p obj_buffer, int size) | |
728 | -{ | |
729 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
730 | - | |
731 | - obj_buffer->buffer_data = realloc(obj_buffer->buffer_data, size); | |
732 | - if (NULL == obj_buffer->buffer_data) | |
733 | - { | |
734 | - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
735 | - } | |
736 | - return vaStatus; | |
737 | -} | |
738 | - | |
739 | -VAStatus dummy_CreateBuffer( | |
740 | - VADriverContextP ctx, | |
741 | - VAContextID context, /* in */ | |
742 | - VABufferType type, /* in */ | |
743 | - unsigned int size, /* in */ | |
744 | - unsigned int num_elements, /* in */ | |
745 | - void *data, /* in */ | |
746 | - VABufferID *buf_id /* out */ | |
747 | -) | |
748 | -{ | |
749 | - INIT_DRIVER_DATA | |
750 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
751 | - int bufferID; | |
752 | - object_buffer_p obj_buffer; | |
753 | - | |
754 | - /* Validate type */ | |
755 | - switch (type) | |
756 | - { | |
757 | - case VAPictureParameterBufferType: | |
758 | - case VAIQMatrixBufferType: | |
759 | - case VABitPlaneBufferType: | |
760 | - case VASliceGroupMapBufferType: | |
761 | - case VASliceParameterBufferType: | |
762 | - case VASliceDataBufferType: | |
763 | - case VAMacroblockParameterBufferType: | |
764 | - case VAResidualDataBufferType: | |
765 | - case VADeblockingParameterBufferType: | |
766 | - case VAImageBufferType: | |
767 | - /* Ok */ | |
768 | - break; | |
769 | - default: | |
770 | - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; | |
771 | - return vaStatus; | |
772 | - } | |
773 | - | |
774 | - bufferID = object_heap_allocate( &driver_data->buffer_heap ); | |
775 | - obj_buffer = BUFFER(bufferID); | |
776 | - if (NULL == obj_buffer) | |
777 | - { | |
778 | - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
779 | - return vaStatus; | |
780 | - } | |
781 | - | |
782 | - obj_buffer->buffer_data = NULL; | |
783 | - | |
784 | - vaStatus = dummy__allocate_buffer(obj_buffer, size * num_elements); | |
785 | - if (VA_STATUS_SUCCESS == vaStatus) | |
786 | - { | |
787 | - obj_buffer->max_num_elements = num_elements; | |
788 | - obj_buffer->num_elements = num_elements; | |
789 | - if (data) | |
790 | - { | |
791 | - memcpy(obj_buffer->buffer_data, data, size * num_elements); | |
792 | - } | |
793 | - } | |
794 | - | |
795 | - if (VA_STATUS_SUCCESS == vaStatus) | |
796 | - { | |
797 | - *buf_id = bufferID; | |
798 | - } | |
799 | - | |
800 | - return vaStatus; | |
801 | -} | |
802 | - | |
803 | - | |
804 | -VAStatus dummy_BufferSetNumElements( | |
805 | - VADriverContextP ctx, | |
806 | - VABufferID buf_id, /* in */ | |
807 | - unsigned int num_elements /* in */ | |
808 | - ) | |
809 | -{ | |
810 | - INIT_DRIVER_DATA | |
811 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
812 | - object_buffer_p obj_buffer = BUFFER(buf_id); | |
813 | - ASSERT(obj_buffer); | |
814 | - | |
815 | - if ((num_elements < 0) || (num_elements > obj_buffer->max_num_elements)) | |
816 | - { | |
817 | - vaStatus = VA_STATUS_ERROR_UNKNOWN; | |
818 | - } | |
819 | - if (VA_STATUS_SUCCESS == vaStatus) | |
820 | - { | |
821 | - obj_buffer->num_elements = num_elements; | |
822 | - } | |
823 | - | |
824 | - return vaStatus; | |
825 | -} | |
826 | - | |
827 | -VAStatus dummy_MapBuffer( | |
828 | - VADriverContextP ctx, | |
829 | - VABufferID buf_id, /* in */ | |
830 | - void **pbuf /* out */ | |
831 | - ) | |
832 | -{ | |
833 | - INIT_DRIVER_DATA | |
834 | - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; | |
835 | - object_buffer_p obj_buffer = BUFFER(buf_id); | |
836 | - ASSERT(obj_buffer); | |
837 | - if (NULL == obj_buffer) | |
838 | - { | |
839 | - vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; | |
840 | - return vaStatus; | |
841 | - } | |
842 | - | |
843 | - if (NULL != obj_buffer->buffer_data) | |
844 | - { | |
845 | - *pbuf = obj_buffer->buffer_data; | |
846 | - vaStatus = VA_STATUS_SUCCESS; | |
847 | - } | |
848 | - return vaStatus; | |
849 | -} | |
850 | - | |
851 | -VAStatus dummy_UnmapBuffer( | |
852 | - VADriverContextP ctx, | |
853 | - VABufferID buf_id /* in */ | |
854 | - ) | |
855 | -{ | |
856 | - /* Do nothing */ | |
857 | - return VA_STATUS_SUCCESS; | |
858 | -} | |
859 | - | |
860 | -static void dummy__destroy_buffer(struct dummy_driver_data *driver_data, object_buffer_p obj_buffer) | |
861 | -{ | |
862 | - if (NULL != obj_buffer->buffer_data) | |
863 | - { | |
864 | - free(obj_buffer->buffer_data); | |
865 | - obj_buffer->buffer_data = NULL; | |
866 | - } | |
867 | - | |
868 | - object_heap_free( &driver_data->buffer_heap, (object_base_p) obj_buffer); | |
869 | -} | |
870 | - | |
871 | -VAStatus dummy_DestroyBuffer( | |
872 | - VADriverContextP ctx, | |
873 | - VABufferID buffer_id | |
874 | - ) | |
875 | -{ | |
876 | - INIT_DRIVER_DATA | |
877 | - object_buffer_p obj_buffer = BUFFER(buffer_id); | |
878 | - ASSERT(obj_buffer); | |
879 | - | |
880 | - dummy__destroy_buffer(driver_data, obj_buffer); | |
881 | - return VA_STATUS_SUCCESS; | |
882 | -} | |
883 | - | |
884 | -VAStatus dummy_BeginPicture( | |
885 | - VADriverContextP ctx, | |
886 | - VAContextID context, | |
887 | - VASurfaceID render_target | |
888 | - ) | |
889 | -{ | |
890 | - INIT_DRIVER_DATA | |
891 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
892 | - object_context_p obj_context; | |
893 | - object_surface_p obj_surface; | |
894 | - | |
895 | - obj_context = CONTEXT(context); | |
896 | - ASSERT(obj_context); | |
897 | - | |
898 | - obj_surface = SURFACE(render_target); | |
899 | - ASSERT(obj_surface); | |
900 | - | |
901 | - obj_context->current_render_target = obj_surface->base.id; | |
902 | - | |
903 | - return vaStatus; | |
904 | -} | |
905 | - | |
906 | -VAStatus dummy_RenderPicture( | |
907 | - VADriverContextP ctx, | |
908 | - VAContextID context, | |
909 | - VABufferID *buffers, | |
910 | - int num_buffers | |
911 | - ) | |
912 | -{ | |
913 | - INIT_DRIVER_DATA | |
914 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
915 | - object_context_p obj_context; | |
916 | - object_surface_p obj_surface; | |
917 | - int i; | |
918 | - | |
919 | - obj_context = CONTEXT(context); | |
920 | - ASSERT(obj_context); | |
921 | - | |
922 | - obj_surface = SURFACE(obj_context->current_render_target); | |
923 | - ASSERT(obj_surface); | |
924 | - | |
925 | - /* verify that we got valid buffer references */ | |
926 | - for(i = 0; i < num_buffers; i++) | |
927 | - { | |
928 | - object_buffer_p obj_buffer = BUFFER(buffers[i]); | |
929 | - ASSERT(obj_buffer); | |
930 | - if (NULL == obj_buffer) | |
931 | - { | |
932 | - vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; | |
933 | - break; | |
934 | - } | |
935 | - } | |
936 | - | |
937 | - /* Release buffers */ | |
938 | - for(i = 0; i < num_buffers; i++) | |
939 | - { | |
940 | - object_buffer_p obj_buffer = BUFFER(buffers[i]); | |
941 | - ASSERT(obj_buffer); | |
942 | - dummy__destroy_buffer(driver_data, obj_buffer); | |
943 | - } | |
944 | - | |
945 | - return vaStatus; | |
946 | -} | |
947 | - | |
948 | -VAStatus dummy_EndPicture( | |
949 | - VADriverContextP ctx, | |
950 | - VAContextID context | |
951 | - ) | |
952 | -{ | |
953 | - INIT_DRIVER_DATA | |
954 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
955 | - object_context_p obj_context; | |
956 | - object_surface_p obj_surface; | |
957 | - | |
958 | - obj_context = CONTEXT(context); | |
959 | - ASSERT(obj_context); | |
960 | - | |
961 | - obj_surface = SURFACE(obj_context->current_render_target); | |
962 | - ASSERT(obj_surface); | |
963 | - | |
964 | - // For now, assume that we are done with rendering right away | |
965 | - obj_context->current_render_target = -1; | |
966 | - | |
967 | - return vaStatus; | |
968 | -} | |
969 | - | |
970 | - | |
971 | -VAStatus dummy_SyncSurface( | |
972 | - VADriverContextP ctx, | |
973 | - VASurfaceID render_target | |
974 | - ) | |
975 | -{ | |
976 | - INIT_DRIVER_DATA | |
977 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
978 | - object_surface_p obj_surface; | |
979 | - | |
980 | - obj_surface = SURFACE(render_target); | |
981 | - ASSERT(obj_surface); | |
982 | - | |
983 | - return vaStatus; | |
984 | -} | |
985 | - | |
986 | -VAStatus dummy_QuerySurfaceStatus( | |
987 | - VADriverContextP ctx, | |
988 | - VASurfaceID render_target, | |
989 | - VASurfaceStatus *status /* out */ | |
990 | - ) | |
991 | -{ | |
992 | - INIT_DRIVER_DATA | |
993 | - VAStatus vaStatus = VA_STATUS_SUCCESS; | |
994 | - object_surface_p obj_surface; | |
995 | - | |
996 | - obj_surface = SURFACE(render_target); | |
997 | - ASSERT(obj_surface); | |
998 | - | |
999 | - *status = VASurfaceReady; | |
1000 | - | |
1001 | - return vaStatus; | |
1002 | -} | |
1003 | - | |
1004 | -VAStatus dummy_PutSurface( | |
1005 | - VADriverContextP ctx, | |
1006 | - VASurfaceID surface, | |
1007 | - void *draw, /* X Drawable */ | |
1008 | - short srcx, | |
1009 | - short srcy, | |
1010 | - unsigned short srcw, | |
1011 | - unsigned short srch, | |
1012 | - short destx, | |
1013 | - short desty, | |
1014 | - unsigned short destw, | |
1015 | - unsigned short desth, | |
1016 | - VARectangle *cliprects, /* client supplied clip list */ | |
1017 | - unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
1018 | - unsigned int flags /* de-interlacing flags */ | |
1019 | - ) | |
1020 | -{ | |
1021 | - /* TODO */ | |
1022 | - return VA_STATUS_ERROR_UNKNOWN; | |
1023 | -} | |
1024 | - | |
1025 | -/* | |
1026 | - * Query display attributes | |
1027 | - * The caller must provide a "attr_list" array that can hold at | |
1028 | - * least vaMaxNumDisplayAttributes() entries. The actual number of attributes | |
1029 | - * returned in "attr_list" is returned in "num_attributes". | |
1030 | - */ | |
1031 | -VAStatus dummy_QueryDisplayAttributes ( | |
1032 | - VADriverContextP ctx, | |
1033 | - VADisplayAttribute *attr_list, /* out */ | |
1034 | - int *num_attributes /* out */ | |
1035 | - ) | |
1036 | -{ | |
1037 | - /* TODO */ | |
1038 | - return VA_STATUS_ERROR_UNKNOWN; | |
1039 | -} | |
1040 | - | |
1041 | -/* | |
1042 | - * Get display attributes | |
1043 | - * This function returns the current attribute values in "attr_list". | |
1044 | - * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field | |
1045 | - * from vaQueryDisplayAttributes() can have their values retrieved. | |
1046 | - */ | |
1047 | -VAStatus dummy_GetDisplayAttributes ( | |
1048 | - VADriverContextP ctx, | |
1049 | - VADisplayAttribute *attr_list, /* in/out */ | |
1050 | - int num_attributes | |
1051 | - ) | |
1052 | -{ | |
1053 | - /* TODO */ | |
1054 | - return VA_STATUS_ERROR_UNKNOWN; | |
1055 | -} | |
1056 | - | |
1057 | -/* | |
1058 | - * Set display attributes | |
1059 | - * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field | |
1060 | - * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or | |
1061 | - * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED | |
1062 | - */ | |
1063 | -VAStatus dummy_SetDisplayAttributes ( | |
1064 | - VADriverContextP ctx, | |
1065 | - VADisplayAttribute *attr_list, | |
1066 | - int num_attributes | |
1067 | - ) | |
1068 | -{ | |
1069 | - /* TODO */ | |
1070 | - return VA_STATUS_ERROR_UNKNOWN; | |
1071 | -} | |
1072 | - | |
1073 | - | |
1074 | -VAStatus dummy_BufferInfo( | |
1075 | - VADriverContextP ctx, | |
1076 | - VABufferID buf_id, /* in */ | |
1077 | - VABufferType *type, /* out */ | |
1078 | - unsigned int *size, /* out */ | |
1079 | - unsigned int *num_elements /* out */ | |
1080 | - ) | |
1081 | -{ | |
1082 | - /* TODO */ | |
1083 | - return VA_STATUS_ERROR_UNIMPLEMENTED; | |
1084 | -} | |
1085 | - | |
1086 | - | |
1087 | - | |
1088 | -VAStatus dummy_LockSurface( | |
1089 | - VADriverContextP ctx, | |
1090 | - VASurfaceID surface, | |
1091 | - unsigned int *fourcc, /* following are output argument */ | |
1092 | - unsigned int *luma_stride, | |
1093 | - unsigned int *chroma_u_stride, | |
1094 | - unsigned int *chroma_v_stride, | |
1095 | - unsigned int *luma_offset, | |
1096 | - unsigned int *chroma_u_offset, | |
1097 | - unsigned int *chroma_v_offset, | |
1098 | - unsigned int *buffer_name, | |
1099 | - void **buffer | |
1100 | - ) | |
1101 | -{ | |
1102 | - /* TODO */ | |
1103 | - return VA_STATUS_ERROR_UNIMPLEMENTED; | |
1104 | -} | |
1105 | - | |
1106 | -VAStatus dummy_UnlockSurface( | |
1107 | - VADriverContextP ctx, | |
1108 | - VASurfaceID surface | |
1109 | - ) | |
1110 | -{ | |
1111 | - /* TODO */ | |
1112 | - return VA_STATUS_ERROR_UNIMPLEMENTED; | |
1113 | -} | |
1114 | - | |
1115 | -VAStatus dummy_Terminate( VADriverContextP ctx ) | |
1116 | -{ | |
1117 | - INIT_DRIVER_DATA | |
1118 | - object_buffer_p obj_buffer; | |
1119 | - object_config_p obj_config; | |
1120 | - object_heap_iterator iter; | |
1121 | - | |
1122 | - /* Clean up left over buffers */ | |
1123 | - obj_buffer = (object_buffer_p) object_heap_first( &driver_data->buffer_heap, &iter); | |
1124 | - while (obj_buffer) | |
1125 | - { | |
1126 | - dummy__information_message("vaTerminate: bufferID %08x still allocated, destroying\n", obj_buffer->base.id); | |
1127 | - dummy__destroy_buffer(driver_data, obj_buffer); | |
1128 | - obj_buffer = (object_buffer_p) object_heap_next( &driver_data->buffer_heap, &iter); | |
1129 | - } | |
1130 | - object_heap_destroy( &driver_data->buffer_heap ); | |
1131 | - | |
1132 | - /* TODO cleanup */ | |
1133 | - object_heap_destroy( &driver_data->surface_heap ); | |
1134 | - | |
1135 | - /* TODO cleanup */ | |
1136 | - object_heap_destroy( &driver_data->context_heap ); | |
1137 | - | |
1138 | - /* Clean up configIDs */ | |
1139 | - obj_config = (object_config_p) object_heap_first( &driver_data->config_heap, &iter); | |
1140 | - while (obj_config) | |
1141 | - { | |
1142 | - object_heap_free( &driver_data->config_heap, (object_base_p) obj_config); | |
1143 | - obj_config = (object_config_p) object_heap_next( &driver_data->config_heap, &iter); | |
1144 | - } | |
1145 | - object_heap_destroy( &driver_data->config_heap ); | |
1146 | - | |
1147 | - free(ctx->pDriverData); | |
1148 | - ctx->pDriverData = NULL; | |
1149 | - | |
1150 | - return VA_STATUS_SUCCESS; | |
1151 | -} | |
1152 | - | |
1153 | -VAStatus VA_DRIVER_INIT_FUNC( VADriverContextP ctx ) | |
1154 | -{ | |
1155 | - struct VADriverVTable * const vtable = ctx->vtable; | |
1156 | - int result; | |
1157 | - struct dummy_driver_data *driver_data; | |
1158 | - | |
1159 | - ctx->version_major = VA_MAJOR_VERSION; | |
1160 | - ctx->version_minor = VA_MINOR_VERSION; | |
1161 | - ctx->max_profiles = DUMMY_MAX_PROFILES; | |
1162 | - ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS; | |
1163 | - ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES; | |
1164 | - ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS; | |
1165 | - ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS; | |
1166 | - ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES; | |
1167 | - ctx->str_vendor = DUMMY_STR_VENDOR; | |
1168 | - | |
1169 | - vtable->vaTerminate = dummy_Terminate; | |
1170 | - vtable->vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints; | |
1171 | - vtable->vaQueryConfigProfiles = dummy_QueryConfigProfiles; | |
1172 | - vtable->vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints; | |
1173 | - vtable->vaQueryConfigAttributes = dummy_QueryConfigAttributes; | |
1174 | - vtable->vaCreateConfig = dummy_CreateConfig; | |
1175 | - vtable->vaDestroyConfig = dummy_DestroyConfig; | |
1176 | - vtable->vaGetConfigAttributes = dummy_GetConfigAttributes; | |
1177 | - vtable->vaCreateSurfaces = dummy_CreateSurfaces; | |
1178 | - vtable->vaDestroySurfaces = dummy_DestroySurfaces; | |
1179 | - vtable->vaCreateContext = dummy_CreateContext; | |
1180 | - vtable->vaDestroyContext = dummy_DestroyContext; | |
1181 | - vtable->vaCreateBuffer = dummy_CreateBuffer; | |
1182 | - vtable->vaBufferSetNumElements = dummy_BufferSetNumElements; | |
1183 | - vtable->vaMapBuffer = dummy_MapBuffer; | |
1184 | - vtable->vaUnmapBuffer = dummy_UnmapBuffer; | |
1185 | - vtable->vaDestroyBuffer = dummy_DestroyBuffer; | |
1186 | - vtable->vaBeginPicture = dummy_BeginPicture; | |
1187 | - vtable->vaRenderPicture = dummy_RenderPicture; | |
1188 | - vtable->vaEndPicture = dummy_EndPicture; | |
1189 | - vtable->vaSyncSurface = dummy_SyncSurface; | |
1190 | - vtable->vaQuerySurfaceStatus = dummy_QuerySurfaceStatus; | |
1191 | - vtable->vaPutSurface = dummy_PutSurface; | |
1192 | - vtable->vaQueryImageFormats = dummy_QueryImageFormats; | |
1193 | - vtable->vaCreateImage = dummy_CreateImage; | |
1194 | - vtable->vaDeriveImage = dummy_DeriveImage; | |
1195 | - vtable->vaDestroyImage = dummy_DestroyImage; | |
1196 | - vtable->vaSetImagePalette = dummy_SetImagePalette; | |
1197 | - vtable->vaGetImage = dummy_GetImage; | |
1198 | - vtable->vaPutImage = dummy_PutImage; | |
1199 | - vtable->vaQuerySubpictureFormats = dummy_QuerySubpictureFormats; | |
1200 | - vtable->vaCreateSubpicture = dummy_CreateSubpicture; | |
1201 | - vtable->vaDestroySubpicture = dummy_DestroySubpicture; | |
1202 | - vtable->vaSetSubpictureImage = dummy_SetSubpictureImage; | |
1203 | - vtable->vaSetSubpictureChromakey = dummy_SetSubpictureChromakey; | |
1204 | - vtable->vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha; | |
1205 | - vtable->vaAssociateSubpicture = dummy_AssociateSubpicture; | |
1206 | - vtable->vaDeassociateSubpicture = dummy_DeassociateSubpicture; | |
1207 | - vtable->vaQueryDisplayAttributes = dummy_QueryDisplayAttributes; | |
1208 | - vtable->vaGetDisplayAttributes = dummy_GetDisplayAttributes; | |
1209 | - vtable->vaSetDisplayAttributes = dummy_SetDisplayAttributes; | |
1210 | - vtable->vaLockSurface = dummy_LockSurface; | |
1211 | - vtable->vaUnlockSurface = dummy_UnlockSurface; | |
1212 | - vtable->vaBufferInfo = dummy_BufferInfo; | |
1213 | - | |
1214 | - driver_data = (struct dummy_driver_data *) malloc( sizeof(*driver_data) ); | |
1215 | - ctx->pDriverData = (void *) driver_data; | |
1216 | - | |
1217 | - result = object_heap_init( &driver_data->config_heap, sizeof(struct object_config), CONFIG_ID_OFFSET ); | |
1218 | - ASSERT( result == 0 ); | |
1219 | - | |
1220 | - result = object_heap_init( &driver_data->context_heap, sizeof(struct object_context), CONTEXT_ID_OFFSET ); | |
1221 | - ASSERT( result == 0 ); | |
1222 | - | |
1223 | - result = object_heap_init( &driver_data->surface_heap, sizeof(struct object_surface), SURFACE_ID_OFFSET ); | |
1224 | - ASSERT( result == 0 ); | |
1225 | - | |
1226 | - result = object_heap_init( &driver_data->buffer_heap, sizeof(struct object_buffer), BUFFER_ID_OFFSET ); | |
1227 | - ASSERT( result == 0 ); | |
1228 | - | |
1229 | - | |
1230 | - return VA_STATUS_SUCCESS; | |
1231 | -} | |
1232 | - |
@@ -1,83 +0,0 @@ | ||
1 | -/* | |
2 | - * Copyright (c) 2007 Intel Corporation. All Rights Reserved. | |
3 | - * | |
4 | - * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | - * copy of this software and associated documentation files (the | |
6 | - * "Software"), to deal in the Software without restriction, including | |
7 | - * without limitation the rights to use, copy, modify, merge, publish, | |
8 | - * distribute, sub license, and/or sell copies of the Software, and to | |
9 | - * permit persons to whom the Software is furnished to do so, subject to | |
10 | - * the following conditions: | |
11 | - * | |
12 | - * The above copyright notice and this permission notice (including the | |
13 | - * next paragraph) shall be included in all copies or substantial portions | |
14 | - * of the Software. | |
15 | - * | |
16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
17 | - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | |
19 | - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR | |
20 | - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
21 | - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
22 | - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | - */ | |
24 | - | |
25 | -#ifndef _DUMMY_DRV_VIDEO_H_ | |
26 | -#define _DUMMY_DRV_VIDEO_H_ | |
27 | - | |
28 | -#include <va/va.h> | |
29 | -#include "object_heap.h" | |
30 | - | |
31 | -#define DUMMY_MAX_PROFILES 11 | |
32 | -#define DUMMY_MAX_ENTRYPOINTS 5 | |
33 | -#define DUMMY_MAX_CONFIG_ATTRIBUTES 10 | |
34 | -#define DUMMY_MAX_IMAGE_FORMATS 10 | |
35 | -#define DUMMY_MAX_SUBPIC_FORMATS 4 | |
36 | -#define DUMMY_MAX_DISPLAY_ATTRIBUTES 4 | |
37 | -#define DUMMY_STR_VENDOR "Dummy Driver 1.0" | |
38 | - | |
39 | -struct dummy_driver_data { | |
40 | - struct object_heap config_heap; | |
41 | - struct object_heap context_heap; | |
42 | - struct object_heap surface_heap; | |
43 | - struct object_heap buffer_heap; | |
44 | -}; | |
45 | - | |
46 | -struct object_config { | |
47 | - struct object_base base; | |
48 | - VAProfile profile; | |
49 | - VAEntrypoint entrypoint; | |
50 | - VAConfigAttrib attrib_list[DUMMY_MAX_CONFIG_ATTRIBUTES]; | |
51 | - int attrib_count; | |
52 | -}; | |
53 | - | |
54 | -struct object_context { | |
55 | - struct object_base base; | |
56 | - VAContextID context_id; | |
57 | - VAConfigID config_id; | |
58 | - VASurfaceID current_render_target; | |
59 | - int picture_width; | |
60 | - int picture_height; | |
61 | - int num_render_targets; | |
62 | - int flags; | |
63 | - VASurfaceID *render_targets; | |
64 | -}; | |
65 | - | |
66 | -struct object_surface { | |
67 | - struct object_base base; | |
68 | - VASurfaceID surface_id; | |
69 | -}; | |
70 | - | |
71 | -struct object_buffer { | |
72 | - struct object_base base; | |
73 | - void *buffer_data; | |
74 | - int max_num_elements; | |
75 | - int num_elements; | |
76 | -}; | |
77 | - | |
78 | -typedef struct object_config *object_config_p; | |
79 | -typedef struct object_context *object_context_p; | |
80 | -typedef struct object_surface *object_surface_p; | |
81 | -typedef struct object_buffer *object_buffer_p; | |
82 | - | |
83 | -#endif /* _DUMMY_DRV_VIDEO_H_ */ |
@@ -1,267 +0,0 @@ | ||
1 | -/* | |
2 | - * Copyright (c) 2007 Intel Corporation. All Rights Reserved. | |
3 | - * | |
4 | - * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | - * copy of this software and associated documentation files (the | |
6 | - * "Software"), to deal in the Software without restriction, including | |
7 | - * without limitation the rights to use, copy, modify, merge, publish, | |
8 | - * distribute, sub license, and/or sell copies of the Software, and to | |
9 | - * permit persons to whom the Software is furnished to do so, subject to | |
10 | - * the following conditions: | |
11 | - * | |
12 | - * The above copyright notice and this permission notice (including the | |
13 | - * next paragraph) shall be included in all copies or substantial portions | |
14 | - * of the Software. | |
15 | - * | |
16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
17 | - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | |
19 | - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR | |
20 | - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
21 | - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
22 | - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | - */ | |
24 | - | |
25 | -#include <stdlib.h> | |
26 | -#include <assert.h> | |
27 | -#include "object_heap.h" | |
28 | - | |
29 | -#define ASSERT assert | |
30 | - | |
31 | -#define LAST_FREE -1 | |
32 | -#define ALLOCATED -2 | |
33 | - | |
34 | -/* | |
35 | - * Expands the heap | |
36 | - * Return 0 on success, -1 on error | |
37 | - */ | |
38 | -static int | |
39 | -object_heap_expand(object_heap_p heap) | |
40 | -{ | |
41 | - int i; | |
42 | - void *new_heap_index; | |
43 | - int next_free; | |
44 | - int new_heap_size = heap->heap_size + heap->heap_increment; | |
45 | - int bucket_index = new_heap_size / heap->heap_increment - 1; | |
46 | - | |
47 | - if (bucket_index >= heap->num_buckets) { | |
48 | - int new_num_buckets = heap->num_buckets + 8; | |
49 | - void **new_bucket; | |
50 | - | |
51 | - new_bucket = realloc(heap->bucket, new_num_buckets * sizeof(void *)); | |
52 | - if (NULL == new_bucket) { | |
53 | - return -1; | |
54 | - } | |
55 | - | |
56 | - heap->num_buckets = new_num_buckets; | |
57 | - heap->bucket = new_bucket; | |
58 | - } | |
59 | - | |
60 | - new_heap_index = (void *) malloc(heap->heap_increment * heap->object_size); | |
61 | - if (NULL == new_heap_index) { | |
62 | - return -1; /* Out of memory */ | |
63 | - } | |
64 | - | |
65 | - heap->bucket[bucket_index] = new_heap_index; | |
66 | - next_free = heap->next_free; | |
67 | - for (i = new_heap_size; i-- > heap->heap_size;) { | |
68 | - object_base_p obj = (object_base_p)(new_heap_index + (i - heap->heap_size) * heap->object_size); | |
69 | - obj->id = i + heap->id_offset; | |
70 | - obj->next_free = next_free; | |
71 | - next_free = i; | |
72 | - } | |
73 | - heap->next_free = next_free; | |
74 | - heap->heap_size = new_heap_size; | |
75 | - return 0; /* Success */ | |
76 | -} | |
77 | - | |
78 | -/* | |
79 | - * Return 0 on success, -1 on error | |
80 | - */ | |
81 | -int | |
82 | -object_heap_init(object_heap_p heap, int object_size, int id_offset) | |
83 | -{ | |
84 | - pthread_mutex_init(&heap->mutex, NULL); | |
85 | - heap->object_size = object_size; | |
86 | - heap->id_offset = id_offset & OBJECT_HEAP_OFFSET_MASK; | |
87 | - heap->heap_size = 0; | |
88 | - heap->heap_increment = 16; | |
89 | - heap->next_free = LAST_FREE; | |
90 | - heap->num_buckets = 0; | |
91 | - heap->bucket = NULL; | |
92 | - return object_heap_expand(heap); | |
93 | -} | |
94 | - | |
95 | -/* | |
96 | - * Allocates an object | |
97 | - * Returns the object ID on success, returns -1 on error | |
98 | - */ | |
99 | -static int | |
100 | -object_heap_allocate_unlocked(object_heap_p heap) | |
101 | -{ | |
102 | - object_base_p obj; | |
103 | - int bucket_index, obj_index; | |
104 | - | |
105 | - if (LAST_FREE == heap->next_free) { | |
106 | - if (-1 == object_heap_expand(heap)) { | |
107 | - return -1; /* Out of memory */ | |
108 | - } | |
109 | - } | |
110 | - ASSERT(heap->next_free >= 0); | |
111 | - | |
112 | - bucket_index = heap->next_free / heap->heap_increment; | |
113 | - obj_index = heap->next_free % heap->heap_increment; | |
114 | - | |
115 | - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); | |
116 | - heap->next_free = obj->next_free; | |
117 | - obj->next_free = ALLOCATED; | |
118 | - return obj->id; | |
119 | -} | |
120 | - | |
121 | -int | |
122 | -object_heap_allocate(object_heap_p heap) | |
123 | -{ | |
124 | - int ret; | |
125 | - | |
126 | - pthread_mutex_lock(&heap->mutex); | |
127 | - ret = object_heap_allocate_unlocked(heap); | |
128 | - pthread_mutex_unlock(&heap->mutex); | |
129 | - return ret; | |
130 | -} | |
131 | - | |
132 | -/* | |
133 | - * Lookup an object by object ID | |
134 | - * Returns a pointer to the object on success, returns NULL on error | |
135 | - */ | |
136 | -static object_base_p | |
137 | -object_heap_lookup_unlocked(object_heap_p heap, int id) | |
138 | -{ | |
139 | - object_base_p obj; | |
140 | - int bucket_index, obj_index; | |
141 | - | |
142 | - if ((id < heap->id_offset) || (id > (heap->heap_size + heap->id_offset))) { | |
143 | - return NULL; | |
144 | - } | |
145 | - id &= OBJECT_HEAP_ID_MASK; | |
146 | - bucket_index = id / heap->heap_increment; | |
147 | - obj_index = id % heap->heap_increment; | |
148 | - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); | |
149 | - | |
150 | - /* Check if the object has in fact been allocated */ | |
151 | - if (obj->next_free != ALLOCATED) { | |
152 | - return NULL; | |
153 | - } | |
154 | - return obj; | |
155 | -} | |
156 | - | |
157 | -object_base_p | |
158 | -object_heap_lookup(object_heap_p heap, int id) | |
159 | -{ | |
160 | - object_base_p obj; | |
161 | - | |
162 | - pthread_mutex_lock(&heap->mutex); | |
163 | - obj = object_heap_lookup_unlocked(heap, id); | |
164 | - pthread_mutex_unlock(&heap->mutex); | |
165 | - return obj; | |
166 | -} | |
167 | - | |
168 | -/* | |
169 | - * Iterate over all objects in the heap. | |
170 | - * Returns a pointer to the first object on the heap, returns NULL if heap is empty. | |
171 | - */ | |
172 | -object_base_p | |
173 | -object_heap_first(object_heap_p heap, object_heap_iterator *iter) | |
174 | -{ | |
175 | - *iter = -1; | |
176 | - return object_heap_next(heap, iter); | |
177 | -} | |
178 | - | |
179 | -/* | |
180 | - * Iterate over all objects in the heap. | |
181 | - * Returns a pointer to the next object on the heap, returns NULL if heap is empty. | |
182 | - */ | |
183 | -static object_base_p | |
184 | -object_heap_next_unlocked(object_heap_p heap, object_heap_iterator *iter) | |
185 | -{ | |
186 | - object_base_p obj; | |
187 | - int bucket_index, obj_index; | |
188 | - int i = *iter + 1; | |
189 | - | |
190 | - while (i < heap->heap_size) { | |
191 | - bucket_index = i / heap->heap_increment; | |
192 | - obj_index = i % heap->heap_increment; | |
193 | - | |
194 | - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); | |
195 | - if (obj->next_free == ALLOCATED) { | |
196 | - *iter = i; | |
197 | - return obj; | |
198 | - } | |
199 | - i++; | |
200 | - } | |
201 | - *iter = i; | |
202 | - return NULL; | |
203 | -} | |
204 | - | |
205 | -object_base_p | |
206 | -object_heap_next(object_heap_p heap, object_heap_iterator *iter) | |
207 | -{ | |
208 | - object_base_p obj; | |
209 | - | |
210 | - pthread_mutex_lock(&heap->mutex); | |
211 | - obj = object_heap_next_unlocked(heap, iter); | |
212 | - pthread_mutex_unlock(&heap->mutex); | |
213 | - return obj; | |
214 | -} | |
215 | - | |
216 | -/* | |
217 | - * Frees an object | |
218 | - */ | |
219 | -static void | |
220 | -object_heap_free_unlocked(object_heap_p heap, object_base_p obj) | |
221 | -{ | |
222 | - /* Check if the object has in fact been allocated */ | |
223 | - ASSERT(obj->next_free == ALLOCATED); | |
224 | - | |
225 | - obj->next_free = heap->next_free; | |
226 | - heap->next_free = obj->id & OBJECT_HEAP_ID_MASK; | |
227 | -} | |
228 | - | |
229 | -void | |
230 | -object_heap_free(object_heap_p heap, object_base_p obj) | |
231 | -{ | |
232 | - if (!obj) | |
233 | - return; | |
234 | - pthread_mutex_lock(&heap->mutex); | |
235 | - object_heap_free_unlocked(heap, obj); | |
236 | - pthread_mutex_unlock(&heap->mutex); | |
237 | -} | |
238 | - | |
239 | -/* | |
240 | - * Destroys a heap, the heap must be empty. | |
241 | - */ | |
242 | -void | |
243 | -object_heap_destroy(object_heap_p heap) | |
244 | -{ | |
245 | - object_base_p obj; | |
246 | - int bucket_index, obj_index, i; | |
247 | - | |
248 | - /* Check if heap is empty */ | |
249 | - for (i = 0; i < heap->heap_size; i++) { | |
250 | - /* Check if object is not still allocated */ | |
251 | - bucket_index = i / heap->heap_increment; | |
252 | - obj_index = i % heap->heap_increment; | |
253 | - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); | |
254 | - ASSERT(obj->next_free != ALLOCATED); | |
255 | - } | |
256 | - | |
257 | - for (i = 0; i < heap->heap_size / heap->heap_increment; i++) { | |
258 | - free(heap->bucket[i]); | |
259 | - } | |
260 | - | |
261 | - pthread_mutex_destroy(&heap->mutex); | |
262 | - | |
263 | - free(heap->bucket); | |
264 | - heap->bucket = NULL; | |
265 | - heap->heap_size = 0; | |
266 | - heap->next_free = LAST_FREE; | |
267 | -} |
@@ -1,100 +0,0 @@ | ||
1 | -/* | |
2 | - * Copyright (c) 2007 Intel Corporation. All Rights Reserved. | |
3 | - * | |
4 | - * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | - * copy of this software and associated documentation files (the | |
6 | - * "Software"), to deal in the Software without restriction, including | |
7 | - * without limitation the rights to use, copy, modify, merge, publish, | |
8 | - * distribute, sub license, and/or sell copies of the Software, and to | |
9 | - * permit persons to whom the Software is furnished to do so, subject to | |
10 | - * the following conditions: | |
11 | - * | |
12 | - * The above copyright notice and this permission notice (including the | |
13 | - * next paragraph) shall be included in all copies or substantial portions | |
14 | - * of the Software. | |
15 | - * | |
16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
17 | - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | |
19 | - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR | |
20 | - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
21 | - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
22 | - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | - */ | |
24 | - | |
25 | -#ifndef OBJECT_HEAP_H | |
26 | -#define OBJECT_HEAP_H | |
27 | - | |
28 | -#include <pthread.h> | |
29 | - | |
30 | -#define OBJECT_HEAP_OFFSET_MASK 0x7F000000 | |
31 | -#define OBJECT_HEAP_ID_MASK 0x00FFFFFF | |
32 | - | |
33 | -typedef struct object_base *object_base_p; | |
34 | -typedef struct object_heap *object_heap_p; | |
35 | - | |
36 | -struct object_base { | |
37 | - int id; | |
38 | - int next_free; | |
39 | -}; | |
40 | - | |
41 | -struct object_heap { | |
42 | - pthread_mutex_t mutex; | |
43 | - int object_size; | |
44 | - int id_offset; | |
45 | - int next_free; | |
46 | - int heap_size; | |
47 | - int heap_increment; | |
48 | - void **bucket; | |
49 | - int num_buckets; | |
50 | -}; | |
51 | - | |
52 | -typedef int object_heap_iterator; | |
53 | - | |
54 | -/* | |
55 | - * Return 0 on success, -1 on error | |
56 | - */ | |
57 | -int | |
58 | -object_heap_init(object_heap_p heap, int object_size, int id_offset); | |
59 | - | |
60 | -/* | |
61 | - * Allocates an object | |
62 | - * Returns the object ID on success, returns -1 on error | |
63 | - */ | |
64 | -int | |
65 | -object_heap_allocate(object_heap_p heap); | |
66 | - | |
67 | -/* | |
68 | - * Lookup an allocated object by object ID | |
69 | - * Returns a pointer to the object on success, returns NULL on error | |
70 | - */ | |
71 | -object_base_p | |
72 | -object_heap_lookup(object_heap_p heap, int id); | |
73 | - | |
74 | -/* | |
75 | - * Iterate over all objects in the heap. | |
76 | - * Returns a pointer to the first object on the heap, returns NULL if heap is empty. | |
77 | - */ | |
78 | -object_base_p | |
79 | -object_heap_first(object_heap_p heap, object_heap_iterator *iter); | |
80 | - | |
81 | -/* | |
82 | - * Iterate over all objects in the heap. | |
83 | - * Returns a pointer to the next object on the heap, returns NULL if heap is empty. | |
84 | - */ | |
85 | -object_base_p | |
86 | -object_heap_next(object_heap_p heap, object_heap_iterator *iter); | |
87 | - | |
88 | -/* | |
89 | - * Frees an object | |
90 | - */ | |
91 | -void | |
92 | -object_heap_free(object_heap_p heap, object_base_p obj); | |
93 | - | |
94 | -/* | |
95 | - * Destroys a heap, the heap must be empty. | |
96 | - */ | |
97 | -void | |
98 | -object_heap_destroy(object_heap_p heap); | |
99 | - | |
100 | -#endif /* OBJECT_HEAP_H */ |