Merged mga branch with trunk
[platform/upstream/libdrm.git] / linux / i810_drm.h
1 #ifndef _I810_DRM_H_
2 #define _I810_DRM_H_
3
4 /* WARNING: These defines must be the same as what the Xserver uses.
5  * if you change them, you must change the defines in the Xserver.
6  */
7
8 /* Might one day want to support the client-side ringbuffer code again.
9  */
10 #ifndef _I810_DEFINES_
11 #define _I810_DEFINES_
12
13 #define I810_USE_BATCH                  1
14 #define I810_DMA_BUF_ORDER              12
15 #define I810_DMA_BUF_SZ                 (1<<I810_DMA_BUF_ORDER)
16 #define I810_DMA_BUF_NR                 256
17 #define I810_NR_SAREA_CLIPRECTS         2
18
19 /* Each region is a minimum of 64k, and there are at most 64 of them.
20  */
21
22 #define I810_NR_TEX_REGIONS 64
23 #define I810_LOG_MIN_TEX_REGION_SIZE 16
24 #endif
25
26 typedef struct _drm_i810_init {
27         enum {
28                 I810_INIT_DMA = 0x01,
29                 I810_CLEANUP_DMA = 0x02
30         } func;
31         int ring_map_idx;
32         int buffer_map_idx;
33         int sarea_priv_offset;
34         unsigned long ring_start;
35         unsigned long ring_end;
36         unsigned long ring_size;
37 } drm_i810_init_t;
38
39 /* Warning: If you change the SAREA structure you must change the Xserver
40  * structure as well */
41
42 typedef struct _drm_i810_tex_region {
43         unsigned char next, prev; /* indices to form a circular LRU  */
44         unsigned char in_use;   /* owned by a client, or free? */
45         int age;                /* tracked by clients to update local LRU's */
46 } drm_i810_tex_region_t;
47
48 typedef struct _drm_i810_sarea {
49         unsigned int nbox;
50         drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS];
51
52         /* Maintain an LRU of contiguous regions of texture space.  If
53          * you think you own a region of texture memory, and it has an
54          * age different to the one you set, then you are mistaken and
55          * it has been stolen by another client.  If global texAge
56          * hasn't changed, there is no need to walk the list.
57          *
58          * These regions can be used as a proxy for the fine-grained
59          * texture information of other clients - by maintaining them
60          * in the same lru which is used to age their own textures,
61          * clients have an approximate lru for the whole of global
62          * texture space, and can make informed decisions as to which
63          * areas to kick out.  There is no need to choose whether to
64          * kick out your own texture or someone else's - simply eject
65          * them all in LRU order.  
66          */
67    
68         drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS+1]; 
69                                 /* Last elt is sentinal */
70         int texAge;             /* last time texture was uploaded */
71         int last_enqueue;       /* last time a buffer was enqueued */
72         int last_dispatch;      /* age of the most recently dispatched buffer */
73         int last_quiescent;     /*  */
74         int ctxOwner;           /* last context to upload state */
75 } drm_i810_sarea_t;
76
77 typedef struct _drm_i810_general {
78         int idx;
79         int used;
80 } drm_i810_general_t;
81
82 /* These may be placeholders if we have more cliprects than
83  * I810_NR_SAREA_CLIPRECTS.  In that case, the client sets discard to
84  * false, indicating that the buffer will be dispatched again with a
85  * new set of cliprects.
86  */
87 typedef struct _drm_i810_vertex {
88         int idx;                /* buffer index */
89         int used;               /* nr bytes in use */
90         int discard;            /* client is finished with the buffer? */
91 } drm_i810_vertex_t;
92
93 #endif /* _I810_DRM_H_ */