📄 mga_drv.h
字号:
/* mga_drv.h -- Private header for the Matrox g200/g400 driver -*- linux-c -*- * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * Jeff Hartmann <jhartmann@valinux.com> * */#ifndef _MGA_DRV_H_#define _MGA_DRV_H_#define MGA_BUF_IN_USE 0#define MGA_BUF_SWAP_PENDING 1#define MGA_BUF_FORCE_FIRE 2#define MGA_BUF_NEEDS_OVERFLOW 3typedef struct { long buffer_status; /* long req'd for set_bit() --RR */ int num_dwords; int max_dwords; u32 *current_dma_ptr; u32 *head; u32 phys_head; unsigned int prim_age; int sec_used; int idx;} drm_mga_prim_buf_t;typedef struct _drm_mga_freelist { __volatile__ unsigned int age; drm_buf_t *buf; struct _drm_mga_freelist *next; struct _drm_mga_freelist *prev;} drm_mga_freelist_t;#define MGA_IN_DISPATCH 0#define MGA_IN_FLUSH 1#define MGA_IN_WAIT 2#define MGA_IN_GETBUF 3typedef struct _drm_mga_private { long dispatch_status; /* long req'd for set_bit() --RR */ unsigned int next_prim_age; __volatile__ unsigned int last_prim_age; int reserved_map_idx; int buffer_map_idx; drm_mga_sarea_t *sarea_priv; int primary_size; int warp_ucode_size; int chipset; unsigned int frontOffset; unsigned int backOffset; unsigned int depthOffset; unsigned int textureOffset; unsigned int textureSize; int cpp; unsigned int stride; int sgram; int use_agp; drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES]; unsigned int WarpPipe; unsigned int vertexsize; atomic_t pending_bufs; void *status_page; unsigned long real_status_page; u8 *ioremap; drm_mga_prim_buf_t **prim_bufs; drm_mga_prim_buf_t *next_prim; drm_mga_prim_buf_t *last_prim; drm_mga_prim_buf_t *current_prim; int current_prim_idx; drm_mga_freelist_t *head; drm_mga_freelist_t *tail; wait_queue_head_t flush_queue; /* Processes waiting until flush */ wait_queue_head_t wait_queue; /* Processes waiting until interrupt */ wait_queue_head_t buf_queue; /* Processes waiting for a free buf */ /* Some validated register values: */ u32 mAccess;} drm_mga_private_t; /* mga_drv.c */extern int mga_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_open(struct inode *inode, struct file *filp);extern int mga_release(struct inode *inode, struct file *filp);extern int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_unlock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* mga_dma.c */extern int mga_dma_schedule(drm_device_t *dev, int locked);extern int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_irq_install(drm_device_t *dev, int irq);extern int mga_irq_uninstall(drm_device_t *dev);extern int mga_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);/* mga_dma_init does init and release */extern int mga_dma_init(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_dma_cleanup(drm_device_t *dev);extern int mga_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern unsigned int mga_create_sync_tag(drm_device_t *dev);extern drm_buf_t *mga_freelist_get(drm_device_t *dev);extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf);extern int mga_advance_primary(drm_device_t *dev);extern void mga_reclaim_buffers(drm_device_t *dev, pid_t pid); /* mga_bufs.c */extern int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_markbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_freebufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_addmap(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* mga_state.c */extern int mga_clear_bufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_swap_bufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_iload(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_vertex(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_indices(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* mga_context.c */extern int mga_resctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_addctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_modctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_getctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_switchctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_newctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern int mga_context_switch(drm_device_t *dev, int old, int new);extern int mga_context_switch_complete(drm_device_t *dev, int new);#define mga_flush_write_combine() mb()typedef enum { TT_GENERAL, TT_BLIT, TT_VECTOR, TT_VERTEX} transferType_t;typedef struct { drm_mga_freelist_t *my_freelist; int discard; int dispatched;} drm_mga_buf_priv_t;#define DWGREG0 0x1c00#define DWGREG0_END 0x1dff#define DWGREG1 0x2c00#define DWGREG1_END 0x2dff#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)#define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2)#define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80)#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r))#define MGA_VERBOSE 0#define MGA_NUM_PRIM_BUFS 8#define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \ int outcount, num_dwords#define PRIM_OVERFLOW(dev, dev_priv, length) do { \ drm_mga_prim_buf_t *tmp_buf = \ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ if( test_bit(MGA_BUF_NEEDS_OVERFLOW, &tmp_buf->buffer_status)) { \ mga_advance_primary(dev); \ mga_dma_schedule(dev, 1); \ tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length || \ tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ mga_advance_primary(dev); \ mga_dma_schedule(dev, 1); \ tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ } \ if(MGA_VERBOSE) \ DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \ dma_ptr = tmp_buf->current_dma_ptr; \ num_dwords = tmp_buf->num_dwords; \ phys_head = tmp_buf->phys_head; \ outcount = 0; \} while(0)#define PRIMGETPTR(dev_priv) do { \ drm_mga_prim_buf_t *tmp_buf = \ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ if(MGA_VERBOSE) \ DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \ dma_ptr = tmp_buf->current_dma_ptr; \ num_dwords = tmp_buf->num_dwords; \ phys_head = tmp_buf->phys_head; \ outcount = 0; \} while(0)#define PRIMPTR(prim_buf) do { \ if(MGA_VERBOSE) \ DRM_DEBUG("PRIMPTR in %s\n", __FUNCTION__); \ dma_ptr = prim_buf->current_dma_ptr; \ num_dwords = prim_buf->num_dwords; \ phys_head = prim_buf->phys_head; \ outcount = 0; \} while(0)#define PRIMFINISH(prim_buf) do { \ if (MGA_VERBOSE) { \ DRM_DEBUG( "PRIMFINISH in %s\n", __FUNCTION__); \ if (outcount & 3) \ DRM_DEBUG(" --- truncation\n"); \ } \ prim_buf->num_dwords = num_dwords; \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -