revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-native / hidd / vgagfx / vgagfx_init.c
blob9b613f191485c209580fd18a8665ea8067e59763
1 /*
2 Copyright © 1995-2017, 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 LC_LIBDEFS_FILE
24 #undef csd
26 extern struct vgaModeDesc vgaDefMode[];
28 #undef SDEBUG
29 #undef DEBUG
30 #define DEBUG 0
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;
41 BOOL res = FALSE;
42 int i;
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 },
52 /* Private bases */
53 { IID_Hidd_BitMap_VGA, &HiddVGABitMapAB },
54 { NULL, NULL }
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"));
61 return FALSE;
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);
73 ACPICABase = NULL;
74 return FALSE;
76 CloseLibrary(ACPICABase);
77 ACPICABase = NULL;
80 InitSemaphore(&csd->sema);
81 InitSemaphore(&csd->HW_acc);
82 NEWLIST(&csd->modelist);
84 if (!OOP_ObtainAttrBases(abd))
85 return FALSE;
87 /* Insert default videomodes */
89 for (i=0; i < NUM_MODES; i++)
91 entry = AllocMem(sizeof(struct vgaModeEntry),MEMF_CLEAR|MEMF_PUBLIC);
92 if (entry)
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);
108 if (!GfxBase)
110 D(bug("[VGAGfx] Failed to open graphics.library!\n"));
112 return FALSE;
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
121 * is installed.
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));
127 if (!i)
129 /* We use ourselves, and no one else does */
130 LIBBASE->library.lib_OpenCnt = 1;
131 res = TRUE;
134 CloseLibrary(&GfxBase->LibNode);
135 return res;
138 ADD2INITLIB(VGAGfx_Init, 0)