Home | History | Annotate | Line # | Download | only in drm
      1  1.1  riastrad /*	$NetBSD: via_drm.h,v 1.2 2021/12/18 23:45:46 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
      5  1.1  riastrad  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
      6  1.1  riastrad  *
      7  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      8  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      9  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     10  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sub license,
     11  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     12  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     13  1.1  riastrad  *
     14  1.1  riastrad  * The above copyright notice and this permission notice (including the
     15  1.1  riastrad  * next paragraph) shall be included in all copies or substantial portions
     16  1.1  riastrad  * of the Software.
     17  1.1  riastrad  *
     18  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     19  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
     21  1.1  riastrad  * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     22  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     23  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     24  1.1  riastrad  * DEALINGS IN THE SOFTWARE.
     25  1.1  riastrad  */
     26  1.1  riastrad #ifndef _VIA_DRM_H_
     27  1.1  riastrad #define _VIA_DRM_H_
     28  1.1  riastrad 
     29  1.1  riastrad #include "drm.h"
     30  1.1  riastrad 
     31  1.1  riastrad #if defined(__cplusplus)
     32  1.1  riastrad extern "C" {
     33  1.1  riastrad #endif
     34  1.1  riastrad 
     35  1.1  riastrad /* WARNING: These defines must be the same as what the Xserver uses.
     36  1.1  riastrad  * if you change them, you must change the defines in the Xserver.
     37  1.1  riastrad  */
     38  1.1  riastrad 
     39  1.1  riastrad #ifndef _VIA_DEFINES_
     40  1.1  riastrad #define _VIA_DEFINES_
     41  1.1  riastrad 
     42  1.1  riastrad 
     43  1.1  riastrad #define VIA_NR_SAREA_CLIPRECTS		8
     44  1.1  riastrad #define VIA_NR_XVMC_PORTS               10
     45  1.1  riastrad #define VIA_NR_XVMC_LOCKS               5
     46  1.1  riastrad #define VIA_MAX_CACHELINE_SIZE          64
     47  1.1  riastrad #define XVMCLOCKPTR(saPriv,lockNo)					\
     48  1.1  riastrad 	((volatile struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
     49  1.1  riastrad 				      (VIA_MAX_CACHELINE_SIZE - 1)) &	\
     50  1.1  riastrad 				     ~(VIA_MAX_CACHELINE_SIZE - 1)) +	\
     51  1.1  riastrad 				    VIA_MAX_CACHELINE_SIZE*(lockNo)))
     52  1.1  riastrad 
     53  1.1  riastrad /* Each region is a minimum of 64k, and there are at most 64 of them.
     54  1.1  riastrad  */
     55  1.1  riastrad #define VIA_NR_TEX_REGIONS 64
     56  1.1  riastrad #define VIA_LOG_MIN_TEX_REGION_SIZE 16
     57  1.1  riastrad #endif
     58  1.1  riastrad 
     59  1.1  riastrad #define VIA_UPLOAD_TEX0IMAGE  0x1	/* handled clientside */
     60  1.1  riastrad #define VIA_UPLOAD_TEX1IMAGE  0x2	/* handled clientside */
     61  1.1  riastrad #define VIA_UPLOAD_CTX        0x4
     62  1.1  riastrad #define VIA_UPLOAD_BUFFERS    0x8
     63  1.1  riastrad #define VIA_UPLOAD_TEX0       0x10
     64  1.1  riastrad #define VIA_UPLOAD_TEX1       0x20
     65  1.1  riastrad #define VIA_UPLOAD_CLIPRECTS  0x40
     66  1.1  riastrad #define VIA_UPLOAD_ALL        0xff
     67  1.1  riastrad 
     68  1.1  riastrad /* VIA specific ioctls */
     69  1.1  riastrad #define DRM_VIA_ALLOCMEM	0x00
     70  1.1  riastrad #define DRM_VIA_FREEMEM	        0x01
     71  1.1  riastrad #define DRM_VIA_AGP_INIT	0x02
     72  1.1  riastrad #define DRM_VIA_FB_INIT	        0x03
     73  1.1  riastrad #define DRM_VIA_MAP_INIT	0x04
     74  1.1  riastrad #define DRM_VIA_DEC_FUTEX       0x05
     75  1.1  riastrad #define NOT_USED
     76  1.1  riastrad #define DRM_VIA_DMA_INIT	0x07
     77  1.1  riastrad #define DRM_VIA_CMDBUFFER	0x08
     78  1.1  riastrad #define DRM_VIA_FLUSH	        0x09
     79  1.1  riastrad #define DRM_VIA_PCICMD	        0x0a
     80  1.1  riastrad #define DRM_VIA_CMDBUF_SIZE	0x0b
     81  1.1  riastrad #define NOT_USED
     82  1.1  riastrad #define DRM_VIA_WAIT_IRQ        0x0d
     83  1.1  riastrad #define DRM_VIA_DMA_BLIT        0x0e
     84  1.1  riastrad #define DRM_VIA_BLIT_SYNC       0x0f
     85  1.1  riastrad 
     86  1.1  riastrad #define DRM_IOCTL_VIA_ALLOCMEM	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
     87  1.1  riastrad #define DRM_IOCTL_VIA_FREEMEM	  DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
     88  1.1  riastrad #define DRM_IOCTL_VIA_AGP_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
     89  1.1  riastrad #define DRM_IOCTL_VIA_FB_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
     90  1.1  riastrad #define DRM_IOCTL_VIA_MAP_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
     91  1.1  riastrad #define DRM_IOCTL_VIA_DEC_FUTEX   DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
     92  1.1  riastrad #define DRM_IOCTL_VIA_DMA_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
     93  1.1  riastrad #define DRM_IOCTL_VIA_CMDBUFFER	  DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
     94  1.1  riastrad #define DRM_IOCTL_VIA_FLUSH	  DRM_IO(  DRM_COMMAND_BASE + DRM_VIA_FLUSH)
     95  1.1  riastrad #define DRM_IOCTL_VIA_PCICMD	  DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
     96  1.1  riastrad #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
     97  1.1  riastrad 					    drm_via_cmdbuf_size_t)
     98  1.1  riastrad #define DRM_IOCTL_VIA_WAIT_IRQ    DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
     99  1.1  riastrad #define DRM_IOCTL_VIA_DMA_BLIT    DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
    100  1.1  riastrad #define DRM_IOCTL_VIA_BLIT_SYNC   DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
    101  1.1  riastrad 
    102  1.1  riastrad /* Indices into buf.Setup where various bits of state are mirrored per
    103  1.1  riastrad  * context and per buffer.  These can be fired at the card as a unit,
    104  1.1  riastrad  * or in a piecewise fashion as required.
    105  1.1  riastrad  */
    106  1.1  riastrad 
    107  1.1  riastrad #define VIA_TEX_SETUP_SIZE 8
    108  1.1  riastrad 
    109  1.1  riastrad /* Flags for clear ioctl
    110  1.1  riastrad  */
    111  1.1  riastrad #define VIA_FRONT   0x1
    112  1.1  riastrad #define VIA_BACK    0x2
    113  1.1  riastrad #define VIA_DEPTH   0x4
    114  1.1  riastrad #define VIA_STENCIL 0x8
    115  1.1  riastrad #define VIA_MEM_VIDEO   0	/* matches drm constant */
    116  1.1  riastrad #define VIA_MEM_AGP     1	/* matches drm constant */
    117  1.1  riastrad #define VIA_MEM_SYSTEM  2
    118  1.1  riastrad #define VIA_MEM_MIXED   3
    119  1.1  riastrad #define VIA_MEM_UNKNOWN 4
    120  1.1  riastrad 
    121  1.1  riastrad typedef struct {
    122  1.1  riastrad 	__u32 offset;
    123  1.1  riastrad 	__u32 size;
    124  1.1  riastrad } drm_via_agp_t;
    125  1.1  riastrad 
    126  1.1  riastrad typedef struct {
    127  1.1  riastrad 	__u32 offset;
    128  1.1  riastrad 	__u32 size;
    129  1.1  riastrad } drm_via_fb_t;
    130  1.1  riastrad 
    131  1.1  riastrad typedef struct {
    132  1.1  riastrad 	__u32 context;
    133  1.1  riastrad 	__u32 type;
    134  1.1  riastrad 	__u32 size;
    135  1.1  riastrad 	unsigned long index;
    136  1.1  riastrad 	unsigned long offset;
    137  1.1  riastrad } drm_via_mem_t;
    138  1.1  riastrad 
    139  1.1  riastrad typedef struct _drm_via_init {
    140  1.1  riastrad 	enum {
    141  1.1  riastrad 		VIA_INIT_MAP = 0x01,
    142  1.1  riastrad 		VIA_CLEANUP_MAP = 0x02
    143  1.1  riastrad 	} func;
    144  1.1  riastrad 
    145  1.1  riastrad 	unsigned long sarea_priv_offset;
    146  1.1  riastrad 	unsigned long fb_offset;
    147  1.1  riastrad 	unsigned long mmio_offset;
    148  1.1  riastrad 	unsigned long agpAddr;
    149  1.1  riastrad } drm_via_init_t;
    150  1.1  riastrad 
    151  1.1  riastrad typedef struct _drm_via_futex {
    152  1.1  riastrad 	enum {
    153  1.1  riastrad 		VIA_FUTEX_WAIT = 0x00,
    154  1.1  riastrad 		VIA_FUTEX_WAKE = 0X01
    155  1.1  riastrad 	} func;
    156  1.1  riastrad 	__u32 ms;
    157  1.1  riastrad 	__u32 lock;
    158  1.1  riastrad 	__u32 val;
    159  1.1  riastrad } drm_via_futex_t;
    160  1.1  riastrad 
    161  1.1  riastrad typedef struct _drm_via_dma_init {
    162  1.1  riastrad 	enum {
    163  1.1  riastrad 		VIA_INIT_DMA = 0x01,
    164  1.1  riastrad 		VIA_CLEANUP_DMA = 0x02,
    165  1.1  riastrad 		VIA_DMA_INITIALIZED = 0x03
    166  1.1  riastrad 	} func;
    167  1.1  riastrad 
    168  1.1  riastrad 	unsigned long offset;
    169  1.1  riastrad 	unsigned long size;
    170  1.1  riastrad 	unsigned long reg_pause_addr;
    171  1.1  riastrad } drm_via_dma_init_t;
    172  1.1  riastrad 
    173  1.1  riastrad typedef struct _drm_via_cmdbuffer {
    174  1.1  riastrad 	char __user *buf;
    175  1.1  riastrad 	unsigned long size;
    176  1.1  riastrad } drm_via_cmdbuffer_t;
    177  1.1  riastrad 
    178  1.1  riastrad /* Warning: If you change the SAREA structure you must change the Xserver
    179  1.1  riastrad  * structure as well */
    180  1.1  riastrad 
    181  1.1  riastrad typedef struct _drm_via_tex_region {
    182  1.1  riastrad 	unsigned char next, prev;	/* indices to form a circular LRU  */
    183  1.1  riastrad 	unsigned char inUse;	/* owned by a client, or free? */
    184  1.1  riastrad 	int age;		/* tracked by clients to update local LRU's */
    185  1.1  riastrad } drm_via_tex_region_t;
    186  1.1  riastrad 
    187  1.1  riastrad typedef struct _drm_via_sarea {
    188  1.1  riastrad 	unsigned int dirty;
    189  1.1  riastrad 	unsigned int nbox;
    190  1.1  riastrad 	struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
    191  1.1  riastrad 	drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
    192  1.1  riastrad 	int texAge;		/* last time texture was uploaded */
    193  1.1  riastrad 	int ctxOwner;		/* last context to upload state */
    194  1.1  riastrad 	int vertexPrim;
    195  1.1  riastrad 
    196  1.1  riastrad 	/*
    197  1.1  riastrad 	 * Below is for XvMC.
    198  1.1  riastrad 	 * We want the lock integers alone on, and aligned to, a cache line.
    199  1.1  riastrad 	 * Therefore this somewhat strange construct.
    200  1.1  riastrad 	 */
    201  1.1  riastrad 
    202  1.1  riastrad 	char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
    203  1.1  riastrad 
    204  1.1  riastrad 	unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
    205  1.1  riastrad 	unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
    206  1.1  riastrad 	unsigned int XvMCCtxNoGrabbed;	/* Last context to hold decoder */
    207  1.1  riastrad 
    208  1.1  riastrad 	/* Used by the 3d driver only at this point, for pageflipping:
    209  1.1  riastrad 	 */
    210  1.1  riastrad 	unsigned int pfCurrentOffset;
    211  1.1  riastrad } drm_via_sarea_t;
    212  1.1  riastrad 
    213  1.1  riastrad typedef struct _drm_via_cmdbuf_size {
    214  1.1  riastrad 	enum {
    215  1.1  riastrad 		VIA_CMDBUF_SPACE = 0x01,
    216  1.1  riastrad 		VIA_CMDBUF_LAG = 0x02
    217  1.1  riastrad 	} func;
    218  1.1  riastrad 	int wait;
    219  1.1  riastrad 	__u32 size;
    220  1.1  riastrad } drm_via_cmdbuf_size_t;
    221  1.1  riastrad 
    222  1.1  riastrad typedef enum {
    223  1.1  riastrad 	VIA_IRQ_ABSOLUTE = 0x0,
    224  1.1  riastrad 	VIA_IRQ_RELATIVE = 0x1,
    225  1.1  riastrad 	VIA_IRQ_SIGNAL = 0x10000000,
    226  1.1  riastrad 	VIA_IRQ_FORCE_SEQUENCE = 0x20000000
    227  1.1  riastrad } via_irq_seq_type_t;
    228  1.1  riastrad 
    229  1.1  riastrad #define VIA_IRQ_FLAGS_MASK 0xF0000000
    230  1.1  riastrad 
    231  1.1  riastrad enum drm_via_irqs {
    232  1.1  riastrad 	drm_via_irq_hqv0 = 0,
    233  1.1  riastrad 	drm_via_irq_hqv1,
    234  1.1  riastrad 	drm_via_irq_dma0_dd,
    235  1.1  riastrad 	drm_via_irq_dma0_td,
    236  1.1  riastrad 	drm_via_irq_dma1_dd,
    237  1.1  riastrad 	drm_via_irq_dma1_td,
    238  1.1  riastrad 	drm_via_irq_num
    239  1.1  riastrad };
    240  1.1  riastrad 
    241  1.1  riastrad struct drm_via_wait_irq_request {
    242  1.1  riastrad 	unsigned irq;
    243  1.1  riastrad 	via_irq_seq_type_t type;
    244  1.1  riastrad 	__u32 sequence;
    245  1.1  riastrad 	__u32 signal;
    246  1.1  riastrad };
    247  1.1  riastrad 
    248  1.1  riastrad typedef union drm_via_irqwait {
    249  1.1  riastrad 	struct drm_via_wait_irq_request request;
    250  1.1  riastrad 	struct drm_wait_vblank_reply reply;
    251  1.1  riastrad } drm_via_irqwait_t;
    252  1.1  riastrad 
    253  1.1  riastrad typedef struct drm_via_blitsync {
    254  1.1  riastrad 	__u32 sync_handle;
    255  1.1  riastrad 	unsigned engine;
    256  1.1  riastrad } drm_via_blitsync_t;
    257  1.1  riastrad 
    258  1.1  riastrad /* - * Below,"flags" is currently unused but will be used for possible future
    259  1.1  riastrad  * extensions like kernel space bounce buffers for bad alignments and
    260  1.1  riastrad  * blit engine busy-wait polling for better latency in the absence of
    261  1.1  riastrad  * interrupts.
    262  1.1  riastrad  */
    263  1.1  riastrad 
    264  1.1  riastrad typedef struct drm_via_dmablit {
    265  1.1  riastrad 	__u32 num_lines;
    266  1.1  riastrad 	__u32 line_length;
    267  1.1  riastrad 
    268  1.1  riastrad 	__u32 fb_addr;
    269  1.1  riastrad 	__u32 fb_stride;
    270  1.1  riastrad 
    271  1.1  riastrad 	unsigned char *mem_addr;
    272  1.1  riastrad 	__u32 mem_stride;
    273  1.1  riastrad 
    274  1.1  riastrad 	__u32 flags;
    275  1.1  riastrad 	int to_fb;
    276  1.1  riastrad 
    277  1.1  riastrad 	drm_via_blitsync_t sync;
    278  1.1  riastrad } drm_via_dmablit_t;
    279  1.1  riastrad 
    280  1.1  riastrad #if defined(__cplusplus)
    281  1.1  riastrad }
    282  1.1  riastrad #endif
    283  1.1  riastrad 
    284  1.1  riastrad #endif				/* _VIA_DRM_H_ */
    285