Home | History | Annotate | Line # | Download | only in drm
      1  1.1  riastrad /*	$NetBSD: r128_drm.h,v 1.2 2021/12/18 23:45:46 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
      4  1.1  riastrad  * Created: Wed Apr  5 19:24:19 2000 by kevin (at) precisioninsight.com
      5  1.1  riastrad  */
      6  1.1  riastrad /*
      7  1.1  riastrad  * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
      8  1.1  riastrad  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
      9  1.1  riastrad  * All rights reserved.
     10  1.1  riastrad  *
     11  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
     12  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
     13  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     14  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     15  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     16  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     17  1.1  riastrad  *
     18  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     19  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     20  1.1  riastrad  * Software.
     21  1.1  riastrad  *
     22  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     23  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     24  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     25  1.1  riastrad  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     26  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     27  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     28  1.1  riastrad  * DEALINGS IN THE SOFTWARE.
     29  1.1  riastrad  *
     30  1.1  riastrad  * Authors:
     31  1.1  riastrad  *    Gareth Hughes <gareth (at) valinux.com>
     32  1.1  riastrad  *    Kevin E. Martin <martin (at) valinux.com>
     33  1.1  riastrad  */
     34  1.1  riastrad 
     35  1.1  riastrad #ifndef __R128_DRM_H__
     36  1.1  riastrad #define __R128_DRM_H__
     37  1.1  riastrad 
     38  1.1  riastrad #include "drm.h"
     39  1.1  riastrad 
     40  1.1  riastrad #if defined(__cplusplus)
     41  1.1  riastrad extern "C" {
     42  1.1  riastrad #endif
     43  1.1  riastrad 
     44  1.1  riastrad /* WARNING: If you change any of these defines, make sure to change the
     45  1.1  riastrad  * defines in the X server file (r128_sarea.h)
     46  1.1  riastrad  */
     47  1.1  riastrad #ifndef __R128_SAREA_DEFINES__
     48  1.1  riastrad #define __R128_SAREA_DEFINES__
     49  1.1  riastrad 
     50  1.1  riastrad /* What needs to be changed for the current vertex buffer?
     51  1.1  riastrad  */
     52  1.1  riastrad #define R128_UPLOAD_CONTEXT		0x001
     53  1.1  riastrad #define R128_UPLOAD_SETUP		0x002
     54  1.1  riastrad #define R128_UPLOAD_TEX0		0x004
     55  1.1  riastrad #define R128_UPLOAD_TEX1		0x008
     56  1.1  riastrad #define R128_UPLOAD_TEX0IMAGES		0x010
     57  1.1  riastrad #define R128_UPLOAD_TEX1IMAGES		0x020
     58  1.1  riastrad #define R128_UPLOAD_CORE		0x040
     59  1.1  riastrad #define R128_UPLOAD_MASKS		0x080
     60  1.1  riastrad #define R128_UPLOAD_WINDOW		0x100
     61  1.1  riastrad #define R128_UPLOAD_CLIPRECTS		0x200	/* handled client-side */
     62  1.1  riastrad #define R128_REQUIRE_QUIESCENCE		0x400
     63  1.1  riastrad #define R128_UPLOAD_ALL			0x7ff
     64  1.1  riastrad 
     65  1.1  riastrad #define R128_FRONT			0x1
     66  1.1  riastrad #define R128_BACK			0x2
     67  1.1  riastrad #define R128_DEPTH			0x4
     68  1.1  riastrad 
     69  1.1  riastrad /* Primitive types
     70  1.1  riastrad  */
     71  1.1  riastrad #define R128_POINTS			0x1
     72  1.1  riastrad #define R128_LINES			0x2
     73  1.1  riastrad #define R128_LINE_STRIP			0x3
     74  1.1  riastrad #define R128_TRIANGLES			0x4
     75  1.1  riastrad #define R128_TRIANGLE_FAN		0x5
     76  1.1  riastrad #define R128_TRIANGLE_STRIP		0x6
     77  1.1  riastrad 
     78  1.1  riastrad /* Vertex/indirect buffer size
     79  1.1  riastrad  */
     80  1.1  riastrad #define R128_BUFFER_SIZE		16384
     81  1.1  riastrad 
     82  1.1  riastrad /* Byte offsets for indirect buffer data
     83  1.1  riastrad  */
     84  1.1  riastrad #define R128_INDEX_PRIM_OFFSET		20
     85  1.1  riastrad #define R128_HOSTDATA_BLIT_OFFSET	32
     86  1.1  riastrad 
     87  1.1  riastrad /* Keep these small for testing.
     88  1.1  riastrad  */
     89  1.1  riastrad #define R128_NR_SAREA_CLIPRECTS		12
     90  1.1  riastrad 
     91  1.1  riastrad /* There are 2 heaps (local/AGP).  Each region within a heap is a
     92  1.1  riastrad  *  minimum of 64k, and there are at most 64 of them per heap.
     93  1.1  riastrad  */
     94  1.1  riastrad #define R128_LOCAL_TEX_HEAP		0
     95  1.1  riastrad #define R128_AGP_TEX_HEAP		1
     96  1.1  riastrad #define R128_NR_TEX_HEAPS		2
     97  1.1  riastrad #define R128_NR_TEX_REGIONS		64
     98  1.1  riastrad #define R128_LOG_TEX_GRANULARITY	16
     99  1.1  riastrad 
    100  1.1  riastrad #define R128_NR_CONTEXT_REGS		12
    101  1.1  riastrad 
    102  1.1  riastrad #define R128_MAX_TEXTURE_LEVELS		11
    103  1.1  riastrad #define R128_MAX_TEXTURE_UNITS		2
    104  1.1  riastrad 
    105  1.1  riastrad #endif				/* __R128_SAREA_DEFINES__ */
    106  1.1  riastrad 
    107  1.1  riastrad typedef struct {
    108  1.1  riastrad 	/* Context state - can be written in one large chunk */
    109  1.1  riastrad 	unsigned int dst_pitch_offset_c;
    110  1.1  riastrad 	unsigned int dp_gui_master_cntl_c;
    111  1.1  riastrad 	unsigned int sc_top_left_c;
    112  1.1  riastrad 	unsigned int sc_bottom_right_c;
    113  1.1  riastrad 	unsigned int z_offset_c;
    114  1.1  riastrad 	unsigned int z_pitch_c;
    115  1.1  riastrad 	unsigned int z_sten_cntl_c;
    116  1.1  riastrad 	unsigned int tex_cntl_c;
    117  1.1  riastrad 	unsigned int misc_3d_state_cntl_reg;
    118  1.1  riastrad 	unsigned int texture_clr_cmp_clr_c;
    119  1.1  riastrad 	unsigned int texture_clr_cmp_msk_c;
    120  1.1  riastrad 	unsigned int fog_color_c;
    121  1.1  riastrad 
    122  1.1  riastrad 	/* Texture state */
    123  1.1  riastrad 	unsigned int tex_size_pitch_c;
    124  1.1  riastrad 	unsigned int constant_color_c;
    125  1.1  riastrad 
    126  1.1  riastrad 	/* Setup state */
    127  1.1  riastrad 	unsigned int pm4_vc_fpu_setup;
    128  1.1  riastrad 	unsigned int setup_cntl;
    129  1.1  riastrad 
    130  1.1  riastrad 	/* Mask state */
    131  1.1  riastrad 	unsigned int dp_write_mask;
    132  1.1  riastrad 	unsigned int sten_ref_mask_c;
    133  1.1  riastrad 	unsigned int plane_3d_mask_c;
    134  1.1  riastrad 
    135  1.1  riastrad 	/* Window state */
    136  1.1  riastrad 	unsigned int window_xy_offset;
    137  1.1  riastrad 
    138  1.1  riastrad 	/* Core state */
    139  1.1  riastrad 	unsigned int scale_3d_cntl;
    140  1.1  riastrad } drm_r128_context_regs_t;
    141  1.1  riastrad 
    142  1.1  riastrad /* Setup registers for each texture unit
    143  1.1  riastrad  */
    144  1.1  riastrad typedef struct {
    145  1.1  riastrad 	unsigned int tex_cntl;
    146  1.1  riastrad 	unsigned int tex_combine_cntl;
    147  1.1  riastrad 	unsigned int tex_size_pitch;
    148  1.1  riastrad 	unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
    149  1.1  riastrad 	unsigned int tex_border_color;
    150  1.1  riastrad } drm_r128_texture_regs_t;
    151  1.1  riastrad 
    152  1.1  riastrad typedef struct drm_r128_sarea {
    153  1.1  riastrad 	/* The channel for communication of state information to the kernel
    154  1.1  riastrad 	 * on firing a vertex buffer.
    155  1.1  riastrad 	 */
    156  1.1  riastrad 	drm_r128_context_regs_t context_state;
    157  1.1  riastrad 	drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
    158  1.1  riastrad 	unsigned int dirty;
    159  1.1  riastrad 	unsigned int vertsize;
    160  1.1  riastrad 	unsigned int vc_format;
    161  1.1  riastrad 
    162  1.1  riastrad 	/* The current cliprects, or a subset thereof.
    163  1.1  riastrad 	 */
    164  1.1  riastrad 	struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS];
    165  1.1  riastrad 	unsigned int nbox;
    166  1.1  riastrad 
    167  1.1  riastrad 	/* Counters for client-side throttling of rendering clients.
    168  1.1  riastrad 	 */
    169  1.1  riastrad 	unsigned int last_frame;
    170  1.1  riastrad 	unsigned int last_dispatch;
    171  1.1  riastrad 
    172  1.1  riastrad 	struct drm_tex_region tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS + 1];
    173  1.1  riastrad 	unsigned int tex_age[R128_NR_TEX_HEAPS];
    174  1.1  riastrad 	int ctx_owner;
    175  1.1  riastrad 	int pfAllowPageFlip;	/* number of 3d windows (0,1,2 or more) */
    176  1.1  riastrad 	int pfCurrentPage;	/* which buffer is being displayed? */
    177  1.1  riastrad } drm_r128_sarea_t;
    178  1.1  riastrad 
    179  1.1  riastrad /* WARNING: If you change any of these defines, make sure to change the
    180  1.1  riastrad  * defines in the Xserver file (xf86drmR128.h)
    181  1.1  riastrad  */
    182  1.1  riastrad 
    183  1.1  riastrad /* Rage 128 specific ioctls
    184  1.1  riastrad  * The device specific ioctl range is 0x40 to 0x79.
    185  1.1  riastrad  */
    186  1.1  riastrad #define DRM_R128_INIT       0x00
    187  1.1  riastrad #define DRM_R128_CCE_START  0x01
    188  1.1  riastrad #define DRM_R128_CCE_STOP   0x02
    189  1.1  riastrad #define DRM_R128_CCE_RESET  0x03
    190  1.1  riastrad #define DRM_R128_CCE_IDLE   0x04
    191  1.1  riastrad /* 0x05 not used */
    192  1.1  riastrad #define DRM_R128_RESET      0x06
    193  1.1  riastrad #define DRM_R128_SWAP       0x07
    194  1.1  riastrad #define DRM_R128_CLEAR      0x08
    195  1.1  riastrad #define DRM_R128_VERTEX     0x09
    196  1.1  riastrad #define DRM_R128_INDICES    0x0a
    197  1.1  riastrad #define DRM_R128_BLIT       0x0b
    198  1.1  riastrad #define DRM_R128_DEPTH      0x0c
    199  1.1  riastrad #define DRM_R128_STIPPLE    0x0d
    200  1.1  riastrad /* 0x0e not used */
    201  1.1  riastrad #define DRM_R128_INDIRECT   0x0f
    202  1.1  riastrad #define DRM_R128_FULLSCREEN 0x10
    203  1.1  riastrad #define DRM_R128_CLEAR2     0x11
    204  1.1  riastrad #define DRM_R128_GETPARAM   0x12
    205  1.1  riastrad #define DRM_R128_FLIP       0x13
    206  1.1  riastrad 
    207  1.1  riastrad #define DRM_IOCTL_R128_INIT       DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INIT, drm_r128_init_t)
    208  1.1  riastrad #define DRM_IOCTL_R128_CCE_START  DRM_IO(  DRM_COMMAND_BASE + DRM_R128_CCE_START)
    209  1.1  riastrad #define DRM_IOCTL_R128_CCE_STOP   DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CCE_STOP, drm_r128_cce_stop_t)
    210  1.1  riastrad #define DRM_IOCTL_R128_CCE_RESET  DRM_IO(  DRM_COMMAND_BASE + DRM_R128_CCE_RESET)
    211  1.1  riastrad #define DRM_IOCTL_R128_CCE_IDLE   DRM_IO(  DRM_COMMAND_BASE + DRM_R128_CCE_IDLE)
    212  1.1  riastrad /* 0x05 not used */
    213  1.1  riastrad #define DRM_IOCTL_R128_RESET      DRM_IO(  DRM_COMMAND_BASE + DRM_R128_RESET)
    214  1.1  riastrad #define DRM_IOCTL_R128_SWAP       DRM_IO(  DRM_COMMAND_BASE + DRM_R128_SWAP)
    215  1.1  riastrad #define DRM_IOCTL_R128_CLEAR      DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR, drm_r128_clear_t)
    216  1.1  riastrad #define DRM_IOCTL_R128_VERTEX     DRM_IOW( DRM_COMMAND_BASE + DRM_R128_VERTEX, drm_r128_vertex_t)
    217  1.1  riastrad #define DRM_IOCTL_R128_INDICES    DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INDICES, drm_r128_indices_t)
    218  1.1  riastrad #define DRM_IOCTL_R128_BLIT       DRM_IOW( DRM_COMMAND_BASE + DRM_R128_BLIT, drm_r128_blit_t)
    219  1.1  riastrad #define DRM_IOCTL_R128_DEPTH      DRM_IOW( DRM_COMMAND_BASE + DRM_R128_DEPTH, drm_r128_depth_t)
    220  1.1  riastrad #define DRM_IOCTL_R128_STIPPLE    DRM_IOW( DRM_COMMAND_BASE + DRM_R128_STIPPLE, drm_r128_stipple_t)
    221  1.1  riastrad /* 0x0e not used */
    222  1.1  riastrad #define DRM_IOCTL_R128_INDIRECT   DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_INDIRECT, drm_r128_indirect_t)
    223  1.1  riastrad #define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_R128_FULLSCREEN, drm_r128_fullscreen_t)
    224  1.1  riastrad #define DRM_IOCTL_R128_CLEAR2     DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR2, drm_r128_clear2_t)
    225  1.1  riastrad #define DRM_IOCTL_R128_GETPARAM   DRM_IOWR( DRM_COMMAND_BASE + DRM_R128_GETPARAM, drm_r128_getparam_t)
    226  1.1  riastrad #define DRM_IOCTL_R128_FLIP       DRM_IO(  DRM_COMMAND_BASE + DRM_R128_FLIP)
    227  1.1  riastrad 
    228  1.1  riastrad typedef struct drm_r128_init {
    229  1.1  riastrad 	enum {
    230  1.1  riastrad 		R128_INIT_CCE = 0x01,
    231  1.1  riastrad 		R128_CLEANUP_CCE = 0x02
    232  1.1  riastrad 	} func;
    233  1.1  riastrad 	unsigned long sarea_priv_offset;
    234  1.1  riastrad 	int is_pci;
    235  1.1  riastrad 	int cce_mode;
    236  1.1  riastrad 	int cce_secure;
    237  1.1  riastrad 	int ring_size;
    238  1.1  riastrad 	int usec_timeout;
    239  1.1  riastrad 
    240  1.1  riastrad 	unsigned int fb_bpp;
    241  1.1  riastrad 	unsigned int front_offset, front_pitch;
    242  1.1  riastrad 	unsigned int back_offset, back_pitch;
    243  1.1  riastrad 	unsigned int depth_bpp;
    244  1.1  riastrad 	unsigned int depth_offset, depth_pitch;
    245  1.1  riastrad 	unsigned int span_offset;
    246  1.1  riastrad 
    247  1.1  riastrad 	unsigned long fb_offset;
    248  1.1  riastrad 	unsigned long mmio_offset;
    249  1.1  riastrad 	unsigned long ring_offset;
    250  1.1  riastrad 	unsigned long ring_rptr_offset;
    251  1.1  riastrad 	unsigned long buffers_offset;
    252  1.1  riastrad 	unsigned long agp_textures_offset;
    253  1.1  riastrad } drm_r128_init_t;
    254  1.1  riastrad 
    255  1.1  riastrad typedef struct drm_r128_cce_stop {
    256  1.1  riastrad 	int flush;
    257  1.1  riastrad 	int idle;
    258  1.1  riastrad } drm_r128_cce_stop_t;
    259  1.1  riastrad 
    260  1.1  riastrad typedef struct drm_r128_clear {
    261  1.1  riastrad 	unsigned int flags;
    262  1.1  riastrad 	unsigned int clear_color;
    263  1.1  riastrad 	unsigned int clear_depth;
    264  1.1  riastrad 	unsigned int color_mask;
    265  1.1  riastrad 	unsigned int depth_mask;
    266  1.1  riastrad } drm_r128_clear_t;
    267  1.1  riastrad 
    268  1.1  riastrad typedef struct drm_r128_vertex {
    269  1.1  riastrad 	int prim;
    270  1.1  riastrad 	int idx;		/* Index of vertex buffer */
    271  1.1  riastrad 	int count;		/* Number of vertices in buffer */
    272  1.1  riastrad 	int discard;		/* Client finished with buffer? */
    273  1.1  riastrad } drm_r128_vertex_t;
    274  1.1  riastrad 
    275  1.1  riastrad typedef struct drm_r128_indices {
    276  1.1  riastrad 	int prim;
    277  1.1  riastrad 	int idx;
    278  1.1  riastrad 	int start;
    279  1.1  riastrad 	int end;
    280  1.1  riastrad 	int discard;		/* Client finished with buffer? */
    281  1.1  riastrad } drm_r128_indices_t;
    282  1.1  riastrad 
    283  1.1  riastrad typedef struct drm_r128_blit {
    284  1.1  riastrad 	int idx;
    285  1.1  riastrad 	int pitch;
    286  1.1  riastrad 	int offset;
    287  1.1  riastrad 	int format;
    288  1.1  riastrad 	unsigned short x, y;
    289  1.1  riastrad 	unsigned short width, height;
    290  1.1  riastrad } drm_r128_blit_t;
    291  1.1  riastrad 
    292  1.1  riastrad typedef struct drm_r128_depth {
    293  1.1  riastrad 	enum {
    294  1.1  riastrad 		R128_WRITE_SPAN = 0x01,
    295  1.1  riastrad 		R128_WRITE_PIXELS = 0x02,
    296  1.1  riastrad 		R128_READ_SPAN = 0x03,
    297  1.1  riastrad 		R128_READ_PIXELS = 0x04
    298  1.1  riastrad 	} func;
    299  1.1  riastrad 	int n;
    300  1.1  riastrad 	int __user *x;
    301  1.1  riastrad 	int __user *y;
    302  1.1  riastrad 	unsigned int __user *buffer;
    303  1.1  riastrad 	unsigned char __user *mask;
    304  1.1  riastrad } drm_r128_depth_t;
    305  1.1  riastrad 
    306  1.1  riastrad typedef struct drm_r128_stipple {
    307  1.1  riastrad 	unsigned int __user *mask;
    308  1.1  riastrad } drm_r128_stipple_t;
    309  1.1  riastrad 
    310  1.1  riastrad typedef struct drm_r128_indirect {
    311  1.1  riastrad 	int idx;
    312  1.1  riastrad 	int start;
    313  1.1  riastrad 	int end;
    314  1.1  riastrad 	int discard;
    315  1.1  riastrad } drm_r128_indirect_t;
    316  1.1  riastrad 
    317  1.1  riastrad typedef struct drm_r128_fullscreen {
    318  1.1  riastrad 	enum {
    319  1.1  riastrad 		R128_INIT_FULLSCREEN = 0x01,
    320  1.1  riastrad 		R128_CLEANUP_FULLSCREEN = 0x02
    321  1.1  riastrad 	} func;
    322  1.1  riastrad } drm_r128_fullscreen_t;
    323  1.1  riastrad 
    324  1.1  riastrad /* 2.3: An ioctl to get parameters that aren't available to the 3d
    325  1.1  riastrad  * client any other way.
    326  1.1  riastrad  */
    327  1.1  riastrad #define R128_PARAM_IRQ_NR            1
    328  1.1  riastrad 
    329  1.1  riastrad typedef struct drm_r128_getparam {
    330  1.1  riastrad 	int param;
    331  1.1  riastrad 	void __user *value;
    332  1.1  riastrad } drm_r128_getparam_t;
    333  1.1  riastrad 
    334  1.1  riastrad #if defined(__cplusplus)
    335  1.1  riastrad }
    336  1.1  riastrad #endif
    337  1.1  riastrad 
    338  1.1  riastrad #endif
    339