2 * Copyright © 2008 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>
29 * @file intel_bufmgr_priv.h
31 * Private definitions of Intel-specific bufmgr functions and structures.
34 #ifndef INTEL_BUFMGR_PRIV_H
35 #define INTEL_BUFMGR_PRIV_H
38 * Context for a buffer manager instance.
40 * Contains public methods followed by private storage for the buffer manager.
42 struct _drm_intel_bufmgr
{
44 * Allocate a buffer object.
46 * Buffer objects are not necessarily initially mapped into CPU virtual
47 * address space or graphics device aperture. They must be mapped using
48 * bo_map() to be used by the CPU, and validated for use using bo_validate()
49 * to be used from the graphics device.
51 drm_intel_bo
*(*bo_alloc
)(drm_intel_bufmgr
*bufmgr
, const char *name
,
52 unsigned long size
, unsigned int alignment
);
55 * Allocate a buffer object, hinting that it will be used as a render target.
57 * This is otherwise the same as bo_alloc.
59 drm_intel_bo
*(*bo_alloc_for_render
)(drm_intel_bufmgr
*bufmgr
,
62 unsigned int alignment
);
64 /** Takes a reference on a buffer object */
65 void (*bo_reference
)(drm_intel_bo
*bo
);
68 * Releases a reference on a buffer object, freeing the data if
71 void (*bo_unreference
)(drm_intel_bo
*bo
);
74 * Maps the buffer into userspace.
76 * This function will block waiting for any existing execution on the
77 * buffer to complete, first. The resulting mapping is available at
80 int (*bo_map
)(drm_intel_bo
*bo
, int write_enable
);
82 /** Reduces the refcount on the userspace mapping of the buffer object. */
83 int (*bo_unmap
)(drm_intel_bo
*bo
);
86 * Write data into an object.
88 * This is an optional function, if missing,
89 * drm_intel_bo will map/memcpy/unmap.
91 int (*bo_subdata
)(drm_intel_bo
*bo
, unsigned long offset
,
92 unsigned long size
, const void *data
);
95 * Read data from an object
97 * This is an optional function, if missing,
98 * drm_intel_bo will map/memcpy/unmap.
100 int (*bo_get_subdata
)(drm_intel_bo
*bo
, unsigned long offset
,
101 unsigned long size
, void *data
);
104 * Waits for rendering to an object by the GPU to have completed.
106 * This is not required for any access to the BO by bo_map, bo_subdata, etc.
107 * It is merely a way for the driver to implement glFinish.
109 void (*bo_wait_rendering
)(drm_intel_bo
*bo
);
112 * Tears down the buffer manager instance.
114 void (*destroy
)(drm_intel_bufmgr
*bufmgr
);
117 * Add relocation entry in reloc_buf, which will be updated with the
118 * target buffer's real offset on on command submission.
120 * Relocations remain in place for the lifetime of the buffer object.
122 * \param bo Buffer to write the relocation into.
123 * \param offset Byte offset within reloc_bo of the pointer to target_bo.
124 * \param target_bo Buffer whose offset should be written into the
126 * \param target_offset Constant value to be added to target_bo's offset in
128 * \param read_domains GEM read domains which the buffer will be read into
129 * by the command that this relocation is part of.
130 * \param write_domains GEM read domains which the buffer will be dirtied
131 * in by the command that this relocation is part of.
133 int (*bo_emit_reloc
)(drm_intel_bo
*bo
, uint32_t offset
,
134 drm_intel_bo
*target_bo
, uint32_t target_offset
,
135 uint32_t read_domains
, uint32_t write_domain
);
137 /** Executes the command buffer pointed to by bo. */
138 int (*bo_exec
)(drm_intel_bo
*bo
, int used
,
139 drm_clip_rect_t
*cliprects
, int num_cliprects
,
143 * Pin a buffer to the aperture and fix the offset until unpinned
145 * \param buf Buffer to pin
146 * \param alignment Required alignment for aperture, in bytes
148 int (*bo_pin
)(drm_intel_bo
*bo
, uint32_t alignment
);
150 * Unpin a buffer from the aperture, allowing it to be removed
152 * \param buf Buffer to unpin
154 int (*bo_unpin
)(drm_intel_bo
*bo
);
156 * Ask that the buffer be placed in tiling mode
158 * \param buf Buffer to set tiling mode for
159 * \param tiling_mode desired, and returned tiling mode
161 int (*bo_set_tiling
)(drm_intel_bo
*bo
, uint32_t *tiling_mode
,
164 * Get the current tiling (and resulting swizzling) mode for the bo.
166 * \param buf Buffer to get tiling mode for
167 * \param tiling_mode returned tiling mode
168 * \param swizzle_mode returned swizzling mode
170 int (*bo_get_tiling
)(drm_intel_bo
*bo
, uint32_t *tiling_mode
,
171 uint32_t *swizzle_mode
);
173 * Create a visible name for a buffer which can be used by other apps
175 * \param buf Buffer to create a name for
176 * \param name Returned name
178 int (*bo_flink
)(drm_intel_bo
*bo
, uint32_t *name
);
180 int (*check_aperture_space
)(drm_intel_bo
**bo_array
, int count
);
183 * Disable buffer reuse for buffers which will be shared in some way,
184 * as with scanout buffers. When the buffer reference count goes to zero,
185 * it will be freed and not placed in the reuse list.
187 * \param bo Buffer to disable reuse for
189 int (*bo_disable_reuse
)(drm_intel_bo
*bo
);
193 * Return the pipe associated with a crtc_id so that vblank
194 * synchronization can use the correct data in the request.
195 * This is only supported for KMS and gem at this point, when
196 * unsupported, this function returns -1 and leaves the decision
197 * of what to do in that case to the caller
199 * \param bufmgr the associated buffer manager
200 * \param crtc_id the crtc identifier
202 int (*get_pipe_from_crtc_id
)(drm_intel_bufmgr
*bufmgr
, int crtc_id
);
204 int debug
; /**< Enables verbose debugging printouts */
207 #endif /* INTEL_BUFMGR_PRIV_H */