2 * Copyright © 2008-2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
31 * Public definitions of Intel-specific bufmgr functions.
34 #ifndef INTEL_BUFMGR_H
35 #define INTEL_BUFMGR_H
41 #if defined(__cplusplus)
47 typedef struct _drm_bacon_bufmgr drm_bacon_bufmgr
;
48 typedef struct _drm_bacon_context drm_bacon_context
;
49 typedef struct _drm_bacon_bo drm_bacon_bo
;
51 struct _drm_bacon_bo
{
53 * Size in bytes of the buffer object.
55 * The size may be larger than the size originally requested for the
56 * allocation, such as being aligned to page size.
61 * Alignment requirement for object
63 * Used for GTT mapping & pinning the object.
68 * Deprecated field containing (possibly the low 32-bits of) the last
69 * seen virtual card address. Use offset64 instead.
74 * Virtual address for accessing the buffer data. Only valid while
83 /** Buffer manager context associated with this buffer object */
84 drm_bacon_bufmgr
*bufmgr
;
87 * MM-specific handle for accessing object
92 * Last seen card virtual address (offset from the beginning of the
93 * aperture) for the object. This should be used to fill relocation
94 * entries when calling drm_bacon_bo_emit_reloc()
99 #define BO_ALLOC_FOR_RENDER (1<<0)
101 drm_bacon_bo
*drm_bacon_bo_alloc(drm_bacon_bufmgr
*bufmgr
, const char *name
,
102 unsigned long size
, unsigned int alignment
);
103 drm_bacon_bo
*drm_bacon_bo_alloc_for_render(drm_bacon_bufmgr
*bufmgr
,
106 unsigned int alignment
);
107 drm_bacon_bo
*drm_bacon_bo_alloc_userptr(drm_bacon_bufmgr
*bufmgr
,
109 void *addr
, uint32_t tiling_mode
,
110 uint32_t stride
, unsigned long size
,
111 unsigned long flags
);
112 drm_bacon_bo
*drm_bacon_bo_alloc_tiled(drm_bacon_bufmgr
*bufmgr
,
114 int x
, int y
, int cpp
,
115 uint32_t *tiling_mode
,
116 unsigned long *pitch
,
117 unsigned long flags
);
118 void drm_bacon_bo_reference(drm_bacon_bo
*bo
);
119 void drm_bacon_bo_unreference(drm_bacon_bo
*bo
);
120 int drm_bacon_bo_map(drm_bacon_bo
*bo
, int write_enable
);
121 int drm_bacon_bo_unmap(drm_bacon_bo
*bo
);
123 int drm_bacon_bo_subdata(drm_bacon_bo
*bo
, unsigned long offset
,
124 unsigned long size
, const void *data
);
125 int drm_bacon_bo_get_subdata(drm_bacon_bo
*bo
, unsigned long offset
,
126 unsigned long size
, void *data
);
127 void drm_bacon_bo_wait_rendering(drm_bacon_bo
*bo
);
129 void drm_bacon_bufmgr_set_debug(drm_bacon_bufmgr
*bufmgr
, int enable_debug
);
130 void drm_bacon_bufmgr_destroy(drm_bacon_bufmgr
*bufmgr
);
131 int drm_bacon_bo_exec(drm_bacon_bo
*bo
, int used
,
132 struct drm_clip_rect
*cliprects
, int num_cliprects
, int DR4
);
133 int drm_bacon_bo_mrb_exec(drm_bacon_bo
*bo
, int used
,
134 struct drm_clip_rect
*cliprects
, int num_cliprects
, int DR4
,
136 int drm_bacon_bufmgr_check_aperture_space(drm_bacon_bo
** bo_array
, int count
);
138 int drm_bacon_bo_emit_reloc(drm_bacon_bo
*bo
, uint32_t offset
,
139 drm_bacon_bo
*target_bo
, uint32_t target_offset
,
140 uint32_t read_domains
, uint32_t write_domain
);
141 int drm_bacon_bo_set_tiling(drm_bacon_bo
*bo
, uint32_t * tiling_mode
,
143 int drm_bacon_bo_get_tiling(drm_bacon_bo
*bo
, uint32_t * tiling_mode
,
144 uint32_t * swizzle_mode
);
145 int drm_bacon_bo_flink(drm_bacon_bo
*bo
, uint32_t * name
);
146 int drm_bacon_bo_busy(drm_bacon_bo
*bo
);
147 int drm_bacon_bo_madvise(drm_bacon_bo
*bo
, int madv
);
148 int drm_bacon_bo_set_softpin_offset(drm_bacon_bo
*bo
, uint64_t offset
);
150 int drm_bacon_bo_disable_reuse(drm_bacon_bo
*bo
);
151 int drm_bacon_bo_is_reusable(drm_bacon_bo
*bo
);
152 int drm_bacon_bo_references(drm_bacon_bo
*bo
, drm_bacon_bo
*target_bo
);
154 /* drm_bacon_bufmgr_gem.c */
155 drm_bacon_bufmgr
*drm_bacon_bufmgr_gem_init(int fd
, int batch_size
);
156 drm_bacon_bo
*drm_bacon_bo_gem_create_from_name(drm_bacon_bufmgr
*bufmgr
,
158 unsigned int handle
);
159 void drm_bacon_bufmgr_gem_enable_reuse(drm_bacon_bufmgr
*bufmgr
);
160 void drm_bacon_bufmgr_gem_set_vma_cache_size(drm_bacon_bufmgr
*bufmgr
,
162 int drm_bacon_gem_bo_map_unsynchronized(drm_bacon_bo
*bo
);
163 int drm_bacon_gem_bo_map_gtt(drm_bacon_bo
*bo
);
165 #define HAVE_DRM_INTEL_GEM_BO_DISABLE_IMPLICIT_SYNC 1
166 int drm_bacon_bufmgr_gem_can_disable_implicit_sync(drm_bacon_bufmgr
*bufmgr
);
167 void drm_bacon_gem_bo_disable_implicit_sync(drm_bacon_bo
*bo
);
168 void drm_bacon_gem_bo_enable_implicit_sync(drm_bacon_bo
*bo
);
170 void *drm_bacon_gem_bo_map__cpu(drm_bacon_bo
*bo
);
171 void *drm_bacon_gem_bo_map__gtt(drm_bacon_bo
*bo
);
172 void *drm_bacon_gem_bo_map__wc(drm_bacon_bo
*bo
);
174 int drm_bacon_gem_bo_get_reloc_count(drm_bacon_bo
*bo
);
175 void drm_bacon_gem_bo_clear_relocs(drm_bacon_bo
*bo
, int start
);
176 void drm_bacon_gem_bo_start_gtt_access(drm_bacon_bo
*bo
, int write_enable
);
178 int drm_bacon_bufmgr_gem_get_devid(drm_bacon_bufmgr
*bufmgr
);
179 int drm_bacon_gem_bo_wait(drm_bacon_bo
*bo
, int64_t timeout_ns
);
181 drm_bacon_context
*drm_bacon_gem_context_create(drm_bacon_bufmgr
*bufmgr
);
182 int drm_bacon_gem_context_get_id(drm_bacon_context
*ctx
,
184 void drm_bacon_gem_context_destroy(drm_bacon_context
*ctx
);
185 int drm_bacon_gem_bo_context_exec(drm_bacon_bo
*bo
, drm_bacon_context
*ctx
,
186 int used
, unsigned int flags
);
187 int drm_bacon_gem_bo_fence_exec(drm_bacon_bo
*bo
,
188 drm_bacon_context
*ctx
,
194 int drm_bacon_bo_gem_export_to_prime(drm_bacon_bo
*bo
, int *prime_fd
);
195 drm_bacon_bo
*drm_bacon_bo_gem_create_from_prime(drm_bacon_bufmgr
*bufmgr
,
196 int prime_fd
, int size
);
198 int drm_bacon_reg_read(drm_bacon_bufmgr
*bufmgr
,
202 int drm_bacon_get_reset_stats(drm_bacon_context
*ctx
,
203 uint32_t *reset_count
,
209 #if defined(__cplusplus)
213 #endif /* INTEL_BUFMGR_H */