2 * Copyright 2007 Nouveau Project
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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
23 #ifndef __NOUVEAU_LOCAL_H__
24 #define __NOUVEAU_LOCAL_H__
27 #include "xf86_OSproc.h"
29 #define NOUVEAU_PRIVATE _X_HIDDEN
30 #define NOUVEAU_PUBLIC _X_EXPORT
32 #if EXA_VERSION_MINOR >= 4
33 #define NOUVEAU_EXA_PIXMAPS 0
34 struct nouveau_pixmap {
35 struct nouveau_bo *bo;
41 #define NOUVEAU_MSG(fmt,args...) ErrorF(fmt, ##args)
42 #define NOUVEAU_ERR(fmt,args...) \
43 ErrorF("%s:%d - "fmt, __func__, __LINE__, ##args)
45 #define NOUVEAU_TIME_MSEC() GetTimeInMillis()
47 #define NOUVEAU_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
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
56 /* Push buffer access macros */
57 #define BEGIN_RING(obj,mthd,size) do { \
58 BEGIN_RING_CH(pNv->chan, pNv->obj, (mthd), (size)); \
61 #define OUT_RING(data) do { \
62 OUT_RING_CH(pNv->chan, (data)); \
65 #define OUT_RINGp(src,size) do { \
66 OUT_RINGp_CH(pNv->chan, (src), (size)); \
69 #define OUT_RINGf(data) do { \
70 union { float v; uint32_t u; } c; \
75 #define WAIT_RING(size) do { \
76 WAIT_RING_CH(pNv->chan, (size)); \
79 #define FIRE_RING() do { \
80 FIRE_RING_CH(pNv->chan); \
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)); \
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)); \
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); \
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); \
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); \
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)); \
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)); \
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)); \
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)); \
135 #define OUT_PIXMAPd(pm,data,flags,vor,tor) do { \
136 OUT_RELOCd(pNv->FB, (data), (flags), (vor), (tor)); \
138 #define OUT_PIXMAPo(pm,flags) do { \
139 OUT_RELOCo(pNv->FB, (flags)); \
141 #define OUT_PIXMAPl(pm,delta,flags) do { \
142 OUT_RELOCl(pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags)); \
144 #define OUT_PIXMAPh(pm,delta,flags) do { \
145 OUT_RELOCh(pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags)); \