revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / hidds / nouveau / nouveau_intern.h
blob680b527dc51af8f55ad2256cc54d6d3dbf2266e0
1 #ifndef _NOUVEAU_INTERN_H
2 #define _NOUVEAU_INTERN_H
3 /*
4 Copyright © 2010-2019, The AROS Development Team. All rights reserved.
5 $Id$
6 */
8 #include <exec/semaphores.h>
9 #include <hidd/gfx.h>
10 #include <hidd/i2c.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;
28 #endif
30 extern struct SignalSemaphore globalLock;
32 enum
34 aoHidd_Gfx_Nouveau_VRAMSize, /* [G..] The amount of total VRAM in bytes */
35 aoHidd_Gfx_Nouveau_GARTSize, /* [G..] The amount of total GART in bytes */
36 aoHidd_Gfx_Nouveau_VRAMFree, /* [G..] The amount of free VRAM in bytes */
37 aoHidd_Gfx_Nouveau_GARTFree, /* [G..] The amount of free GART in bytes */
39 num_Hidd_Gfx_Nouveau_Attrs
42 #define aHidd_Gfx_Nouveau_VRAMSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMSize)
43 #define aHidd_Gfx_Nouveau_GARTSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTSize)
44 #define aHidd_Gfx_Nouveau_VRAMFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMFree)
45 #define aHidd_Gfx_Nouveau_GARTFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTFree)
47 #define IS_GFXNOUVEAU_ATTR(attr, idx) \
48 (((idx) = (attr) - HiddGfxNouveauAttrBase) < num_Hidd_Gfx_Nouveau_Attrs)
50 struct HIDDNouveauData
52 struct nouveau_bo *cursor;
53 ULONG selectedcrtcid;
54 APTR selectedmode;
55 APTR selectedconnector;
56 OOP_Object *compositor;
59 #define CLID_Hidd_BitMap_Nouveau "hidd.bitmap.nouveau"
60 #define IID_Hidd_BitMap_Nouveau "hidd.bitmap.nouveau"
62 #define HiddBitMapNouveauAttrBase __IHidd_BitMap_Nouveau
64 #ifndef __OOP_NOATTRBASES__
65 extern OOP_AttrBase HiddBitMapNouveauAttrBase;
66 #endif
68 enum
70 aoHidd_BitMap_Nouveau_CompositorHidd, /* [I..] The compositor object that will be used by bitmap */
72 num_Hidd_BitMap_Nouveau_Attrs
75 #define aHidd_BitMap_Nouveau_CompositorHidd (HiddBitMapNouveauAttrBase + aoHidd_BitMap_Nouveau_CompositorHidd)
77 #define IS_BITMAPNOUVEAU_ATTR(attr, idx) \
78 (((idx) = (attr) - HiddBitMapNouveauAttrBase) < num_Hidd_BitMap_Nouveau_Attrs)
80 struct HIDDNouveauBitMapData
82 struct SignalSemaphore semaphore;
83 struct nouveau_bo *bo; /* Buffer object behind bitmap. Don't make any
84 assumptions about buffer mapping (bo->map)
85 state. This state however can only be changed
86 when lock is held on bitmap */
88 ULONG height; /* Height of bitmap in pixels */
89 ULONG width; /* Width of bitmap in pixels */
90 ULONG pitch; /* Width of single data row in bytes */
91 UBYTE bytesperpixel; /* In bytes, how many bytes to store a pixel */
92 UBYTE depth; /* In bits, how many bits used to represt the color */
93 BOOL displayable; /* Can bitmap be displayed on screen */
95 /* Information connected with display */
96 OOP_Object *compositor; /* Compositor object used by bitmap */
97 LONG xoffset; /* Offset to bitmap point that is displayed as (0,0) on screen */
98 LONG yoffset; /* Offset to bitmap point that is displayed as (0,0) on screen */
99 ULONG fbid; /* Contains ID under which bitmap
100 is registered as framebuffer or
101 0 otherwise */
104 #define CLID_Hidd_I2C_Nouveau "hidd.i2c.nouveau"
105 #define IID_Hidd_I2C_Nouveau "hidd.i2c.nouveau"
107 #define HiddI2CNouveauAttrBase __IHidd_I2C_Nouveau
109 #ifndef __OOP_NOATTRBASES__
110 extern OOP_AttrBase HiddI2CNouveauAttrBase;
111 #endif
113 enum
115 aoHidd_I2C_Nouveau_Chan, /* [I..] The nouveau_i2c_chan object */
117 num_Hidd_I2C_Nouveau_Attrs
120 #define aHidd_I2C_Nouveau_Chan (HiddI2CNouveauAttrBase + aoHidd_I2C_Nouveau_Chan)
122 #define IS_I2CNOUVEAU_ATTR(attr, idx) \
123 (((idx) = (attr) - HiddI2CNouveauAttrBase) < num_Hidd_I2C_Nouveau_Attrs)
125 struct HIDDNouveauI2CData
127 IPTR i2c_chan;
130 #define CLID_Hidd_Gallium_Nouveau "hidd.gallium.nouveau"
132 struct HIDDGalliumNouveauData
136 struct CardData
138 /* Card controlling objects */
139 ULONG architecture;
140 BOOL IsPCIE;
141 struct nouveau_device *dev; /* Device object acquired from libdrm */
142 struct nouveau_channel *chan;
144 struct nouveau_notifier *notify0;
145 struct nouveau_notifier *vblank_sem;
147 struct nouveau_grobj *NvImageBlit;
148 struct nouveau_grobj *NvContextSurfaces;
149 struct nouveau_grobj *NvRop;
150 struct nouveau_grobj *NvImagePattern;
151 struct nouveau_grobj *NvRectangle;
152 struct nouveau_grobj *NvMemFormat;
153 struct nouveau_grobj *Nv2D;
154 struct nouveau_grobj *Nv3D;
155 struct nouveau_grobj *NvSW;
156 struct nouveau_bo *shader_mem;
157 struct nouveau_bo *tesla_scratch;
159 struct nouveau_bo *GART; /* Buffer in GART for upload/download of images */
160 struct SignalSemaphore gartsemaphore;
163 struct staticdata
165 OOP_Class *basegc; /* baseclass for CreateObject */
166 OOP_Class *basebm; /* baseclass for CreateObject */
167 OOP_Class *basegallium; /* baseclass for CreateObject */
168 OOP_Class *basei2c;
170 OOP_Class *gfxclass;
171 OOP_Class *bmclass;
172 OOP_Class *i2cclass;
173 OOP_Class *galliumclass;
174 OOP_Class *compositorclass;
176 OOP_AttrBase hiddAttrBase;
177 OOP_AttrBase pixFmtAttrBase;
178 OOP_AttrBase gfxAttrBase;
179 OOP_AttrBase gfxNouveauAttrBase;
180 OOP_AttrBase syncAttrBase;
181 OOP_AttrBase bitMapAttrBase;
182 OOP_AttrBase planarAttrBase;
183 OOP_AttrBase i2cNouveauAttrBase;
184 OOP_AttrBase galliumAttrBase;
185 OOP_AttrBase gcAttrBase;
186 OOP_AttrBase compositorAttrBase;
187 OOP_AttrBase bitMapNouveauAttrBase;
189 OOP_MethodID mid_CopyMemBox16;
190 OOP_MethodID mid_CopyMemBox32;
191 OOP_MethodID mid_PutMem32Image16;
192 OOP_MethodID mid_GetMem32Image16;
193 OOP_MethodID mid_PutMemTemplate16;
194 OOP_MethodID mid_PutMemTemplate32;
195 OOP_MethodID mid_PutMemPattern16;
196 OOP_MethodID mid_PutMemPattern32;
197 OOP_MethodID mid_ConvertPixels;
198 OOP_MethodID mid_GetPixFmt;
200 OOP_MethodID mid_BitMapPositionChanged;
201 OOP_MethodID mid_BitMapRectChanged;
202 OOP_MethodID mid_ValidateBitMapPositionChange;
204 struct CardData carddata;
206 struct SignalSemaphore multibitmapsemaphore;
209 LIBBASETYPE
211 struct Library base;
212 struct staticdata sd;
215 #define METHOD(base, id, name) \
216 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
218 #define BASE(lib) ((LIBBASETYPEPTR)(lib))
220 #define SD(cl) (&BASE(cl->UserData)->sd)
222 #define LOCK_ENGINE { ObtainSemaphore(&globalLock); }
223 #define UNLOCK_ENGINE { ReleaseSemaphore(&globalLock); }
225 #define LOCK_BITMAP { ObtainSemaphore(&bmdata->semaphore); }
226 #define UNLOCK_BITMAP { ReleaseSemaphore(&bmdata->semaphore); }
228 #define LOCK_BITMAP_BM(bmdata) { ObtainSemaphore(&(bmdata)->semaphore); }
229 #define UNLOCK_BITMAP_BM(bmdata) { ReleaseSemaphore(&(bmdata)->semaphore); }
231 #define LOCK_MULTI_BITMAP { ObtainSemaphore(&(SD(cl))->multibitmapsemaphore); }
232 #define UNLOCK_MULTI_BITMAP { ReleaseSemaphore(&(SD(cl))->multibitmapsemaphore); }
234 #define UNMAP_BUFFER { if (bmdata->bo->map) nouveau_bo_unmap(bmdata->bo); }
235 #define UNMAP_BUFFER_BM(bmdata) { if ((bmdata)->bo->map) nouveau_bo_unmap((bmdata)->bo); }
237 #define MAP_BUFFER { if (!bmdata->bo->map) nouveau_bo_map(bmdata->bo, NOUVEAU_BO_RDWR); }
238 #define MAP_BUFFER_BM(bmdata) { if (!(bmdata)->bo->map) nouveau_bo_map((bmdata)->bo, NOUVEAU_BO_RDWR); }
240 #define IS_NOUVEAU_BM_CLASS(x) ((x) == SD(cl)->bmclass)
242 #define writel(val, addr) (*(volatile ULONG*)(addr) = (val))
243 #define readl(addr) (*(volatile ULONG*)(addr))
244 #define writew(val, addr) (*(volatile UWORD*)(addr) = (val))
245 #define readw(addr) (*(volatile UWORD*)(addr))
247 enum DMAObjects
249 NvNullObject = 0x00000000,
250 NvContextSurfaces = 0x80000010,
251 NvRop = 0x80000011,
252 NvImagePattern = 0x80000012,
253 NvClipRectangle = 0x80000013,
254 NvSolidLine = 0x80000014,
255 NvImageBlit = 0x80000015,
256 NvRectangle = 0x80000016,
257 NvScaledImage = 0x80000017,
258 NvMemFormat = 0x80000018,
259 Nv3D = 0x80000019,
260 NvImageFromCpu = 0x8000001A,
261 NvContextBeta1 = 0x8000001B,
262 NvContextBeta4 = 0x8000001C,
263 Nv2D = 0x80000020,
264 NvSW = 0x80000021,
265 NvDmaFB = 0xD8000001,
266 NvDmaTT = 0xD8000002,
267 NvDmaNotifier0 = 0xD8000003,
268 NvVBlankSem = 0xD8000004,
271 #define NV_ARCH_03 0x03
272 #define NV_ARCH_04 0x04
273 #define NV_ARCH_10 0x10
274 #define NV_ARCH_20 0x20
275 #define NV_ARCH_30 0x30
276 #define NV_ARCH_40 0x40
277 #define NV_ARCH_50 0x50
278 #define NV_ARCH_C0 0xC0
280 #define BLENDOP_SOLID 1
281 #define BLENDOP_ALPHA_PREMULT 3
282 #define BLENDOP_ALPHA 13
284 /* nv_accel_common.c */
285 BOOL HIDDNouveauAccelCommonInit(struct CardData * carddata);
286 VOID HIDDNouveauAccelFree(struct CardData * carddata);
288 BOOL NVAccelGetCtxSurf2DFormatFromPixmap(struct HIDDNouveauBitMapData * bmdata, LONG *fmt_ret);
290 /* nv04_exa.c */
291 VOID HIDDNouveauNV04SetPattern(struct CardData * carddata, LONG clr0, LONG clr1,
292 LONG pat0, LONG pat1);
293 BOOL HIDDNouveauNV04FillSolidRect(struct CardData * carddata,
294 struct HIDDNouveauBitMapData * bmdata, LONG minX, LONG minY, LONG maxX,
295 LONG maxY, ULONG drawmode, ULONG color);
296 BOOL HIDDNouveauNV04CopySameFormat(struct CardData * carddata,
297 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
298 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
299 ULONG drawmode);
301 /* nv10_exa.c */
302 BOOL HIDDNouveauNV103DCopyBox(struct CardData * carddata,
303 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
304 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
305 ULONG blendop);
307 /* nv30_exa.c */
308 BOOL HIDDNouveauNV303DCopyBox(struct CardData * carddata,
309 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
310 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
311 ULONG blendop);
313 /* nv40_exa.c */
314 BOOL HIDDNouveauNV403DCopyBox(struct CardData * carddata,
315 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
316 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
317 ULONG blendop);
319 /* nv50_exa.c */
320 VOID HIDDNouveauNV50SetPattern(struct CardData * carddata, LONG col0,
321 LONG col1, LONG pat0, LONG pat1);
322 BOOL HIDDNouveauNV50FillSolidRect(struct CardData * carddata,
323 struct HIDDNouveauBitMapData * bmdata, LONG minX, LONG minY, LONG maxX,
324 LONG maxY, ULONG drawmode, ULONG color);
325 BOOL HIDDNouveauNV50CopySameFormat(struct CardData * carddata,
326 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
327 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
328 ULONG drawmode);
330 /* nvc0_exa.c */
331 VOID HIDDNouveauNVC0SetPattern(struct CardData * carddata, LONG clr0, LONG clr1,
332 LONG pat0, LONG pat1);
333 BOOL HIDDNouveauNVC0FillSolidRect(struct CardData * carddata,
334 struct HIDDNouveauBitMapData * bmdata, LONG minX, LONG minY, LONG maxX,
335 LONG maxY, ULONG drawmode, ULONG color);
336 BOOL HIDDNouveauNVC0CopySameFormat(struct CardData * carddata,
337 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
338 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
339 ULONG drawmode);
341 /* nouveau_accel.c */
342 BOOL HiddNouveauWriteFromRAM(
343 APTR src, ULONG srcPitch, HIDDT_StdPixFmt srcPixFmt,
344 APTR dst, ULONG dstPitch,
345 ULONG width, ULONG height,
346 OOP_Class *cl, OOP_Object *o);
347 BOOL HiddNouveauReadIntoRAM(
348 APTR src, ULONG srcPitch,
349 APTR dst, ULONG dstPitch, HIDDT_StdPixFmt dstPixFmt,
350 ULONG width, ULONG height,
351 OOP_Class *cl, OOP_Object *o);
352 BOOL HiddNouveauAccelARGBUpload3D(
353 UBYTE * srcpixels, ULONG srcpitch,
354 LONG x, LONG y, LONG width, LONG height,
355 OOP_Class *cl, OOP_Object *o);
356 BOOL HiddNouveauAccelAPENUpload3D(
357 UBYTE * srcalpha, BOOL srcinvertalpha, ULONG srcpitch, ULONG srcpenrgb,
358 LONG x, LONG y, LONG width, LONG height,
359 OOP_Class *cl, OOP_Object *o);
360 VOID HIDDNouveauBitMapPutAlphaImage32(struct HIDDNouveauBitMapData * bmdata,
361 APTR srcbuff, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
362 VOID HIDDNouveauBitMapPutAlphaImage16(struct HIDDNouveauBitMapData * bmdata,
363 APTR srcbuff, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
364 VOID HIDDNouveauBitMapPutAlphaTemplate32(struct HIDDNouveauBitMapData * bmdata,
365 OOP_Object * gc, OOP_Object * bm, BOOL invertalpha,
366 UBYTE * srcalpha, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
367 VOID HIDDNouveauBitMapPutAlphaTemplate16(struct HIDDNouveauBitMapData * bmdata,
368 OOP_Object * gc, OOP_Object * bm, BOOL invertalpha,
369 UBYTE * srcalpha, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
370 VOID HIDDNouveauBitMapDrawSolidLine(struct HIDDNouveauBitMapData * bmdata,
371 OOP_Object * gc, LONG destX1, LONG destY1, LONG destX2, LONG destY2);
373 /* nouveau_exa.c */
374 BOOL HiddNouveauNVAccelUploadM2MF(
375 UBYTE * srcpixels, ULONG srcpitch, HIDDT_StdPixFmt srcPixFmt,
376 LONG x, LONG y, LONG width, LONG height,
377 OOP_Class *cl, OOP_Object *o);
378 BOOL HiddNouveauNVAccelDownloadM2MF(
379 UBYTE * dstpixels, ULONG dstpitch, HIDDT_StdPixFmt dstPixFmt,
380 LONG x, LONG y, LONG width, LONG height,
381 OOP_Class *cl, OOP_Object *o);
383 VOID HIDDNouveauShowCursor(OOP_Object * gfx, BOOL visible);
384 BOOL HIDDNouveauSwitchToVideoMode(OOP_Object * bm);
385 VOID HIDDNouveauSetOffsets(OOP_Object * bm, LONG newxoffset, LONG newyoffset);
387 /* Declaration of nouveau initialization function */
388 extern int nouveau_init(void);
390 /* Commom memory allocation */
391 APTR HIDDNouveauAlloc(ULONG size);
392 VOID HIDDNouveauFree(APTR memory);
394 #endif /* _NOUVEAU_INTERN_H */