2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: VGA Gfx Hidd for standalone AROS
9 #define __OOP_NOATTRBASES__
11 #include <aros/symbolsets.h>
12 #include <exec/lists.h>
13 #include <graphics/driver.h>
14 #include <graphics/gfxbase.h>
16 #include <utility/utility.h>
17 #include <proto/acpica.h>
18 #include <proto/exec.h>
19 #include <proto/graphics.h>
20 #include <proto/oop.h>
22 #include LC_LIBDEFS_FILE
26 extern struct vgaModeDesc vgaDefMode
[];
31 #include <aros/debug.h>
33 /* ACPICABase is optional */
34 struct Library
*ACPICABase
= NULL
;
36 static int VGAGfx_Init(LIBBASETYPEPTR LIBBASE
)
38 struct GfxBase
*GfxBase
;
39 struct VGAGfx_staticdata
*csd
= &LIBBASE
->vsd
;
40 struct vgaModeEntry
*entry
;
44 struct OOP_ABDescr abd
[] =
46 { IID_Hidd
, &HiddAttrBase
},
47 { IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
48 { IID_Hidd_ChunkyBM
, &HiddChunkyBMAttrBase
},
49 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
50 { IID_Hidd_Gfx
, &HiddGfxAttrBase
},
51 { IID_Hidd_Sync
, &HiddSyncAttrBase
},
53 { IID_Hidd_BitMap_VGA
, &HiddVGABitMapAB
},
57 /* We are not compatible with VESA driver */
58 if (OOP_FindClass("hidd.gfx.vesa"))
60 D(bug("[VGAGfx] VESA driver found, not initializing VGA\n"));
64 if ((ACPICABase
= OpenLibrary("acpica.library", 0)))
66 ACPI_TABLE_FADT
*fadt
;
68 if ((AcpiGetTable("FACP", 1, (ACPI_TABLE_HEADER
**)&fadt
) == AE_OK
) &&
69 (fadt
->BootFlags
& ACPI_FADT_NO_VGA
))
71 D(bug("[VGAGfx] Disabled by ACPI\n"));
72 CloseLibrary(ACPICABase
);
76 CloseLibrary(ACPICABase
);
80 InitSemaphore(&csd
->sema
);
81 InitSemaphore(&csd
->HW_acc
);
82 NEWLIST(&csd
->modelist
);
84 if (!OOP_ObtainAttrBases(abd
))
87 /* Insert default videomodes */
89 for (i
=0; i
< NUM_MODES
; i
++)
91 entry
= AllocMem(sizeof(struct vgaModeEntry
),MEMF_CLEAR
|MEMF_PUBLIC
);
94 entry
->Desc
=&(vgaDefMode
[i
]);
95 ADDHEAD(&csd
->modelist
,entry
);
96 D(bug("Added default mode: %s\n", entry
->Desc
->name
));
100 D(bug("[VGAGfx] Init: Everything OK, installing driver\n"));
103 * Open graphics.library ourselves because we will close it
104 * after adding the driver.
105 * Autoinit code would close it only upon driver expunge.
107 GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 41);
110 D(bug("[VGAGfx] Failed to open graphics.library!\n"));
115 csd
->basebm
= OOP_FindClass(CLID_Hidd_BitMap
);
118 * It is unknown (and no way to know) what hardware part this driver uses.
119 * In order to avoid conflicts with disk-based native-mode hardware
120 * drivers it needs to be removed from the system when some other driver
122 * This is done by graphics.library if DDRV_BootMode is set to TRUE.
124 i
= AddDisplayDriver(csd
->vgaclass
, NULL
, DDRV_BootMode
, TRUE
, TAG_DONE
);
126 D(bug("[VGAGfx] AddDisplayDriver() result: %u\n", i
));
129 /* We use ourselves, and no one else does */
130 LIBBASE
->library
.lib_OpenCnt
= 1;
134 CloseLibrary(&GfxBase
->LibNode
);
138 ADD2INITLIB(VGAGfx_Init
, 0)