Initial commit of libva
[platform/upstream/libva.git] / dummy_drv_video / object_heap.h
1 /*
2  * @COPYRIGHT@ Intel Confidential - Unreleased Software
3  */
4
5 #ifndef _OBJECT_HEAP_H_
6 #define _OBJECT_HEAP_H_
7
8 #define OBJECT_HEAP_OFFSET_MASK         0x7F000000
9 #define OBJECT_HEAP_ID_MASK                     0x00FFFFFF
10
11 typedef struct object_base *object_base_p;
12 typedef struct object_heap *object_heap_p;
13
14 struct object_base {
15     int id;
16     int next_free;
17 };
18
19 struct object_heap {
20     int object_size;
21     int id_offset;
22     void *heap_index;
23     int next_free;
24     int heap_size;
25     int heap_increment;
26 };
27
28 typedef int object_heap_iterator;
29
30 /*
31  * Return 0 on success, -1 on error
32  */
33 int object_heap_init( object_heap_p heap, int object_size, int id_offset);
34
35 /*
36  * Allocates an object
37  * Returns the object ID on success, returns -1 on error
38  */
39 int object_heap_allocate( object_heap_p heap );
40
41 /*
42  * Lookup an allocated object by object ID
43  * Returns a pointer to the object on success, returns NULL on error
44  */
45 object_base_p object_heap_lookup( object_heap_p heap, int id );
46
47 /*
48  * Iterate over all objects in the heap.
49  * Returns a pointer to the first object on the heap, returns NULL if heap is empty.
50  */
51 object_base_p object_heap_first( object_heap_p heap, object_heap_iterator *iter );
52
53 /*
54  * Iterate over all objects in the heap.
55  * Returns a pointer to the next object on the heap, returns NULL if heap is empty.
56  */
57 object_base_p object_heap_next( object_heap_p heap, object_heap_iterator *iter );
58
59 /*
60  * Frees an object
61  */
62 void object_heap_free( object_heap_p heap, object_base_p obj );
63
64 /*
65  * Destroys a heap, the heap must be empty.
66  */
67 void object_heap_destroy( object_heap_p heap );
68
69 #endif /* _OBJECT_HEAP_H_ */