grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / gallium / gallium_func.c
blob27ccec3153bcf42144227b72f58b7b604de63765
1 /*
2 Copyright 2010, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "gallium_intern.h"
7 #include <proto/oop.h>
8 #include <aros/debug.h>
10 #undef HiddGalliumAttrBase
11 #define HiddGalliumAttrBase GB(GalliumBase)->galliumAttrBase
13 BOOL IsVersionMatching(ULONG version, OOP_Object * driver, struct Library * GalliumBase)
15 IPTR galliuminterfaceversion = 0;
17 if ((!driver) || (!GalliumBase))
18 return FALSE;
20 OOP_GetAttr(driver, aHidd_Gallium_GalliumInterfaceVersion, &galliuminterfaceversion);
22 return (version == (ULONG)galliuminterfaceversion);
25 OOP_Object * SelectGalliumDriver(ULONG requestedinterfaceversion, struct Library * GalliumBase)
27 OOP_Object * driver = NULL;
29 /* 1. Let see if we can create hidd.gallium.nouveau object. This will
30 only work if the nouveau.hidd is actually loaded and used */
31 driver = OOP_NewObject(NULL, "hidd.gallium.nouveau", NULL);
32 if (driver)
34 if (IsVersionMatching(requestedinterfaceversion, driver, GalliumBase))
35 return driver;
36 else
38 /* Failed version check */
39 OOP_DisposeObject(driver);
40 driver = NULL;
44 /* 2. Nouveau fails,try the next best...*/
45 driver = OOP_NewObject(NULL, "hidd.gallium.i915", NULL);
46 if (driver)
48 if (IsVersionMatching(requestedinterfaceversion, driver, GalliumBase)){
49 return driver;
51 else
53 /* Failed version check */
54 OOP_DisposeObject(driver);
55 driver = NULL;
59 /* 3. Everything else failed. Let's try loading softpipe */
60 if (!GB(GalliumBase)->drivermodule)
61 GB(GalliumBase)->drivermodule = OpenLibrary("softpipe.hidd", 9);
63 if (GB(GalliumBase)->drivermodule)
65 driver = OOP_NewObject(NULL, "hidd.gallium.softpipe", NULL);
66 if (driver)
68 if (IsVersionMatching(requestedinterfaceversion, driver, GalliumBase))
69 return driver;
70 else
72 /* Failed version check */
73 OOP_DisposeObject(driver);
74 driver = NULL;
78 /* Failed. Close library */
79 CloseLibrary(GB(GalliumBase)->drivermodule);
80 GB(GalliumBase)->drivermodule = NULL;
83 return NULL;