2 Copyright 2010, The AROS Development Team. All rights reserved.
6 #include "gallium_intern.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
))
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
);
34 if (IsVersionMatching(requestedinterfaceversion
, driver
, GalliumBase
))
38 /* Failed version check */
39 OOP_DisposeObject(driver
);
44 /* 2. Nouveau fails,try the next best...*/
45 driver
= OOP_NewObject(NULL
, "hidd.gallium.i915", NULL
);
48 if (IsVersionMatching(requestedinterfaceversion
, driver
, GalliumBase
)){
53 /* Failed version check */
54 OOP_DisposeObject(driver
);
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
);
68 if (IsVersionMatching(requestedinterfaceversion
, driver
, GalliumBase
))
72 /* Failed version check */
73 OOP_DisposeObject(driver
);
78 /* Failed. Close library */
79 CloseLibrary(GB(GalliumBase
)->drivermodule
);
80 GB(GalliumBase
)->drivermodule
= NULL
;