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 //#define NOUVEAU_MODESET_TRACE
51 /* User FIFO control */
52 //#define NOUVEAU_DMA_TRACE
53 //#define NOUVEAU_DMA_DEBUG
54 #define NOUVEAU_DMA_SUBCHAN_LRU
55 #define NOUVEAU_DMA_BARRIER mem_barrier();
56 #define NOUVEAU_DMA_TIMEOUT 2000
58 /* Push buffer access macros */
59 #define BEGIN_RING(obj,mthd,size) do { \
60 BEGIN_RING_CH(pNv->chan, pNv->obj, (mthd), (size)); \
63 #define OUT_RING(data) do { \
64 OUT_RING_CH(pNv->chan, (data)); \
67 #define OUT_RINGp(src,size) do { \
68 OUT_RINGp_CH(pNv->chan, (src), (size)); \
71 #define OUT_RINGf(data) do { \
72 union { float v; uint32_t u; } c; \
77 #define WAIT_RING(size) do { \
78 WAIT_RING_CH(pNv->chan, (size)); \
81 #define FIRE_RING() do { \
82 FIRE_RING_CH(pNv->chan); \
85 #define OUT_RELOC(bo,data,flags,vor,tor) do { \
86 struct nouveau_channel_priv *chan = nouveau_channel(pNv->chan); \
87 nouveau_bo_emit_reloc(&chan->base, &chan->pushbuf[chan->dma.cur], \
88 (bo), (data), (flags), (vor), (tor)); \
92 /* Raw data + flags depending on FB/TT buffer */
93 #define OUT_RELOCd(bo,data,flags,vor,tor) do { \
94 OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor)); \
97 /* FB/TT object handle */
98 #define OUT_RELOCo(bo,flags) do { \
99 OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \
100 pNv->chan->vram->handle, pNv->chan->gart->handle); \
103 /* Low 32-bits of offset */
104 #define OUT_RELOCl(bo,delta,flags) do { \
105 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \
108 /* High 32-bits of offset */
109 #define OUT_RELOCh(bo,delta,flags) do { \
110 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \
114 /* Alternate versions of OUT_RELOCx above, takes pixmaps instead of BOs */
115 #if NOUVEAU_EXA_PIXMAPS
116 #define OUT_PIXMAPd(pm,data,flags,vor,tor) do { \
117 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
118 struct nouveau_bo *pmo = nvpix->bo; \
119 OUT_RELOCd(pmo, (data), (flags), (vor), (tor)); \
121 #define OUT_PIXMAPo(pm,flags) do { \
122 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
123 struct nouveau_bo *pmo = nvpix->bo; \
124 OUT_RELOCo(pmo, (flags)); \
126 #define OUT_PIXMAPl(pm,delta,flags) do { \
127 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
128 struct nouveau_bo *pmo = nvpix->bo; \
129 OUT_RELOCl(pmo, (delta), (flags)); \
131 #define OUT_PIXMAPh(pm,delta,flags) do { \
132 struct nouveau_pixmap *nvpix = exaGetPixmapDriverPrivate((pm)); \
133 struct nouveau_bo *pmo = nvpix->bo; \
134 OUT_RELOCh(pmo, (delta), (flags)); \
137 #define OUT_PIXMAPd(pm,data,flags,vor,tor) do { \
138 OUT_RELOCd(pNv->FB, (data), (flags), (vor), (tor)); \
140 #define OUT_PIXMAPo(pm,flags) do { \
141 OUT_RELOCo(pNv->FB, (flags)); \
143 #define OUT_PIXMAPl(pm,delta,flags) do { \
144 OUT_RELOCl(pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags)); \
146 #define OUT_PIXMAPh(pm,delta,flags) do { \
147 OUT_RELOCh(pNv->FB, exaGetPixmapOffset(pm) + (delta), (flags)); \