nvbios: Add some valid register ranges for nv50.
[nouveau] / src / nouveau_local.h
1 /*
2  * Copyright 2007 Nouveau Project
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22
23 #ifndef __NOUVEAU_LOCAL_H__
24 #define __NOUVEAU_LOCAL_H__
25
26 #include "compiler.h"
27 #include "xf86_OSproc.h"
28
29 #define NOUVEAU_PRIVATE _X_HIDDEN
30 #define NOUVEAU_PUBLIC _X_EXPORT
31
32 #if EXA_VERSION_MINOR >= 4
33 #define NOUVEAU_EXA_PIXMAPS 0
34 struct nouveau_pixmap {
35         struct nouveau_bo *bo;
36         int mapped;
37 };
38 #endif
39
40 /* Debug output */
41 #define NOUVEAU_MSG(fmt,args...) ErrorF(fmt, ##args)
42 #define NOUVEAU_ERR(fmt,args...) \
43         ErrorF("%s:%d - "fmt, __func__, __LINE__, ##args)
44
45 #define NOUVEAU_TIME_MSEC() GetTimeInMillis()
46
47 #define NOUVEAU_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
48
49 /* User FIFO control */
50 //#define NOUVEAU_DMA_TRACE
51 //#define NOUVEAU_DMA_DEBUG
52 #define NOUVEAU_DMA_SUBCHAN_LRU
53 #define NOUVEAU_DMA_BARRIER mem_barrier();
54 #define NOUVEAU_DMA_TIMEOUT 2000
55
56 /* Push buffer access macros */
57 #define BEGIN_RING(obj,mthd,size) do {                                         \
58         BEGIN_RING_CH(pNv->chan, pNv->obj, (mthd), (size));                    \
59 } while(0)
60
61 #define OUT_RING(data) do {                                                    \
62         OUT_RING_CH(pNv->chan, (data));                                        \
63 } while(0)
64
65 #define OUT_RINGp(src,size) do {                                               \
66         OUT_RINGp_CH(pNv->chan, (src), (size));                                \
67 } while(0)
68
69 #define OUT_RINGf(data) do {                                                   \
70         union { float v; uint32_t u; } c;                                      \
71         c.v = (data);                                                          \
72         OUT_RING(c.u);                                                         \
73 } while(0)
74
75 #define WAIT_RING(size) do {                                                   \
76         WAIT_RING_CH(pNv->chan, (size));                                       \
77 } while(0)
78
79 #define FIRE_RING() do {                                                       \
80         FIRE_RING_CH(pNv->chan);                                               \
81 } while(0)
82
83 #define OUT_RELOC(bo,data,flags,vor,tor) do {                                  \
84         struct nouveau_channel_priv *chan = nouveau_channel(pNv->chan);        \
85         nouveau_bo_emit_reloc(&chan->base, &chan->pushbuf[chan->dma.cur],      \
86                               (bo), (data), (flags), (vor), (tor));            \
87         OUT_RING(0);                                                           \
88 } while(0)
89
90 /* Raw data + flags depending on FB/TT buffer */
91 #define OUT_RELOCd(bo,data,flags,vor,tor) do {                                 \
92         OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor));        \
93 } while(0)
94
95 /* FB/TT object handle */
96 #define OUT_RELOCo(bo,flags) do {                                              \
97         OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR,                            \
98                   pNv->chan->vram->handle, pNv->chan->gart->handle);           \
99 } while(0)
100
101 /* Low 32-bits of offset */
102 #define OUT_RELOCl(bo,delta,flags) do {                                        \
103         OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0);              \
104 } while(0)
105
106 /* High 32-bits of offset */
107 #define OUT_RELOCh(bo,delta,flags) do {                                        \
108         OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0);             \
109 } while(0)
110
111
112 /* Alternate versions of OUT_RELOCx above, takes pixmaps instead of BOs */
113 #if NOUVEAU_EXA_PIXMAPS
114 #define OUT_PIXMAPd(pm,data,flags,vor,tor) do {                                \
115         struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm));        \
116         struct nouveau_bo *pmo = nvpix->bo;                                    \
117         OUT_RELOCd(pmo, (data), (flags), (vor), (tor));                        \
118 } while(0)
119 #define OUT_PIXMAPo(pm,flags) do {                                             \
120         struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm));        \
121         struct nouveau_bo *pmo = nvpix->bo;                                    \
122         OUT_RELOCo(pmo, (flags));                                              \
123 } while(0)
124 #define OUT_PIXMAPl(pm,delta,flags) do {                                       \
125         struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm));        \
126         struct nouveau_bo *pmo = nvpix->bo;                                    \
127         OUT_RELOCl(pmo, (delta), (flags));                                     \
128 } while(0)
129 #define OUT_PIXMAPh(pm,delta,flags) do {                                       \
130         struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm));        \
131         struct nouveau_bo *pmo = nvpix->bo;                                    \
132         OUT_RELOCh(pmo, (delta), (flags));                                     \
133 } while(0)
134 #else
135 #define OUT_PIXMAPd(pm,data,flags,vor,tor) do {                                \
136         OUT_RELOCd(pNv->FB, (data), (flags), (vor), (tor));                    \
137 } while(0)
138 #define OUT_PIXMAPo(pm,flags) do {                                             \
139         OUT_RELOCo(pNv->FB, (flags));                                          \
140 } while(0)
141 #define OUT_PIXMAPl(pm,delta,flags) do {                                       \
142         OUT_RELOCl(pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags));        \
143 } while(0)
144 #define OUT_PIXMAPh(pm,delta,flags) do {                                       \
145         OUT_RELOCh(pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags));        \
146 } while(0)
147 #endif
148
149 #endif