39539762175b79f466b97192d0755f44ea3e647a
[linux-2.6.git] / drivers / video / tegra / nvmap / nvmap_heap.h
1 /*
2  * drivers/video/tegra/nvmap_heap.h
3  *
4  * GPU heap allocator.
5  *
6  * Copyright (c) 2010, NVIDIA Corporation.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  */
22
23 #ifndef __NVMAP_HEAP_H
24 #define __NVMAP_HEAP_H
25
26 struct device;
27 struct nvmap_heap;
28 struct attribute_group;
29
30 struct nvmap_heap_block {
31         unsigned long   base;
32         unsigned int    type;
33         struct nvmap_handle *handle;
34 };
35
36 #define NVMAP_HEAP_MIN_BUDDY_SIZE       8192
37
38 struct nvmap_heap *nvmap_heap_create(struct device *parent, const char *name,
39                                      unsigned long base, size_t len,
40                                      unsigned int buddy_size, void *arg);
41
42 void nvmap_heap_destroy(struct nvmap_heap *heap);
43
44 void *nvmap_heap_device_to_arg(struct device *dev);
45
46 void *nvmap_heap_to_arg(struct nvmap_heap *heap);
47
48 struct nvmap_heap_block *nvmap_heap_alloc(struct nvmap_heap *heap, size_t len,
49                                           size_t align, unsigned int prot,
50                                           struct nvmap_handle *handle);
51
52 struct nvmap_heap *nvmap_block_to_heap(struct nvmap_heap_block *b);
53
54 void nvmap_heap_free(struct nvmap_heap_block *block);
55
56 int nvmap_heap_create_group(struct nvmap_heap *heap,
57                             const struct attribute_group *grp);
58
59 void nvmap_heap_remove_group(struct nvmap_heap *heap,
60                              const struct attribute_group *grp);
61
62 int __init nvmap_heap_init(void);
63
64 void nvmap_heap_deinit(void);
65
66 #endif