Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / i386-pc / drivers / vga.hidd / onbitmap.c
blobb0c42a0cbfcb0e17b09ad7612ae98bc8897c8abf
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Bitmap class for VGA hidd.
6 Lang: English.
7 */
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
14 #include <exec/memory.h>
15 #include <exec/lists.h>
17 #include <graphics/rastport.h>
18 #include <graphics/gfx.h>
19 #include <oop/oop.h>
21 #include <aros/symbolsets.h>
23 #include <hidd/graphics.h>
25 #include <assert.h>
27 #include "vgahw.h"
28 #include "vga.h"
29 #include "vgaclass.h"
31 #include "bitmap.h"
33 #include LC_LIBDEFS_FILE
35 /* Don't initialize static variables with "=0", otherwise they go into DATA segment */
37 static OOP_AttrBase HiddBitMapAttrBase;
38 static OOP_AttrBase HiddPixFmtAttrBase;
39 static OOP_AttrBase HiddGfxAttrBase;
40 static OOP_AttrBase HiddSyncAttrBase;
41 static OOP_AttrBase HiddVGAGfxAB;
42 static OOP_AttrBase HiddVGABitMapAB;
44 static struct OOP_ABDescr attrbases[] =
46 { IID_Hidd_BitMap, &HiddBitMapAttrBase },
47 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
48 { IID_Hidd_Gfx, &HiddGfxAttrBase },
49 { IID_Hidd_Sync, &HiddSyncAttrBase },
50 /* Private bases */
51 { IID_Hidd_VGAgfx, &HiddVGAGfxAB },
52 { IID_Hidd_VGABitMap, &HiddVGABitMapAB },
53 { NULL, NULL }
56 void vgaRestore(struct vgaHWRec *, BOOL onlyDAC);
57 void * vgaSave(struct vgaHWRec *);
58 int vgaInitMode(struct vgaModeDesc *, struct vgaHWRec *);
59 void vgaLoadPalette(struct vgaHWRec *, unsigned char *);
61 void free_onbmclass(struct vga_staticdata *);
63 #define MNAME_ROOT(x) PCVGAOnBM__Root__ ## x
64 #define MNAME_BM(x) PCVGAOnBM__Hidd_BitMap__ ## x
66 #define SDEBUG 0
67 #define DEBUG 0
68 #include <aros/debug.h>
70 #define OnBitmap 1
71 #include "bitmap_common.c"
73 #if 0
75 void clr();
76 void scr_RawPutChars(char *, int);
78 char tab[127];
80 #define rkprintf(x...) scr_RawPutChars(tab, sprintf(tab, x))
82 #else
84 #define clr() /* eps */
85 #define rkprintf(x...) /* eps */
87 #endif
89 /*********** BitMap::New() *************************************/
91 OOP_Object *PCVGAOnBM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
93 EnterFunc(bug("VGAGfx.BitMap::New()\n"));
95 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
96 if (o)
98 struct bitmap_data *data;
100 OOP_Object *pf;
102 IPTR width, height, depth;
104 data = OOP_INST_DATA(cl, o);
106 /* clear all data */
107 memset(data, 0, sizeof(struct bitmap_data));
109 /* Get attr values */
110 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
111 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
112 OOP_GetAttr(o, aHidd_BitMap_PixFmt, &pf);
113 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
115 ASSERT (width != 0 && height != 0 && depth != 0);
118 We must only create depths that are supported by the friend drawable
119 Currently we only support the default depth
122 data->width = width;
123 data->height = height;
124 data->bpp = depth;
125 data->Regs = AllocVec(sizeof(struct vgaHWRec),MEMF_PUBLIC|MEMF_CLEAR);
126 data->disp = -1;
127 width=(width+15) & ~15;
130 Here there is brand new method of getting pixelclock data.
131 It was introduced here to make the code more portable. Besides
132 it may now be used as a base for creating other low level
133 video drivers
136 if (data->Regs)
138 data->VideoData = AllocVec(width*height,MEMF_PUBLIC|MEMF_CLEAR);
139 if (data->VideoData)
141 struct vgaModeDesc mode;
142 HIDDT_ModeID modeid;
143 OOP_Object *sync;
144 OOP_Object *pf;
145 ULONG pixelc;
147 /* We should be able to get modeID from the bitmap */
148 OOP_GetAttr(o, aHidd_BitMap_ModeID, &modeid);
150 if (modeid != vHidd_ModeID_Invalid)
152 struct Box box = {0, 0, width-1, height-1};
154 /* Get Sync and PixelFormat properties */
155 HIDD_Gfx_GetMode(XSD(cl)->vgahidd, modeid, &sync, &pf);
157 mode.Width = width;
158 mode.Height = height;
159 mode.Depth = depth;
160 OOP_GetAttr(sync, aHidd_Sync_PixelClock, &pixelc);
162 mode.clock = (pixelc > 26000000) ? 1 : 0;
163 mode.Flags = 0;
164 mode.HSkew = 0;
165 OOP_GetAttr(sync, aHidd_Sync_HDisp, &mode.HDisplay);
166 OOP_GetAttr(sync, aHidd_Sync_VDisp, &mode.VDisplay);
167 OOP_GetAttr(sync, aHidd_Sync_HSyncStart, &mode.HSyncStart);
168 OOP_GetAttr(sync, aHidd_Sync_VSyncStart, &mode.VSyncStart);
169 OOP_GetAttr(sync, aHidd_Sync_HSyncEnd, &mode.HSyncEnd);
170 OOP_GetAttr(sync, aHidd_Sync_VSyncEnd, &mode.VSyncEnd);
171 OOP_GetAttr(sync, aHidd_Sync_HTotal, &mode.HTotal);
172 OOP_GetAttr(sync, aHidd_Sync_VTotal, &mode.VTotal);
174 ObtainSemaphore(&XSD(cl)->HW_acc);
176 /* Now, when the best display mode is chosen, we can build it */
177 vgaInitMode(&mode, data->Regs);
178 vgaLoadPalette(data->Regs,(unsigned char *)NULL);
181 Because of not defined BitMap_Show method show
182 bitmap immediately
185 vgaRestore(data->Regs, FALSE);
186 vgaRefreshArea(data, 1, &box);
188 ReleaseSemaphore(&XSD(cl)->HW_acc);
190 XSD(cl)->visible = data; /* Set created object as visible */
192 ReturnPtr("VGAGfx.BitMap::New()", OOP_Object *, o);
195 } /* if got data->VideoData */
196 FreeVec(data->Regs);
197 } /* if got data->Regs */
200 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
201 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
204 o = NULL;
205 } /* if created object */
207 ReturnPtr("VGAGfx.BitMap::New()", OOP_Object *, o);
210 /********** Bitmap::Dispose() ***********************************/
212 VOID PCVGAOnBM__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
214 struct bitmap_data *data = OOP_INST_DATA(cl, o);
215 EnterFunc(bug("VGAGfx.BitMap::Dispose()\n"));
217 if (data->VideoData)
218 FreeVec(data->VideoData);
219 if (data->Regs)
220 FreeVec(data->Regs);
222 OOP_DoSuperMethod(cl, o, msg);
224 ReturnVoid("VGAGfx.BitMap::Dispose");
227 /*** init_onbmclass *********************************************************/
229 static int PCVGAOnBM_Init(LIBBASETYPEPTR LIBBASE)
231 EnterFunc(bug("PCVGAOnBM_Init\n"));
233 ReturnInt("PCVGAOnBM_Init", ULONG, OOP_ObtainAttrBases(attrbases));
236 /*** expunge_onbmclass *******************************************************/
238 static int PCVGAOnBM_Expunge(LIBBASETYPEPTR LIBBASE)
240 EnterFunc(bug("PCVGAOnBM_Expunge\n"));
242 OOP_ReleaseAttrBases(attrbases);
243 ReturnInt("PCVGAOnBM_Expunge", int, TRUE);
246 /*****************************************************************************/
248 ADD2INITLIB(PCVGAOnBM_Init, 0)
249 ADD2EXPUNGELIB(PCVGAOnBM_Expunge, 0)