]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/gpu/host1x/host1x_bo.h
i2o: convert bus code to use dev_groups
[karo-tx-linux.git] / drivers / gpu / host1x / host1x_bo.h
1 /*
2  * Tegra host1x Memory Management Abstraction header
3  *
4  * Copyright (c) 2012-2013, NVIDIA Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef _HOST1X_BO_H
20 #define _HOST1X_BO_H
21
22 struct host1x_bo;
23
24 struct host1x_bo_ops {
25         struct host1x_bo *(*get)(struct host1x_bo *bo);
26         void (*put)(struct host1x_bo *bo);
27         dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt);
28         void (*unpin)(struct host1x_bo *bo, struct sg_table *sgt);
29         void *(*mmap)(struct host1x_bo *bo);
30         void (*munmap)(struct host1x_bo *bo, void *addr);
31         void *(*kmap)(struct host1x_bo *bo, unsigned int pagenum);
32         void (*kunmap)(struct host1x_bo *bo, unsigned int pagenum, void *addr);
33 };
34
35 struct host1x_bo {
36         const struct host1x_bo_ops *ops;
37 };
38
39 static inline void host1x_bo_init(struct host1x_bo *bo,
40                                   const struct host1x_bo_ops *ops)
41 {
42         bo->ops = ops;
43 }
44
45 static inline struct host1x_bo *host1x_bo_get(struct host1x_bo *bo)
46 {
47         return bo->ops->get(bo);
48 }
49
50 static inline void host1x_bo_put(struct host1x_bo *bo)
51 {
52         bo->ops->put(bo);
53 }
54
55 static inline dma_addr_t host1x_bo_pin(struct host1x_bo *bo,
56                                        struct sg_table **sgt)
57 {
58         return bo->ops->pin(bo, sgt);
59 }
60
61 static inline void host1x_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt)
62 {
63         bo->ops->unpin(bo, sgt);
64 }
65
66 static inline void *host1x_bo_mmap(struct host1x_bo *bo)
67 {
68         return bo->ops->mmap(bo);
69 }
70
71 static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr)
72 {
73         bo->ops->munmap(bo, addr);
74 }
75
76 static inline void *host1x_bo_kmap(struct host1x_bo *bo, unsigned int pagenum)
77 {
78         return bo->ops->kmap(bo, pagenum);
79 }
80
81 static inline void host1x_bo_kunmap(struct host1x_bo *bo,
82                                     unsigned int pagenum, void *addr)
83 {
84         bo->ops->kunmap(bo, pagenum, addr);
85 }
86
87 #endif