xref: /OK3568_Linux_fs/kernel/include/uapi/drm/nouveau_drm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2005 Stephane Marchesin.
3*4882a593Smuzhiyun  * All Rights Reserved.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
6*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
7*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
8*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
10*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * The above copyright notice and this permission notice (including the next
13*4882a593Smuzhiyun  * paragraph) shall be included in all copies or substantial portions of the
14*4882a593Smuzhiyun  * Software.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19*4882a593Smuzhiyun  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20*4882a593Smuzhiyun  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21*4882a593Smuzhiyun  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22*4882a593Smuzhiyun  * OTHER DEALINGS IN THE SOFTWARE.
23*4882a593Smuzhiyun  */
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #ifndef __NOUVEAU_DRM_H__
26*4882a593Smuzhiyun #define __NOUVEAU_DRM_H__
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #define DRM_NOUVEAU_EVENT_NVIF                                       0x80000000
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #include "drm.h"
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #if defined(__cplusplus)
33*4882a593Smuzhiyun extern "C" {
34*4882a593Smuzhiyun #endif
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #define NOUVEAU_GEM_DOMAIN_CPU       (1 << 0)
37*4882a593Smuzhiyun #define NOUVEAU_GEM_DOMAIN_VRAM      (1 << 1)
38*4882a593Smuzhiyun #define NOUVEAU_GEM_DOMAIN_GART      (1 << 2)
39*4882a593Smuzhiyun #define NOUVEAU_GEM_DOMAIN_MAPPABLE  (1 << 3)
40*4882a593Smuzhiyun #define NOUVEAU_GEM_DOMAIN_COHERENT  (1 << 4)
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #define NOUVEAU_GEM_TILE_COMP        0x00030000 /* nv50-only */
43*4882a593Smuzhiyun #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
44*4882a593Smuzhiyun #define NOUVEAU_GEM_TILE_16BPP       0x00000001
45*4882a593Smuzhiyun #define NOUVEAU_GEM_TILE_32BPP       0x00000002
46*4882a593Smuzhiyun #define NOUVEAU_GEM_TILE_ZETA        0x00000004
47*4882a593Smuzhiyun #define NOUVEAU_GEM_TILE_NONCONTIG   0x00000008
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun struct drm_nouveau_gem_info {
50*4882a593Smuzhiyun 	__u32 handle;
51*4882a593Smuzhiyun 	__u32 domain;
52*4882a593Smuzhiyun 	__u64 size;
53*4882a593Smuzhiyun 	__u64 offset;
54*4882a593Smuzhiyun 	__u64 map_handle;
55*4882a593Smuzhiyun 	__u32 tile_mode;
56*4882a593Smuzhiyun 	__u32 tile_flags;
57*4882a593Smuzhiyun };
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun struct drm_nouveau_gem_new {
60*4882a593Smuzhiyun 	struct drm_nouveau_gem_info info;
61*4882a593Smuzhiyun 	__u32 channel_hint;
62*4882a593Smuzhiyun 	__u32 align;
63*4882a593Smuzhiyun };
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define NOUVEAU_GEM_MAX_BUFFERS 1024
66*4882a593Smuzhiyun struct drm_nouveau_gem_pushbuf_bo_presumed {
67*4882a593Smuzhiyun 	__u32 valid;
68*4882a593Smuzhiyun 	__u32 domain;
69*4882a593Smuzhiyun 	__u64 offset;
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun struct drm_nouveau_gem_pushbuf_bo {
73*4882a593Smuzhiyun 	__u64 user_priv;
74*4882a593Smuzhiyun 	__u32 handle;
75*4882a593Smuzhiyun 	__u32 read_domains;
76*4882a593Smuzhiyun 	__u32 write_domains;
77*4882a593Smuzhiyun 	__u32 valid_domains;
78*4882a593Smuzhiyun 	struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
79*4882a593Smuzhiyun };
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun #define NOUVEAU_GEM_RELOC_LOW  (1 << 0)
82*4882a593Smuzhiyun #define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
83*4882a593Smuzhiyun #define NOUVEAU_GEM_RELOC_OR   (1 << 2)
84*4882a593Smuzhiyun #define NOUVEAU_GEM_MAX_RELOCS 1024
85*4882a593Smuzhiyun struct drm_nouveau_gem_pushbuf_reloc {
86*4882a593Smuzhiyun 	__u32 reloc_bo_index;
87*4882a593Smuzhiyun 	__u32 reloc_bo_offset;
88*4882a593Smuzhiyun 	__u32 bo_index;
89*4882a593Smuzhiyun 	__u32 flags;
90*4882a593Smuzhiyun 	__u32 data;
91*4882a593Smuzhiyun 	__u32 vor;
92*4882a593Smuzhiyun 	__u32 tor;
93*4882a593Smuzhiyun };
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun #define NOUVEAU_GEM_MAX_PUSH 512
96*4882a593Smuzhiyun struct drm_nouveau_gem_pushbuf_push {
97*4882a593Smuzhiyun 	__u32 bo_index;
98*4882a593Smuzhiyun 	__u32 pad;
99*4882a593Smuzhiyun 	__u64 offset;
100*4882a593Smuzhiyun 	__u64 length;
101*4882a593Smuzhiyun };
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun struct drm_nouveau_gem_pushbuf {
104*4882a593Smuzhiyun 	__u32 channel;
105*4882a593Smuzhiyun 	__u32 nr_buffers;
106*4882a593Smuzhiyun 	__u64 buffers;
107*4882a593Smuzhiyun 	__u32 nr_relocs;
108*4882a593Smuzhiyun 	__u32 nr_push;
109*4882a593Smuzhiyun 	__u64 relocs;
110*4882a593Smuzhiyun 	__u64 push;
111*4882a593Smuzhiyun 	__u32 suffix0;
112*4882a593Smuzhiyun 	__u32 suffix1;
113*4882a593Smuzhiyun #define NOUVEAU_GEM_PUSHBUF_SYNC                                    (1ULL << 0)
114*4882a593Smuzhiyun 	__u64 vram_available;
115*4882a593Smuzhiyun 	__u64 gart_available;
116*4882a593Smuzhiyun };
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun #define NOUVEAU_GEM_CPU_PREP_NOWAIT                                  0x00000001
119*4882a593Smuzhiyun #define NOUVEAU_GEM_CPU_PREP_WRITE                                   0x00000004
120*4882a593Smuzhiyun struct drm_nouveau_gem_cpu_prep {
121*4882a593Smuzhiyun 	__u32 handle;
122*4882a593Smuzhiyun 	__u32 flags;
123*4882a593Smuzhiyun };
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun struct drm_nouveau_gem_cpu_fini {
126*4882a593Smuzhiyun 	__u32 handle;
127*4882a593Smuzhiyun };
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun #define DRM_NOUVEAU_GETPARAM           0x00 /* deprecated */
130*4882a593Smuzhiyun #define DRM_NOUVEAU_SETPARAM           0x01 /* deprecated */
131*4882a593Smuzhiyun #define DRM_NOUVEAU_CHANNEL_ALLOC      0x02 /* deprecated */
132*4882a593Smuzhiyun #define DRM_NOUVEAU_CHANNEL_FREE       0x03 /* deprecated */
133*4882a593Smuzhiyun #define DRM_NOUVEAU_GROBJ_ALLOC        0x04 /* deprecated */
134*4882a593Smuzhiyun #define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC  0x05 /* deprecated */
135*4882a593Smuzhiyun #define DRM_NOUVEAU_GPUOBJ_FREE        0x06 /* deprecated */
136*4882a593Smuzhiyun #define DRM_NOUVEAU_NVIF               0x07
137*4882a593Smuzhiyun #define DRM_NOUVEAU_SVM_INIT           0x08
138*4882a593Smuzhiyun #define DRM_NOUVEAU_SVM_BIND           0x09
139*4882a593Smuzhiyun #define DRM_NOUVEAU_GEM_NEW            0x40
140*4882a593Smuzhiyun #define DRM_NOUVEAU_GEM_PUSHBUF        0x41
141*4882a593Smuzhiyun #define DRM_NOUVEAU_GEM_CPU_PREP       0x42
142*4882a593Smuzhiyun #define DRM_NOUVEAU_GEM_CPU_FINI       0x43
143*4882a593Smuzhiyun #define DRM_NOUVEAU_GEM_INFO           0x44
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun struct drm_nouveau_svm_init {
146*4882a593Smuzhiyun 	__u64 unmanaged_addr;
147*4882a593Smuzhiyun 	__u64 unmanaged_size;
148*4882a593Smuzhiyun };
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun struct drm_nouveau_svm_bind {
151*4882a593Smuzhiyun 	__u64 header;
152*4882a593Smuzhiyun 	__u64 va_start;
153*4882a593Smuzhiyun 	__u64 va_end;
154*4882a593Smuzhiyun 	__u64 npages;
155*4882a593Smuzhiyun 	__u64 stride;
156*4882a593Smuzhiyun 	__u64 result;
157*4882a593Smuzhiyun 	__u64 reserved0;
158*4882a593Smuzhiyun 	__u64 reserved1;
159*4882a593Smuzhiyun };
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_COMMAND_SHIFT          0
162*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_COMMAND_BITS           8
163*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_COMMAND_MASK           ((1 << 8) - 1)
164*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_PRIORITY_SHIFT         8
165*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_PRIORITY_BITS          8
166*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_PRIORITY_MASK          ((1 << 8) - 1)
167*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_TARGET_SHIFT           16
168*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_TARGET_BITS            32
169*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_TARGET_MASK            0xffffffff
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun /*
172*4882a593Smuzhiyun  * Below is use to validate ioctl argument, userspace can also use it to make
173*4882a593Smuzhiyun  * sure that no bit are set beyond known fields for a given kernel version.
174*4882a593Smuzhiyun  */
175*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_VALID_BITS     48
176*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_VALID_MASK     ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1)
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun /*
180*4882a593Smuzhiyun  * NOUVEAU_BIND_COMMAND__MIGRATE: synchronous migrate to target memory.
181*4882a593Smuzhiyun  * result: number of page successfuly migrate to the target memory.
182*4882a593Smuzhiyun  */
183*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_COMMAND__MIGRATE               0
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun /*
186*4882a593Smuzhiyun  * NOUVEAU_SVM_BIND_HEADER_TARGET__GPU_VRAM: target the GPU VRAM memory.
187*4882a593Smuzhiyun  */
188*4882a593Smuzhiyun #define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM               (1UL << 31)
189*4882a593Smuzhiyun 
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_SVM_INIT           DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_INIT, struct drm_nouveau_svm_init)
192*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_SVM_BIND           DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_BIND, struct drm_nouveau_svm_bind)
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_GEM_NEW            DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
195*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF        DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, struct drm_nouveau_gem_pushbuf)
196*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP       DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep)
197*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI       DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini)
198*4882a593Smuzhiyun #define DRM_IOCTL_NOUVEAU_GEM_INFO           DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun #if defined(__cplusplus)
201*4882a593Smuzhiyun }
202*4882a593Smuzhiyun #endif
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun #endif /* __NOUVEAU_DRM_H__ */
205