wip.
[AROS.git] / arch / arm-native / soc / broadcom / 2708 / hidd / videocoregfx / videocoregfx_class.c
blobe0d04c1db39186c012a624ea456d6b4e1e9dbad4
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: VideoCore Gfx Hidd Class.
6 Lang: English.
7 */
9 #define DEBUG 1
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <aros/asmcall.h>
15 #include <proto/exec.h>
16 #include <proto/oop.h>
17 #include <proto/utility.h>
18 #include <aros/symbolsets.h>
19 #include <devices/inputevent.h>
20 #include <exec/alerts.h>
21 #include <exec/memory.h>
22 #include <graphics/displayinfo.h>
23 #include <graphics/view.h>
24 #include <hardware/custom.h>
25 #include <hidd/hidd.h>
26 #include <hidd/graphics.h>
27 #include <oop/oop.h>
28 #include <clib/alib_protos.h>
29 #include <string.h>
31 #include "videocoregfx_class.h"
32 #include "videocoregfx_hardware.h"
33 #include "videocoregfx_bitmap.h"
35 #include LC_LIBDEFS_FILE
37 #define MNAME_ROOT(x) VideoCoreGfx__Root__ ## x
38 #define MNAME_GFX(x) VideoCoreGfx__Hidd_Gfx__ ## x
40 #define SYNCTAGS_SIZE (11 * sizeof(struct TagItem))
42 APTR FNAME_SUPPORT(GenModeArray)(OOP_Class *cl, OOP_Object *o, struct List *modelist, struct TagItem *fmts)
44 APTR modearray = NULL;
45 struct TagItem *ma_syncs = NULL, *ma_synctags = NULL;
46 int i, fmtcount = 0, modecount = 0;
47 struct DisplayMode *modecurrent;
49 /* quickly count fmts and modes */
50 while (fmts[fmtcount].ti_Tag == aHidd_Gfx_PixFmtTags)
51 fmtcount++;
53 ForeachNode(modelist, modecurrent)
55 modecount++;
58 D(bug("[VideoCoreGfx] %s: %d PixFmts, %d SyncModes\n", __PRETTY_FUNCTION__, fmtcount, modecount));
60 /* build our table .. */
61 if (fmtcount && modecount)
63 if ((modearray = AllocVec((fmtcount * sizeof(struct TagItem)) + ((modecount + 1) * sizeof(struct TagItem)) + (modecount * SYNCTAGS_SIZE), MEMF_PUBLIC)) != NULL)
65 D(bug("[VideoCoreGfx] %s: PixFmt's @ 0x%p\n", __PRETTY_FUNCTION__, modearray));
67 struct TagItem *ma_fmts = (struct TagItem *)modearray;
69 for (i = 0; i < fmtcount; i ++)
71 ma_fmts[i].ti_Tag = aHidd_Gfx_PixFmtTags;
72 ma_fmts[i].ti_Data = fmts[i].ti_Data;
74 ma_syncs = (struct TagItem *)&ma_fmts[fmtcount];
75 D(bug("[VideoCoreGfx] %s: SyncMode's @ 0x%p\n", __PRETTY_FUNCTION__, ma_syncs));
76 ma_synctags = (struct TagItem *)&ma_syncs[modecount + 1];
77 i = 0;
78 ForeachNode(modelist, modecurrent)
80 D(bug("[VideoCoreGfx] %s: SyncMode #%d Tags @ 0x%p\n", __PRETTY_FUNCTION__, i, ma_synctags));
82 ma_syncs[i].ti_Tag = aHidd_Gfx_SyncTags;
83 ma_syncs[i].ti_Data = ma_synctags;
85 ma_synctags[0].ti_Tag = aHidd_Sync_PixelClock;
86 ma_synctags[0].ti_Data = modecurrent->dm_clock * 1000;
87 ma_synctags[1].ti_Tag = aHidd_Sync_HDisp;
88 ma_synctags[1].ti_Data = modecurrent->dm_hdisp;
89 ma_synctags[2].ti_Tag = aHidd_Sync_HSyncStart;
90 ma_synctags[2].ti_Data = modecurrent->dm_hstart;
91 ma_synctags[3].ti_Tag = aHidd_Sync_HSyncEnd;
92 ma_synctags[3].ti_Data = modecurrent->dm_hend;
93 ma_synctags[4].ti_Tag = aHidd_Sync_HTotal;
94 ma_synctags[4].ti_Data = modecurrent->dm_htotal;
95 ma_synctags[5].ti_Tag = aHidd_Sync_VDisp;
96 ma_synctags[5].ti_Data = modecurrent->dm_vdisp;
97 ma_synctags[6].ti_Tag = aHidd_Sync_VSyncStart;
98 ma_synctags[6].ti_Data = modecurrent->dm_vstart;
99 ma_synctags[7].ti_Tag = aHidd_Sync_VSyncEnd;
100 ma_synctags[7].ti_Data = modecurrent->dm_vend;
101 ma_synctags[8].ti_Tag = aHidd_Sync_VTotal;
102 ma_synctags[8].ti_Data = modecurrent->dm_vtotal;
103 ma_synctags[9].ti_Tag = aHidd_Sync_Description;
104 ma_synctags[9].ti_Data = modecurrent->dm_descr;
105 ma_synctags[10].ti_Tag = TAG_DONE;
107 ma_synctags = (struct TagItem *)&ma_synctags[11];
108 i++;
110 ma_syncs[i].ti_Tag = TAG_DONE;
113 #if defined(DEBUGMODEARRAY)
114 if (modearray)
116 ma_syncs = (struct TagItem *)modearray;
117 while (ma_syncs->ti_Tag != TAG_DONE)
119 D(bug("[VideoCoreGfx] %s: 0x%p: %08x, %08x\n", __PRETTY_FUNCTION__, ma_syncs, ma_syncs->ti_Tag, ma_syncs->ti_Data));
120 ma_syncs++;
122 D(bug("[VideoCoreGfx] %s: 0x%p: %08x, %08x\n", __PRETTY_FUNCTION__, ma_syncs, ma_syncs->ti_Tag, ma_syncs->ti_Data));
124 #endif
125 return (APTR)modearray;
128 void FNAME_SUPPORT(DestroyModeArray)(struct List *modelist, APTR modearray)
130 D(bug("[VideoCoreGfx] %s()\n", __PRETTY_FUNCTION__));
133 OOP_Object *MNAME_ROOT(New)(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
135 struct VideoCoreGfx_staticdata *xsd = XSD(cl);
136 OOP_Object *self = NULL;
138 struct TagItem gfxmsg_tags[2];
139 struct pRoot_New gfxmsg_New;
141 struct List vc_modelist;
142 APTR vc_modearray, vc_pixfmts;
144 EnterFunc(bug("VideoCoreGfx::New()\n"));
146 NewList(&vc_modelist);
148 FNAME_SUPPORT(SDTV_SyncGen)(&vc_modelist, cl);
149 FNAME_SUPPORT(HDMI_SyncGen)(&vc_modelist, cl);
150 vc_pixfmts = FNAME_SUPPORT(GenPixFmts)(cl);
152 if ((vc_modearray = FNAME_SUPPORT(GenModeArray)(cl, o, &vc_modelist, (struct TagItem *)vc_pixfmts)) != NULL)
154 D(bug("[VideoCoreGfx] VideoCoreGfx::New: Generated Mode Array @ 0x%p\n", vc_modearray));
156 gfxmsg_tags[0].ti_Tag = aHidd_Gfx_ModeTags;
157 gfxmsg_tags[0].ti_Data = (IPTR)vc_modearray;
158 gfxmsg_tags[1].ti_Tag = TAG_MORE;
159 gfxmsg_tags[1].ti_Data = (IPTR)msg->attrList;
160 gfxmsg_New.mID = msg->mID;
161 gfxmsg_New.attrList = gfxmsg_tags;
162 msg = &gfxmsg_New;
164 D(bug("[VideoCoreGfx] VideoCoreGfx::New: Creating object [cl:0x%p, o:0x%p, msg:0x%p]\n", cl, o, msg));
166 if ((self = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg)) != NULL)
168 D(bug("[VideoCoreGfx] VideoCoreGfx::New: Storing reference to self in staticdata\n"));
169 XSD(cl)->vcsd_VideoCoreGfxInstance = self;
171 FNAME_SUPPORT(DestroyModeArray)(&vc_modelist, vc_modearray);
174 ReturnPtr("VideoCoreGfx::New: Obj", OOP_Object *, self);
177 VOID MNAME_ROOT(Dispose)(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
179 D(bug("[VideoCoreGfx] VideoCoreGfx::Dispose()\n"));
181 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
184 VOID MNAME_ROOT(Get)(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
186 ULONG idx;
187 BOOL found = FALSE;
189 // D(bug("[VideoCoreGfx] VideoCoreGfx::Get()\n"));
191 if (IS_GFX_ATTR(msg->attrID, idx))
193 switch (idx)
195 case aoHidd_Gfx_MemorySize:
196 *msg->storage = (IPTR)(XSD(cl)->vcsd_GPUMemManage.mhe_MemHeader.mh_Upper - XSD(cl)->vcsd_GPUMemManage.mhe_MemHeader.mh_Lower);
197 found = TRUE;
198 break;
201 if (!found)
202 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
205 OOP_Object *MNAME_GFX(NewBitMap)(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NewBitMap *msg)
207 BOOL displayable;
208 BOOL framebuffer;
209 struct TagItem newbm_tags[2] =
211 {TAG_IGNORE, 0 },
212 {TAG_MORE , (IPTR)msg->attrList}
214 struct pHidd_Gfx_NewBitMap newbm_msg;
216 EnterFunc(bug("VideoCoreGfx::NewBitMap()\n"));
218 displayable = (BOOL)GetTagData(aHidd_BitMap_Displayable, FALSE, msg->attrList);
219 framebuffer = (BOOL)GetTagData(aHidd_BitMap_FrameBuffer, FALSE, msg->attrList);
220 if (framebuffer)
222 D(bug("[VideoCoreGfx] VideoCoreGfx::NewBitMap: Using OnScreenBM\n"));
223 newbm_tags[0].ti_Tag = aHidd_BitMap_ClassPtr;
224 newbm_tags[0].ti_Data = (IPTR)XSD(cl)->vcsd_VideoCoreGfxOnBMClass;
226 else
228 /* Non-displayable friends of our bitmaps are plain chunky bitmaps */
229 OOP_Object *friend = (OOP_Object *)GetTagData(aHidd_BitMap_Friend, 0, msg->attrList);
231 if (displayable || (friend && (OOP_OCLASS(friend) == XSD(cl)->vcsd_VideoCoreGfxOnBMClass)))
233 D(bug("[VideoCoreGfx] VideoCoreGfx::NewBitMap: Using OffScreenBM (ChunkyBM)\n"));
234 newbm_tags[0].ti_Tag = aHidd_BitMap_ClassID;
235 newbm_tags[0].ti_Data = (IPTR)CLID_Hidd_ChunkyBM;
239 newbm_msg.mID = msg->mID;
240 newbm_msg.attrList = newbm_tags;
242 ReturnPtr("VideoCoreGfx::NewBitMap: Obj", OOP_Object *, (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&newbm_msg));