Home | History | Annotate | Line # | Download | only in drm
      1  1.1  riastrad /*	$NetBSD: savage_drm.h,v 1.2 2021/12/18 23:45:46 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /* savage_drm.h -- Public header for the savage driver
      4  1.1  riastrad  *
      5  1.1  riastrad  * Copyright 2004  Felix Kuehling
      6  1.1  riastrad  * All Rights Reserved.
      7  1.1  riastrad  *
      8  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      9  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
     10  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     11  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sub license,
     12  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     13  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     14  1.1  riastrad  *
     15  1.1  riastrad  * The above copyright notice and this permission notice (including the
     16  1.1  riastrad  * next paragraph) shall be included in all copies or substantial portions
     17  1.1  riastrad  * of the Software.
     18  1.1  riastrad  *
     19  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     20  1.1  riastrad  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     21  1.1  riastrad  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     22  1.1  riastrad  * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR
     23  1.1  riastrad  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
     24  1.1  riastrad  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     25  1.1  riastrad  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     26  1.1  riastrad  */
     27  1.1  riastrad 
     28  1.1  riastrad #ifndef __SAVAGE_DRM_H__
     29  1.1  riastrad #define __SAVAGE_DRM_H__
     30  1.1  riastrad 
     31  1.1  riastrad #include "drm.h"
     32  1.1  riastrad 
     33  1.1  riastrad #if defined(__cplusplus)
     34  1.1  riastrad extern "C" {
     35  1.1  riastrad #endif
     36  1.1  riastrad 
     37  1.1  riastrad #ifndef __SAVAGE_SAREA_DEFINES__
     38  1.1  riastrad #define __SAVAGE_SAREA_DEFINES__
     39  1.1  riastrad 
     40  1.1  riastrad /* 2 heaps (1 for card, 1 for agp), each divided into up to 128
     41  1.1  riastrad  * regions, subject to a minimum region size of (1<<16) == 64k.
     42  1.1  riastrad  *
     43  1.1  riastrad  * Clients may subdivide regions internally, but when sharing between
     44  1.1  riastrad  * clients, the region size is the minimum granularity.
     45  1.1  riastrad  */
     46  1.1  riastrad 
     47  1.1  riastrad #define SAVAGE_CARD_HEAP		0
     48  1.1  riastrad #define SAVAGE_AGP_HEAP			1
     49  1.1  riastrad #define SAVAGE_NR_TEX_HEAPS		2
     50  1.1  riastrad #define SAVAGE_NR_TEX_REGIONS		16
     51  1.1  riastrad #define SAVAGE_LOG_MIN_TEX_REGION_SIZE	16
     52  1.1  riastrad 
     53  1.1  riastrad #endif				/* __SAVAGE_SAREA_DEFINES__ */
     54  1.1  riastrad 
     55  1.1  riastrad typedef struct _drm_savage_sarea {
     56  1.1  riastrad 	/* LRU lists for texture memory in agp space and on the card.
     57  1.1  riastrad 	 */
     58  1.1  riastrad 	struct drm_tex_region texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS +
     59  1.1  riastrad 						      1];
     60  1.1  riastrad 	unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
     61  1.1  riastrad 
     62  1.1  riastrad 	/* Mechanism to validate card state.
     63  1.1  riastrad 	 */
     64  1.1  riastrad 	int ctxOwner;
     65  1.1  riastrad } drm_savage_sarea_t, *drm_savage_sarea_ptr;
     66  1.1  riastrad 
     67  1.1  riastrad /* Savage-specific ioctls
     68  1.1  riastrad  */
     69  1.1  riastrad #define DRM_SAVAGE_BCI_INIT		0x00
     70  1.1  riastrad #define DRM_SAVAGE_BCI_CMDBUF           0x01
     71  1.1  riastrad #define DRM_SAVAGE_BCI_EVENT_EMIT	0x02
     72  1.1  riastrad #define DRM_SAVAGE_BCI_EVENT_WAIT	0x03
     73  1.1  riastrad 
     74  1.1  riastrad #define DRM_IOCTL_SAVAGE_BCI_INIT		DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_INIT, drm_savage_init_t)
     75  1.1  riastrad #define DRM_IOCTL_SAVAGE_BCI_CMDBUF		DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_CMDBUF, drm_savage_cmdbuf_t)
     76  1.1  riastrad #define DRM_IOCTL_SAVAGE_BCI_EVENT_EMIT	DRM_IOWR(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_EMIT, drm_savage_event_emit_t)
     77  1.1  riastrad #define DRM_IOCTL_SAVAGE_BCI_EVENT_WAIT	DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_WAIT, drm_savage_event_wait_t)
     78  1.1  riastrad 
     79  1.1  riastrad #define SAVAGE_DMA_PCI	1
     80  1.1  riastrad #define SAVAGE_DMA_AGP	3
     81  1.1  riastrad typedef struct drm_savage_init {
     82  1.1  riastrad 	enum {
     83  1.1  riastrad 		SAVAGE_INIT_BCI = 1,
     84  1.1  riastrad 		SAVAGE_CLEANUP_BCI = 2
     85  1.1  riastrad 	} func;
     86  1.1  riastrad 	unsigned int sarea_priv_offset;
     87  1.1  riastrad 
     88  1.1  riastrad 	/* some parameters */
     89  1.1  riastrad 	unsigned int cob_size;
     90  1.1  riastrad 	unsigned int bci_threshold_lo, bci_threshold_hi;
     91  1.1  riastrad 	unsigned int dma_type;
     92  1.1  riastrad 
     93  1.1  riastrad 	/* frame buffer layout */
     94  1.1  riastrad 	unsigned int fb_bpp;
     95  1.1  riastrad 	unsigned int front_offset, front_pitch;
     96  1.1  riastrad 	unsigned int back_offset, back_pitch;
     97  1.1  riastrad 	unsigned int depth_bpp;
     98  1.1  riastrad 	unsigned int depth_offset, depth_pitch;
     99  1.1  riastrad 
    100  1.1  riastrad 	/* local textures */
    101  1.1  riastrad 	unsigned int texture_offset;
    102  1.1  riastrad 	unsigned int texture_size;
    103  1.1  riastrad 
    104  1.1  riastrad 	/* physical locations of non-permanent maps */
    105  1.1  riastrad 	unsigned long status_offset;
    106  1.1  riastrad 	unsigned long buffers_offset;
    107  1.1  riastrad 	unsigned long agp_textures_offset;
    108  1.1  riastrad 	unsigned long cmd_dma_offset;
    109  1.1  riastrad } drm_savage_init_t;
    110  1.1  riastrad 
    111  1.1  riastrad typedef union drm_savage_cmd_header drm_savage_cmd_header_t;
    112  1.1  riastrad typedef struct drm_savage_cmdbuf {
    113  1.1  riastrad 	/* command buffer in client's address space */
    114  1.1  riastrad 	drm_savage_cmd_header_t __user *cmd_addr;
    115  1.1  riastrad 	unsigned int size;	/* size of the command buffer in 64bit units */
    116  1.1  riastrad 
    117  1.1  riastrad 	unsigned int dma_idx;	/* DMA buffer index to use */
    118  1.1  riastrad 	int discard;		/* discard DMA buffer when done */
    119  1.1  riastrad 	/* vertex buffer in client's address space */
    120  1.1  riastrad 	unsigned int __user *vb_addr;
    121  1.1  riastrad 	unsigned int vb_size;	/* size of client vertex buffer in bytes */
    122  1.1  riastrad 	unsigned int vb_stride;	/* stride of vertices in 32bit words */
    123  1.1  riastrad 	/* boxes in client's address space */
    124  1.1  riastrad 	struct drm_clip_rect __user *box_addr;
    125  1.1  riastrad 	unsigned int nbox;	/* number of clipping boxes */
    126  1.1  riastrad } drm_savage_cmdbuf_t;
    127  1.1  riastrad 
    128  1.1  riastrad #define SAVAGE_WAIT_2D  0x1	/* wait for 2D idle before updating event tag */
    129  1.1  riastrad #define SAVAGE_WAIT_3D  0x2	/* wait for 3D idle before updating event tag */
    130  1.1  riastrad #define SAVAGE_WAIT_IRQ 0x4	/* emit or wait for IRQ, not implemented yet */
    131  1.1  riastrad typedef struct drm_savage_event {
    132  1.1  riastrad 	unsigned int count;
    133  1.1  riastrad 	unsigned int flags;
    134  1.1  riastrad } drm_savage_event_emit_t, drm_savage_event_wait_t;
    135  1.1  riastrad 
    136  1.1  riastrad /* Commands for the cmdbuf ioctl
    137  1.1  riastrad  */
    138  1.1  riastrad #define SAVAGE_CMD_STATE	0	/* a range of state registers */
    139  1.1  riastrad #define SAVAGE_CMD_DMA_PRIM	1	/* vertices from DMA buffer */
    140  1.1  riastrad #define SAVAGE_CMD_VB_PRIM	2	/* vertices from client vertex buffer */
    141  1.1  riastrad #define SAVAGE_CMD_DMA_IDX	3	/* indexed vertices from DMA buffer */
    142  1.1  riastrad #define SAVAGE_CMD_VB_IDX	4	/* indexed vertices client vertex buffer */
    143  1.1  riastrad #define SAVAGE_CMD_CLEAR	5	/* clear buffers */
    144  1.1  riastrad #define SAVAGE_CMD_SWAP		6	/* swap buffers */
    145  1.1  riastrad 
    146  1.1  riastrad /* Primitive types
    147  1.1  riastrad */
    148  1.1  riastrad #define SAVAGE_PRIM_TRILIST	0	/* triangle list */
    149  1.1  riastrad #define SAVAGE_PRIM_TRISTRIP	1	/* triangle strip */
    150  1.1  riastrad #define SAVAGE_PRIM_TRIFAN	2	/* triangle fan */
    151  1.1  riastrad #define SAVAGE_PRIM_TRILIST_201	3	/* reorder verts for correct flat
    152  1.1  riastrad 					 * shading on s3d */
    153  1.1  riastrad 
    154  1.1  riastrad /* Skip flags (vertex format)
    155  1.1  riastrad  */
    156  1.1  riastrad #define SAVAGE_SKIP_Z		0x01
    157  1.1  riastrad #define SAVAGE_SKIP_W		0x02
    158  1.1  riastrad #define SAVAGE_SKIP_C0		0x04
    159  1.1  riastrad #define SAVAGE_SKIP_C1		0x08
    160  1.1  riastrad #define SAVAGE_SKIP_S0		0x10
    161  1.1  riastrad #define SAVAGE_SKIP_T0		0x20
    162  1.1  riastrad #define SAVAGE_SKIP_ST0		0x30
    163  1.1  riastrad #define SAVAGE_SKIP_S1		0x40
    164  1.1  riastrad #define SAVAGE_SKIP_T1		0x80
    165  1.1  riastrad #define SAVAGE_SKIP_ST1		0xc0
    166  1.1  riastrad #define SAVAGE_SKIP_ALL_S3D	0x3f
    167  1.1  riastrad #define SAVAGE_SKIP_ALL_S4	0xff
    168  1.1  riastrad 
    169  1.1  riastrad /* Buffer names for clear command
    170  1.1  riastrad  */
    171  1.1  riastrad #define SAVAGE_FRONT		0x1
    172  1.1  riastrad #define SAVAGE_BACK		0x2
    173  1.1  riastrad #define SAVAGE_DEPTH		0x4
    174  1.1  riastrad 
    175  1.1  riastrad /* 64-bit command header
    176  1.1  riastrad  */
    177  1.1  riastrad union drm_savage_cmd_header {
    178  1.1  riastrad 	struct {
    179  1.1  riastrad 		unsigned char cmd;	/* command */
    180  1.1  riastrad 		unsigned char pad0;
    181  1.1  riastrad 		unsigned short pad1;
    182  1.1  riastrad 		unsigned short pad2;
    183  1.1  riastrad 		unsigned short pad3;
    184  1.1  riastrad 	} cmd;			/* generic */
    185  1.1  riastrad 	struct {
    186  1.1  riastrad 		unsigned char cmd;
    187  1.1  riastrad 		unsigned char global;	/* need idle engine? */
    188  1.1  riastrad 		unsigned short count;	/* number of consecutive registers */
    189  1.1  riastrad 		unsigned short start;	/* first register */
    190  1.1  riastrad 		unsigned short pad3;
    191  1.1  riastrad 	} state;		/* SAVAGE_CMD_STATE */
    192  1.1  riastrad 	struct {
    193  1.1  riastrad 		unsigned char cmd;
    194  1.1  riastrad 		unsigned char prim;	/* primitive type */
    195  1.1  riastrad 		unsigned short skip;	/* vertex format (skip flags) */
    196  1.1  riastrad 		unsigned short count;	/* number of vertices */
    197  1.1  riastrad 		unsigned short start;	/* first vertex in DMA/vertex buffer */
    198  1.1  riastrad 	} prim;			/* SAVAGE_CMD_DMA_PRIM, SAVAGE_CMD_VB_PRIM */
    199  1.1  riastrad 	struct {
    200  1.1  riastrad 		unsigned char cmd;
    201  1.1  riastrad 		unsigned char prim;
    202  1.1  riastrad 		unsigned short skip;
    203  1.1  riastrad 		unsigned short count;	/* number of indices that follow */
    204  1.1  riastrad 		unsigned short pad3;
    205  1.1  riastrad 	} idx;			/* SAVAGE_CMD_DMA_IDX, SAVAGE_CMD_VB_IDX */
    206  1.1  riastrad 	struct {
    207  1.1  riastrad 		unsigned char cmd;
    208  1.1  riastrad 		unsigned char pad0;
    209  1.1  riastrad 		unsigned short pad1;
    210  1.1  riastrad 		unsigned int flags;
    211  1.1  riastrad 	} clear0;		/* SAVAGE_CMD_CLEAR */
    212  1.1  riastrad 	struct {
    213  1.1  riastrad 		unsigned int mask;
    214  1.1  riastrad 		unsigned int value;
    215  1.1  riastrad 	} clear1;		/* SAVAGE_CMD_CLEAR data */
    216  1.1  riastrad };
    217  1.1  riastrad 
    218  1.1  riastrad #if defined(__cplusplus)
    219  1.1  riastrad }
    220  1.1  riastrad #endif
    221  1.1  riastrad 
    222  1.1  riastrad #endif
    223