2 Copyright © 1995-2015, 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>
25 #include LC_LIBDEFS_FILE
27 extern struct vgaModeDesc vgaDefMode
[];
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
},
52 { IID_Hidd_BitMap_VGA
, &HiddVGABitMapAB
},
56 static int PCVGA_Init(LIBBASETYPEPTR LIBBASE
)
58 struct GfxBase
*GfxBase
;
59 struct vga_staticdata
*xsd
= &LIBBASE
->vsd
;
60 struct vgaModeEntry
*entry
;
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"));
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
);
83 CloseLibrary(ACPICABase
);
87 InitSemaphore(&xsd
->sema
);
88 InitSemaphore(&xsd
->HW_acc
);
89 NEWLIST(&xsd
->modelist
);
91 if (!OOP_ObtainAttrBases(abd
))
94 /* Insert default videomodes */
96 for (i
=0; i
< NUM_MODES
; i
++)
98 entry
= AllocMem(sizeof(struct vgaModeEntry
),MEMF_CLEAR
|MEMF_PUBLIC
);
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);
117 D(bug("[VGA] Failed to open graphics.library!\n"));
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
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
));
136 /* We use ourselves, and no one else does */
137 LIBBASE
->library
.lib_OpenCnt
= 1;
141 CloseLibrary(&GfxBase
->LibNode
);
145 ADD2INITLIB(PCVGA_Init
, 0)