130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/*
230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright 2005 Stephane Marchesin.
330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * All Rights Reserved.
430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Permission is hereby granted, free of charge, to any person obtaining a
630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * copy of this software and associated documentation files (the "Software"),
730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * to deal in the Software without restriction, including without limitation
830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * the rights to use, copy, modify, merge, publish, distribute, sublicense,
930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * and/or sell copies of the Software, and to permit persons to whom the
1030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Software is furnished to do so, subject to the following conditions:
1130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * The above copyright notice and this permission notice (including the next
1330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * paragraph) shall be included in all copies or substantial portions of the
1430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Software.
1530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng *
1630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * OTHER DEALINGS IN THE SOFTWARE.
2330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */
2430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
2530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#ifndef __NOUVEAU_DRM_H__
2630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define __NOUVEAU_DRM_H__
2730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
287c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define DRM_NOUVEAU_EVENT_NVIF                                       0x80000000
297c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris
307c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris/* reserved object handles when using deprecated object APIs - these
317c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris * are here so that libdrm can allow interoperability with the new
327c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris * object APIs
337c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris */
347c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define NOUVEAU_ABI16_CLIENT   0xffffffff
357c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define NOUVEAU_ABI16_DEVICE   0xdddddddd
367c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define NOUVEAU_ABI16_CHAN(n) (0xcccc0000 | (n))
377c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris
3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_CPU       (1 << 0)
3930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_VRAM      (1 << 1)
4030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_GART      (1 << 2)
4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_MAPPABLE  (1 << 3)
4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
4330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_COMP        0x00030000 /* nv50-only */
4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
4530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_16BPP       0x00000001
4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_32BPP       0x00000002
4730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_ZETA        0x00000004
4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_NONCONTIG   0x00000008
4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
5030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_info {
5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t handle;
5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t domain;
5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t size;
5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t offset;
5530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t map_handle;
5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t tile_mode;
5730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t tile_flags;
5830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
5930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
6030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_new {
6130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	struct drm_nouveau_gem_info info;
6230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t channel_hint;
6330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t align;
6430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
6530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
6630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_MAX_BUFFERS 1024
6730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_bo_presumed {
6830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t valid;
6930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t domain;
7030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t offset;
7130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
7230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
7330692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_bo {
7430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t user_priv;
7530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t handle;
7630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t read_domains;
7730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t write_domains;
7830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t valid_domains;
7930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
8030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
8130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
8230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_RELOC_LOW  (1 << 0)
8330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
8430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_RELOC_OR   (1 << 2)
8530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_MAX_RELOCS 1024
8630692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_reloc {
8730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t reloc_bo_index;
8830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t reloc_bo_offset;
8930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t bo_index;
9030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t flags;
9130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t data;
9230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t vor;
9330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t tor;
9430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
9530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
9630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_MAX_PUSH 512
9730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_push {
9830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t bo_index;
9930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t pad;
10030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t offset;
10130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t length;
10230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
10330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
10430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf {
10530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t channel;
10630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t nr_buffers;
10730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t buffers;
10830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t nr_relocs;
10930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t nr_push;
11030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t relocs;
11130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t push;
11230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t suffix0;
11330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t suffix1;
11430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t vram_available;
11530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint64_t gart_available;
11630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
11730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
11830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_CPU_PREP_NOWAIT                                  0x00000001
11930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_CPU_PREP_WRITE                                   0x00000004
12030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_cpu_prep {
12130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t handle;
12230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t flags;
12330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
12430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
12530692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_cpu_fini {
12630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng	uint32_t handle;
12730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng};
12830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
12930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GETPARAM           0x00 /* deprecated */
13030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_SETPARAM           0x01 /* deprecated */
13130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_CHANNEL_ALLOC      0x02 /* deprecated */
13230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_CHANNEL_FREE       0x03 /* deprecated */
13330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GROBJ_ALLOC        0x04 /* deprecated */
13430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC  0x05 /* deprecated */
13530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GPUOBJ_FREE        0x06 /* deprecated */
1367c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define DRM_NOUVEAU_NVIF               0x07
13730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_NEW            0x40
13830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_PUSHBUF        0x41
13930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_CPU_PREP       0x42
14030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_CPU_FINI       0x43
14130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_INFO           0x44
14230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
14330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_NEW            DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
14430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF        DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, struct drm_nouveau_gem_pushbuf)
14530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP       DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep)
14630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI       DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini)
14730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_INFO           DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
14830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng
14930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif /* __NOUVEAU_DRM_H__ */
150