2 Copyright © 2013-2017, The AROS Development Team. All rights reserved.
5 Desc: BCM VideoCore4 Gfx Hidd Class.
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>
28 #include <clib/alib_protos.h>
31 #include "vc4gfx_hidd.h"
32 #include "vc4gfx_hardware.h"
33 #include "vc4gfx_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
)
53 ForeachNode(modelist
, modecurrent
)
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 struct TagItem
*ma_fmts
= (struct TagItem
*)modearray
;
67 D(bug("[VideoCoreGfx] %s: PixFmt's @ 0x%p\n", __PRETTY_FUNCTION__
, modearray
));
69 for (i
= 0; i
< fmtcount
; i
++)
71 D(bug("[VideoCoreGfx] %s: PixFmt #%d @ 0x%p\n", __PRETTY_FUNCTION__
, i
, fmts
[i
].ti_Data
));
72 ma_fmts
[i
].ti_Tag
= aHidd_Gfx_PixFmtTags
;
73 ma_fmts
[i
].ti_Data
= fmts
[i
].ti_Data
;
75 ma_syncs
= (struct TagItem
*)&ma_fmts
[fmtcount
];
76 D(bug("[VideoCoreGfx] %s: SyncMode's @ 0x%p\n", __PRETTY_FUNCTION__
, ma_syncs
));
77 ma_synctags
= (struct TagItem
*)&ma_syncs
[modecount
+ 1];
79 ForeachNode(modelist
, modecurrent
)
81 D(bug("[VideoCoreGfx] %s: SyncMode #%d Tags @ 0x%p\n", __PRETTY_FUNCTION__
, i
, ma_synctags
));
83 ma_syncs
[i
].ti_Tag
= aHidd_Gfx_SyncTags
;
84 ma_syncs
[i
].ti_Data
= (IPTR
)ma_synctags
;
86 ma_synctags
[0].ti_Tag
= aHidd_Sync_PixelClock
;
87 ma_synctags
[0].ti_Data
= modecurrent
->dm_clock
* 1000;
88 ma_synctags
[1].ti_Tag
= aHidd_Sync_HDisp
;
89 ma_synctags
[1].ti_Data
= modecurrent
->dm_hdisp
;
90 ma_synctags
[2].ti_Tag
= aHidd_Sync_HSyncStart
;
91 ma_synctags
[2].ti_Data
= modecurrent
->dm_hstart
;
92 ma_synctags
[3].ti_Tag
= aHidd_Sync_HSyncEnd
;
93 ma_synctags
[3].ti_Data
= modecurrent
->dm_hend
;
94 ma_synctags
[4].ti_Tag
= aHidd_Sync_HTotal
;
95 ma_synctags
[4].ti_Data
= modecurrent
->dm_htotal
;
96 ma_synctags
[5].ti_Tag
= aHidd_Sync_VDisp
;
97 ma_synctags
[5].ti_Data
= modecurrent
->dm_vdisp
;
98 ma_synctags
[6].ti_Tag
= aHidd_Sync_VSyncStart
;
99 ma_synctags
[6].ti_Data
= modecurrent
->dm_vstart
;
100 ma_synctags
[7].ti_Tag
= aHidd_Sync_VSyncEnd
;
101 ma_synctags
[7].ti_Data
= modecurrent
->dm_vend
;
102 ma_synctags
[8].ti_Tag
= aHidd_Sync_VTotal
;
103 ma_synctags
[8].ti_Data
= modecurrent
->dm_vtotal
;
104 ma_synctags
[9].ti_Tag
= aHidd_Sync_Description
;
105 ma_synctags
[9].ti_Data
= (IPTR
)modecurrent
->dm_descr
;
106 ma_synctags
[10].ti_Tag
= TAG_DONE
;
108 ma_synctags
= (struct TagItem
*)&ma_synctags
[11];
111 ma_syncs
[i
].ti_Tag
= TAG_DONE
;
114 #if defined(DEBUGMODEARRAY)
117 ma_syncs
= (struct TagItem
*)modearray
;
118 while (ma_syncs
->ti_Tag
!= TAG_DONE
)
120 D(bug("[VideoCoreGfx] %s: 0x%p: %08x, %08x\n", __PRETTY_FUNCTION__
, ma_syncs
, ma_syncs
->ti_Tag
, ma_syncs
->ti_Data
));
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
[] =
140 { aHidd_Gfx_ModeTags
, (IPTR
)NULL
},
141 { aHidd_Name
, (IPTR
)"vc4gfx.hidd" },
142 { aHidd_HardwareName
, (IPTR
)"VideoCore4 Display Adaptor" },
143 { aHidd_ProducerName
, (IPTR
)"Broadcom Corporation" },
144 { TAG_MORE
, (IPTR
)msg
->attrList
}
146 struct pRoot_New gfxmsg_New
;
148 struct List vc_modelist
;
149 APTR vc_modearray
, vc_pixfmts
;
151 EnterFunc(bug("VideoCoreGfx::New()\n"));
153 NewList(&vc_modelist
);
155 FNAME_SUPPORT(SDTV_SyncGen
)(&vc_modelist
, cl
);
156 FNAME_SUPPORT(HDMI_SyncGen
)(&vc_modelist
, cl
);
157 vc_pixfmts
= FNAME_SUPPORT(GenPixFmts
)(cl
);
159 if ((vc_modearray
= FNAME_SUPPORT(GenModeArray
)(cl
, o
, &vc_modelist
, (struct TagItem
*)vc_pixfmts
)) != NULL
)
161 D(bug("[VideoCoreGfx] VideoCoreGfx::New: Generated Mode Array @ 0x%p\n", vc_modearray
));
163 gfxmsg_tags
[0].ti_Data
= (IPTR
)vc_modearray
;
165 gfxmsg_New
.mID
= msg
->mID
;
166 gfxmsg_New
.attrList
= gfxmsg_tags
;
169 D(bug("[VideoCoreGfx] VideoCoreGfx::New: Creating object [cl:0x%p, o:0x%p, msg:0x%p]\n", cl
, o
, msg
));
171 if ((self
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
)) != NULL
)
173 D(bug("[VideoCoreGfx] VideoCoreGfx::New: Storing reference to self in staticdata\n"));
174 XSD(cl
)->vcsd_VideoCoreGfxInstance
= self
;
176 FNAME_SUPPORT(DestroyModeArray
)(&vc_modelist
, vc_modearray
);
179 ReturnPtr("VideoCoreGfx::New: Obj", OOP_Object
*, self
);
182 VOID
MNAME_ROOT(Dispose
)(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
184 D(bug("[VideoCoreGfx] VideoCoreGfx::Dispose()\n"));
186 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
189 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
194 // D(bug("[VideoCoreGfx] VideoCoreGfx::Get()\n"));
196 if (IS_GFX_ATTR(msg
->attrID
, idx
))
200 case aoHidd_Gfx_MemorySize
:
201 *msg
->storage
= (IPTR
)(XSD(cl
)->vcsd_GPUMemManage
.mhe_MemHeader
.mh_Upper
- XSD(cl
)->vcsd_GPUMemManage
.mhe_MemHeader
.mh_Lower
);
207 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
210 OOP_Object
*MNAME_GFX(CreateObject
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CreateObject
*msg
)
212 OOP_Object
*object
= NULL
;
214 EnterFunc(bug("VideoCoreGfx::CreateObject()\n"));
216 if (msg
->cl
== XSD(cl
)->vcsd_basebm
)
220 struct TagItem newbm_tags
[2] =
223 {TAG_MORE
, (IPTR
)msg
->attrList
}
225 struct pHidd_Gfx_CreateObject newbm_msg
;
227 displayable
= (BOOL
)GetTagData(aHidd_BitMap_Displayable
, FALSE
, msg
->attrList
);
228 framebuffer
= (BOOL
)GetTagData(aHidd_BitMap_FrameBuffer
, FALSE
, msg
->attrList
);
231 D(bug("[VideoCoreGfx] VideoCoreGfx::CreateObject: Using OnScreenBM\n"));
232 newbm_tags
[0].ti_Tag
= aHidd_BitMap_ClassPtr
;
233 newbm_tags
[0].ti_Data
= (IPTR
)XSD(cl
)->vcsd_VideoCoreGfxOnBMClass
;
237 /* Non-displayable friends of our bitmaps are plain chunky bitmaps */
238 OOP_Object
*friend = (OOP_Object
*)GetTagData(aHidd_BitMap_Friend
, 0, msg
->attrList
);
240 if (displayable
|| (friend && (OOP_OCLASS(friend) == XSD(cl
)->vcsd_VideoCoreGfxOnBMClass
)))
242 D(bug("[VideoCoreGfx] VideoCoreGfx::CreateObject: Using OffScreenBM (ChunkyBM)\n"));
243 newbm_tags
[0].ti_Tag
= aHidd_BitMap_ClassID
;
244 newbm_tags
[0].ti_Data
= (IPTR
)CLID_Hidd_ChunkyBM
;
248 newbm_msg
.mID
= msg
->mID
;
249 newbm_msg
.cl
= msg
->cl
;
250 newbm_msg
.attrList
= newbm_tags
;
252 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)&newbm_msg
);
255 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
257 ReturnPtr("VideoCoreGfx::CreateObject: Obj", OOP_Object
*, object
);