Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / arch / common / hidd.radeon / ati.h
blob4cd5f6d8297f6606421e0d3c0e7089791ab665ff
1 #ifndef _ATI_H
2 #define _ATI_H
4 /*
5 Copyright � 2004-2007, The AROS Development Team. All rights reserved.
6 $Id$
7 */
9 #include <exec/types.h>
10 #include <exec/libraries.h>
11 #include <exec/execbase.h>
12 #include <exec/nodes.h>
13 #include <exec/lists.h>
14 #include <exec/semaphores.h>
15 #include <exec/memory.h>
16 #include <exec/memheaderext.h>
17 #include <dos/bptr.h>
19 #include <devices/timer.h>
21 #include <aros/libcall.h>
22 #include <aros/asmcall.h>
24 #include <hidd/graphics.h>
26 #include <oop/oop.h>
28 #include <aros/arossupportbase.h>
29 #include <exec/execbase.h>
31 #include "radeon.h"
33 #define IID_Hidd_Gfx_Ati "IRadeonDriver"
34 #define IID_Hidd_ATIBitMap "IRadeonBitmap"
35 #define CLID_Hidd_Gfx_Ati "RadeonDriver"
37 extern OOP_AttrBase HiddPCIDeviceAttrBase;
38 extern OOP_AttrBase HiddBitMapAttrBase;
39 extern OOP_AttrBase HiddPixFmtAttrBase;
40 extern OOP_AttrBase HiddSyncAttrBase;
41 extern OOP_AttrBase HiddGfxAttrBase;
42 extern OOP_AttrBase HiddATIBitMapAttrBase;
43 extern OOP_AttrBase HiddI2CAttrBase;
44 extern OOP_AttrBase HiddI2CDeviceAttrBase;
45 extern OOP_AttrBase __IHidd_PlanarBM;
47 enum {
48 aoHidd_ATIBitMap_Drawable,
50 num_Hidd_ATIBitMap_Attrs
53 #define aHidd_ATIBitMap_Drawable (HiddATIBitMapAttrBase + aoHidd_ATIBitMap_Drawable)
55 #define IS_BM_ATTR(attr, idx) (((idx)=(attr)-HiddBitMapAttrBase) < num_Hidd_BitMap_Attrs)
56 #define IS_ATIBM_ATTR(attr, idx) (((idx)=(attr)-HiddATIBitMapAttrBase) < num_Hidd_ATIBitMap_Attrs)
58 typedef struct __bm {
59 struct SignalSemaphore bmLock;
61 OOP_Object *BitMap; // BitMap OOP Object
62 IPTR framebuffer; // Points to pixel data
63 void **addresses;
64 ULONG width; // Bitmap width
65 ULONG height; // Bitmap height
66 ULONG pitch; // BytesPerRow aligned
67 UBYTE depth; // Bitmap depth
68 UBYTE bpp; // BytesPerPixel
69 UBYTE onbm; // is onbitmap?
70 UBYTE fbgfx; // is framebuffer in gfx memory
71 ULONG usecount; // counts BitMap accesses
73 ULONG dp_gui_master_cntl;
74 ULONG dp_gui_master_cntl_clip;
75 ULONG pitch_offset;
76 UBYTE datatype;
78 ULONG surface_format;
79 ULONG pattern_format;
80 ULONG rect_format;
81 ULONG line_format;
83 struct CardState *state;
84 } atiBitMap;
86 struct ati_staticdata {
87 struct SignalSemaphore HWLock; /* Hardware exclusive semaphore */
88 struct SignalSemaphore MultiBMLock; /* To lock more than one bitmap at a time */
90 struct MsgPort mp;
91 struct timerequest tr;
93 APTR memPool;
95 struct MemHeader CardMem;
96 ULONG *CardMemBmp;
97 LONG CardMemSize;
99 struct MemHeaderExt managedMem;
101 struct Card Card;
102 struct CardState *poweron_state;
103 IPTR scratch_buffer;
104 UBYTE *cpuscratch;
106 OOP_Object *AtiObject;
107 OOP_Object *PCIObject;
108 OOP_Object *PCIDevice;
109 OOP_Object *PCIDriver;
111 OOP_Class *AtiClass;
112 OOP_Class *AtiI2C;
113 OOP_Class *OnBMClass;
114 OOP_Class *OffBMClass;
115 OOP_Class *PlanarBMClass;
117 OOP_AttrBase pciAttrBase;
118 OOP_AttrBase atiBitMapAttrBase;
119 OOP_AttrBase bitMapAttrBase;
120 OOP_AttrBase pixFmtAttrBase;
121 OOP_AttrBase gfxAttrBase;
122 OOP_AttrBase syncAttrBase;
123 OOP_AttrBase i2cAttrBase;
124 OOP_AttrBase i2cDeviceAttrBase;
125 OOP_AttrBase planarAttrBase;
127 OOP_MethodID mid_ReadLong;
128 OOP_MethodID mid_CopyMemBox8;
129 OOP_MethodID mid_CopyMemBox16;
130 OOP_MethodID mid_CopyMemBox32;
131 OOP_MethodID mid_PutMem32Image8;
132 OOP_MethodID mid_PutMem32Image16;
133 OOP_MethodID mid_GetMem32Image8;
134 OOP_MethodID mid_GetMem32Image16;
135 OOP_MethodID mid_GetImage;
136 OOP_MethodID mid_Clear;
137 OOP_MethodID mid_PutMemTemplate8;
138 OOP_MethodID mid_PutMemTemplate16;
139 OOP_MethodID mid_PutMemTemplate32;
140 OOP_MethodID mid_PutMemPattern8;
141 OOP_MethodID mid_PutMemPattern16;
142 OOP_MethodID mid_PutMemPattern32;
143 OOP_MethodID mid_CopyLUTMemBox16;
144 OOP_MethodID mid_CopyLUTMemBox32;
146 HIDDT_DPMSLevel dpms;
149 struct atibase {
150 struct Library LibNode;
151 struct ati_staticdata sd;
154 struct planarbm_data
156 UBYTE **planes;
157 ULONG planebuf_size;
158 ULONG bytesperrow;
159 ULONG rows;
160 UBYTE depth;
161 BOOL planes_alloced;
164 #define BASE(lib) ((struct atibase*)(lib))
166 #define SD(cl) (&BASE(cl->UserData)->sd)
168 #define METHOD(base, id, name) \
169 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
171 #define METHOD_NAME(base, id, name) \
172 base ## __ ## id ## __ ## name
174 #define METHOD_NAME_S(base, id, name) \
175 # base "__" # id "__" # name
177 #define LOCK_HW { ObtainSemaphore(&sd->HWLock); }
178 #define UNLOCK_HW { ReleaseSemaphore(&sd->HWLock); }
180 #define LOCK_BITMAP { ObtainSemaphore(&bm->bmLock); }
181 #define UNLOCK_BITMAP { ReleaseSemaphore(&bm->bmLock); }
183 #define LOCK_BITMAP_BM(bm) { ObtainSemaphore(&(bm)->bmLock); }
184 #define UNLOCK_BITMAP_BM(bm) { ReleaseSemaphore(&(bm)->bmLock); }
186 #define LOCK_MULTI_BITMAP { ObtainSemaphore(&sd->MultiBMLock); }
187 #define UNLOCK_MULTI_BITMAP { ReleaseSemaphore(&sd->MultiBMLock); }
189 //#define LOCK_HW { while (sd->HWLock.ss_QueueCount) Reschedule(FindTask(NULL)); sd->HWLock.ss_QueueCount=1; }
190 //#define UNLOCK_HW { sd->HWLock.ss_QueueCount=0; }
192 //#define LOCK_BITMAP { while (bm->bmLock.ss_QueueCount) Reschedule(FindTask(NULL)); bm->bmLock.ss_QueueCount=1; }
193 //#define UNLOCK_BITMAP { bm->bmLock.ss_QueueCount=0; }
195 //#define LOCK_BITMAP_BM(bm) { while (bm->bmLock.ss_QueueCount) Reschedule(FindTask(NULL)); bm->bmLock.ss_QueueCount=1; }
196 //#define UNLOCK_BITMAP_BM(bm) { bm->bmLock.ss_QueueCount=0; }
198 //#define LOCK_MULTI_BITMAP { while (sd->MultiBMLock.ss_QueueCount) Reschedule(FindTask(NULL)); sd->MultiBMLock.ss_QueueCount=1; }
199 //#define UNLOCK_MULTI_BITMAP { sd->MultiBMLock.ss_QueueCount=0; }
201 #endif /* _ATI_H */