4 #include "mga_drm_public.h"
7 /* Isn't this fun. This has to be fixed asap by emitting primary
8 * dma commands in the 'do_dma' ioctl.
13 unsigned int ContextState[MGA_CTX_SETUP_SIZE];
14 unsigned int ServerState[MGA_2D_SETUP_SIZE];
15 unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
16 unsigned int WarpPipe;
20 xf86drmClipRectRec boxes[MGA_NR_SAREA_CLIPRECTS];
24 #define MGA_DMA_GENERAL 0
25 #define MGA_DMA_VERTEX 1
26 #define MGA_DMA_SETUP 2
27 #define MGA_DMA_ILOAD 3
30 #define DWGREG0 0x1c00
31 #define DWGREG0_END 0x1dff
32 #define DWGREG1 0x2c00
33 #define DWGREG1_END 0x2dff
35 #define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)
36 #define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2)
37 #define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80)
38 #define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r))
41 /* Macros for inserting commands into a secondary dma buffer.
44 #define DMALOCALS u8 tempIndex[4]; u32 *dma_ptr; \
45 int outcount, num_dwords;
47 #define DMAGETPTR(buf) do { \
48 dma_ptr = (u32 *)((u8 *)buf->address + buf->used); \
50 num_dwords = buf->used / 4; \
53 #define DMAADVANCE(buf) do { \
54 buf->used = num_dwords * 4; \
57 #define DMAOUTREG(reg, val) do { \
58 tempIndex[outcount]=ADRINDEX(reg); \
59 dma_ptr[++outcount] = val; \
60 if (outcount == 4) { \
62 dma_ptr[0] = *(u32 *)tempIndex; \
73 /* Primary buffer versions of above -- pretty similar really.
75 #define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \
76 int outcount, num_dwords
78 #define PRIMRESET(dev_priv) do { \
79 dev_priv->prim_num_dwords = 0; \
80 dev_priv->current_dma_ptr = dev_priv->prim_head; \
83 #define PRIMGETPTR(dev_priv) do { \
84 dma_ptr = dev_priv->current_dma_ptr; \
85 phys_head = dev_priv->prim_phys_head; \
86 num_dwords = dev_priv->prim_num_dwords; \
90 #define PRIMADVANCE(dev_priv) do { \
91 dev_priv->prim_num_dwords = num_dwords; \
92 dev_priv->current_dma_ptr = dma_ptr; \
95 #define PRIMOUTREG(reg, val) do { \
96 tempIndex[outcount]=ADRINDEX(reg); \
97 dma_ptr[1+outcount] = val; \
98 if( ++outcount == 4) { \
100 dma_ptr[0] = *(u32 *)tempIndex; \
106 "OUT %x val %x dma_ptr %p nr_dwords %d\n", \
107 outcount, ADRINDEX(reg), dma_ptr, \