Wanderer/Info: fix compilation
[AROS.git] / arch / all-native / hidd / vga / vga_init.c
blob183c790218ab5489e20d4f336126e41499ff1135
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: vga gfx Hidd for standalone AROS
6 Lang: english
7 */
9 #define __OOP_NOATTRBASES__
11 #include <aros/symbolsets.h>
12 #include <exec/lists.h>
13 #include <graphics/driver.h>
14 #include <graphics/gfxbase.h>
15 #include <oop/oop.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 "vga.h"
23 #include "vgaclass.h"
25 #include LC_LIBDEFS_FILE
27 extern struct vgaModeDesc vgaDefMode[];
29 #undef SDEBUG
30 #undef DEBUG
31 #define DEBUG 0
32 #include <aros/debug.h>
34 /* ACPICABase is optional */
35 struct Library *ACPICABase = NULL;
37 OOP_AttrBase HiddBitMapAttrBase;
38 OOP_AttrBase HiddChunkyBMAttrBase;
39 OOP_AttrBase HiddPixFmtAttrBase;
40 OOP_AttrBase HiddGfxAttrBase;
41 OOP_AttrBase HiddSyncAttrBase;
42 OOP_AttrBase HiddVGABitMapAB;
44 static struct OOP_ABDescr abd[] =
46 { IID_Hidd_BitMap, &HiddBitMapAttrBase },
47 { IID_Hidd_ChunkyBM, &HiddChunkyBMAttrBase },
48 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
49 { IID_Hidd_Gfx, &HiddGfxAttrBase },
50 { IID_Hidd_Sync, &HiddSyncAttrBase },
51 /* Private bases */
52 { IID_Hidd_BitMap_VGA, &HiddVGABitMapAB },
53 { NULL, NULL }
56 static int PCVGA_Init(LIBBASETYPEPTR LIBBASE)
58 struct GfxBase *GfxBase;
59 struct vga_staticdata *xsd = &LIBBASE->vsd;
60 struct vgaModeEntry *entry;
61 BOOL res = FALSE;
62 int i;
64 /* We are not compatible with VESA driver */
65 if (OOP_FindClass("hidd.gfx.vesa"))
67 D(bug("[VGA] VESA driver found, not initializing VGA\n"));
68 return FALSE;
71 if ((ACPICABase = OpenLibrary("acpica.library", 0)))
73 ACPI_TABLE_FADT *fadt;
75 if ((AcpiGetTable("FACP", 1, (ACPI_TABLE_HEADER **)&fadt) == AE_OK) &&
76 (fadt->BootFlags & ACPI_FADT_NO_VGA))
78 D(bug("[VGA] Disabled by ACPI\n"));
79 CloseLibrary(ACPICABase);
80 ACPICABase = NULL;
81 return FALSE;
83 CloseLibrary(ACPICABase);
84 ACPICABase = NULL;
87 InitSemaphore(&xsd->sema);
88 InitSemaphore(&xsd->HW_acc);
89 NEWLIST(&xsd->modelist);
91 if (!OOP_ObtainAttrBases(abd))
92 return FALSE;
94 /* Insert default videomodes */
96 for (i=0; i < NUM_MODES; i++)
98 entry = AllocMem(sizeof(struct vgaModeEntry),MEMF_CLEAR|MEMF_PUBLIC);
99 if (entry)
101 entry->Desc=&(vgaDefMode[i]);
102 ADDHEAD(&xsd->modelist,entry);
103 D(bug("Added default mode: %s\n", entry->Desc->name));
107 D(bug("[VGA] Init: Everything OK, installing driver\n"));
110 * Open graphics.library ourselves because we will close it
111 * after adding the driver.
112 * Autoinit code would close it only upon driver expunge.
114 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 41);
115 if (!GfxBase)
117 D(bug("[VGA] Failed to open graphics.library!\n"));
119 return FALSE;
122 xsd->basebm = OOP_FindClass(CLID_Hidd_BitMap);
125 * It is unknown (and no way to know) what hardware part this driver uses.
126 * In order to avoid conflicts with disk-based native-mode hardware
127 * drivers it needs to be removed from the system when some other driver
128 * is installed.
129 * This is done by graphics.library if DDRV_BootMode is set to TRUE.
131 i = AddDisplayDriver(xsd->vgaclass, NULL, DDRV_BootMode, TRUE, TAG_DONE);
133 D(bug("[VGA] AddDisplayDriver() result: %u\n", i));
134 if (!i)
136 /* We use ourselves, and no one else does */
137 LIBBASE->library.lib_OpenCnt = 1;
138 res = TRUE;
141 CloseLibrary(&GfxBase->LibNode);
142 return res;
145 ADD2INITLIB(PCVGA_Init, 0)