2 Copyright � 2009-2010, The AROS Development Team. All rights reserved.
12 #include <aros/debug.h>
13 #include <aros/libcall.h>
14 #include <aros/asmcall.h>
15 #include <aros/symbolsets.h>
17 #include <exec/types.h>
18 #include <exec/memory.h>
19 #include <hidd/hidd.h>
20 #include <hidd/graphics.h>
21 #include <proto/exec.h>
22 #include <proto/oop.h>
23 #include <proto/utility.h>
25 #include LC_LIBDEFS_FILE
27 #include "intelG33_intern.h"
28 #include "intelG33_regs.h"
30 #define BASE(lib) ((struct IntelG33Base*)(lib))
31 #define SD(cl) (&BASE(cl->UserData)->sd)
32 #define sd ((struct staticdata*)SD(cl))
34 #define METHOD(base, id, name) \
35 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
37 #define METHOD_NAME(base, id, name) \
38 base ## __ ## id ## __ ## name
40 #define METHOD_NAME_S(base, id, name) \
41 # base "__" # id "__" # name
43 #define MAKE_SYNC(name,clock,hdisp,hstart,hend,htotal,vdisp,vstart,vend,vtotal,descr) \
44 struct TagItem sync_ ## name[]={ \
45 { aHidd_Sync_PixelClock, clock*1000 }, \
46 { aHidd_Sync_HDisp, hdisp }, \
47 { aHidd_Sync_HSyncStart, hstart }, \
48 { aHidd_Sync_HSyncEnd, hend }, \
49 { aHidd_Sync_HTotal, htotal }, \
50 { aHidd_Sync_VDisp, vdisp }, \
51 { aHidd_Sync_VSyncStart, vstart }, \
52 { aHidd_Sync_VSyncEnd, vend }, \
53 { aHidd_Sync_VTotal, vtotal }, \
54 { aHidd_Sync_Description, (IPTR)descr }, \
58 OOP_Object
*METHOD(IntelG33
, Root
, New
) {
59 D(bug("[G33] Root New\n"));
61 /* TODO: Calculate timings for allowed screen modes based on (E-)EDID information */
63 MAKE_SYNC(1024x768_60
, 65000,
64 1024, 1048, 1184, 1344,
68 struct TagItem pftags_24bpp
[] = {
69 { aHidd_PixFmt_RedShift
, 8 }, /* 0 */
70 { aHidd_PixFmt_GreenShift
, 16 }, /* 1 */
71 { aHidd_PixFmt_BlueShift
, 24 }, /* 2 */
72 { aHidd_PixFmt_AlphaShift
, 0 }, /* 3 */
73 { aHidd_PixFmt_RedMask
, 0x00ff0000 }, /* 4 */
74 { aHidd_PixFmt_GreenMask
, 0x0000ff00 }, /* 5 */
75 { aHidd_PixFmt_BlueMask
, 0x000000ff }, /* 6 */
76 { aHidd_PixFmt_AlphaMask
, 0x00000000 }, /* 7 */
77 { aHidd_PixFmt_ColorModel
, vHidd_ColorModel_TrueColor
}, /* 8 */
78 { aHidd_PixFmt_Depth
, 24 }, /* 9 */
79 { aHidd_PixFmt_BytesPerPixel
, 4 }, /* 10 */
80 { aHidd_PixFmt_BitsPerPixel
, 24 }, /* 11 */
81 { aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_BGR032
}, /* 12 Native */
82 { aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Chunky
}, /* 15 */
86 struct TagItem modetags
[] = {
87 { aHidd_Gfx_PixFmtTags
, (IPTR
)pftags_24bpp
},
88 { aHidd_Gfx_SyncTags
, (IPTR
)sync_1024x768_60
},
92 struct TagItem mytags
[] = {
93 { aHidd_Gfx_ModeTags
, (IPTR
)modetags
},
94 { TAG_MORE
, (IPTR
)msg
->attrList
}
97 struct pRoot_New mymsg
;
100 mymsg
.attrList
= mytags
;
104 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
105 EnterFunc(bug("[G33] New()=%08x\n",o
));
107 sd
->IntelG33Object
= o
;
115 aoHidd_Gfx_IsWindowed
116 xxx aoHidd_Gfx_ActiveBMCallBack
117 xxx aoHidd_Gfx_ActiveBMCallBackData
119 aoHidd_Gfx_PixFmtTags
123 aoHidd_Gfx_SupportsHWCursor
126 void METHOD(IntelG33
, Root
, Get
) {
127 D(bug("[G33] Root Get\n"));
131 if (IS_GFX_ATTR(msg
->attrID
, idx
)) {
133 case aoHidd_Gfx_SupportsHWCursor
:
134 D(bug(" (GET) HWCursor\n"));
135 *msg
->storage
= (IPTR
)TRUE
;
138 case aoHidd_Gfx_DPMSLevel
:
139 D(bug(" (GET) DPMSLevel\n"));
141 switch(((G33_RD_REGW(MMADR
, ADPA
)>>10)&0x3)) {
143 *msg
->storage
= vHidd_Gfx_DPMSLevel_On
;
146 *msg
->storage
= vHidd_Gfx_DPMSLevel_Suspend
;
149 *msg
->storage
= vHidd_Gfx_DPMSLevel_Standby
;
152 *msg
->storage
= vHidd_Gfx_DPMSLevel_Off
;
159 D(bug(" (GET) ID = %d\n",idx
));
163 D(bug(" (GET) Not gfx attribute\n"));
167 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
172 void METHOD(IntelG33
, Root
, Set
) {
173 D(bug("[G33] Root Set\n"));
176 const struct TagItem
*tags
, *tag
;
178 tags
= msg
->attrList
;
180 while ((tag
= NextTagItem(&tags
))) {
181 if (IS_GFX_ATTR(tag
->ti_Tag
, idx
)) {
183 case aoHidd_Gfx_DPMSLevel
:
184 D(bug(" (SET) DPMSLevel\n"));
186 switch(tag
->ti_Data
) {
187 case vHidd_Gfx_DPMSLevel_On
:
188 G33_WRM_REGW(MMADR
, ADPA
, 0x0000, DPMSMASK
);
190 case vHidd_Gfx_DPMSLevel_Suspend
:
191 G33_WRM_REGW(MMADR
, ADPA
, 0x0400, DPMSMASK
);
193 case vHidd_Gfx_DPMSLevel_Standby
:
194 G33_WRM_REGW(MMADR
, ADPA
, 0x0800, DPMSMASK
);
196 case vHidd_Gfx_DPMSLevel_Off
:
197 G33_WRM_REGW(MMADR
, ADPA
, 0x0c00, DPMSMASK
);
203 D(bug(" (SET) ID = %d\n",idx
));
207 D(bug(" (SET) Not gfx attribute\n"));
210 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
213 OOP_Object
*METHOD(IntelG33
, Hidd_Gfx
, NewBitMap
) {
214 D(bug("[G33] Hidd_Gfx NewBitMap\n"));
216 BOOL displayable
, framebuffer
;
217 OOP_Class
*classptr
= NULL
;
218 struct TagItem mytags
[2];
219 struct pHidd_Gfx_NewBitMap mymsg
;
221 /* Displayable bitmap ? */
222 displayable
= GetTagData(aHidd_BitMap_Displayable
, FALSE
, msg
->attrList
);
223 framebuffer
= GetTagData(aHidd_BitMap_FrameBuffer
, FALSE
, msg
->attrList
);
226 D(bug(" ...Asked for framebuffer\n"));
227 /* If the user asks for a framebuffer map we must ALLWAYS supply a class */
228 classptr
= sd
->OnBMClass
;
229 }else if (displayable
) {
230 D(bug(" ...Asked for displayable\n"));
231 classptr
= sd
->OnBMClass
;
234 modeid
= (HIDDT_ModeID
)GetTagData(aHidd_BitMap_ModeID
, vHidd_ModeID_Invalid
, msg
->attrList
);
236 if (vHidd_ModeID_Invalid
!= modeid
) {
237 /* User supplied a valid modeid. We can use our offscreen class */
238 classptr
= sd
->OnBMClass
;
241 We may create an offscreen bitmap if the user supplied a friend
242 bitmap. But we need to check that he did not supplied a StdPixFmt
244 HIDDT_StdPixFmt stdpf
;
245 stdpf
= (HIDDT_StdPixFmt
)GetTagData(aHidd_BitMap_StdPixFmt
, vHidd_StdPixFmt_Unknown
, msg
->attrList
);
247 if (vHidd_StdPixFmt_Plane
== stdpf
) {
248 classptr
= sd
->PlanarBMClass
;
249 } else if (vHidd_StdPixFmt_Unknown
== stdpf
) {
250 /* No std pixfmt supplied */
253 /* Did the user supply a friend bitmap ? */
254 friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, 0, msg
->attrList
);
255 if (NULL
!= friend) {
256 /* User supplied friend bitmap. Is the friend bitmap a G33 Gfx hidd bitmap ? */
258 OOP_GetAttr(friend, aHidd_BitMap_GfxHidd
, (APTR
)&gfxhidd
);
260 /* Friend was G33 hidd bitmap. Now we can supply our own class */
261 classptr
= sd
->OffBMClass
;
268 if (NULL
!= classptr
) {
269 /* Yes. We must let the superclass note that we do this. This is
270 done through adding a tag in front of the taglist */
271 mytags
[0].ti_Tag
= aHidd_BitMap_ClassPtr
;
272 mytags
[0].ti_Data
= (IPTR
)classptr
;
273 mytags
[1].ti_Tag
= TAG_MORE
;
274 mytags
[1].ti_Data
= (IPTR
)msg
->attrList
;
276 /* Like in Gfx::New() we init a new message struct */
277 mymsg
.mID
= msg
->mID
;
278 mymsg
.attrList
= mytags
;
280 /* Pass the new message to the superclass */
284 return (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);