savage_common.h revision ab47cfaa
1ab47cfaaSmrg/* savage_common.h -- Public header for the savage driver (IOCTLs) 2ab47cfaaSmrg * 3ab47cfaaSmrg * Copyright 2004 Felix Kuehling 4ab47cfaaSmrg * All Rights Reserved. 5ab47cfaaSmrg * 6ab47cfaaSmrg * Permission is hereby granted, free of charge, to any person obtaining a 7ab47cfaaSmrg * copy of this software and associated documentation files (the "Software"), 8ab47cfaaSmrg * to deal in the Software without restriction, including without limitation 9ab47cfaaSmrg * the rights to use, copy, modify, merge, publish, distribute, sub license, 10ab47cfaaSmrg * and/or sell copies of the Software, and to permit persons to whom the 11ab47cfaaSmrg * Software is furnished to do so, subject to the following conditions: 12ab47cfaaSmrg * 13ab47cfaaSmrg * The above copyright notice and this permission notice (including the 14ab47cfaaSmrg * next paragraph) shall be included in all copies or substantial portions 15ab47cfaaSmrg * of the Software. 16ab47cfaaSmrg * 17ab47cfaaSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18ab47cfaaSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19ab47cfaaSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 20ab47cfaaSmrg * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21ab47cfaaSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22ab47cfaaSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23ab47cfaaSmrg * DEALINGS IN THE SOFTWARE. 24ab47cfaaSmrg */ 25ab47cfaaSmrg 26ab47cfaaSmrg#ifndef __SAVAGE_COMMON_H__ 27ab47cfaaSmrg#define __SAVAGE_COMMON_H__ 28ab47cfaaSmrg 29ab47cfaaSmrg#include <inttypes.h> 30ab47cfaaSmrg 31ab47cfaaSmrg/* Savage-specific ioctls 32ab47cfaaSmrg */ 33ab47cfaaSmrg#define DRM_SAVAGE_BCI_INIT 0x00 34ab47cfaaSmrg#define DRM_SAVAGE_BCI_CMDBUF 0x01 35ab47cfaaSmrg#define DRM_SAVAGE_BCI_EVENT_EMIT 0x02 36ab47cfaaSmrg#define DRM_SAVAGE_BCI_EVENT_WAIT 0x03 37ab47cfaaSmrg 38ab47cfaaSmrg#define SAVAGE_DMA_PCI 1 39ab47cfaaSmrg#define SAVAGE_DMA_AGP 3 40ab47cfaaSmrgtypedef struct { 41ab47cfaaSmrg enum { 42ab47cfaaSmrg SAVAGE_INIT_BCI = 1, 43ab47cfaaSmrg SAVAGE_CLEANUP_BCI = 2 44ab47cfaaSmrg } func; 45ab47cfaaSmrg unsigned int sarea_priv_offset; 46ab47cfaaSmrg 47ab47cfaaSmrg /* some parameters */ 48ab47cfaaSmrg unsigned int cob_size; 49ab47cfaaSmrg unsigned int bci_threshold_lo, bci_threshold_hi; 50ab47cfaaSmrg unsigned int dma_type; 51ab47cfaaSmrg 52ab47cfaaSmrg /* frame buffer layout */ 53ab47cfaaSmrg unsigned int fb_bpp; 54ab47cfaaSmrg unsigned int front_offset, front_pitch; 55ab47cfaaSmrg unsigned int back_offset, back_pitch; 56ab47cfaaSmrg unsigned int depth_bpp; 57ab47cfaaSmrg unsigned int depth_offset, depth_pitch; 58ab47cfaaSmrg 59ab47cfaaSmrg /* local textures */ 60ab47cfaaSmrg unsigned int texture_offset; 61ab47cfaaSmrg unsigned int texture_size; 62ab47cfaaSmrg 63ab47cfaaSmrg /* physical locations of non-permanent maps */ 64ab47cfaaSmrg unsigned long status_offset; 65ab47cfaaSmrg unsigned long buffers_offset; 66ab47cfaaSmrg unsigned long agp_textures_offset; 67ab47cfaaSmrg unsigned long cmd_dma_offset; 68ab47cfaaSmrg} drmSAVAGEInit; 69ab47cfaaSmrg 70ab47cfaaSmrgtypedef union drmSAVAGECmdHeader drmSAVAGECmdHeader; 71ab47cfaaSmrgtypedef struct { 72ab47cfaaSmrg /* command buffer in client's address space */ 73ab47cfaaSmrg drmSAVAGECmdHeader *cmd_addr; 74ab47cfaaSmrg unsigned int size; /* size of the command buffer in 64bit units */ 75ab47cfaaSmrg 76ab47cfaaSmrg unsigned int dma_idx; /* DMA buffer index to use */ 77ab47cfaaSmrg int discard; /* discard DMA buffer when done */ 78ab47cfaaSmrg /* vertex buffer in client's address space */ 79ab47cfaaSmrg unsigned int *vb_addr; 80ab47cfaaSmrg unsigned int vb_size; /* size of client vertex buffer in bytes */ 81ab47cfaaSmrg unsigned int vb_stride; /* stride of vertices in 32bit words */ 82ab47cfaaSmrg /* boxes in client's address space */ 83ab47cfaaSmrg drm_clip_rect_t *box_addr; 84ab47cfaaSmrg unsigned int nbox; /* number of clipping boxes */ 85ab47cfaaSmrg} drmSAVAGECmdbuf; 86ab47cfaaSmrg 87ab47cfaaSmrg#define SAVAGE_WAIT_2D 0x1 /* wait for 2D idle before updating event tag */ 88ab47cfaaSmrg#define SAVAGE_WAIT_3D 0x2 /* wait for 3D idle before updating event tag */ 89ab47cfaaSmrg#define SAVAGE_WAIT_IRQ 0x4 /* emit or wait for IRQ, not implemented yet */ 90ab47cfaaSmrgtypedef struct { 91ab47cfaaSmrg unsigned int count; 92ab47cfaaSmrg unsigned int flags; 93ab47cfaaSmrg} drmSAVAGEEventEmit, drmSAVAGEEventWait; 94ab47cfaaSmrg 95ab47cfaaSmrg/* Commands for the cmdbuf ioctl 96ab47cfaaSmrg */ 97ab47cfaaSmrg#define SAVAGE_CMD_STATE 0 /* a range of state registers */ 98ab47cfaaSmrg#define SAVAGE_CMD_DMA_PRIM 1 /* vertices from DMA buffer */ 99ab47cfaaSmrg#define SAVAGE_CMD_VTX_PRIM 2 /* vertices from client vertex buffer */ 100ab47cfaaSmrg#define SAVAGE_CMD_DMA_IDX 3 /* indexed vertices from DMA buffer */ 101ab47cfaaSmrg#define SAVAGE_CMD_VTX_IDX 4 /* indexed vertices client vertex buffer */ 102ab47cfaaSmrg#define SAVAGE_CMD_CLEAR 5 /* clear buffers */ 103ab47cfaaSmrg#define SAVAGE_CMD_SWAP 6 /* swap buffers */ 104ab47cfaaSmrg 105ab47cfaaSmrg/* Primitive types 106ab47cfaaSmrg*/ 107ab47cfaaSmrg#define SAVAGE_PRIM_TRILIST 0 /* triangle list */ 108ab47cfaaSmrg#define SAVAGE_PRIM_TRISTRIP 1 /* triangle strip */ 109ab47cfaaSmrg#define SAVAGE_PRIM_TRIFAN 2 /* triangle fan */ 110ab47cfaaSmrg#define SAVAGE_PRIM_TRILIST_201 3 /* reorder verts for correct flat 111ab47cfaaSmrg * shading on s3d */ 112ab47cfaaSmrg 113ab47cfaaSmrg/* Skip flags (vertex format) 114ab47cfaaSmrg */ 115ab47cfaaSmrg#define SAVAGE_SKIP_Z 0x01 116ab47cfaaSmrg#define SAVAGE_SKIP_W 0x02 117ab47cfaaSmrg#define SAVAGE_SKIP_C0 0x04 118ab47cfaaSmrg#define SAVAGE_SKIP_C1 0x08 119ab47cfaaSmrg#define SAVAGE_SKIP_S0 0x10 120ab47cfaaSmrg#define SAVAGE_SKIP_T0 0x20 121ab47cfaaSmrg#define SAVAGE_SKIP_ST0 0x30 122ab47cfaaSmrg#define SAVAGE_SKIP_S1 0x40 123ab47cfaaSmrg#define SAVAGE_SKIP_T1 0x80 124ab47cfaaSmrg#define SAVAGE_SKIP_ST1 0xc0 125ab47cfaaSmrg#define SAVAGE_SKIP_ALL_S3D 0x3f 126ab47cfaaSmrg#define SAVAGE_SKIP_ALL_S4 0xff 127ab47cfaaSmrg 128ab47cfaaSmrg/* Buffer names for clear command 129ab47cfaaSmrg */ 130ab47cfaaSmrg#define SAVAGE_FRONT 0x1 131ab47cfaaSmrg#define SAVAGE_BACK 0x2 132ab47cfaaSmrg#define SAVAGE_DEPTH 0x4 133ab47cfaaSmrg 134ab47cfaaSmrg/* 64-bit command header 135ab47cfaaSmrg */ 136ab47cfaaSmrgunion drmSAVAGECmdHeader { 137ab47cfaaSmrg struct { 138ab47cfaaSmrg unsigned char cmd; /* command */ 139ab47cfaaSmrg unsigned char pad0; 140ab47cfaaSmrg unsigned short pad1; 141ab47cfaaSmrg unsigned short pad2; 142ab47cfaaSmrg unsigned short pad3; 143ab47cfaaSmrg } cmd; /* generic */ 144ab47cfaaSmrg struct { 145ab47cfaaSmrg unsigned char cmd; 146ab47cfaaSmrg unsigned char global; /* need idle engine? */ 147ab47cfaaSmrg unsigned short count; /* number of consecutive registers */ 148ab47cfaaSmrg unsigned short start; /* first register */ 149ab47cfaaSmrg unsigned short pad3; 150ab47cfaaSmrg } state; /* SAVAGE_CMD_STATE */ 151ab47cfaaSmrg struct { 152ab47cfaaSmrg unsigned char cmd; 153ab47cfaaSmrg unsigned char prim; /* primitive type */ 154ab47cfaaSmrg unsigned short skip; /* vertex format (skip flags) */ 155ab47cfaaSmrg unsigned short count; /* number of vertices */ 156ab47cfaaSmrg unsigned short start; /* first vertex in DMA/vertex buffer */ 157ab47cfaaSmrg } prim; /* SAVAGE_CMD_DMA_PRIM, SAVAGE_CMD_VB_PRIM */ 158ab47cfaaSmrg struct { 159ab47cfaaSmrg unsigned char cmd; 160ab47cfaaSmrg unsigned char prim; 161ab47cfaaSmrg unsigned short skip; 162ab47cfaaSmrg unsigned short count; /* number of indices that follow */ 163ab47cfaaSmrg unsigned short pad3; 164ab47cfaaSmrg } idx; /* SAVAGE_CMD_DMA_IDX, SAVAGE_CMD_VB_IDX */ 165ab47cfaaSmrg struct { 166ab47cfaaSmrg unsigned char cmd; 167ab47cfaaSmrg unsigned char pad0; 168ab47cfaaSmrg unsigned short pad1; 169ab47cfaaSmrg unsigned int flags; 170ab47cfaaSmrg } clear0; /* SAVAGE_CMD_CLEAR */ 171ab47cfaaSmrg struct { 172ab47cfaaSmrg unsigned int mask; 173ab47cfaaSmrg unsigned int value; 174ab47cfaaSmrg } clear1; /* SAVAGE_CMD_CLEAR data */ 175ab47cfaaSmrg}; 176ab47cfaaSmrg 177ab47cfaaSmrg#endif /* __SAVAGE_COMMON_H__ */ 178