2 Copyright 2009, The AROS Development Team. All rights reserved.
8 #include "drm_global.h"
10 struct drm_driver
*current_drm_driver
= NULL
;
12 int drm_lastclose(struct drm_device
* dev
)
14 if (dev
->driver
->lastclose
)
15 dev
->driver
->lastclose(dev
);
18 drm_irq_uninstall(dev
);
23 static void drm_cleanup(struct drm_device
* dev
)
27 if (dev
->driver
->unload
)
28 dev
->driver
->unload(dev
);
30 if (drm_core_has_AGP(dev
) && dev
->agp
)
37 void drm_exit(struct drm_driver
* driver
)
39 drm_cleanup(driver
->dev
);
41 drm_aros_pci_shutdown(driver
);
43 HIDDNouveauFree(driver
->dev
->pdev
);
44 HIDDNouveauFree(driver
->dev
);
46 current_drm_driver
= NULL
;
49 static int drm_init_device(struct drm_driver
* driver
)
51 /* If this function is called, the card was already found */
52 driver
->dev
= HIDDNouveauAlloc(sizeof(struct drm_device
));
53 struct drm_device
* dev
= driver
->dev
;
56 INIT_LIST_HEAD(&dev
->maplist
);
58 InitSemaphore(&dev
->struct_mutex
.semaphore
);
60 dev
->pci_vendor
= driver
->VendorID
;
61 dev
->pci_device
= driver
->ProductID
;
62 dev
->pdev
= HIDDNouveauAlloc(sizeof(struct pci_dev
));
63 dev
->pdev
->oopdev
= driver
->pciDevice
;
66 if (drm_core_has_AGP(dev
)) {
67 if (drm_device_is_agp(dev
))
68 dev
->agp
= drm_agp_init(dev
);
69 if (drm_core_check_feature(dev
, DRIVER_REQUIRE_AGP
)
70 && (dev
->agp
== NULL
)) {
71 DRM_ERROR("Cannot initialize the agpgart module.\n");
76 if (driver
->driver_features
& DRIVER_GEM
) {
77 if (drm_gem_init(dev
)) {
78 DRM_ERROR("Cannot initialize graphics execution "
84 if (!dev
->driver
->load
)
87 ret
= dev
->driver
->load(dev
, 0);
91 if (dev
->driver
->firstopen
)
93 ret
= dev
->driver
->firstopen(dev
);
101 int drm_init(struct drm_driver
* driver
)
105 if (drm_aros_pci_init(driver
))
108 if (drm_aros_pci_find_supported_video_card(driver
))
111 bug("\003\n"); /* Tell vga text mode debug output to die */
113 if (drm_init_device(driver
))
119 current_drm_driver
= driver
;