Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / hidds / nouveau / nouveau_intern.h
blobfbb73bfdc903911aa4a075e11f39857cefc6c3b1
1 #ifndef _NOUVEAU_INTERN_H
2 #define _NOUVEAU_INTERN_H
3 /*
4 Copyright © 2010-2015, The AROS Development Team. All rights reserved.
5 $Id$
6 */
8 #include <hidd/graphics.h>
9 #include <hidd/i2c.h>
10 #include <hidd/gallium.h>
12 #include "nouveau/nouveau_drmif.h"
13 #include "nouveau/nouveau_bo.h"
14 #include "nouveau/nouveau_channel.h"
15 #include "nouveau/nouveau_notifier.h"
16 #include "nouveau/nouveau_grobj.h"
18 #include LC_LIBDEFS_FILE
20 #define CLID_Hidd_Gfx_Nouveau "hidd.gfx.nouveau"
21 #define IID_Hidd_Gfx_Nouveau "hidd.gfx.nouveau"
23 #define HiddGfxNouveauAttrBase __IHidd_Gfx_Nouveau
25 #ifndef __OOP_NOATTRBASES__
26 extern OOP_AttrBase HiddGfxNouveauAttrBase;
27 #endif
29 enum
31 aoHidd_Gfx_Nouveau_VRAMSize, /* [G..] The amount of total VRAM in bytes */
32 aoHidd_Gfx_Nouveau_GARTSize, /* [G..] The amount of total GART in bytes */
33 aoHidd_Gfx_Nouveau_VRAMFree, /* [G..] The amount of free VRAM in bytes */
34 aoHidd_Gfx_Nouveau_GARTFree, /* [G..] The amount of free GART in bytes */
36 num_Hidd_Gfx_Nouveau_Attrs
39 #define aHidd_Gfx_Nouveau_VRAMSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMSize)
40 #define aHidd_Gfx_Nouveau_GARTSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTSize)
41 #define aHidd_Gfx_Nouveau_VRAMFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMFree)
42 #define aHidd_Gfx_Nouveau_GARTFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTFree)
44 #define IS_GFXNOUVEAU_ATTR(attr, idx) \
45 (((idx) = (attr) - HiddGfxNouveauAttrBase) < num_Hidd_Gfx_Nouveau_Attrs)
47 struct HIDDNouveauData
49 struct nouveau_bo *cursor;
50 ULONG selectedcrtcid;
51 APTR selectedmode;
52 APTR selectedconnector;
53 OOP_Object *compositor;
56 #define CLID_Hidd_BitMap_Nouveau "hidd.bitmap.nouveau"
57 #define IID_Hidd_BitMap_Nouveau "hidd.bitmap.nouveau"
59 #define HiddBitMapNouveauAttrBase __IHidd_BitMap_Nouveau
61 #ifndef __OOP_NOATTRBASES__
62 extern OOP_AttrBase HiddBitMapNouveauAttrBase;
63 #endif
65 enum
67 aoHidd_BitMap_Nouveau_CompositorHidd, /* [I..] The compositor object that will be used by bitmap */
69 num_Hidd_BitMap_Nouveau_Attrs
72 #define aHidd_BitMap_Nouveau_CompositorHidd (HiddBitMapNouveauAttrBase + aoHidd_BitMap_Nouveau_CompositorHidd)
74 #define IS_BITMAPNOUVEAU_ATTR(attr, idx) \
75 (((idx) = (attr) - HiddBitMapNouveauAttrBase) < num_Hidd_BitMap_Nouveau_Attrs)
77 struct HIDDNouveauBitMapData
79 struct SignalSemaphore semaphore;
80 struct nouveau_bo *bo; /* Buffer object behind bitmap. Don't make any
81 assumptions about buffer mapping (bo->map)
82 state. This state however can only be changed
83 when lock is held on bitmap */
85 ULONG height; /* Height of bitmap in pixels */
86 ULONG width; /* Width of bitmap in pixels */
87 ULONG pitch; /* Width of single data row in bytes */
88 UBYTE bytesperpixel; /* In bytes, how many bytes to store a pixel */
89 UBYTE depth; /* In bits, how many bits used to represt the color */
90 BOOL displayable; /* Can bitmap be displayed on screen */
92 /* Information connected with display */
93 OOP_Object *compositor; /* Compositor object used by bitmap */
94 LONG xoffset; /* Offset to bitmap point that is displayed as (0,0) on screen */
95 LONG yoffset; /* Offset to bitmap point that is displayed as (0,0) on screen */
96 ULONG fbid; /* Contains ID under which bitmap
97 is registered as framebuffer or
98 0 otherwise */
101 #define CLID_Hidd_I2C_Nouveau "hidd.i2c.nouveau"
102 #define IID_Hidd_I2C_Nouveau "hidd.i2c.nouveau"
104 #define HiddI2CNouveauAttrBase __IHidd_I2C_Nouveau
106 #ifndef __OOP_NOATTRBASES__
107 extern OOP_AttrBase HiddI2CNouveauAttrBase;
108 #endif
110 enum
112 aoHidd_I2C_Nouveau_Chan, /* [I..] The nouveau_i2c_chan object */
114 num_Hidd_I2C_Nouveau_Attrs
117 #define aHidd_I2C_Nouveau_Chan (HiddI2CNouveauAttrBase + aoHidd_I2C_Nouveau_Chan)
119 #define IS_I2CNOUVEAU_ATTR(attr, idx) \
120 (((idx) = (attr) - HiddI2CNouveauAttrBase) < num_Hidd_I2C_Nouveau_Attrs)
122 struct HIDDNouveauI2CData
124 IPTR i2c_chan;
127 #define CLID_Hidd_Gallium_Nouveau "hidd.gallium.nouveau"
129 struct HIDDGalliumNouveauData
133 struct CardData
135 /* Card controlling objects */
136 ULONG architecture;
137 BOOL IsPCIE;
138 struct nouveau_device *dev; /* Device object acquired from libdrm */
139 struct nouveau_channel *chan;
141 struct nouveau_notifier *notify0;
142 struct nouveau_notifier *vblank_sem;
144 struct nouveau_grobj *NvImageBlit;
145 struct nouveau_grobj *NvContextSurfaces;
146 struct nouveau_grobj *NvRop;
147 struct nouveau_grobj *NvImagePattern;
148 struct nouveau_grobj *NvRectangle;
149 struct nouveau_grobj *NvMemFormat;
150 struct nouveau_grobj *Nv2D;
151 struct nouveau_grobj *Nv3D;
152 struct nouveau_grobj *NvSW;
153 struct nouveau_bo *shader_mem;
154 struct nouveau_bo *tesla_scratch;
156 struct nouveau_bo *GART; /* Buffer in GART for upload/download of images */
157 struct SignalSemaphore gartsemaphore;
160 struct staticdata
162 OOP_Class *basegc; /* baseclass for CreateObject */
163 OOP_Class *basebm; /* baseclass for CreateObject */
164 OOP_Class *basegallium; /* baseclass for CreateObject */
166 OOP_Class *gfxclass;
167 OOP_Class *bmclass;
168 OOP_Class *i2cclass;
169 OOP_Class *galliumclass;
170 OOP_Class *compositorclass;
172 OOP_AttrBase pixFmtAttrBase;
173 OOP_AttrBase gfxAttrBase;
174 OOP_AttrBase gfxNouveauAttrBase;
175 OOP_AttrBase syncAttrBase;
176 OOP_AttrBase bitMapAttrBase;
177 OOP_AttrBase planarAttrBase;
178 OOP_AttrBase i2cNouveauAttrBase;
179 OOP_AttrBase galliumAttrBase;
180 OOP_AttrBase gcAttrBase;
181 OOP_AttrBase compositorAttrBase;
182 OOP_AttrBase bitMapNouveauAttrBase;
184 OOP_MethodID mid_CopyMemBox16;
185 OOP_MethodID mid_CopyMemBox32;
186 OOP_MethodID mid_PutMem32Image16;
187 OOP_MethodID mid_GetMem32Image16;
188 OOP_MethodID mid_PutMemTemplate16;
189 OOP_MethodID mid_PutMemTemplate32;
190 OOP_MethodID mid_PutMemPattern16;
191 OOP_MethodID mid_PutMemPattern32;
192 OOP_MethodID mid_ConvertPixels;
193 OOP_MethodID mid_GetPixFmt;
195 OOP_MethodID mid_BitMapPositionChanged;
196 OOP_MethodID mid_BitMapRectChanged;
197 OOP_MethodID mid_ValidateBitMapPositionChange;
199 struct CardData carddata;
201 struct SignalSemaphore multibitmapsemaphore;
204 LIBBASETYPE
206 struct Library base;
207 struct staticdata sd;
210 #define METHOD(base, id, name) \
211 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
213 #define BASE(lib) ((LIBBASETYPEPTR)(lib))
215 #define SD(cl) (&BASE(cl->UserData)->sd)
217 #define LOCK_BITMAP { ObtainSemaphore(&bmdata->semaphore); }
218 #define UNLOCK_BITMAP { ReleaseSemaphore(&bmdata->semaphore); }
220 #define LOCK_BITMAP_BM(bmdata) { ObtainSemaphore(&(bmdata)->semaphore); }
221 #define UNLOCK_BITMAP_BM(bmdata) { ReleaseSemaphore(&(bmdata)->semaphore); }
223 #define LOCK_MULTI_BITMAP { ObtainSemaphore(&(SD(cl))->multibitmapsemaphore); }
224 #define UNLOCK_MULTI_BITMAP { ReleaseSemaphore(&(SD(cl))->multibitmapsemaphore); }
226 #define UNMAP_BUFFER { if (bmdata->bo->map) nouveau_bo_unmap(bmdata->bo); }
227 #define UNMAP_BUFFER_BM(bmdata) { if ((bmdata)->bo->map) nouveau_bo_unmap((bmdata)->bo); }
229 #define MAP_BUFFER { if (!bmdata->bo->map) nouveau_bo_map(bmdata->bo, NOUVEAU_BO_RDWR); }
230 #define MAP_BUFFER_BM(bmdata) { if (!(bmdata)->bo->map) nouveau_bo_map((bmdata)->bo, NOUVEAU_BO_RDWR); }
232 #define IS_NOUVEAU_BM_CLASS(x) ((x) == SD(cl)->bmclass)
234 #define writel(val, addr) (*(volatile ULONG*)(addr) = (val))
235 #define readl(addr) (*(volatile ULONG*)(addr))
236 #define writew(val, addr) (*(volatile UWORD*)(addr) = (val))
237 #define readw(addr) (*(volatile UWORD*)(addr))
239 enum DMAObjects
241 NvNullObject = 0x00000000,
242 NvContextSurfaces = 0x80000010,
243 NvRop = 0x80000011,
244 NvImagePattern = 0x80000012,
245 NvClipRectangle = 0x80000013,
246 NvSolidLine = 0x80000014,
247 NvImageBlit = 0x80000015,
248 NvRectangle = 0x80000016,
249 NvScaledImage = 0x80000017,
250 NvMemFormat = 0x80000018,
251 Nv3D = 0x80000019,
252 NvImageFromCpu = 0x8000001A,
253 NvContextBeta1 = 0x8000001B,
254 NvContextBeta4 = 0x8000001C,
255 Nv2D = 0x80000020,
256 NvSW = 0x80000021,
257 NvDmaFB = 0xD8000001,
258 NvDmaTT = 0xD8000002,
259 NvDmaNotifier0 = 0xD8000003,
260 NvVBlankSem = 0xD8000004,
263 #define NV_ARCH_03 0x03
264 #define NV_ARCH_04 0x04
265 #define NV_ARCH_10 0x10
266 #define NV_ARCH_20 0x20
267 #define NV_ARCH_30 0x30
268 #define NV_ARCH_40 0x40
269 #define NV_ARCH_50 0x50
270 #define NV_ARCH_C0 0xC0
272 #define BLENDOP_SOLID 1
273 #define BLENDOP_ALPHA_PREMULT 3
274 #define BLENDOP_ALPHA 13
276 /* nv_accel_common.c */
277 BOOL HIDDNouveauAccelCommonInit(struct CardData * carddata);
278 VOID HIDDNouveauAccelFree(struct CardData * carddata);
280 BOOL NVAccelGetCtxSurf2DFormatFromPixmap(struct HIDDNouveauBitMapData * bmdata, LONG *fmt_ret);
282 /* nv04_exa.c */
283 VOID HIDDNouveauNV04SetPattern(struct CardData * carddata, LONG clr0, LONG clr1,
284 LONG pat0, LONG pat1);
285 BOOL HIDDNouveauNV04FillSolidRect(struct CardData * carddata,
286 struct HIDDNouveauBitMapData * bmdata, LONG minX, LONG minY, LONG maxX,
287 LONG maxY, ULONG drawmode, ULONG color);
288 BOOL HIDDNouveauNV04CopySameFormat(struct CardData * carddata,
289 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
290 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
291 ULONG drawmode);
293 /* nv10_exa.c */
294 BOOL HIDDNouveauNV103DCopyBox(struct CardData * carddata,
295 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
296 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
297 ULONG blendop);
299 /* nv30_exa.c */
300 BOOL HIDDNouveauNV303DCopyBox(struct CardData * carddata,
301 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
302 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
303 ULONG blendop);
305 /* nv40_exa.c */
306 BOOL HIDDNouveauNV403DCopyBox(struct CardData * carddata,
307 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
308 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
309 ULONG blendop);
311 /* nv50_exa.c */
312 VOID HIDDNouveauNV50SetPattern(struct CardData * carddata, LONG col0,
313 LONG col1, LONG pat0, LONG pat1);
314 BOOL HIDDNouveauNV50FillSolidRect(struct CardData * carddata,
315 struct HIDDNouveauBitMapData * bmdata, LONG minX, LONG minY, LONG maxX,
316 LONG maxY, ULONG drawmode, ULONG color);
317 BOOL HIDDNouveauNV50CopySameFormat(struct CardData * carddata,
318 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
319 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
320 ULONG drawmode);
322 /* nvc0_exa.c */
323 VOID HIDDNouveauNVC0SetPattern(struct CardData * carddata, LONG clr0, LONG clr1,
324 LONG pat0, LONG pat1);
325 BOOL HIDDNouveauNVC0FillSolidRect(struct CardData * carddata,
326 struct HIDDNouveauBitMapData * bmdata, LONG minX, LONG minY, LONG maxX,
327 LONG maxY, ULONG drawmode, ULONG color);
328 BOOL HIDDNouveauNVC0CopySameFormat(struct CardData * carddata,
329 struct HIDDNouveauBitMapData * srcdata, struct HIDDNouveauBitMapData * destdata,
330 LONG srcX, LONG srcY, LONG destX, LONG destY, LONG width, LONG height,
331 ULONG drawmode);
333 /* nouveau_accel.c */
334 BOOL HiddNouveauWriteFromRAM(
335 APTR src, ULONG srcPitch, HIDDT_StdPixFmt srcPixFmt,
336 APTR dst, ULONG dstPitch,
337 ULONG width, ULONG height,
338 OOP_Class *cl, OOP_Object *o);
339 BOOL HiddNouveauReadIntoRAM(
340 APTR src, ULONG srcPitch,
341 APTR dst, ULONG dstPitch, HIDDT_StdPixFmt dstPixFmt,
342 ULONG width, ULONG height,
343 OOP_Class *cl, OOP_Object *o);
344 BOOL HiddNouveauAccelARGBUpload3D(
345 UBYTE * srcpixels, ULONG srcpitch,
346 LONG x, LONG y, LONG width, LONG height,
347 OOP_Class *cl, OOP_Object *o);
348 BOOL HiddNouveauAccelAPENUpload3D(
349 UBYTE * srcalpha, BOOL srcinvertalpha, ULONG srcpitch, ULONG srcpenrgb,
350 LONG x, LONG y, LONG width, LONG height,
351 OOP_Class *cl, OOP_Object *o);
352 VOID HIDDNouveauBitMapPutAlphaImage32(struct HIDDNouveauBitMapData * bmdata,
353 APTR srcbuff, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
354 VOID HIDDNouveauBitMapPutAlphaImage16(struct HIDDNouveauBitMapData * bmdata,
355 APTR srcbuff, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
356 VOID HIDDNouveauBitMapPutAlphaTemplate32(struct HIDDNouveauBitMapData * bmdata,
357 OOP_Object * gc, OOP_Object * bm, BOOL invertalpha,
358 UBYTE * srcalpha, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
359 VOID HIDDNouveauBitMapPutAlphaTemplate16(struct HIDDNouveauBitMapData * bmdata,
360 OOP_Object * gc, OOP_Object * bm, BOOL invertalpha,
361 UBYTE * srcalpha, ULONG srcpitch, LONG destX, LONG destY, LONG width, LONG height);
362 VOID HIDDNouveauBitMapDrawSolidLine(struct HIDDNouveauBitMapData * bmdata,
363 OOP_Object * gc, LONG destX1, LONG destY1, LONG destX2, LONG destY2);
365 /* nouveau_exa.c */
366 BOOL HiddNouveauNVAccelUploadM2MF(
367 UBYTE * srcpixels, ULONG srcpitch, HIDDT_StdPixFmt srcPixFmt,
368 LONG x, LONG y, LONG width, LONG height,
369 OOP_Class *cl, OOP_Object *o);
370 BOOL HiddNouveauNVAccelDownloadM2MF(
371 UBYTE * dstpixels, ULONG dstpitch, HIDDT_StdPixFmt dstPixFmt,
372 LONG x, LONG y, LONG width, LONG height,
373 OOP_Class *cl, OOP_Object *o);
375 VOID HIDDNouveauShowCursor(OOP_Object * gfx, BOOL visible);
376 BOOL HIDDNouveauSwitchToVideoMode(OOP_Object * bm);
377 VOID HIDDNouveauSetOffsets(OOP_Object * bm, LONG newxoffset, LONG newyoffset);
379 /* Declaration of nouveau initialization function */
380 extern int nouveau_init(void);
382 /* Commom memory allocation */
383 APTR HIDDNouveauAlloc(ULONG size);
384 VOID HIDDNouveauFree(APTR memory);
386 #endif /* _NOUVEAU_INTERN_H */