]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/gpu/drm/radeon/radeon_object.h
2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
24 * Authors: Dave Airlie
28 #ifndef __RADEON_OBJECT_H__
29 #define __RADEON_OBJECT_H__
31 #include <drm/radeon_drm.h>
35 * radeon_mem_type_to_domain - return domain corresponding to mem_type
36 * @mem_type: ttm memory type
38 * Returns corresponding domain of the ttm mem_type
40 static inline unsigned radeon_mem_type_to_domain(u32 mem_type
)
44 return RADEON_GEM_DOMAIN_VRAM
;
46 return RADEON_GEM_DOMAIN_GTT
;
48 return RADEON_GEM_DOMAIN_CPU
;
55 int radeon_bo_reserve(struct radeon_bo
*bo
, bool no_wait
);
57 static inline void radeon_bo_unreserve(struct radeon_bo
*bo
)
59 ttm_bo_unreserve(&bo
->tbo
);
63 * radeon_bo_gpu_offset - return GPU offset of bo
64 * @bo: radeon object for which we query the offset
66 * Returns current GPU offset of the object.
68 * Note: object should either be pinned or reserved when calling this
69 * function, it might be useful to add check for this for debugging.
71 static inline u64
radeon_bo_gpu_offset(struct radeon_bo
*bo
)
73 return bo
->tbo
.offset
;
76 static inline unsigned long radeon_bo_size(struct radeon_bo
*bo
)
78 return bo
->tbo
.num_pages
<< PAGE_SHIFT
;
81 static inline bool radeon_bo_is_reserved(struct radeon_bo
*bo
)
83 return !!atomic_read(&bo
->tbo
.reserved
);
86 static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo
*bo
)
88 return (bo
->tbo
.num_pages
<< PAGE_SHIFT
) / RADEON_GPU_PAGE_SIZE
;
91 static inline unsigned radeon_bo_gpu_page_alignment(struct radeon_bo
*bo
)
93 return (bo
->tbo
.mem
.page_alignment
<< PAGE_SHIFT
) / RADEON_GPU_PAGE_SIZE
;
97 * radeon_bo_mmap_offset - return mmap offset of bo
98 * @bo: radeon object for which we query the offset
100 * Returns mmap offset of the object.
102 * Note: addr_space_offset is constant after ttm bo init thus isn't protected
105 static inline u64
radeon_bo_mmap_offset(struct radeon_bo
*bo
)
107 return bo
->tbo
.addr_space_offset
;
110 extern int radeon_bo_wait(struct radeon_bo
*bo
, u32
*mem_type
,
113 extern int radeon_bo_create(struct radeon_device
*rdev
,
114 unsigned long size
, int byte_align
,
115 bool kernel
, u32 domain
,
116 struct radeon_bo
**bo_ptr
);
117 extern int radeon_bo_kmap(struct radeon_bo
*bo
, void **ptr
);
118 extern void radeon_bo_kunmap(struct radeon_bo
*bo
);
119 extern void radeon_bo_unref(struct radeon_bo
**bo
);
120 extern int radeon_bo_pin(struct radeon_bo
*bo
, u32 domain
, u64
*gpu_addr
);
121 extern int radeon_bo_unpin(struct radeon_bo
*bo
);
122 extern int radeon_bo_evict_vram(struct radeon_device
*rdev
);
123 extern void radeon_bo_force_delete(struct radeon_device
*rdev
);
124 extern int radeon_bo_init(struct radeon_device
*rdev
);
125 extern void radeon_bo_fini(struct radeon_device
*rdev
);
126 extern void radeon_bo_list_add_object(struct radeon_bo_list
*lobj
,
127 struct list_head
*head
);
128 extern int radeon_bo_list_validate(struct list_head
*head
);
129 extern int radeon_bo_fbdev_mmap(struct radeon_bo
*bo
,
130 struct vm_area_struct
*vma
);
131 extern int radeon_bo_set_tiling_flags(struct radeon_bo
*bo
,
132 u32 tiling_flags
, u32 pitch
);
133 extern void radeon_bo_get_tiling_flags(struct radeon_bo
*bo
,
134 u32
*tiling_flags
, u32
*pitch
);
135 extern int radeon_bo_check_tiling(struct radeon_bo
*bo
, bool has_moved
,
137 extern void radeon_bo_move_notify(struct ttm_buffer_object
*bo
,
138 struct ttm_mem_reg
*mem
);
139 extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object
*bo
);
140 extern int radeon_bo_get_surface_reg(struct radeon_bo
*bo
);
141 extern struct radeon_bo_va
*radeon_bo_va(struct radeon_bo
*rbo
,
142 struct radeon_vm
*vm
);
147 extern int radeon_sa_bo_manager_init(struct radeon_device
*rdev
,
148 struct radeon_sa_manager
*sa_manager
,
149 unsigned size
, u32 domain
);
150 extern void radeon_sa_bo_manager_fini(struct radeon_device
*rdev
,
151 struct radeon_sa_manager
*sa_manager
);
152 extern int radeon_sa_bo_manager_start(struct radeon_device
*rdev
,
153 struct radeon_sa_manager
*sa_manager
);
154 extern int radeon_sa_bo_manager_suspend(struct radeon_device
*rdev
,
155 struct radeon_sa_manager
*sa_manager
);
156 extern int radeon_sa_bo_new(struct radeon_device
*rdev
,
157 struct radeon_sa_manager
*sa_manager
,
158 struct radeon_sa_bo
*sa_bo
,
159 unsigned size
, unsigned align
);
160 extern void radeon_sa_bo_free(struct radeon_device
*rdev
,
161 struct radeon_sa_bo
*sa_bo
);