4 Copyright © 2004-2015, The AROS Development Team. All rights reserved.
7 Desc: private header file
11 #include <exec/types.h>
12 #include <exec/libraries.h>
13 #include <exec/semaphores.h>
14 #include <exec/nodes.h>
15 #include <exec/execbase.h>
16 #include <exec/memory.h>
23 #include <hidd/graphics.h>
28 #define IID_Hidd_Gfx_nVidia "hidd.gfx.nv"
29 #define CLID_Hidd_Gfx_nVidia "hidd.gfx.nv"
31 #define IID_Hidd_nvBitMap "hidd.bitmap.nv"
34 aoHidd_nvBitMap_Drawable
,
36 num_Hidd_nvBitMap_Attrs
39 #define aHidd_nvBitMap_Drawable (HiddNVidiaBitMapAttrBase + aoHidd_nvBitMap_Drawable)
41 #define IS_BM_ATTR(attr, idx) (((idx)=(attr)-HiddBitMapAttrBase) < num_Hidd_BitMap_Attrs)
42 #define IS_NVBM_ATTR(attr, idx) (((idx)=(attr)-HiddNVidiaBitMapAttrBase) < num_Hidd_nvBitMap_Attrs)
45 NV04
= 0, NV05
, NV05M64
, NV06
, NV10
,
46 NV11
, NV11M
, NV15
, NV17
, NV17M
,
47 NV18
, NV18M
, NV20
, NV25
, NV28
,
48 NV30
, NV31
, NV34
, NV35
, NV36
,
54 typedef struct _sync
{
57 ULONG HDisplay
, HSyncStart
, HSyncEnd
, HTotal
;
58 ULONG VDisplay
, VSyncStart
, VSyncEnd
, VTotal
;
61 typedef struct CardState
{
111 typedef struct Card
{
116 ULONG FrameBufferSize
;
124 UWORD Chipset
; /* == ProductID */
125 ULONG CrystalFreqKHz
;
126 ULONG RamAmountKBytes
;
127 ULONG MaxVClockFreqKHz
;
128 ULONG MinVClockFreqKHz
;
129 ULONG RamBandwidthKBytesPerSec
;
134 ULONG FifoEmptyCount
;
155 volatile ULONG
*PCRTC0
;
156 volatile ULONG
*PCRTC
;
157 volatile ULONG
*PRAMDAC0
;
159 volatile ULONG
*PFIFO
;
160 volatile ULONG
*PGRAPH
;
161 volatile ULONG
*PEXTDEV
;
162 volatile ULONG
*PTIMER
;
164 volatile ULONG
*PRAMIN
;
165 volatile ULONG
*FIFO
;
166 volatile ULONG
*CURSOR
;
167 volatile UBYTE
*PCIO0
;
168 volatile UBYTE
*PCIO
;
169 volatile UBYTE
*PVIO
;
170 volatile UBYTE
*PDIO0
;
171 volatile UBYTE
*PDIO
;
172 volatile ULONG
*PRAMDAC
;
174 struct CardState
*CurrentState
;
176 void (*DMAKickoffCallback
)(struct staticdata
*sd
);
177 } RIVA_HW_INST
, *NVPtr
;
180 struct MemHeader
*CardMem
;
182 struct SignalSemaphore HWLock
; /* Hardware exclusive semaphore */
183 struct SignalSemaphore MultiBMLock
; /* To lock more than one bitmap at a time */
186 OOP_Class
*basebm
; /* baseclass for CreateObject */
189 OOP_Class
*onbmclass
;
190 OOP_Class
*offbmclass
;
191 OOP_Class
*planarbmclass
;
195 OOP_Object
*nvobject
;
196 OOP_Object
*pcidriver
;
198 OOP_AttrBase pciAttrBase
;
199 OOP_AttrBase bitMapAttrBase
;
200 OOP_AttrBase nvBitMapAttrBase
;
201 OOP_AttrBase pixFmtAttrBase
;
202 OOP_AttrBase gfxAttrBase
;
203 OOP_AttrBase syncAttrBase
;
204 OOP_AttrBase planarAttrBase
;
206 HIDDT_DPMSLevel dpms
;
208 struct CardState
*poweron_state
;
212 UWORD src_pitch
, dst_pitch
;
213 ULONG src_offset
, dst_offset
;
214 ULONG surface_format
;
215 ULONG pattern_format
;
219 OOP_MethodID mid_ReadLong
;
220 OOP_MethodID mid_CopyMemBox8
;
221 OOP_MethodID mid_CopyMemBox16
;
222 OOP_MethodID mid_CopyMemBox32
;
223 OOP_MethodID mid_PutMem32Image8
;
224 OOP_MethodID mid_PutMem32Image16
;
225 OOP_MethodID mid_GetMem32Image8
;
226 OOP_MethodID mid_GetMem32Image16
;
227 OOP_MethodID mid_GetImage
;
228 OOP_MethodID mid_Clear
;
229 OOP_MethodID mid_PutMemTemplate8
;
230 OOP_MethodID mid_PutMemTemplate16
;
231 OOP_MethodID mid_PutMemTemplate32
;
232 OOP_MethodID mid_PutMemPattern8
;
233 OOP_MethodID mid_PutMemPattern16
;
234 OOP_MethodID mid_PutMemPattern32
;
235 OOP_MethodID mid_CopyLUTMemBox16
;
236 OOP_MethodID mid_CopyLUTMemBox32
;
243 typedef struct __bm
{
244 struct SignalSemaphore bmLock
;
246 OOP_Object
*BitMap
; // BitMap OOP Object
247 IPTR framebuffer
; // Points to pixel data
248 ULONG width
; // Bitmap width
249 ULONG height
; // Bitmap height
250 ULONG pitch
; // BytesPerRow aligned
251 UBYTE depth
; // Bitmap depth
252 UBYTE bpp
; // BytesPerPixel
253 UBYTE onbm
; // is onbitmap?
254 UBYTE fbgfx
; // is framebuffer in gfx memory
255 ULONG usecount
; // counts BitMap accesses
257 ULONG surface_format
;
258 ULONG pattern_format
;
262 struct CardState
*state
;
275 #define LOCK_HW { ObtainSemaphore(&_sd->HWLock); }
276 #define UNLOCK_HW { ReleaseSemaphore(&_sd->HWLock); }
278 #define LOCK_BITMAP { ObtainSemaphore(&bm->bmLock); }
279 #define UNLOCK_BITMAP { ReleaseSemaphore(&bm->bmLock); }
281 #define LOCK_BITMAP_BM(bm) { ObtainSemaphore(&(bm)->bmLock); }
282 #define UNLOCK_BITMAP_BM(bm) { ReleaseSemaphore(&(bm)->bmLock); }
284 #define LOCK_MULTI_BITMAP { ObtainSemaphore(&_sd->MultiBMLock); }
285 #define UNLOCK_MULTI_BITMAP { ReleaseSemaphore(&_sd->MultiBMLock); }
287 #include LC_LIBDEFS_FILE
290 struct Library LibNode
;
292 struct staticdata sd
;
296 #define V_DBLSCAN 0x01
299 void LoadState(struct staticdata
*, struct CardState
*);
300 void SaveState(struct staticdata
*, struct CardState
*);
301 void DPMS(struct staticdata
*, HIDDT_DPMSLevel
);
302 void InitMode(struct staticdata
*sd
, struct CardState
*,
303 ULONG width
, ULONG height
, UBYTE bpp
, ULONG pixelc
, ULONG base
,
304 ULONG HDisplay
, ULONG VDisplay
,
305 ULONG HSyncStart
, ULONG HSyncEnd
, ULONG HTotal
,
306 ULONG VSyncStart
, ULONG VSyncEnd
, ULONG VTotal
);
307 void acc_test(struct staticdata
*);
310 void NVLockUnlock(struct staticdata
*, UBYTE
);
311 int NVShowHideCursor (struct staticdata
*, UBYTE
);
312 void NVDmaKickoff(struct Card
*);
313 void NVDmaWait(struct Card
*, int);
314 void NVSync(struct staticdata
*);
315 void NVDMAKickoffCallback(struct staticdata
*);
316 void NVSetPattern(struct staticdata
*, ULONG
, ULONG
, ULONG
, ULONG
);
317 void NVSetRopSolid(struct staticdata
*, ULONG
, ULONG
);
318 void NVSelectHead(struct staticdata
*sd
, UBYTE head
);
319 BOOL
NVIsConnected (struct staticdata
*sd
, UBYTE output
);
321 void nv4GetConfig(struct staticdata
*);
322 void nv10GetConfig(struct staticdata
*);
323 IPTR
AllocBitmapArea(struct staticdata
*, ULONG
, ULONG
, ULONG
, BOOL
);
324 VOID
FreeBitmapArea(struct staticdata
*, IPTR
, ULONG
, ULONG
, ULONG
);
326 #define NVDmaNext(pNv, data) \
327 (pNv)->dmaBase[(pNv)->dmaCurrent++] = (data)
329 #define NVDmaStart(pNv, tag, size) { \
330 if((pNv)->dmaFree <= (size)) \
331 NVDmaWait(pNv, size); \
332 NVDmaNext(pNv, ((size) << 18) | (tag)); \
333 (pNv)->dmaFree -= ((size) + 1); \
336 //#if defined(__i386__)
337 //#define _NV_FENCE() asm volatile ("outb %0,%w1"::"a"(0),"Nd"(0x3d0));
339 #define _NV_FENCE() /* eps */
342 #define WRITE_PUT(pNv, data) { \
343 volatile UBYTE scratch; \
345 scratch = (pNv)->FrameBuffer[0]; \
346 (void)scratch; /* unused */ \
347 (pNv)->FIFO[0x0010] = (data) << 2; \
351 #define READ_GET(pNv) ((pNv)->FIFO[0x0011] >> 2)