diff options
Diffstat (limited to 'linux/mga_dma.h')
-rw-r--r-- | linux/mga_dma.h | 146 |
1 files changed, 83 insertions, 63 deletions
diff --git a/linux/mga_dma.h b/linux/mga_dma.h index 7f1c5795..97d83005 100644 --- a/linux/mga_dma.h +++ b/linux/mga_dma.h @@ -2,30 +2,24 @@ #define MGA_DMA_H #include "mga_drm_public.h" +typedef enum { + TT_GENERAL, + TT_BLIT, + TT_VECTOR, + TT_VERTEX +} transferType_t; - -/* Isn't this fun. This has to be fixed asap by emitting primary - * dma commands in the 'do_dma' ioctl. - */ typedef struct { - int dma_type; - - unsigned int ContextState[MGA_CTX_SETUP_SIZE]; - unsigned int ServerState[MGA_2D_SETUP_SIZE]; - unsigned int TexState[2][MGA_TEX_SETUP_SIZE]; - unsigned int WarpPipe; - unsigned int dirty; - - unsigned int nbox; - xf86drmClipRectRec boxes[MGA_NR_SAREA_CLIPRECTS]; + drm_mga_freelist_t *my_freelist; } drm_mga_buf_priv_t; - -#define MGA_DMA_GENERAL 0 +#define MGA_DMA_GENERAL 0 /* not used */ #define MGA_DMA_VERTEX 1 #define MGA_DMA_SETUP 2 #define MGA_DMA_ILOAD 3 - +#define MGA_DMA_CLEAR 4 /* placeholder */ +#define MGA_DMA_SWAP 5 /* placeholder */ +#define MGA_DMA_DISCARD 6 #define DWGREG0 0x1c00 #define DWGREG0_END 0x1dff @@ -37,76 +31,102 @@ typedef struct { #define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80) #define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) +#define MGA_VERBOSE 0 -/* Macros for inserting commands into a secondary dma buffer. +#define MGA_NUM_PRIM_BUFS 8 +/* Primary buffer versions of above -- pretty similar really. */ -#define DMALOCALS u8 tempIndex[4]; u32 *dma_ptr; \ - int outcount, num_dwords; +#define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \ + int outcount, num_dwords -#define DMAGETPTR(buf) do { \ - dma_ptr = (u32 *)((u8 *)buf->address + buf->used); \ - outcount = 0; \ - num_dwords = buf->used / 4; \ +#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( (tmp_buf->max_dwords - tmp_buf->num_dwords) < length || \ +tmp_buf->sec_used > (MGA_DMA_BUF_NR / 2)) { \ + atomic_set(&tmp_buf->force_fire, 1); \ + mga_advance_primary(dev); \ + mga_dma_schedule(dev, 1); \ + } else if( atomic_read(&tmp_buf->needs_overflow)) { \ + mga_advance_primary(dev); \ + mga_dma_schedule(dev, 1); \ +} \ } while(0) -#define DMAADVANCE(buf) do { \ - buf->used = num_dwords * 4; \ +#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 DMAOUTREG(reg, val) do { \ - tempIndex[outcount]=ADRINDEX(reg); \ - dma_ptr[++outcount] = val; \ - if (outcount == 4) { \ - outcount = 0; \ - dma_ptr[0] = *(u32 *)tempIndex; \ - dma_ptr+=5; \ - num_dwords += 5; \ - } \ -}while (0) - - - -#define VERBO 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) -/* Primary buffer versions of above -- pretty similar really. - */ -#define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \ - int outcount, num_dwords +#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; \ + prim_buf->current_dma_ptr = dma_ptr; \ +} while(0) -#define PRIMRESET(dev_priv) do { \ - dev_priv->prim_num_dwords = 0; \ - dev_priv->current_dma_ptr = dev_priv->prim_head; \ -} while (0) - -#define PRIMGETPTR(dev_priv) do { \ - dma_ptr = dev_priv->current_dma_ptr; \ - phys_head = dev_priv->prim_phys_head; \ - num_dwords = dev_priv->prim_num_dwords; \ - outcount = 0; \ +#define PRIMADVANCE(dev_priv) do { \ +drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + if (MGA_VERBOSE) { \ + DRM_DEBUG("PRIMADVANCE in %s\n", __FUNCTION__); \ + if (outcount & 3) \ + DRM_DEBUG(" --- truncation\n"); \ + } \ + tmp_buf->num_dwords = num_dwords; \ + tmp_buf->current_dma_ptr = dma_ptr; \ } while (0) -#define PRIMADVANCE(dev_priv) do { \ - dev_priv->prim_num_dwords = num_dwords; \ - dev_priv->current_dma_ptr = dma_ptr; \ +#define PRIMUPDATE(dev_priv) do { \ +drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + tmp_buf->sec_used++; \ } while (0) #define PRIMOUTREG(reg, val) do { \ tempIndex[outcount]=ADRINDEX(reg); \ dma_ptr[1+outcount] = val; \ + if (MGA_VERBOSE) \ + DRM_DEBUG(" PRIMOUT %d: 0x%x -- 0x%x\n", \ + num_dwords + 1 + outcount, ADRINDEX(reg), val); \ if( ++outcount == 4) { \ outcount = 0; \ dma_ptr[0] = *(u32 *)tempIndex; \ dma_ptr+=5; \ num_dwords += 5; \ } \ - if (VERBO) \ - printk(KERN_INFO \ - "OUT %x val %x dma_ptr %p nr_dwords %d\n", \ - outcount, ADRINDEX(reg), dma_ptr, \ - num_dwords); \ }while (0) +#define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \ + DC_sgnzero_enable | DC_shftzero_enable | \ + (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \ + DC_solid_enable | DC_transc_enable) + + +#define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \ + DC_solid_disable | DC_arzero_disable | \ + DC_sgnzero_enable | DC_shftzero_enable | \ + (0xC << DC_bop_SHIFT) | DC_bltmod_bfcol | \ + DC_pattern_disable | DC_transc_disable | \ + DC_clipdis_enable) \ #endif |