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 2830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0) 2930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) 3030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 3130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 3230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 3330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */ 3430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00 3530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_16BPP 0x00000001 3630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_32BPP 0x00000002 3730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_ZETA 0x00000004 3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008 3930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 4030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_info { 4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t handle; 4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t domain; 4330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t size; 4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t offset; 4530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t map_handle; 4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t tile_mode; 4730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t tile_flags; 4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 5030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_new { 5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng struct drm_nouveau_gem_info info; 5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t channel_hint; 5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t align; 5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 5530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_MAX_BUFFERS 1024 5730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_bo_presumed { 5830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t valid; 5930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t domain; 6030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t offset; 6130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 6230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 6330692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_bo { 6430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t user_priv; 6530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t handle; 6630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t read_domains; 6730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t write_domains; 6830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t valid_domains; 6930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng struct drm_nouveau_gem_pushbuf_bo_presumed presumed; 7030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 7130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 7230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_RELOC_LOW (1 << 0) 7330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_RELOC_HIGH (1 << 1) 7430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_RELOC_OR (1 << 2) 7530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_MAX_RELOCS 1024 7630692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_reloc { 7730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t reloc_bo_index; 7830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t reloc_bo_offset; 7930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t bo_index; 8030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t flags; 8130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t data; 8230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t vor; 8330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t tor; 8430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 8530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 8630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_MAX_PUSH 512 8730692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf_push { 8830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t bo_index; 8930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t pad; 9030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t offset; 9130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t length; 9230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 9330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 9430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_pushbuf { 9530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t channel; 9630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t nr_buffers; 9730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t buffers; 9830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t nr_relocs; 9930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t nr_push; 10030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t relocs; 10130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t push; 10230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t suffix0; 10330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t suffix1; 10430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t vram_available; 10530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint64_t gart_available; 10630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 10730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 10830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001 10930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004 11030692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_cpu_prep { 11130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t handle; 11230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t flags; 11330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 11430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 11530692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct drm_nouveau_gem_cpu_fini { 11630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng uint32_t handle; 11730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 11830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 11930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */ 12030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */ 12130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */ 12230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */ 12330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */ 12430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */ 12530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */ 12630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_NEW 0x40 12730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_PUSHBUF 0x41 12830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_CPU_PREP 0x42 12930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_CPU_FINI 0x43 13030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_NOUVEAU_GEM_INFO 0x44 13130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 13230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new) 13330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, struct drm_nouveau_gem_pushbuf) 13430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep) 13530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini) 13630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define DRM_IOCTL_NOUVEAU_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info) 13730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 13830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif /* __NOUVEAU_DRM_H__ */ 139