wip prep commit in lieu of gfx subsystem update changes.
[AROS.git] / arch / all-linux / hidd / linuxfb / linuxfbgfx_startup.c
blobc388faa2a418781061828a08aecf26aecd0a73f2
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: gfx Hidd for linux framebuffer
6 Lang: english
7 */
9 /*
10 * A newstyle startup code for resident display drivers.
12 * Now it's the job of the driver to add ifself to the system.
13 * The driver does not have to be a library anymore, it can be
14 * plain executable which is started from DEVS:Monitors.
16 * The job of driver startup code is to create all necessary
17 * classes (driver class and bitmap class) and create as many
18 * driver objects as possible. Every object needs to be given
19 * to AddDisplayDriverA() in order to become functional.
21 * When the transition completes, kludges from bootmenu and
22 * dosboot will be removed. Noone will care about library
23 * open etc.
26 #include <aros/debug.h>
27 #include <aros/symbolsets.h>
28 #include <graphics/gfxbase.h>
29 #include <proto/exec.h>
30 #include <proto/graphics.h>
31 #include <proto/oop.h>
32 #include <hidd/unixio.h>
34 #include LC_LIBDEFS_FILE
36 /* Prevent redefinition of struct timeval */
37 #define timeval sys_timeval
39 /* avoid conflicts between our __unused define and the ones that might come in
40 via fcntl.h */
41 #undef __unused
42 #include <fcntl.h>
44 #undef timeval
46 #undef LSD
47 #define LSD(cl) (&LIBBASE->lsd)
49 static int LinuxFB_Startup(LIBBASETYPEPTR LIBBASE)
51 int res = FALSE;
52 struct GfxBase *GfxBase;
53 ULONG err;
54 struct TagItem gfx_attrs[] =
56 {aHidd_LinuxFB_File, 0},
57 {TAG_DONE , 0}
60 D(bug("[LinuxFB] LinuxFB_Startup()\n"));
62 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 41);
63 D(bug("[LinuxFB_Startup] GfxBase 0x%p\n", GfxBase));
64 if (!GfxBase)
65 return FALSE;
67 /* TODO: In future we will support more framebuffers */
68 gfx_attrs[0].ti_Data = Hidd_UnixIO_OpenFile(LIBBASE->lsd.unixio, "/dev/fb0", O_RDWR, 0, NULL);
69 if (gfx_attrs[0].ti_Data == -1)
71 CloseLibrary(&GfxBase->LibNode);
72 return FALSE;
76 * In future we will be able to call this several times in a loop.
77 * This will allow us to create several displays.
79 err = AddDisplayDriverA(LIBBASE->lsd.gfxclass, gfx_attrs, NULL);
81 D(bug("[LinuxFB_Startup] AddDisplayDriver() result: %u\n", err));
83 if (!err)
85 res = TRUE;
86 /* We use ourselves, and noone else */
87 LIBBASE->library.lib_OpenCnt = 1;
90 CloseLibrary(&GfxBase->LibNode);
92 return res;
95 static int LinuxFB_Test(LIBBASETYPEPTR LIBBASE)
97 OOP_Class *x11 = OOP_FindClass("hidd.gfx.x11");
99 D(bug("[LinuxFB_Test] X11 class 0x%p\n", x11));
100 return x11 ? FALSE : TRUE;
103 /* This routine must be called AFTER everything all other initialization was run */
104 ADD2INITLIB(LinuxFB_Startup, 10);
106 ADD2INITLIB(LinuxFB_Test, -10);