Resurrected incomplete Intel graphics driver in case anyone wants to
[cake.git] / arch / common / hidd.intelG33 / intelG33_class.c
blob0e6d5d1c66ae095bb8f18340688722504996ef74
1 /*
2 Copyright � 2009-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: intelG33_class.c
6 Lang: English
7 */
11 #define DEBUG 1
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 }, \
55 { TAG_DONE, 0UL }}
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,
65 768, 771, 777, 806,
66 "IntelG33:1024x768");
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 */
83 { TAG_DONE, 0UL }
86 struct TagItem modetags[] = {
87 { aHidd_Gfx_PixFmtTags, (IPTR)pftags_24bpp },
88 { aHidd_Gfx_SyncTags, (IPTR)sync_1024x768_60 },
89 { TAG_DONE, 0UL }
92 struct TagItem mytags[] = {
93 { aHidd_Gfx_ModeTags, (IPTR)modetags },
94 { TAG_MORE, (IPTR)msg->attrList }
97 struct pRoot_New mymsg;
99 mymsg.mID = msg->mID;
100 mymsg.attrList = mytags;
102 msg = &mymsg;
104 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
105 EnterFunc(bug("[G33] New()=%08x\n",o));
106 if (o) {
107 sd->IntelG33Object = o;
110 return o;
115 aoHidd_Gfx_IsWindowed
116 xxx aoHidd_Gfx_ActiveBMCallBack
117 xxx aoHidd_Gfx_ActiveBMCallBackData
118 aoHidd_Gfx_DPMSLevel
119 aoHidd_Gfx_PixFmtTags
120 aoHidd_Gfx_SyncTags
121 aoHidd_Gfx_ModeTags
122 aoHidd_Gfx_NumSyncs
123 aoHidd_Gfx_SupportsHWCursor
126 void METHOD(IntelG33, Root, Get) {
127 D(bug("[G33] Root Get\n"));
129 ULONG idx;
130 BOOL found = FALSE;
131 if (IS_GFX_ATTR(msg->attrID, idx)) {
132 switch (idx) {
133 case aoHidd_Gfx_SupportsHWCursor:
134 D(bug(" (GET) HWCursor\n"));
135 *msg->storage = (IPTR)TRUE;
136 found = TRUE;
137 break;
138 case aoHidd_Gfx_DPMSLevel:
139 D(bug(" (GET) DPMSLevel\n"));
140 CSLOCK(DPMS)
141 switch(((G33_RD_REGW(MMADR, ADPA)>>10)&0x3)) {
142 case 0:
143 *msg->storage = vHidd_Gfx_DPMSLevel_On;
144 break;
145 case 1:
146 *msg->storage = vHidd_Gfx_DPMSLevel_Suspend;
147 break;
148 case 2:
149 *msg->storage = vHidd_Gfx_DPMSLevel_Standby;
150 break;
151 case 3:
152 *msg->storage = vHidd_Gfx_DPMSLevel_Off;
153 break;
155 CSUNLOCK(DPMS)
156 found = TRUE;
157 break;
158 default:
159 D(bug(" (GET) ID = %d\n",idx));
160 break;
162 }else{
163 D(bug(" (GET) Not gfx attribute\n"));
166 if (!found)
167 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
169 return;
172 void METHOD(IntelG33, Root, Set) {
173 D(bug("[G33] Root Set\n"));
175 ULONG idx;
176 const struct TagItem *tags, *tag;
178 tags = msg->attrList;
180 while ((tag = NextTagItem(&tags))) {
181 if (IS_GFX_ATTR(tag->ti_Tag, idx)) {
182 switch(idx) {
183 case aoHidd_Gfx_DPMSLevel:
184 D(bug(" (SET) DPMSLevel\n"));
185 CSLOCK(DPMS)
186 switch(tag->ti_Data) {
187 case vHidd_Gfx_DPMSLevel_On:
188 G33_WRM_REGW(MMADR, ADPA, 0x0000, DPMSMASK);
189 break;
190 case vHidd_Gfx_DPMSLevel_Suspend:
191 G33_WRM_REGW(MMADR, ADPA, 0x0400, DPMSMASK);
192 break;
193 case vHidd_Gfx_DPMSLevel_Standby:
194 G33_WRM_REGW(MMADR, ADPA, 0x0800, DPMSMASK);
195 break;
196 case vHidd_Gfx_DPMSLevel_Off:
197 G33_WRM_REGW(MMADR, ADPA, 0x0c00, DPMSMASK);
198 break;
200 CSUNLOCK(DPMS)
201 break;
202 default:
203 D(bug(" (SET) ID = %d\n",idx));
204 break;
206 }else{
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);
225 if (framebuffer) {
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;
232 }else {
233 HIDDT_ModeID modeid;
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;
239 } else {
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 */
251 OOP_Object *friend;
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 ? */
257 OOP_Object *gfxhidd;
258 OOP_GetAttr(friend, aHidd_BitMap_GfxHidd, (APTR)&gfxhidd);
259 if (gfxhidd == o) {
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 */
281 msg = &mymsg;
284 return (OOP_Object*)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);