1fa225cbcSrjs/************************************************************************** 2fa225cbcSrjs 3fa225cbcSrjsCopyright 2001 VA Linux Systems Inc., Fremont, California. 4fa225cbcSrjsCopyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. 5fa225cbcSrjs 6fa225cbcSrjsAll Rights Reserved. 7fa225cbcSrjs 8fa225cbcSrjsPermission is hereby granted, free of charge, to any person obtaining a 9fa225cbcSrjscopy of this software and associated documentation files (the "Software"), 10fa225cbcSrjsto deal in the Software without restriction, including without limitation 11fa225cbcSrjson the rights to use, copy, modify, merge, publish, distribute, sub 12fa225cbcSrjslicense, and/or sell copies of the Software, and to permit persons to whom 13fa225cbcSrjsthe Software is furnished to do so, subject to the following conditions: 14fa225cbcSrjs 15fa225cbcSrjsThe above copyright notice and this permission notice (including the next 16fa225cbcSrjsparagraph) shall be included in all copies or substantial portions of the 17fa225cbcSrjsSoftware. 18fa225cbcSrjs 19fa225cbcSrjsTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20fa225cbcSrjsIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21fa225cbcSrjsFITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 22fa225cbcSrjsATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 23fa225cbcSrjsDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 24fa225cbcSrjsOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25fa225cbcSrjsUSE OR OTHER DEALINGS IN THE SOFTWARE. 26fa225cbcSrjs 27fa225cbcSrjs**************************************************************************/ 28fa225cbcSrjs 29fa225cbcSrjs 30fa225cbcSrjs#ifndef _I830_COMMON_H_ 31fa225cbcSrjs#define _I830_COMMON_H_ 32fa225cbcSrjs 33fa225cbcSrjs#include <stdint.h> 34fa225cbcSrjs 35fa225cbcSrjs#define I830_NR_TEX_REGIONS 255 /* maximum due to use of chars for next/prev */ 36fa225cbcSrjs#define I830_LOG_MIN_TEX_REGION_SIZE 14 37fa225cbcSrjs 38fa225cbcSrjs 39fa225cbcSrjs/* Driver specific DRM command indices 40fa225cbcSrjs * NOTE: these are not OS specific, but they are driver specific 41fa225cbcSrjs */ 42fa225cbcSrjs#define DRM_I830_INIT 0x00 43fa225cbcSrjs#define DRM_I830_FLUSH 0x01 44fa225cbcSrjs#define DRM_I830_FLIP 0x02 45fa225cbcSrjs#define DRM_I830_BATCHBUFFER 0x03 46fa225cbcSrjs#define DRM_I830_IRQ_EMIT 0x04 47fa225cbcSrjs#define DRM_I830_IRQ_WAIT 0x05 48fa225cbcSrjs#define DRM_I830_GETPARAM 0x06 49fa225cbcSrjs#define DRM_I830_SETPARAM 0x07 50fa225cbcSrjs#define DRM_I830_ALLOC 0x08 51fa225cbcSrjs#define DRM_I830_FREE 0x09 52fa225cbcSrjs#define DRM_I830_INIT_HEAP 0x0a 53fa225cbcSrjs#define DRM_I830_CMDBUFFER 0x0b 54fa225cbcSrjs#define DRM_I830_DESTROY_HEAP 0x0c 55fa225cbcSrjs#define DRM_I830_SET_VBLANK_PIPE 0x0d 56fa225cbcSrjs#define DRM_I830_GET_VBLANK_PIPE 0x0e 57fa225cbcSrjs#define DRM_I830_HWS_PAGE_ADDR 0x11 58fa225cbcSrjs 59fa225cbcSrjs 60fa225cbcSrjstypedef struct { 61fa225cbcSrjs enum { 62fa225cbcSrjs I830_INIT_DMA = 0x01, 63fa225cbcSrjs I830_CLEANUP_DMA = 0x02, 64fa225cbcSrjs I830_RESUME_DMA = 0x03 65fa225cbcSrjs } func; 66fa225cbcSrjs unsigned int mmio_offset; 67fa225cbcSrjs int sarea_priv_offset; 68fa225cbcSrjs unsigned int ring_start; 69fa225cbcSrjs unsigned int ring_end; 70fa225cbcSrjs unsigned int ring_size; 71fa225cbcSrjs unsigned int front_offset; 72fa225cbcSrjs unsigned int back_offset; 73fa225cbcSrjs unsigned int depth_offset; 74fa225cbcSrjs unsigned int w; 75fa225cbcSrjs unsigned int h; 76fa225cbcSrjs unsigned int pitch; /* Pitch of front buffer in units of pixels */ 77fa225cbcSrjs unsigned int pitch_bits; 78fa225cbcSrjs unsigned int back_pitch; 79fa225cbcSrjs unsigned int depth_pitch; 80fa225cbcSrjs unsigned int cpp; 81fa225cbcSrjs unsigned int chipset; 82fa225cbcSrjs} drmI830Init; 83fa225cbcSrjs 84fa225cbcSrjstypedef struct { 85fa225cbcSrjs drmTextureRegion texList[I830_NR_TEX_REGIONS+1]; 86fa225cbcSrjs int last_upload; /* last time texture was uploaded */ 87fa225cbcSrjs int last_enqueue; /* last time a buffer was enqueued */ 88fa225cbcSrjs volatile int last_dispatch; /* age of the most recently dispatched buffer */ 89fa225cbcSrjs int ctxOwner; /* last context to upload state */ 90fa225cbcSrjs int texAge; 91fa225cbcSrjs int pf_enabled; /* is pageflipping allowed? */ 92fa225cbcSrjs int pf_active; 93fa225cbcSrjs int pf_current_page; /* which buffer is being displayed? */ 94fa225cbcSrjs int perf_boxes; /* performance boxes to be displayed */ 95fa225cbcSrjs int width, height; /* screen size in pixels */ 96fa225cbcSrjs 97fa225cbcSrjs drm_handle_t front_handle; 98fa225cbcSrjs int front_offset; 99fa225cbcSrjs int front_size; 100fa225cbcSrjs 101fa225cbcSrjs drm_handle_t back_handle; 102fa225cbcSrjs int back_offset; 103fa225cbcSrjs int back_size; 104fa225cbcSrjs 105fa225cbcSrjs drm_handle_t depth_handle; 106fa225cbcSrjs int depth_offset; 107fa225cbcSrjs int depth_size; 108fa225cbcSrjs 109fa225cbcSrjs drm_handle_t tex_handle; 110fa225cbcSrjs int tex_offset; 111fa225cbcSrjs int tex_size; 112fa225cbcSrjs int log_tex_granularity; 113fa225cbcSrjs int pitch; 114fa225cbcSrjs int rotation; /* 0, 90, 180 or 270 */ 115fa225cbcSrjs int rotated_offset; 116fa225cbcSrjs int rotated_size; 117fa225cbcSrjs int rotated_pitch; 118fa225cbcSrjs int virtualX, virtualY; 119fa225cbcSrjs 120fa225cbcSrjs unsigned int front_tiled; 121fa225cbcSrjs unsigned int back_tiled; 122fa225cbcSrjs unsigned int depth_tiled; 123fa225cbcSrjs unsigned int rotated_tiled; 124fa225cbcSrjs unsigned int rotated2_tiled; 125fa225cbcSrjs 126fa225cbcSrjs int pipeA_x; 127fa225cbcSrjs int pipeA_y; 128fa225cbcSrjs int pipeA_w; 129fa225cbcSrjs int pipeA_h; 130fa225cbcSrjs int pipeB_x; 131fa225cbcSrjs int pipeB_y; 132fa225cbcSrjs int pipeB_w; 133fa225cbcSrjs int pipeB_h; 134fa225cbcSrjs 135fa225cbcSrjs /* Triple buffering */ 136fa225cbcSrjs drm_handle_t third_handle; 137fa225cbcSrjs int third_offset; 138fa225cbcSrjs int third_size; 139fa225cbcSrjs unsigned int third_tiled; 140fa225cbcSrjs 141fa225cbcSrjs /* buffer object handles for the static buffers. May change 142fa225cbcSrjs * over the lifetime of the client, though it doesn't in our current 143fa225cbcSrjs * implementation. 144fa225cbcSrjs */ 145fa225cbcSrjs unsigned int front_bo_handle; 146fa225cbcSrjs unsigned int back_bo_handle; 147fa225cbcSrjs unsigned int third_bo_handle; 148fa225cbcSrjs unsigned int depth_bo_handle; 149fa225cbcSrjs} drmI830Sarea; 150fa225cbcSrjs 151fa225cbcSrjs/* Flags for perf_boxes 152fa225cbcSrjs */ 153fa225cbcSrjs#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */ 154fa225cbcSrjs#define I830_BOX_FLIP 0x2 /* populated by kernel */ 155fa225cbcSrjs#define I830_BOX_WAIT 0x4 /* populated by kernel & client */ 156fa225cbcSrjs#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */ 157fa225cbcSrjs#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */ 158fa225cbcSrjs 159fa225cbcSrjs 160fa225cbcSrjstypedef struct { 161fa225cbcSrjs int start; /* agp offset */ 162fa225cbcSrjs int used; /* nr bytes in use */ 163fa225cbcSrjs int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */ 164fa225cbcSrjs int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/ 165fa225cbcSrjs int num_cliprects; /* mulitpass with multiple cliprects? */ 166fa225cbcSrjs drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */ 167fa225cbcSrjs} drmI830BatchBuffer; 168fa225cbcSrjs 169fa225cbcSrjstypedef struct { 170fa225cbcSrjs char *buf; /* agp offset */ 171fa225cbcSrjs int sz; /* nr bytes in use */ 172fa225cbcSrjs int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */ 173fa225cbcSrjs int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/ 174fa225cbcSrjs int num_cliprects; /* mulitpass with multiple cliprects? */ 175fa225cbcSrjs drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */ 176fa225cbcSrjs} drmI830CmdBuffer; 177fa225cbcSrjs 178fa225cbcSrjstypedef struct { 179fa225cbcSrjs int *irq_seq; 180fa225cbcSrjs} drmI830IrqEmit; 181fa225cbcSrjs 182fa225cbcSrjstypedef struct { 183fa225cbcSrjs int irq_seq; 184fa225cbcSrjs} drmI830IrqWait; 185fa225cbcSrjs 186fa225cbcSrjstypedef struct { 187fa225cbcSrjs int param; 188fa225cbcSrjs int *value; 189fa225cbcSrjs} drmI830GetParam; 190fa225cbcSrjs 191fa225cbcSrjs#define I830_PARAM_IRQ_ACTIVE 1 192fa225cbcSrjs#define I830_PARAM_ALLOW_BATCHBUFFER 2 193fa225cbcSrjs 194fa225cbcSrjstypedef struct { 195fa225cbcSrjs int param; 196fa225cbcSrjs int value; 197fa225cbcSrjs} drmI830SetParam; 198fa225cbcSrjs 199fa225cbcSrjs#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1 200fa225cbcSrjs#define I830_SETPARAM_TEX_LRU_LOG_GRANULARITY 2 201fa225cbcSrjs#define I830_SETPARAM_ALLOW_BATCHBUFFER 3 202fa225cbcSrjs 203fa225cbcSrjs 204fa225cbcSrjs/* A memory manager for regions of shared memory: 205fa225cbcSrjs */ 206fa225cbcSrjs#define I830_MEM_REGION_AGP 1 207fa225cbcSrjs 208fa225cbcSrjstypedef struct { 209fa225cbcSrjs int region; 210fa225cbcSrjs int alignment; 211fa225cbcSrjs int size; 212fa225cbcSrjs int *region_offset; /* offset from start of fb or agp */ 213fa225cbcSrjs} drmI830MemAlloc; 214fa225cbcSrjs 215fa225cbcSrjstypedef struct { 216fa225cbcSrjs int region; 217fa225cbcSrjs int region_offset; 218fa225cbcSrjs} drmI830MemFree; 219fa225cbcSrjs 220fa225cbcSrjstypedef struct { 221fa225cbcSrjs int region; 222fa225cbcSrjs int size; 223fa225cbcSrjs int start; 224fa225cbcSrjs} drmI830MemInitHeap; 225fa225cbcSrjs 226fa225cbcSrjstypedef struct { 227fa225cbcSrjs int region; 228fa225cbcSrjs} drmI830MemDestroyHeap; 229fa225cbcSrjs 230fa225cbcSrjs#define DRM_I830_VBLANK_PIPE_A 1 231fa225cbcSrjs#define DRM_I830_VBLANK_PIPE_B 2 232fa225cbcSrjs 233fa225cbcSrjstypedef struct { 234fa225cbcSrjs int pipe; 235fa225cbcSrjs} drmI830VBlankPipe; 236fa225cbcSrjs 237fa225cbcSrjstypedef struct { 238fa225cbcSrjs uint64_t addr; 239fa225cbcSrjs} drmI830HWS; 240fa225cbcSrjs 241fa225cbcSrjs#endif /* _I830_DRM_H_ */ 242