122944501Smrg/* 222944501Smrg * Copyright 2005 Stephane Marchesin. 322944501Smrg * All Rights Reserved. 422944501Smrg * 522944501Smrg * Permission is hereby granted, free of charge, to any person obtaining a 622944501Smrg * copy of this software and associated documentation files (the "Software"), 722944501Smrg * to deal in the Software without restriction, including without limitation 822944501Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 922944501Smrg * and/or sell copies of the Software, and to permit persons to whom the 1022944501Smrg * Software is furnished to do so, subject to the following conditions: 1122944501Smrg * 1222944501Smrg * The above copyright notice and this permission notice (including the next 1322944501Smrg * paragraph) shall be included in all copies or substantial portions of the 1422944501Smrg * Software. 1522944501Smrg * 1622944501Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1722944501Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1822944501Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1922944501Smrg * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 2022944501Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2122944501Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2222944501Smrg * OTHER DEALINGS IN THE SOFTWARE. 2322944501Smrg */ 2422944501Smrg 2522944501Smrg#ifndef __NOUVEAU_DRM_H__ 2622944501Smrg#define __NOUVEAU_DRM_H__ 2722944501Smrg 2822944501Smrg#define NOUVEAU_DRM_HEADER_PATCHLEVEL 16 2922944501Smrg 3000a23bdaSmrg#include "drm.h" 3100a23bdaSmrg 3200a23bdaSmrg#if defined(__cplusplus) 3300a23bdaSmrgextern "C" { 3400a23bdaSmrg#endif 3500a23bdaSmrg 3622944501Smrgstruct drm_nouveau_channel_alloc { 3722944501Smrg uint32_t fb_ctxdma_handle; 3822944501Smrg uint32_t tt_ctxdma_handle; 3922944501Smrg 4022944501Smrg int channel; 4122944501Smrg uint32_t pushbuf_domains; 4222944501Smrg 4322944501Smrg /* Notifier memory */ 4422944501Smrg uint32_t notifier_handle; 4522944501Smrg 4622944501Smrg /* DRM-enforced subchannel assignments */ 4722944501Smrg struct { 4822944501Smrg uint32_t handle; 4922944501Smrg uint32_t grclass; 5022944501Smrg } subchan[8]; 5122944501Smrg uint32_t nr_subchan; 5222944501Smrg}; 5322944501Smrg 5422944501Smrgstruct drm_nouveau_channel_free { 5522944501Smrg int channel; 5622944501Smrg}; 5722944501Smrg 5822944501Smrgstruct drm_nouveau_grobj_alloc { 5922944501Smrg int channel; 6022944501Smrg uint32_t handle; 6122944501Smrg int class; 6222944501Smrg}; 6322944501Smrg 6422944501Smrgstruct drm_nouveau_notifierobj_alloc { 6522944501Smrg uint32_t channel; 6622944501Smrg uint32_t handle; 6722944501Smrg uint32_t size; 6822944501Smrg uint32_t offset; 6922944501Smrg}; 7022944501Smrg 7122944501Smrgstruct drm_nouveau_gpuobj_free { 7222944501Smrg int channel; 7322944501Smrg uint32_t handle; 7422944501Smrg}; 7522944501Smrg 7622944501Smrg#define NOUVEAU_GETPARAM_PCI_VENDOR 3 7722944501Smrg#define NOUVEAU_GETPARAM_PCI_DEVICE 4 7822944501Smrg#define NOUVEAU_GETPARAM_BUS_TYPE 5 7922944501Smrg#define NOUVEAU_GETPARAM_FB_SIZE 8 8022944501Smrg#define NOUVEAU_GETPARAM_AGP_SIZE 9 8122944501Smrg#define NOUVEAU_GETPARAM_CHIPSET_ID 11 8222944501Smrg#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12 8322944501Smrg#define NOUVEAU_GETPARAM_GRAPH_UNITS 13 84d049871aSmrg#define NOUVEAU_GETPARAM_PTIMER_TIME 14 8569dda199Smrg#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15 8669dda199Smrg#define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16 8722944501Smrgstruct drm_nouveau_getparam { 8822944501Smrg uint64_t param; 8922944501Smrg uint64_t value; 9022944501Smrg}; 9122944501Smrg 9222944501Smrgstruct drm_nouveau_setparam { 9322944501Smrg uint64_t param; 9422944501Smrg uint64_t value; 9522944501Smrg}; 9622944501Smrg 9722944501Smrg#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0) 9822944501Smrg#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) 9922944501Smrg#define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 10022944501Smrg#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 101e6188e58Smrg#define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4) 10222944501Smrg 1037cdc0497Smrg#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */ 10469dda199Smrg#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00 10569dda199Smrg#define NOUVEAU_GEM_TILE_16BPP 0x00000001 10669dda199Smrg#define NOUVEAU_GEM_TILE_32BPP 0x00000002 10769dda199Smrg#define NOUVEAU_GEM_TILE_ZETA 0x00000004 10869dda199Smrg#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008 10969dda199Smrg 11022944501Smrgstruct drm_nouveau_gem_info { 11100a23bdaSmrg __u32 handle; 11200a23bdaSmrg __u32 domain; 11300a23bdaSmrg __u64 size; 11400a23bdaSmrg __u64 offset; 11500a23bdaSmrg __u64 map_handle; 11600a23bdaSmrg __u32 tile_mode; 11700a23bdaSmrg __u32 tile_flags; 11822944501Smrg}; 11922944501Smrg 12022944501Smrgstruct drm_nouveau_gem_new { 12122944501Smrg struct drm_nouveau_gem_info info; 12200a23bdaSmrg __u32 channel_hint; 12300a23bdaSmrg __u32 align; 12422944501Smrg}; 12522944501Smrg 12622944501Smrg#define NOUVEAU_GEM_MAX_BUFFERS 1024 12722944501Smrgstruct drm_nouveau_gem_pushbuf_bo_presumed { 12800a23bdaSmrg __u32 valid; 12900a23bdaSmrg __u32 domain; 13000a23bdaSmrg __u64 offset; 13122944501Smrg}; 13222944501Smrg 13322944501Smrgstruct drm_nouveau_gem_pushbuf_bo { 13400a23bdaSmrg __u64 user_priv; 13500a23bdaSmrg __u32 handle; 13600a23bdaSmrg __u32 read_domains; 13700a23bdaSmrg __u32 write_domains; 13800a23bdaSmrg __u32 valid_domains; 13922944501Smrg struct drm_nouveau_gem_pushbuf_bo_presumed presumed; 14022944501Smrg}; 14122944501Smrg 14222944501Smrg#define NOUVEAU_GEM_RELOC_LOW (1 << 0) 14322944501Smrg#define NOUVEAU_GEM_RELOC_HIGH (1 << 1) 14422944501Smrg#define NOUVEAU_GEM_RELOC_OR (1 << 2) 14522944501Smrg#define NOUVEAU_GEM_MAX_RELOCS 1024 14622944501Smrgstruct drm_nouveau_gem_pushbuf_reloc { 14700a23bdaSmrg __u32 reloc_bo_index; 14800a23bdaSmrg __u32 reloc_bo_offset; 14900a23bdaSmrg __u32 bo_index; 15000a23bdaSmrg __u32 flags; 15100a23bdaSmrg __u32 data; 15200a23bdaSmrg __u32 vor; 15300a23bdaSmrg __u32 tor; 15422944501Smrg}; 15522944501Smrg 15622944501Smrg#define NOUVEAU_GEM_MAX_PUSH 512 15722944501Smrgstruct drm_nouveau_gem_pushbuf_push { 15800a23bdaSmrg __u32 bo_index; 15900a23bdaSmrg __u32 pad; 16000a23bdaSmrg __u64 offset; 16100a23bdaSmrg __u64 length; 16222944501Smrg}; 16322944501Smrg 16422944501Smrgstruct drm_nouveau_gem_pushbuf { 16500a23bdaSmrg __u32 channel; 16600a23bdaSmrg __u32 nr_buffers; 16700a23bdaSmrg __u64 buffers; 16800a23bdaSmrg __u32 nr_relocs; 16900a23bdaSmrg __u32 nr_push; 17000a23bdaSmrg __u64 relocs; 17100a23bdaSmrg __u64 push; 17200a23bdaSmrg __u32 suffix0; 17300a23bdaSmrg __u32 suffix1; 1749bd392adSmrg#define NOUVEAU_GEM_PUSHBUF_SYNC (1ULL << 0) 17500a23bdaSmrg __u64 vram_available; 17600a23bdaSmrg __u64 gart_available; 17722944501Smrg}; 17822944501Smrg 17922944501Smrg#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001 18022944501Smrg#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004 18122944501Smrgstruct drm_nouveau_gem_cpu_prep { 18200a23bdaSmrg __u32 handle; 18300a23bdaSmrg __u32 flags; 18422944501Smrg}; 18522944501Smrg 18622944501Smrgstruct drm_nouveau_gem_cpu_fini { 18700a23bdaSmrg __u32 handle; 18822944501Smrg}; 18922944501Smrg 1909bd392adSmrg#define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */ 1919bd392adSmrg#define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */ 1929bd392adSmrg#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */ 1939bd392adSmrg#define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */ 1949bd392adSmrg#define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */ 1959bd392adSmrg#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */ 1969bd392adSmrg#define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */ 1973f012e29Smrg#define DRM_NOUVEAU_NVIF 0x07 1989bd392adSmrg#define DRM_NOUVEAU_SVM_INIT 0x08 1999bd392adSmrg#define DRM_NOUVEAU_SVM_BIND 0x09 20022944501Smrg#define DRM_NOUVEAU_GEM_NEW 0x40 20122944501Smrg#define DRM_NOUVEAU_GEM_PUSHBUF 0x41 20222944501Smrg#define DRM_NOUVEAU_GEM_CPU_PREP 0x42 20322944501Smrg#define DRM_NOUVEAU_GEM_CPU_FINI 0x43 20422944501Smrg#define DRM_NOUVEAU_GEM_INFO 0x44 20522944501Smrg 2069bd392adSmrgstruct drm_nouveau_svm_init { 2079bd392adSmrg __u64 unmanaged_addr; 2089bd392adSmrg __u64 unmanaged_size; 2099bd392adSmrg}; 2109bd392adSmrg 2119bd392adSmrgstruct drm_nouveau_svm_bind { 2129bd392adSmrg __u64 header; 2139bd392adSmrg __u64 va_start; 2149bd392adSmrg __u64 va_end; 2159bd392adSmrg __u64 npages; 2169bd392adSmrg __u64 stride; 2179bd392adSmrg __u64 result; 2189bd392adSmrg __u64 reserved0; 2199bd392adSmrg __u64 reserved1; 2209bd392adSmrg}; 2219bd392adSmrg 2229bd392adSmrg#define NOUVEAU_SVM_BIND_COMMAND_SHIFT 0 2239bd392adSmrg#define NOUVEAU_SVM_BIND_COMMAND_BITS 8 2249bd392adSmrg#define NOUVEAU_SVM_BIND_COMMAND_MASK ((1 << 8) - 1) 2259bd392adSmrg#define NOUVEAU_SVM_BIND_PRIORITY_SHIFT 8 2269bd392adSmrg#define NOUVEAU_SVM_BIND_PRIORITY_BITS 8 2279bd392adSmrg#define NOUVEAU_SVM_BIND_PRIORITY_MASK ((1 << 8) - 1) 2289bd392adSmrg#define NOUVEAU_SVM_BIND_TARGET_SHIFT 16 2299bd392adSmrg#define NOUVEAU_SVM_BIND_TARGET_BITS 32 2309bd392adSmrg#define NOUVEAU_SVM_BIND_TARGET_MASK 0xffffffff 2319bd392adSmrg 2329bd392adSmrg/* 2339bd392adSmrg * Below is use to validate ioctl argument, userspace can also use it to make 2349bd392adSmrg * sure that no bit are set beyond known fields for a given kernel version. 2359bd392adSmrg */ 2369bd392adSmrg#define NOUVEAU_SVM_BIND_VALID_BITS 48 2379bd392adSmrg#define NOUVEAU_SVM_BIND_VALID_MASK ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1) 2389bd392adSmrg 2399bd392adSmrg 2409bd392adSmrg/* 2419bd392adSmrg * NOUVEAU_BIND_COMMAND__MIGRATE: synchronous migrate to target memory. 2429bd392adSmrg * result: number of page successfuly migrate to the target memory. 2439bd392adSmrg */ 2449bd392adSmrg#define NOUVEAU_SVM_BIND_COMMAND__MIGRATE 0 2459bd392adSmrg 2469bd392adSmrg/* 2479bd392adSmrg * NOUVEAU_SVM_BIND_HEADER_TARGET__GPU_VRAM: target the GPU VRAM memory. 2489bd392adSmrg */ 2499bd392adSmrg#define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM (1UL << 31) 2509bd392adSmrg 2519bd392adSmrg 25200a23bdaSmrg#if defined(__cplusplus) 25300a23bdaSmrg} 25400a23bdaSmrg#endif 25500a23bdaSmrg 25622944501Smrg#endif /* __NOUVEAU_DRM_H__ */ 257