1 /**************************************************************************
3 * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
5 * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 **************************************************************************/
24 * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
27 #ifndef _TTM_PLACEMENT_USER_H_
28 #define _TTM_PLACEMENT_USER_H_
30 #if !defined(__KERNEL__) && !defined(_KERNEL)
33 #include <linux/kernel.h>
36 #include "ttm/ttm_placement.h"
38 #define TTM_PLACEMENT_MAJOR 0
39 #define TTM_PLACEMENT_MINOR 1
40 #define TTM_PLACEMENT_PL 0
41 #define TTM_PLACEMENT_DATE "080819"
44 * struct ttm_pl_create_req
46 * @size: The buffer object size.
47 * @placement: Flags that indicate initial acceptable
49 * @page_alignment: Required alignment in pages.
51 * Input to the TTM_BO_CREATE ioctl.
54 struct ttm_pl_create_req {
57 uint32_t page_alignment;
61 * struct ttm_pl_create_ub_req
63 * @size: The buffer object size.
64 * @user_address: User-space address of the memory area that
65 * should be used to back the buffer object cast to 64-bit.
66 * @placement: Flags that indicate initial acceptable
68 * @page_alignment: Required alignment in pages.
70 * Input to the TTM_BO_CREATE_UB ioctl.
73 struct ttm_pl_create_ub_req {
75 uint64_t user_address;
77 uint32_t page_alignment;
83 * @gpu_offset: The current offset into the memory region used.
84 * This can be used directly by the GPU if there are no
85 * additional GPU mapping procedures used by the driver.
87 * @bo_size: Actual buffer object size.
89 * @map_handle: Offset into the device address space.
90 * Used for map, seek, read, write. This will never change
91 * during the lifetime of an object.
93 * @placement: Flag indicating the placement status of
94 * the buffer object using the TTM_PL flags above.
96 * @sync_object_arg: Used for user-space synchronization and
97 * depends on the synchronization model used. If fences are
98 * used, this is the buffer_object::fence_type_mask
100 * Output from the TTM_PL_CREATE and TTM_PL_REFERENCE, and
101 * TTM_PL_SETSTATUS ioctls.
110 uint32_t sync_object_arg;
115 * struct ttm_pl_setstatus_req
117 * @set_placement: Placement flags to set.
119 * @clr_placement: Placement flags to clear.
121 * @handle: The object handle
123 * Input to the TTM_PL_SETSTATUS ioctl.
126 struct ttm_pl_setstatus_req {
127 uint32_t set_placement;
128 uint32_t clr_placement;
134 * struct ttm_pl_reference_req
136 * @handle: The object to put a reference on.
138 * Input to the TTM_PL_REFERENCE and the TTM_PL_UNREFERENCE ioctls.
141 struct ttm_pl_reference_req {
147 * ACCESS mode flags for SYNCCPU.
149 * TTM_SYNCCPU_MODE_READ will guarantee that the GPU is not
150 * writing to the buffer.
152 * TTM_SYNCCPU_MODE_WRITE will guarantee that the GPU is not
153 * accessing the buffer.
155 * TTM_SYNCCPU_MODE_NO_BLOCK makes sure the call does not wait
156 * for GPU accesses to finish but return -EBUSY.
158 * TTM_SYNCCPU_MODE_TRYCACHED Try to place the buffer in cacheable
159 * memory while synchronized for CPU.
162 #define TTM_PL_SYNCCPU_MODE_READ TTM_ACCESS_READ
163 #define TTM_PL_SYNCCPU_MODE_WRITE TTM_ACCESS_WRITE
164 #define TTM_PL_SYNCCPU_MODE_NO_BLOCK (1 << 2)
165 #define TTM_PL_SYNCCPU_MODE_TRYCACHED (1 << 3)
168 * struct ttm_pl_synccpu_arg
170 * @handle: The object to synchronize.
172 * @access_mode: access mode indicated by the
173 * TTM_SYNCCPU_MODE flags.
175 * @op: indicates whether to grab or release the
176 * buffer for cpu usage.
178 * Input to the TTM_PL_SYNCCPU ioctl.
181 struct ttm_pl_synccpu_arg {
183 uint32_t access_mode;
185 TTM_PL_SYNCCPU_OP_GRAB,
186 TTM_PL_SYNCCPU_OP_RELEASE
192 * Waiting mode flags for the TTM_BO_WAITIDLE ioctl.
194 * TTM_WAITIDLE_MODE_LAZY: Allow for sleeps during polling
197 * TTM_WAITIDLE_MODE_NO_BLOCK: Don't block waiting for GPU,
198 * but return -EBUSY if the buffer is busy.
201 #define TTM_PL_WAITIDLE_MODE_LAZY (1 << 0)
202 #define TTM_PL_WAITIDLE_MODE_NO_BLOCK (1 << 1)
205 * struct ttm_waitidle_arg
207 * @handle: The object to synchronize.
209 * @mode: wait mode indicated by the
210 * TTM_SYNCCPU_MODE flags.
212 * Argument to the TTM_BO_WAITIDLE ioctl.
215 struct ttm_pl_waitidle_arg {
220 union ttm_pl_create_arg {
221 struct ttm_pl_create_req req;
222 struct ttm_pl_rep rep;
225 union ttm_pl_reference_arg {
226 struct ttm_pl_reference_req req;
227 struct ttm_pl_rep rep;
230 union ttm_pl_setstatus_arg {
231 struct ttm_pl_setstatus_req req;
232 struct ttm_pl_rep rep;
235 union ttm_pl_create_ub_arg {
236 struct ttm_pl_create_ub_req req;
237 struct ttm_pl_rep rep;
244 #define TTM_PL_CREATE 0x00
245 #define TTM_PL_REFERENCE 0x01
246 #define TTM_PL_UNREF 0x02
247 #define TTM_PL_SYNCCPU 0x03
248 #define TTM_PL_WAITIDLE 0x04
249 #define TTM_PL_SETSTATUS 0x05
250 #define TTM_PL_CREATE_UB 0x06