blob: 91d2f3142cb4070f1b966de4b9e91139ade7f569 [file] [log] [blame]
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +02001/*
2 * Copyright 2005 Stephane Marchesin.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
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 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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.
23 */
24
25#ifndef __NOUVEAU_DRM_H__
26#define __NOUVEAU_DRM_H__
27
Luca Barbierib496c632010-01-29 09:53:24 +010028#define NOUVEAU_DRM_HEADER_PATCHLEVEL 16
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +020029
Eric Anholt8d34bba2017-11-08 11:06:55 -080030#include "drm.h"
31
32#if defined(__cplusplus)
33extern "C" {
34#endif
35
Andrew Chew33ecedf2015-09-28 12:09:57 +030036/* reserved object handles when using deprecated object APIs - these
37 * are here so that libdrm can allow interoperability with the new
38 * object APIs
39 */
40#define NOUVEAU_ABI16_CLIENT 0xffffffff
41#define NOUVEAU_ABI16_DEVICE 0xdddddddd
42#define NOUVEAU_ABI16_CHAN(n) (0xcccc0000 | (n))
43
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +020044struct drm_nouveau_channel_alloc {
45 uint32_t fb_ctxdma_handle;
46 uint32_t tt_ctxdma_handle;
47
48 int channel;
Luca Barbierib496c632010-01-29 09:53:24 +010049 uint32_t pushbuf_domains;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +020050
51 /* Notifier memory */
52 uint32_t notifier_handle;
53
54 /* DRM-enforced subchannel assignments */
55 struct {
56 uint32_t handle;
57 uint32_t grclass;
58 } subchan[8];
59 uint32_t nr_subchan;
60};
61
62struct drm_nouveau_channel_free {
63 int channel;
64};
65
66struct drm_nouveau_grobj_alloc {
67 int channel;
68 uint32_t handle;
69 int class;
70};
71
72struct drm_nouveau_notifierobj_alloc {
73 uint32_t channel;
74 uint32_t handle;
75 uint32_t size;
76 uint32_t offset;
77};
78
79struct drm_nouveau_gpuobj_free {
80 int channel;
81 uint32_t handle;
82};
83
84/* FIXME : maybe unify {GET,SET}PARAMs */
85#define NOUVEAU_GETPARAM_PCI_VENDOR 3
86#define NOUVEAU_GETPARAM_PCI_DEVICE 4
87#define NOUVEAU_GETPARAM_BUS_TYPE 5
88#define NOUVEAU_GETPARAM_FB_PHYSICAL 6
89#define NOUVEAU_GETPARAM_AGP_PHYSICAL 7
90#define NOUVEAU_GETPARAM_FB_SIZE 8
91#define NOUVEAU_GETPARAM_AGP_SIZE 9
92#define NOUVEAU_GETPARAM_PCI_PHYSICAL 10
93#define NOUVEAU_GETPARAM_CHIPSET_ID 11
94#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
Marcin Koƛcielnickif2730572010-01-26 18:39:21 +000095#define NOUVEAU_GETPARAM_GRAPH_UNITS 13
Dave Airlie431f7f02010-08-04 08:41:23 +100096#define NOUVEAU_GETPARAM_PTIMER_TIME 14
Francisco Jerez1b9187c2010-09-28 22:47:11 +020097#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
Francisco Jerezc5286f42010-10-21 23:02:43 +020098#define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +020099struct drm_nouveau_getparam {
100 uint64_t param;
101 uint64_t value;
102};
103
104struct drm_nouveau_setparam {
105 uint64_t param;
106 uint64_t value;
107};
108
109#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
110#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
111#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
112#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
David Ungc09651e2015-08-17 14:36:38 -0700113#define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200114
Daniel Stone8e535dd2018-03-30 13:04:30 +0100115#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */
Francisco Jerez1b9187c2010-09-28 22:47:11 +0200116#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
117#define NOUVEAU_GEM_TILE_16BPP 0x00000001
118#define NOUVEAU_GEM_TILE_32BPP 0x00000002
119#define NOUVEAU_GEM_TILE_ZETA 0x00000004
120#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
121
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200122struct drm_nouveau_gem_info {
Eric Anholtf6966982017-11-08 11:22:55 -0800123 __u32 handle;
124 __u32 domain;
125 __u64 size;
126 __u64 offset;
127 __u64 map_handle;
128 __u32 tile_mode;
129 __u32 tile_flags;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200130};
131
Andrew Chew5c9a7cf2015-07-17 11:46:30 -0700132struct drm_nouveau_gem_set_tiling {
133 uint32_t handle;
134 uint32_t tile_mode;
135 uint32_t tile_flags;
136};
137
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200138struct drm_nouveau_gem_new {
139 struct drm_nouveau_gem_info info;
Eric Anholtf6966982017-11-08 11:22:55 -0800140 __u32 channel_hint;
141 __u32 align;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200142};
143
Luca Barbierib496c632010-01-29 09:53:24 +0100144#define NOUVEAU_GEM_MAX_BUFFERS 1024
145struct drm_nouveau_gem_pushbuf_bo_presumed {
Eric Anholtf6966982017-11-08 11:22:55 -0800146 __u32 valid;
147 __u32 domain;
148 __u64 offset;
Luca Barbierib496c632010-01-29 09:53:24 +0100149};
150
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200151struct drm_nouveau_gem_pushbuf_bo {
Eric Anholtf6966982017-11-08 11:22:55 -0800152 __u64 user_priv;
153 __u32 handle;
154 __u32 read_domains;
155 __u32 write_domains;
156 __u32 valid_domains;
Luca Barbierib496c632010-01-29 09:53:24 +0100157 struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200158};
159
160#define NOUVEAU_GEM_RELOC_LOW (1 << 0)
161#define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
162#define NOUVEAU_GEM_RELOC_OR (1 << 2)
Luca Barbierib496c632010-01-29 09:53:24 +0100163#define NOUVEAU_GEM_MAX_RELOCS 1024
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200164struct drm_nouveau_gem_pushbuf_reloc {
Eric Anholtf6966982017-11-08 11:22:55 -0800165 __u32 reloc_bo_index;
166 __u32 reloc_bo_offset;
167 __u32 bo_index;
168 __u32 flags;
169 __u32 data;
170 __u32 vor;
171 __u32 tor;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200172};
173
Ben Skeggs88e8a8b2010-02-16 15:42:00 +1000174#define NOUVEAU_GEM_MAX_PUSH 512
Luca Barbierib496c632010-01-29 09:53:24 +0100175struct drm_nouveau_gem_pushbuf_push {
Eric Anholtf6966982017-11-08 11:22:55 -0800176 __u32 bo_index;
177 __u32 pad;
178 __u64 offset;
179 __u64 length;
Luca Barbierib496c632010-01-29 09:53:24 +0100180};
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200181
182struct drm_nouveau_gem_pushbuf {
Eric Anholtf6966982017-11-08 11:22:55 -0800183 __u32 channel;
184 __u32 nr_buffers;
185 __u64 buffers;
186 __u32 nr_relocs;
187 __u32 nr_push;
188 __u64 relocs;
189 __u64 push;
190 __u32 suffix0;
191 __u32 suffix1;
192 __u64 vram_available;
193 __u64 gart_available;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200194};
195
Andrew Chewfbef8702015-07-20 11:22:04 -0700196#define NOUVEAU_GEM_PUSHBUF_2_FENCE_WAIT 0x00000001
197#define NOUVEAU_GEM_PUSHBUF_2_FENCE_EMIT 0x00000002
198struct drm_nouveau_gem_pushbuf_2 {
199 uint32_t channel;
200 uint32_t flags;
201 uint32_t nr_push;
202 uint32_t nr_buffers;
203 int32_t fence; /* in/out, depends on flags */
204 uint32_t pad;
205 uint64_t push; /* in raw hw format */
206 uint64_t buffers; /* ptr to drm_nouveau_gem_pushbuf_bo */
207 uint64_t vram_available;
208 uint64_t gart_available;
209};
210
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200211#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
212#define NOUVEAU_GEM_CPU_PREP_NOBLOCK 0x00000002
213#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
214struct drm_nouveau_gem_cpu_prep {
Eric Anholtf6966982017-11-08 11:22:55 -0800215 __u32 handle;
216 __u32 flags;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200217};
218
219struct drm_nouveau_gem_cpu_fini {
Eric Anholtf6966982017-11-08 11:22:55 -0800220 __u32 handle;
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200221};
222
Xia Yang5afe8e02015-11-20 15:39:10 -0800223#define NOUVEAU_GEM_AS_SPARSE 0x00000001
Andrew Chewe2686ba2015-08-12 12:19:08 -0700224struct drm_nouveau_gem_as_alloc {
225 uint64_t pages; /* in, page length */
226 uint32_t page_size; /* in, byte page size */
Xia Yang5afe8e02015-11-20 15:39:10 -0800227 uint32_t flags; /* in, flags of address space */
Andrew Chewe2686ba2015-08-12 12:19:08 -0700228 uint64_t align; /* in, requested alignment in bytes */
229 uint64_t address; /* in/out, non-zero for fixed address allocation */
230};
231
232struct drm_nouveau_gem_as_free {
233 uint64_t address; /* in, byte address */
234};
235
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200236enum nouveau_bus_type {
237 NV_AGP = 0,
238 NV_PCI = 1,
239 NV_PCIE = 2,
240};
241
242struct drm_nouveau_sarea {
243};
244
Andrew Chewefae5ab2015-06-26 09:45:22 +0300245#define NOUVEAU_GEM_CHANNEL_FIFO_ERROR_IDLE_TIMEOUT 8
246#define NOUVEAU_GEM_CHANNEL_GR_ERROR_SW_NOTIFY 13
247#define NOUVEAU_GEM_CHANNEL_FIFO_ERROR_MMU_ERR_FLT 31
248#define NOUVEAU_GEM_CHANNEL_PBDMA_ERROR 32
249struct drm_nouveau_gem_set_error_notifier {
250 uint32_t channel;
251 uint32_t buffer;
252 uint32_t offset; /* in bytes, u32-aligned */
253};
254
Andrew Chew9af912e2016-02-23 17:46:28 -0800255struct drm_nouveau_gem_map {
256 uint32_t handle;
257 uint32_t domain;
258 uint64_t offset;
259 uint64_t delta;
260 uint64_t length;
261 uint32_t tile_mode;
262 uint32_t tile_flags;
263};
264
265struct drm_nouveau_gem_unmap {
266 uint32_t handle;
267 uint32_t pad;
268 uint64_t offset;
269 uint64_t delta;
270 uint64_t length;
271};
272
Luca Barbierib496c632010-01-29 09:53:24 +0100273#define DRM_NOUVEAU_GETPARAM 0x00
274#define DRM_NOUVEAU_SETPARAM 0x01
275#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02
276#define DRM_NOUVEAU_CHANNEL_FREE 0x03
277#define DRM_NOUVEAU_GROBJ_ALLOC 0x04
278#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05
279#define DRM_NOUVEAU_GPUOBJ_FREE 0x06
Andrew Chew33ecedf2015-09-28 12:09:57 +0300280#define DRM_NOUVEAU_NVIF 0x07
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200281#define DRM_NOUVEAU_GEM_NEW 0x40
282#define DRM_NOUVEAU_GEM_PUSHBUF 0x41
Luca Barbierib496c632010-01-29 09:53:24 +0100283#define DRM_NOUVEAU_GEM_CPU_PREP 0x42
284#define DRM_NOUVEAU_GEM_CPU_FINI 0x43
285#define DRM_NOUVEAU_GEM_INFO 0x44
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200286
David Ungf1d84bc2015-05-08 11:49:29 -0700287/* The ioctls below are marked as staging */
288#define DRM_NOUVEAU_GEM_SET_TILING 0x50
289#define DRM_NOUVEAU_GEM_PUSHBUF_2 0x51
Andrew Chew02d5c462015-08-12 12:22:21 -0700290#define DRM_NOUVEAU_GEM_SET_INFO 0x52
Andrew Chewe2686ba2015-08-12 12:19:08 -0700291#define DRM_NOUVEAU_GEM_AS_ALLOC 0x53
292#define DRM_NOUVEAU_GEM_AS_FREE 0x54
Andrew Chewefae5ab2015-06-26 09:45:22 +0300293#define DRM_NOUVEAU_GEM_SET_ERROR_NOTIFIER 0x55
Andrew Chew9af912e2016-02-23 17:46:28 -0800294#define DRM_NOUVEAU_GEM_MAP 0x56
295#define DRM_NOUVEAU_GEM_UNMAP 0x57
David Ungf1d84bc2015-05-08 11:49:29 -0700296
Eric Anholt8d34bba2017-11-08 11:06:55 -0800297#if defined(__cplusplus)
298}
299#endif
Pekka Paalanen3a87b1f2009-11-21 01:00:36 +0200300#endif /* __NOUVEAU_DRM_H__ */