1 #ifndef _NOUVEAU_INTERN_H
2 #define _NOUVEAU_INTERN_H
4 Copyright © 2010-2019, The AROS Development Team. All rights reserved.
8 #include <exec/semaphores.h>
11 #include <hidd/gallium.h>
13 #include "nouveau/nouveau_drmif.h"
14 #include "nouveau/nouveau_bo.h"
15 #include "nouveau/nouveau_channel.h"
16 #include "nouveau/nouveau_notifier.h"
17 #include "nouveau/nouveau_grobj.h"
19 #include LC_LIBDEFS_FILE
21 #define CLID_Hidd_Gfx_Nouveau "hidd.gfx.nouveau"
22 #define IID_Hidd_Gfx_Nouveau "hidd.gfx.nouveau"
24 #define HiddGfxNouveauAttrBase __IHidd_Gfx_Nouveau
26 #ifndef __OOP_NOATTRBASES__
27 extern OOP_AttrBase HiddGfxNouveauAttrBase
;
30 extern struct SignalSemaphore globalLock
;
32 struct HIDDNouveauData
34 struct nouveau_bo
*cursor
;
37 APTR selectedconnector
;
38 OOP_Object
*compositor
;
41 #define CLID_Hidd_BitMap_Nouveau "hidd.bitmap.nouveau"
42 #define IID_Hidd_BitMap_Nouveau "hidd.bitmap.nouveau"
44 #define HiddBitMapNouveauAttrBase __IHidd_BitMap_Nouveau
46 #ifndef __OOP_NOATTRBASES__
47 extern OOP_AttrBase HiddBitMapNouveauAttrBase
;
52 aoHidd_BitMap_Nouveau_CompositorHidd
, /* [I..] The compositor object that will be used by bitmap */
54 num_Hidd_BitMap_Nouveau_Attrs
57 #define aHidd_BitMap_Nouveau_CompositorHidd (HiddBitMapNouveauAttrBase + aoHidd_BitMap_Nouveau_CompositorHidd)
59 #define IS_BITMAPNOUVEAU_ATTR(attr, idx) \
60 (((idx) = (attr) - HiddBitMapNouveauAttrBase) < num_Hidd_BitMap_Nouveau_Attrs)
62 struct HIDDNouveauBitMapData
64 struct SignalSemaphore semaphore
;
65 struct nouveau_bo
*bo
; /* Buffer object behind bitmap. Don't make any
66 assumptions about buffer mapping (bo->map)
67 state. This state however can only be changed
68 when lock is held on bitmap */
70 ULONG height
; /* Height of bitmap in pixels */
71 ULONG width
; /* Width of bitmap in pixels */
72 ULONG pitch
; /* Width of single data row in bytes */
73 UBYTE bytesperpixel
; /* In bytes, how many bytes to store a pixel */
74 UBYTE depth
; /* In bits, how many bits used to represt the color */
75 BOOL displayable
; /* Can bitmap be displayed on screen */
77 /* Information connected with display */
78 OOP_Object
*compositor
; /* Compositor object used by bitmap */
79 LONG xoffset
; /* Offset to bitmap point that is displayed as (0,0) on screen */
80 LONG yoffset
; /* Offset to bitmap point that is displayed as (0,0) on screen */
81 ULONG fbid
; /* Contains ID under which bitmap
82 is registered as framebuffer or
86 #define CLID_Hidd_I2C_Nouveau "hidd.i2c.nouveau"
87 #define IID_Hidd_I2C_Nouveau "hidd.i2c.nouveau"
89 #define HiddI2CNouveauAttrBase __IHidd_I2C_Nouveau
91 #ifndef __OOP_NOATTRBASES__
92 extern OOP_AttrBase HiddI2CNouveauAttrBase
;
97 aoHidd_I2C_Nouveau_Chan
, /* [I..] The nouveau_i2c_chan object */
99 num_Hidd_I2C_Nouveau_Attrs
102 #define aHidd_I2C_Nouveau_Chan (HiddI2CNouveauAttrBase + aoHidd_I2C_Nouveau_Chan)
104 #define IS_I2CNOUVEAU_ATTR(attr, idx) \
105 (((idx) = (attr) - HiddI2CNouveauAttrBase) < num_Hidd_I2C_Nouveau_Attrs)
107 struct HIDDNouveauI2CData
112 #define CLID_Hidd_Gallium_Nouveau "hidd.gallium.nouveau"
114 struct HIDDGalliumNouveauData
120 /* Card controlling objects */
123 struct nouveau_device
*dev
; /* Device object acquired from libdrm */
124 struct nouveau_channel
*chan
;
126 struct nouveau_notifier
*notify0
;
127 struct nouveau_notifier
*vblank_sem
;
129 struct nouveau_grobj
*NvImageBlit
;
130 struct nouveau_grobj
*NvContextSurfaces
;
131 struct nouveau_grobj
*NvRop
;
132 struct nouveau_grobj
*NvImagePattern
;
133 struct nouveau_grobj
*NvRectangle
;
134 struct nouveau_grobj
*NvMemFormat
;
135 struct nouveau_grobj
*Nv2D
;
136 struct nouveau_grobj
*Nv3D
;
137 struct nouveau_grobj
*NvSW
;
138 struct nouveau_bo
*shader_mem
;
139 struct nouveau_bo
*tesla_scratch
;
141 struct nouveau_bo
*GART
; /* Buffer in GART for upload/download of images */
142 struct SignalSemaphore gartsemaphore
;
147 OOP_Class
*basegc
; /* baseclass for CreateObject */
148 OOP_Class
*basebm
; /* baseclass for CreateObject */
149 OOP_Class
*basegallium
; /* baseclass for CreateObject */
155 OOP_Class
*galliumclass
;
156 OOP_Class
*compositorclass
;
158 OOP_AttrBase hiddAttrBase
;
159 OOP_AttrBase pixFmtAttrBase
;
160 OOP_AttrBase gfxAttrBase
;
161 OOP_AttrBase gfxNouveauAttrBase
;
162 OOP_AttrBase syncAttrBase
;
163 OOP_AttrBase bitMapAttrBase
;
164 OOP_AttrBase planarAttrBase
;
165 OOP_AttrBase i2cNouveauAttrBase
;
166 OOP_AttrBase galliumAttrBase
;
167 OOP_AttrBase gcAttrBase
;
168 OOP_AttrBase compositorAttrBase
;
169 OOP_AttrBase bitMapNouveauAttrBase
;
171 OOP_MethodID mid_CopyMemBox16
;
172 OOP_MethodID mid_CopyMemBox32
;
173 OOP_MethodID mid_PutMem32Image16
;
174 OOP_MethodID mid_GetMem32Image16
;
175 OOP_MethodID mid_PutMemTemplate16
;
176 OOP_MethodID mid_PutMemTemplate32
;
177 OOP_MethodID mid_PutMemPattern16
;
178 OOP_MethodID mid_PutMemPattern32
;
179 OOP_MethodID mid_ConvertPixels
;
180 OOP_MethodID mid_GetPixFmt
;
182 OOP_MethodID mid_BitMapPositionChanged
;
183 OOP_MethodID mid_BitMapRectChanged
;
184 OOP_MethodID mid_ValidateBitMapPositionChange
;
186 struct CardData carddata
;
188 struct SignalSemaphore multibitmapsemaphore
;
194 struct staticdata sd
;
197 #define METHOD(base, id, name) \
198 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
200 #define BASE(lib) ((LIBBASETYPEPTR)(lib))
202 #define SD(cl) (&BASE(cl->UserData)->sd)
204 #define LOCK_ENGINE { ObtainSemaphore(&globalLock); }
205 #define UNLOCK_ENGINE { ReleaseSemaphore(&globalLock); }
207 #define LOCK_BITMAP { ObtainSemaphore(&bmdata->semaphore); }
208 #define UNLOCK_BITMAP { ReleaseSemaphore(&bmdata->semaphore); }
210 #define LOCK_BITMAP_BM(bmdata) { ObtainSemaphore(&(bmdata)->semaphore); }
211 #define UNLOCK_BITMAP_BM(bmdata) { ReleaseSemaphore(&(bmdata)->semaphore); }
213 #define LOCK_MULTI_BITMAP { ObtainSemaphore(&(SD(cl))->multibitmapsemaphore); }
214 #define UNLOCK_MULTI_BITMAP { ReleaseSemaphore(&(SD(cl))->multibitmapsemaphore); }
216 #define UNMAP_BUFFER { if (bmdata->bo->map) nouveau_bo_unmap(bmdata->bo); }
217 #define UNMAP_BUFFER_BM(bmdata) { if ((bmdata)->bo->map) nouveau_bo_unmap((bmdata)->bo); }
219 #define MAP_BUFFER { if (!bmdata->bo->map) nouveau_bo_map(bmdata->bo, NOUVEAU_BO_RDWR); }
220 #define MAP_BUFFER_BM(bmdata) { if (!(bmdata)->bo->map) nouveau_bo_map((bmdata)->bo, NOUVEAU_BO_RDWR); }
222 #define IS_NOUVEAU_BM_CLASS(x) ((x) == SD(cl)->bmclass)
224 #define writel(val, addr) (*(volatile ULONG*)(addr) = (val))
225 #define readl(addr) (*(volatile ULONG*)(addr))
226 #define writew(val, addr) (*(volatile UWORD*)(addr) = (val))
227 #define readw(addr) (*(volatile UWORD*)(addr))
231 NvNullObject
= 0x00000000,
232 NvContextSurfaces
= 0x80000010,
234 NvImagePattern
= 0x80000012,
235 NvClipRectangle
= 0x80000013,
236 NvSolidLine
= 0x80000014,
237 NvImageBlit
= 0x80000015,
238 NvRectangle
= 0x80000016,
239 NvScaledImage
= 0x80000017,
240 NvMemFormat
= 0x80000018,
242 NvImageFromCpu
= 0x8000001A,
243 NvContextBeta1
= 0x8000001B,
244 NvContextBeta4
= 0x8000001C,
247 NvDmaFB
= 0xD8000001,
248 NvDmaTT
= 0xD8000002,
249 NvDmaNotifier0
= 0xD8000003,
250 NvVBlankSem
= 0xD8000004,
253 #define NV_ARCH_03 0x03
254 #define NV_ARCH_04 0x04
255 #define NV_ARCH_10 0x10
256 #define NV_ARCH_20 0x20
257 #define NV_ARCH_30 0x30
258 #define NV_ARCH_40 0x40
259 #define NV_ARCH_50 0x50
260 #define NV_ARCH_C0 0xC0
262 #define BLENDOP_SOLID 1
263 #define BLENDOP_ALPHA_PREMULT 3
264 #define BLENDOP_ALPHA 13
266 /* nv_accel_common.c */
267 BOOL
HIDDNouveauAccelCommonInit(struct CardData
* carddata
);
268 VOID
HIDDNouveauAccelFree(struct CardData
* carddata
);
270 BOOL
NVAccelGetCtxSurf2DFormatFromPixmap(struct HIDDNouveauBitMapData
* bmdata
, LONG
*fmt_ret
);
273 VOID
HIDDNouveauNV04SetPattern(struct CardData
* carddata
, LONG clr0
, LONG clr1
,
274 LONG pat0
, LONG pat1
);
275 BOOL
HIDDNouveauNV04FillSolidRect(struct CardData
* carddata
,
276 struct HIDDNouveauBitMapData
* bmdata
, LONG minX
, LONG minY
, LONG maxX
,
277 LONG maxY
, ULONG drawmode
, ULONG color
);
278 BOOL
HIDDNouveauNV04CopySameFormat(struct CardData
* carddata
,
279 struct HIDDNouveauBitMapData
* srcdata
, struct HIDDNouveauBitMapData
* destdata
,
280 LONG srcX
, LONG srcY
, LONG destX
, LONG destY
, LONG width
, LONG height
,
284 BOOL
HIDDNouveauNV103DCopyBox(struct CardData
* carddata
,
285 struct HIDDNouveauBitMapData
* srcdata
, struct HIDDNouveauBitMapData
* destdata
,
286 LONG srcX
, LONG srcY
, LONG destX
, LONG destY
, LONG width
, LONG height
,
290 BOOL
HIDDNouveauNV303DCopyBox(struct CardData
* carddata
,
291 struct HIDDNouveauBitMapData
* srcdata
, struct HIDDNouveauBitMapData
* destdata
,
292 LONG srcX
, LONG srcY
, LONG destX
, LONG destY
, LONG width
, LONG height
,
296 BOOL
HIDDNouveauNV403DCopyBox(struct CardData
* carddata
,
297 struct HIDDNouveauBitMapData
* srcdata
, struct HIDDNouveauBitMapData
* destdata
,
298 LONG srcX
, LONG srcY
, LONG destX
, LONG destY
, LONG width
, LONG height
,
302 VOID
HIDDNouveauNV50SetPattern(struct CardData
* carddata
, LONG col0
,
303 LONG col1
, LONG pat0
, LONG pat1
);
304 BOOL
HIDDNouveauNV50FillSolidRect(struct CardData
* carddata
,
305 struct HIDDNouveauBitMapData
* bmdata
, LONG minX
, LONG minY
, LONG maxX
,
306 LONG maxY
, ULONG drawmode
, ULONG color
);
307 BOOL
HIDDNouveauNV50CopySameFormat(struct CardData
* carddata
,
308 struct HIDDNouveauBitMapData
* srcdata
, struct HIDDNouveauBitMapData
* destdata
,
309 LONG srcX
, LONG srcY
, LONG destX
, LONG destY
, LONG width
, LONG height
,
313 VOID
HIDDNouveauNVC0SetPattern(struct CardData
* carddata
, LONG clr0
, LONG clr1
,
314 LONG pat0
, LONG pat1
);
315 BOOL
HIDDNouveauNVC0FillSolidRect(struct CardData
* carddata
,
316 struct HIDDNouveauBitMapData
* bmdata
, LONG minX
, LONG minY
, LONG maxX
,
317 LONG maxY
, ULONG drawmode
, ULONG color
);
318 BOOL
HIDDNouveauNVC0CopySameFormat(struct CardData
* carddata
,
319 struct HIDDNouveauBitMapData
* srcdata
, struct HIDDNouveauBitMapData
* destdata
,
320 LONG srcX
, LONG srcY
, LONG destX
, LONG destY
, LONG width
, LONG height
,
323 /* nouveau_accel.c */
324 BOOL
HiddNouveauWriteFromRAM(
325 APTR src
, ULONG srcPitch
, HIDDT_StdPixFmt srcPixFmt
,
326 APTR dst
, ULONG dstPitch
,
327 ULONG width
, ULONG height
,
328 OOP_Class
*cl
, OOP_Object
*o
);
329 BOOL
HiddNouveauReadIntoRAM(
330 APTR src
, ULONG srcPitch
,
331 APTR dst
, ULONG dstPitch
, HIDDT_StdPixFmt dstPixFmt
,
332 ULONG width
, ULONG height
,
333 OOP_Class
*cl
, OOP_Object
*o
);
334 BOOL
HiddNouveauAccelARGBUpload3D(
335 UBYTE
* srcpixels
, ULONG srcpitch
,
336 LONG x
, LONG y
, LONG width
, LONG height
,
337 OOP_Class
*cl
, OOP_Object
*o
);
338 BOOL
HiddNouveauAccelAPENUpload3D(
339 UBYTE
* srcalpha
, BOOL srcinvertalpha
, ULONG srcpitch
, ULONG srcpenrgb
,
340 LONG x
, LONG y
, LONG width
, LONG height
,
341 OOP_Class
*cl
, OOP_Object
*o
);
342 VOID
HIDDNouveauBitMapPutAlphaImage32(struct HIDDNouveauBitMapData
* bmdata
,
343 APTR srcbuff
, ULONG srcpitch
, LONG destX
, LONG destY
, LONG width
, LONG height
);
344 VOID
HIDDNouveauBitMapPutAlphaImage16(struct HIDDNouveauBitMapData
* bmdata
,
345 APTR srcbuff
, ULONG srcpitch
, LONG destX
, LONG destY
, LONG width
, LONG height
);
346 VOID
HIDDNouveauBitMapPutAlphaTemplate32(struct HIDDNouveauBitMapData
* bmdata
,
347 OOP_Object
* gc
, OOP_Object
* bm
, BOOL invertalpha
,
348 UBYTE
* srcalpha
, ULONG srcpitch
, LONG destX
, LONG destY
, LONG width
, LONG height
);
349 VOID
HIDDNouveauBitMapPutAlphaTemplate16(struct HIDDNouveauBitMapData
* bmdata
,
350 OOP_Object
* gc
, OOP_Object
* bm
, BOOL invertalpha
,
351 UBYTE
* srcalpha
, ULONG srcpitch
, LONG destX
, LONG destY
, LONG width
, LONG height
);
352 VOID
HIDDNouveauBitMapDrawSolidLine(struct HIDDNouveauBitMapData
* bmdata
,
353 OOP_Object
* gc
, LONG destX1
, LONG destY1
, LONG destX2
, LONG destY2
);
356 BOOL
HiddNouveauNVAccelUploadM2MF(
357 UBYTE
* srcpixels
, ULONG srcpitch
, HIDDT_StdPixFmt srcPixFmt
,
358 LONG x
, LONG y
, LONG width
, LONG height
,
359 OOP_Class
*cl
, OOP_Object
*o
);
360 BOOL
HiddNouveauNVAccelDownloadM2MF(
361 UBYTE
* dstpixels
, ULONG dstpitch
, HIDDT_StdPixFmt dstPixFmt
,
362 LONG x
, LONG y
, LONG width
, LONG height
,
363 OOP_Class
*cl
, OOP_Object
*o
);
365 VOID
HIDDNouveauShowCursor(OOP_Object
* gfx
, BOOL visible
);
366 BOOL
HIDDNouveauSwitchToVideoMode(OOP_Object
* bm
);
367 VOID
HIDDNouveauSetOffsets(OOP_Object
* bm
, LONG newxoffset
, LONG newyoffset
);
369 /* Declaration of nouveau initialization function */
370 extern int nouveau_init(void);
372 /* Commom memory allocation */
373 APTR
HIDDNouveauAlloc(ULONG size
);
374 VOID
HIDDNouveauFree(APTR memory
);
376 #endif /* _NOUVEAU_INTERN_H */