18c2ecf20Sopenharmony_ci/* savage_drm.h -- Public header for the savage driver 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright 2004 Felix Kuehling 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 78c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 88c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 98c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license, 108c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 118c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the 148c2ecf20Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 158c2ecf20Sopenharmony_ci * of the Software. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 188c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 198c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 208c2ecf20Sopenharmony_ci * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR 218c2ecf20Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 228c2ecf20Sopenharmony_ci * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 238c2ecf20Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#ifndef __SAVAGE_DRM_H__ 278c2ecf20Sopenharmony_ci#define __SAVAGE_DRM_H__ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#include "drm.h" 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#if defined(__cplusplus) 328c2ecf20Sopenharmony_ciextern "C" { 338c2ecf20Sopenharmony_ci#endif 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#ifndef __SAVAGE_SAREA_DEFINES__ 368c2ecf20Sopenharmony_ci#define __SAVAGE_SAREA_DEFINES__ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* 2 heaps (1 for card, 1 for agp), each divided into up to 128 398c2ecf20Sopenharmony_ci * regions, subject to a minimum region size of (1<<16) == 64k. 408c2ecf20Sopenharmony_ci * 418c2ecf20Sopenharmony_ci * Clients may subdivide regions internally, but when sharing between 428c2ecf20Sopenharmony_ci * clients, the region size is the minimum granularity. 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define SAVAGE_CARD_HEAP 0 468c2ecf20Sopenharmony_ci#define SAVAGE_AGP_HEAP 1 478c2ecf20Sopenharmony_ci#define SAVAGE_NR_TEX_HEAPS 2 488c2ecf20Sopenharmony_ci#define SAVAGE_NR_TEX_REGIONS 16 498c2ecf20Sopenharmony_ci#define SAVAGE_LOG_MIN_TEX_REGION_SIZE 16 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#endif /* __SAVAGE_SAREA_DEFINES__ */ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_citypedef struct _drm_savage_sarea { 548c2ecf20Sopenharmony_ci /* LRU lists for texture memory in agp space and on the card. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci struct drm_tex_region texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS + 578c2ecf20Sopenharmony_ci 1]; 588c2ecf20Sopenharmony_ci unsigned int texAge[SAVAGE_NR_TEX_HEAPS]; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci /* Mechanism to validate card state. 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ci int ctxOwner; 638c2ecf20Sopenharmony_ci} drm_savage_sarea_t, *drm_savage_sarea_ptr; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Savage-specific ioctls 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci#define DRM_SAVAGE_BCI_INIT 0x00 688c2ecf20Sopenharmony_ci#define DRM_SAVAGE_BCI_CMDBUF 0x01 698c2ecf20Sopenharmony_ci#define DRM_SAVAGE_BCI_EVENT_EMIT 0x02 708c2ecf20Sopenharmony_ci#define DRM_SAVAGE_BCI_EVENT_WAIT 0x03 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_INIT, drm_savage_init_t) 738c2ecf20Sopenharmony_ci#define DRM_IOCTL_SAVAGE_BCI_CMDBUF DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_CMDBUF, drm_savage_cmdbuf_t) 748c2ecf20Sopenharmony_ci#define DRM_IOCTL_SAVAGE_BCI_EVENT_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_EMIT, drm_savage_event_emit_t) 758c2ecf20Sopenharmony_ci#define DRM_IOCTL_SAVAGE_BCI_EVENT_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_WAIT, drm_savage_event_wait_t) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define SAVAGE_DMA_PCI 1 788c2ecf20Sopenharmony_ci#define SAVAGE_DMA_AGP 3 798c2ecf20Sopenharmony_citypedef struct drm_savage_init { 808c2ecf20Sopenharmony_ci enum { 818c2ecf20Sopenharmony_ci SAVAGE_INIT_BCI = 1, 828c2ecf20Sopenharmony_ci SAVAGE_CLEANUP_BCI = 2 838c2ecf20Sopenharmony_ci } func; 848c2ecf20Sopenharmony_ci unsigned int sarea_priv_offset; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci /* some parameters */ 878c2ecf20Sopenharmony_ci unsigned int cob_size; 888c2ecf20Sopenharmony_ci unsigned int bci_threshold_lo, bci_threshold_hi; 898c2ecf20Sopenharmony_ci unsigned int dma_type; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci /* frame buffer layout */ 928c2ecf20Sopenharmony_ci unsigned int fb_bpp; 938c2ecf20Sopenharmony_ci unsigned int front_offset, front_pitch; 948c2ecf20Sopenharmony_ci unsigned int back_offset, back_pitch; 958c2ecf20Sopenharmony_ci unsigned int depth_bpp; 968c2ecf20Sopenharmony_ci unsigned int depth_offset, depth_pitch; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci /* local textures */ 998c2ecf20Sopenharmony_ci unsigned int texture_offset; 1008c2ecf20Sopenharmony_ci unsigned int texture_size; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci /* physical locations of non-permanent maps */ 1038c2ecf20Sopenharmony_ci unsigned long status_offset; 1048c2ecf20Sopenharmony_ci unsigned long buffers_offset; 1058c2ecf20Sopenharmony_ci unsigned long agp_textures_offset; 1068c2ecf20Sopenharmony_ci unsigned long cmd_dma_offset; 1078c2ecf20Sopenharmony_ci} drm_savage_init_t; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_citypedef union drm_savage_cmd_header drm_savage_cmd_header_t; 1108c2ecf20Sopenharmony_citypedef struct drm_savage_cmdbuf { 1118c2ecf20Sopenharmony_ci /* command buffer in client's address space */ 1128c2ecf20Sopenharmony_ci drm_savage_cmd_header_t __user *cmd_addr; 1138c2ecf20Sopenharmony_ci unsigned int size; /* size of the command buffer in 64bit units */ 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci unsigned int dma_idx; /* DMA buffer index to use */ 1168c2ecf20Sopenharmony_ci int discard; /* discard DMA buffer when done */ 1178c2ecf20Sopenharmony_ci /* vertex buffer in client's address space */ 1188c2ecf20Sopenharmony_ci unsigned int __user *vb_addr; 1198c2ecf20Sopenharmony_ci unsigned int vb_size; /* size of client vertex buffer in bytes */ 1208c2ecf20Sopenharmony_ci unsigned int vb_stride; /* stride of vertices in 32bit words */ 1218c2ecf20Sopenharmony_ci /* boxes in client's address space */ 1228c2ecf20Sopenharmony_ci struct drm_clip_rect __user *box_addr; 1238c2ecf20Sopenharmony_ci unsigned int nbox; /* number of clipping boxes */ 1248c2ecf20Sopenharmony_ci} drm_savage_cmdbuf_t; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#define SAVAGE_WAIT_2D 0x1 /* wait for 2D idle before updating event tag */ 1278c2ecf20Sopenharmony_ci#define SAVAGE_WAIT_3D 0x2 /* wait for 3D idle before updating event tag */ 1288c2ecf20Sopenharmony_ci#define SAVAGE_WAIT_IRQ 0x4 /* emit or wait for IRQ, not implemented yet */ 1298c2ecf20Sopenharmony_citypedef struct drm_savage_event { 1308c2ecf20Sopenharmony_ci unsigned int count; 1318c2ecf20Sopenharmony_ci unsigned int flags; 1328c2ecf20Sopenharmony_ci} drm_savage_event_emit_t, drm_savage_event_wait_t; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* Commands for the cmdbuf ioctl 1358c2ecf20Sopenharmony_ci */ 1368c2ecf20Sopenharmony_ci#define SAVAGE_CMD_STATE 0 /* a range of state registers */ 1378c2ecf20Sopenharmony_ci#define SAVAGE_CMD_DMA_PRIM 1 /* vertices from DMA buffer */ 1388c2ecf20Sopenharmony_ci#define SAVAGE_CMD_VB_PRIM 2 /* vertices from client vertex buffer */ 1398c2ecf20Sopenharmony_ci#define SAVAGE_CMD_DMA_IDX 3 /* indexed vertices from DMA buffer */ 1408c2ecf20Sopenharmony_ci#define SAVAGE_CMD_VB_IDX 4 /* indexed vertices client vertex buffer */ 1418c2ecf20Sopenharmony_ci#define SAVAGE_CMD_CLEAR 5 /* clear buffers */ 1428c2ecf20Sopenharmony_ci#define SAVAGE_CMD_SWAP 6 /* swap buffers */ 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci/* Primitive types 1458c2ecf20Sopenharmony_ci*/ 1468c2ecf20Sopenharmony_ci#define SAVAGE_PRIM_TRILIST 0 /* triangle list */ 1478c2ecf20Sopenharmony_ci#define SAVAGE_PRIM_TRISTRIP 1 /* triangle strip */ 1488c2ecf20Sopenharmony_ci#define SAVAGE_PRIM_TRIFAN 2 /* triangle fan */ 1498c2ecf20Sopenharmony_ci#define SAVAGE_PRIM_TRILIST_201 3 /* reorder verts for correct flat 1508c2ecf20Sopenharmony_ci * shading on s3d */ 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* Skip flags (vertex format) 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_Z 0x01 1558c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_W 0x02 1568c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_C0 0x04 1578c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_C1 0x08 1588c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_S0 0x10 1598c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_T0 0x20 1608c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_ST0 0x30 1618c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_S1 0x40 1628c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_T1 0x80 1638c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_ST1 0xc0 1648c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_ALL_S3D 0x3f 1658c2ecf20Sopenharmony_ci#define SAVAGE_SKIP_ALL_S4 0xff 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci/* Buffer names for clear command 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_ci#define SAVAGE_FRONT 0x1 1708c2ecf20Sopenharmony_ci#define SAVAGE_BACK 0x2 1718c2ecf20Sopenharmony_ci#define SAVAGE_DEPTH 0x4 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* 64-bit command header 1748c2ecf20Sopenharmony_ci */ 1758c2ecf20Sopenharmony_ciunion drm_savage_cmd_header { 1768c2ecf20Sopenharmony_ci struct { 1778c2ecf20Sopenharmony_ci unsigned char cmd; /* command */ 1788c2ecf20Sopenharmony_ci unsigned char pad0; 1798c2ecf20Sopenharmony_ci unsigned short pad1; 1808c2ecf20Sopenharmony_ci unsigned short pad2; 1818c2ecf20Sopenharmony_ci unsigned short pad3; 1828c2ecf20Sopenharmony_ci } cmd; /* generic */ 1838c2ecf20Sopenharmony_ci struct { 1848c2ecf20Sopenharmony_ci unsigned char cmd; 1858c2ecf20Sopenharmony_ci unsigned char global; /* need idle engine? */ 1868c2ecf20Sopenharmony_ci unsigned short count; /* number of consecutive registers */ 1878c2ecf20Sopenharmony_ci unsigned short start; /* first register */ 1888c2ecf20Sopenharmony_ci unsigned short pad3; 1898c2ecf20Sopenharmony_ci } state; /* SAVAGE_CMD_STATE */ 1908c2ecf20Sopenharmony_ci struct { 1918c2ecf20Sopenharmony_ci unsigned char cmd; 1928c2ecf20Sopenharmony_ci unsigned char prim; /* primitive type */ 1938c2ecf20Sopenharmony_ci unsigned short skip; /* vertex format (skip flags) */ 1948c2ecf20Sopenharmony_ci unsigned short count; /* number of vertices */ 1958c2ecf20Sopenharmony_ci unsigned short start; /* first vertex in DMA/vertex buffer */ 1968c2ecf20Sopenharmony_ci } prim; /* SAVAGE_CMD_DMA_PRIM, SAVAGE_CMD_VB_PRIM */ 1978c2ecf20Sopenharmony_ci struct { 1988c2ecf20Sopenharmony_ci unsigned char cmd; 1998c2ecf20Sopenharmony_ci unsigned char prim; 2008c2ecf20Sopenharmony_ci unsigned short skip; 2018c2ecf20Sopenharmony_ci unsigned short count; /* number of indices that follow */ 2028c2ecf20Sopenharmony_ci unsigned short pad3; 2038c2ecf20Sopenharmony_ci } idx; /* SAVAGE_CMD_DMA_IDX, SAVAGE_CMD_VB_IDX */ 2048c2ecf20Sopenharmony_ci struct { 2058c2ecf20Sopenharmony_ci unsigned char cmd; 2068c2ecf20Sopenharmony_ci unsigned char pad0; 2078c2ecf20Sopenharmony_ci unsigned short pad1; 2088c2ecf20Sopenharmony_ci unsigned int flags; 2098c2ecf20Sopenharmony_ci } clear0; /* SAVAGE_CMD_CLEAR */ 2108c2ecf20Sopenharmony_ci struct { 2118c2ecf20Sopenharmony_ci unsigned int mask; 2128c2ecf20Sopenharmony_ci unsigned int value; 2138c2ecf20Sopenharmony_ci } clear1; /* SAVAGE_CMD_CLEAR data */ 2148c2ecf20Sopenharmony_ci}; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#if defined(__cplusplus) 2178c2ecf20Sopenharmony_ci} 2188c2ecf20Sopenharmony_ci#endif 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci#endif 221