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_FALLBACK(fmt,args...) do { \
46 NOUVEAU_ERR("FALLBACK: "fmt, ##args); \
50 #define NOUVEAU_FALLBACK(fmt,args...) do { \
55 #define NOUVEAU_TIME_MSEC() GetTimeInMillis()
57 #define NOUVEAU_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
59 /* User FIFO control */
60 //#define NOUVEAU_DMA_TRACE
61 //#define NOUVEAU_DMA_DEBUG
62 #define NOUVEAU_DMA_SUBCHAN_LRU
63 #define NOUVEAU_DMA_BARRIER mem_barrier();
64 #define NOUVEAU_DMA_TIMEOUT 2000
66 /* Push buffer access macros */
67 #define BEGIN_RING(chan,obj,mthd,size) do { \
68 BEGIN_RING_CH((chan), (obj), (mthd), (size)); \
71 #define OUT_RING(chan,data) do { \
72 OUT_RING_CH((chan), (data)); \
75 #define OUT_RINGp(chan,src,size) do { \
76 OUT_RINGp_CH((chan), (src), (size)); \
79 #define OUT_RINGf(chan,data) do { \
80 union { float v; uint32_t u; } c; \
82 OUT_RING((chan), c.u); \
85 #define WAIT_RING(chan,size) do { \
86 WAIT_RING_CH((chan), (size)); \
89 #define FIRE_RING(chan) do { \
90 FIRE_RING_CH((chan)); \
93 #define OUT_RELOC(chan,bo,data,flags,vor,tor) do { \
94 struct nouveau_channel_priv *nvchan = nouveau_channel(chan); \
95 nouveau_bo_emit_reloc((chan), &nvchan->pushbuf[nvchan->dma.cur], \
96 (bo), (data), (flags), (vor), (tor)); \
97 OUT_RING((chan), 0); \
100 /* Raw data + flags depending on FB/TT buffer */
101 #define OUT_RELOCd(chan,bo,data,flags,vor,tor) do { \
102 OUT_RELOC((chan), (bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor));\
105 /* FB/TT object handle */
106 #define OUT_RELOCo(chan,bo,flags) do { \
107 OUT_RELOC((chan), (bo), 0, (flags) | NOUVEAU_BO_OR, \
108 (chan)->vram->handle, (chan)->gart->handle); \
111 /* Low 32-bits of offset */
112 #define OUT_RELOCl(chan,bo,delta,flags) do { \
113 OUT_RELOC((chan), (bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \
116 /* High 32-bits of offset */
117 #define OUT_RELOCh(chan,bo,delta,flags) do { \
118 OUT_RELOC((chan), (bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \
122 /* Alternate versions of OUT_RELOCx above, takes pixmaps instead of BOs */
123 #if NOUVEAU_EXA_PIXMAPS
124 #define OUT_PIXMAPd(chan,pm,data,flags,vor,tor) do { \
125 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
126 struct nouveau_bo *pmo = nvpix->bo; \
127 OUT_RELOCd((chan), pmo, (data), (flags), (vor), (tor)); \
129 #define OUT_PIXMAPo(chan,pm,flags) do { \
130 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
131 struct nouveau_bo *pmo = nvpix->bo; \
132 OUT_RELOCo((chan), pmo, (flags)); \
134 #define OUT_PIXMAPl(chan,pm,delta,flags) do { \
135 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
136 struct nouveau_bo *pmo = nvpix->bo; \
137 OUT_RELOCl((chan), pmo, (delta), (flags)); \
139 #define OUT_PIXMAPh(chan,pm,delta,flags) do { \
140 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
141 struct nouveau_bo *pmo = nvpix->bo; \
142 OUT_RELOCh((chan), pmo, (delta), (flags)); \
145 #define OUT_PIXMAPd(chan,pm,data,flags,vor,tor) do { \
146 OUT_RELOCd((chan), pNv->FB, (data), (flags), (vor), (tor)); \
148 #define OUT_PIXMAPo(chan,pm,flags) do { \
149 OUT_RELOCo((chan), pNv->FB, (flags)); \
151 #define OUT_PIXMAPl(chan,pm,delta,flags) do { \
152 OUT_RELOCl((chan), pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags));\
154 #define OUT_PIXMAPh(chan,pm,delta,flags) do { \
155 OUT_RELOCh((chan), pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags));\