2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
9 #define __OOP_NOATTRBASES__
11 #include <aros/asmcall.h>
12 #include <proto/exec.h>
13 #include <proto/oop.h>
14 #include <proto/utility.h>
15 #include <aros/symbolsets.h>
16 #include <devices/inputevent.h>
17 #include <exec/alerts.h>
18 #include <exec/memory.h>
19 #include <hardware/custom.h>
20 #include <hidd/hidd.h>
23 #include <clib/alib_protos.h>
27 #include <aros/debug.h>
29 #include "vesagfx_hidd.h"
30 #include "vesagfx_support.h"
32 #include LC_LIBDEFS_FILE
34 AROS_INTH1(ResetHandler
, struct HWData
*, hwdata
)
45 OOP_Object
*VESAGfx__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
47 struct TagItem pftags
[] =
49 {aHidd_PixFmt_RedShift
, 0}, /* 0 */
50 {aHidd_PixFmt_GreenShift
, 0}, /* 1 */
51 {aHidd_PixFmt_BlueShift
, 0}, /* 2 */
52 {aHidd_PixFmt_AlphaShift
, 0}, /* 3 */
53 {aHidd_PixFmt_RedMask
, 0}, /* 4 */
54 {aHidd_PixFmt_GreenMask
, 0}, /* 5 */
55 {aHidd_PixFmt_BlueMask
, 0}, /* 6 */
56 {aHidd_PixFmt_AlphaMask
, 0}, /* 7 */
57 {aHidd_PixFmt_ColorModel
, 0}, /* 8 */
58 {aHidd_PixFmt_Depth
, 0}, /* 9 */
59 {aHidd_PixFmt_BytesPerPixel
,0}, /* 10 */
60 {aHidd_PixFmt_BitsPerPixel
, 0}, /* 11 */
61 {aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Native
}, /* 12 */
62 {aHidd_PixFmt_CLUTShift
, 0}, /* 13 */
63 {aHidd_PixFmt_CLUTMask
, 0}, /* 14 */
64 {aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Chunky
}, /* 15 */
67 struct TagItem sync_mode
[] =
69 {aHidd_Sync_HDisp
, 0},
70 {aHidd_Sync_VDisp
, 0},
71 {aHidd_Sync_HMax
, 16384},
72 {aHidd_Sync_VMax
, 16384},
73 {aHidd_Sync_Description
, (IPTR
)"VESA:%hx%v"},
76 struct TagItem modetags
[] =
78 {aHidd_Gfx_PixFmtTags
, (IPTR
)pftags
},
79 {aHidd_Gfx_SyncTags
, (IPTR
)sync_mode
},
82 struct TagItem yourtags
[] =
84 {aHidd_Gfx_ModeTags
, (IPTR
)modetags
},
85 { aHidd_Name
, (IPTR
)"vesagfx.hidd" },
86 { aHidd_HardwareName
, (IPTR
)"VESA Compatible Controller" },
87 { aHidd_ProducerName
, (IPTR
)"vesa.org" },
90 struct pRoot_New yourmsg
;
92 EnterFunc(bug("VESAGfx::New()\n"));
94 /* Protect against some stupid programmer wishing to
95 create one more VESA driver */
96 if (XSD(cl
)->vesagfxhidd
)
99 pftags
[0].ti_Data
= XSD(cl
)->data
.redshift
;
100 pftags
[1].ti_Data
= XSD(cl
)->data
.greenshift
;
101 pftags
[2].ti_Data
= XSD(cl
)->data
.blueshift
;
102 pftags
[4].ti_Data
= XSD(cl
)->data
.redmask
;
103 pftags
[5].ti_Data
= XSD(cl
)->data
.greenmask
;
104 pftags
[6].ti_Data
= XSD(cl
)->data
.bluemask
;
105 pftags
[8].ti_Data
= (XSD(cl
)->data
.depth
> 8) ? vHidd_ColorModel_TrueColor
: vHidd_ColorModel_Palette
;
106 pftags
[9].ti_Data
= (XSD(cl
)->data
.depth
> 24) ? 24 : XSD(cl
)->data
.depth
;
107 pftags
[10].ti_Data
= XSD(cl
)->data
.bytesperpixel
;
108 pftags
[11].ti_Data
= (XSD(cl
)->data
.bitsperpixel
> 24) ? 24 : XSD(cl
)->data
.bitsperpixel
;
109 pftags
[14].ti_Data
= (1 << XSD(cl
)->data
.depth
) - 1;
111 sync_mode
[0].ti_Data
= XSD(cl
)->data
.width
;
112 sync_mode
[1].ti_Data
= XSD(cl
)->data
.height
;
114 yourtags
[1].ti_Data
= (IPTR
)msg
->attrList
;
115 yourmsg
.mID
= msg
->mID
;
116 yourmsg
.attrList
= yourtags
;
118 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)&yourmsg
);
121 struct VESAGfxHiddData
*data
= OOP_INST_DATA(cl
, o
);
123 D(bug("Got object from super\n"));
124 XSD(cl
)->vesagfxhidd
= o
;
126 data
->ResetInterrupt
.is_Code
= (VOID_FUNC
)ResetHandler
;
127 data
->ResetInterrupt
.is_Data
= &XSD(cl
)->data
;
128 AddResetCallback(&data
->ResetInterrupt
);
130 ReturnPtr("VESAGfx::New", OOP_Object
*, o
);
133 VOID
VESAGfx__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
135 struct VESAGfxHiddData
*data
= OOP_INST_DATA(cl
, o
);
137 RemResetCallback(&data
->ResetInterrupt
);
138 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
139 XSD(cl
)->vesagfxhidd
= NULL
;
142 VOID
VESAGfx__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
146 if (IS_GFX_ATTR(msg
->attrID
, idx
))
150 case aoHidd_Gfx_NoFrameBuffer
:
151 *msg
->storage
= TRUE
;
155 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
158 OOP_Object
*VESAGfx__Hidd_Gfx__CreateObject(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CreateObject
*msg
)
160 OOP_Object
*object
= NULL
;
162 D(bug("[VESA] %s()\n", __PRETTY_FUNCTION__
));
163 D(bug("[VESA] %s: requested class 0x%p\n", __PRETTY_FUNCTION__
, msg
->cl
));
164 D(bug("[VESA] %s: base bitmap class 0x%p\n", __PRETTY_FUNCTION__
, XSD(cl
)->basebm
));
166 if (msg
->cl
== XSD(cl
)->basebm
)
169 struct TagItem tags
[2] =
172 {TAG_MORE
, (IPTR
)msg
->attrList
}
174 struct pHidd_Gfx_CreateObject p
;
176 displayable
= GetTagData(aHidd_BitMap_Displayable
, FALSE
, msg
->attrList
);
179 /* Only displayable bitmaps are bitmaps of our class */
180 tags
[0].ti_Tag
= aHidd_BitMap_ClassPtr
;
181 tags
[0].ti_Data
= (IPTR
)XSD(cl
)->bmclass
;
185 /* Non-displayable friends of our bitmaps are plain chunky bitmaps */
186 OOP_Object
*friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, 0, msg
->attrList
);
188 if (friend && (OOP_OCLASS(friend) == XSD(cl
)->bmclass
))
190 tags
[0].ti_Tag
= aHidd_BitMap_ClassID
;
191 tags
[0].ti_Data
= (IPTR
)CLID_Hidd_ChunkyBM
;
199 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)&p
);
202 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
204 ReturnPtr("VESAGfx::CreateObject", OOP_Object
*, object
);
207 /********* GfxHidd::Show() ***************************/
209 OOP_Object
*VESAGfx__Hidd_Gfx__Show(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_Show
*msg
)
211 struct VESAGfx_staticdata
*data
= XSD(cl
);
212 struct TagItem tags
[] = {
213 {aHidd_BitMap_Visible
, FALSE
},
217 D(bug("[VESAGfx] Show(0x%p), old visible 0x%p\n", msg
->bitMap
, data
->visible
));
219 LOCK_FRAMEBUFFER(data
);
221 /* Remove old bitmap from the screen */
224 D(bug("[VESAGfx] Hiding old bitmap\n"));
225 OOP_SetAttrs(data
->visible
, tags
);
230 /* If we have a bitmap to show, set it as visible */
231 D(bug("[VESAGfx] Showing new bitmap\n"));
232 tags
[0].ti_Data
= TRUE
;
233 OOP_SetAttrs(msg
->bitMap
, tags
);
237 D(bug("[VESAGfx] Blanking screen\n"));
238 /* Otherwise simply clear the framebuffer */
239 ClearBuffer(&data
->data
);
242 data
->visible
= msg
->bitMap
;
243 UNLOCK_FRAMEBUFFER(data
);
245 D(bug("[VESAGfx] Show() done\n"));