1 /* 2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. 3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sub license, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial portions 14 * of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 */ 24 #ifndef _VIA_DRM_H_ 25 #define _VIA_DRM_H_ 26 27 /* WARNING: These defines must be the same as what the Xserver uses. 28 * if you change them, you must change the defines in the Xserver. 29 */ 30 31 #ifndef _VIA_DEFINES_ 32 #define _VIA_DEFINES_ 33 34 #define VIA_DMA_BUF_ORDER 12 35 #define VIA_DMA_BUF_SZ (1 << VIA_DMA_BUF_ORDER) 36 #define VIA_DMA_BUF_NR 256 37 #define VIA_NR_SAREA_CLIPRECTS 8 38 39 /* Each region is a minimum of 64k, and there are at most 64 of them. 40 */ 41 #define VIA_NR_TEX_REGIONS 64 42 #define VIA_LOG_MIN_TEX_REGION_SIZE 16 43 #endif 44 45 #define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */ 46 #define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */ 47 #define VIA_UPLOAD_CTX 0x4 48 #define VIA_UPLOAD_BUFFERS 0x8 49 #define VIA_UPLOAD_TEX0 0x10 50 #define VIA_UPLOAD_TEX1 0x20 51 #define VIA_UPLOAD_CLIPRECTS 0x40 52 #define VIA_UPLOAD_ALL 0xff 53 54 /* VIA specific ioctls */ 55 #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t) 56 #define DRM_IOCTL_VIA_FREEMEM DRM_IOW(0x41, drm_via_mem_t) 57 #define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(0x42, drm_via_agp_t) 58 #define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(0x43, drm_via_fb_t) 59 #define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(0x44, drm_via_init_t) 60 61 /* Indices into buf.Setup where various bits of state are mirrored per 62 * context and per buffer. These can be fired at the card as a unit, 63 * or in a piecewise fashion as required. 64 */ 65 66 #define VIA_TEX_SETUP_SIZE 8 67 68 /* Flags for clear ioctl 69 */ 70 #define VIA_FRONT 0x1 71 #define VIA_BACK 0x2 72 #define VIA_DEPTH 0x4 73 #define VIA_STENCIL 0x8 74 #define VIDEO 0 75 #define AGP 1 76 77 typedef struct { 78 unsigned int offset; 79 unsigned int size; 80 } drm_via_agp_t; 81 82 typedef struct { 83 unsigned int offset; 84 unsigned int size; 85 } drm_via_fb_t; 86 87 typedef struct { 88 unsigned int context; 89 unsigned int type; 90 unsigned int size; 91 unsigned long index; 92 unsigned long offset; 93 } drm_via_mem_t; 94 95 typedef struct _drm_via_init { 96 enum { 97 VIA_INIT_MAP = 0x01, 98 VIA_CLEANUP_MAP = 0x02 99 } func; 100 101 unsigned long sarea_priv_offset; 102 unsigned long fb_offset; 103 unsigned long mmio_offset; 104 unsigned long agpAddr; 105 } drm_via_init_t; 106 107 /* Warning: If you change the SAREA structure you must change the Xserver 108 * structure as well */ 109 110 typedef struct _drm_via_tex_region { 111 unsigned char next, prev; /* indices to form a circular LRU */ 112 unsigned char inUse; /* owned by a client, or free? */ 113 int age; /* tracked by clients to update local LRU's */ 114 } drm_via_tex_region_t; 115 116 typedef struct _drm_via_sarea { 117 unsigned int dirty; 118 unsigned int nbox; 119 drm_clip_rect_t boxes[VIA_NR_SAREA_CLIPRECTS]; 120 drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1]; 121 int texAge; /* last time texture was uploaded */ 122 int ctxOwner; /* last context to upload state */ 123 int vertexPrim; 124 } drm_via_sarea_t; 125 126 typedef struct _drm_via_flush_agp { 127 unsigned int offset; 128 unsigned int size; 129 unsigned int index; 130 int discard; /* client is finished with the buffer? */ 131 } drm_via_flush_agp_t; 132 133 typedef struct _drm_via_flush_sys { 134 unsigned int offset; 135 unsigned int size; 136 unsigned long index; 137 int discard; /* client is finished with the buffer? */ 138 } drm_via_flush_sys_t; 139 140 #ifdef __KERNEL__ 141 int via_fb_init(struct inode *inode, struct file *filp, unsigned int cmd, 142 unsigned long arg); 143 int via_mem_alloc(struct inode *inode, struct file *filp, unsigned int cmd, 144 unsigned long arg); 145 int via_mem_free(struct inode *inode, struct file *filp, unsigned int cmd, 146 unsigned long arg); 147 int via_agp_init(struct inode *inode, struct file *filp, unsigned int cmd, 148 unsigned long arg); 149 int via_dma_alloc(struct inode *inode, struct file *filp, unsigned int cmd, 150 unsigned long arg); 151 int via_dma_free(struct inode *inode, struct file *filp, unsigned int cmd, 152 unsigned long arg); 153 int via_map_init(struct inode *inode, struct file *filp, unsigned int cmd, 154 unsigned long arg); 155 #endif 156 #endif /* _VIA_DRM_H_ */ 157