agp/drm: Adapt according to the recent pci code change
[dragonfly.git] / sys / dev / drm / savage_drv.c
blob75cc59e19baf627908d735d9c3bfd02cbe79461a
1 /* savage_drv.c -- Savage DRI driver
2 */
3 /*-
4 * Copyright 2005 Eric Anholt
5 * All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Authors:
26 * Eric Anholt <anholt@FreeBSD.org>
29 #include "dev/drm/drmP.h"
30 #include "dev/drm/drm.h"
31 #include "dev/drm/savage_drm.h"
32 #include "dev/drm/savage_drv.h"
33 #include "dev/drm/drm_pciids.h"
35 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
36 static drm_pci_id_list_t savage_pciidlist[] = {
37 savage_PCI_IDS
40 static void savage_configure(struct drm_device *dev)
42 dev->driver->driver_features =
43 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
44 DRIVER_HAVE_DMA;
46 dev->driver->buf_priv_size = sizeof(drm_savage_buf_priv_t);
47 dev->driver->load = savage_driver_load;
48 dev->driver->firstopen = savage_driver_firstopen;
49 dev->driver->lastclose = savage_driver_lastclose;
50 dev->driver->unload = savage_driver_unload;
51 dev->driver->reclaim_buffers_locked = savage_reclaim_buffers;
52 dev->driver->dma_ioctl = savage_bci_buffers;
54 dev->driver->ioctls = savage_ioctls;
55 dev->driver->max_ioctl = savage_max_ioctl;
57 dev->driver->name = DRIVER_NAME;
58 dev->driver->desc = DRIVER_DESC;
59 dev->driver->date = DRIVER_DATE;
60 dev->driver->major = DRIVER_MAJOR;
61 dev->driver->minor = DRIVER_MINOR;
62 dev->driver->patchlevel = DRIVER_PATCHLEVEL;
65 static int
66 savage_probe(device_t kdev)
68 return drm_probe(kdev, savage_pciidlist);
71 static int
72 savage_attach(device_t kdev)
74 struct drm_device *dev = device_get_softc(kdev);
76 dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
77 M_WAITOK | M_ZERO);
79 savage_configure(dev);
81 return drm_attach(kdev, savage_pciidlist);
84 static int
85 savage_detach(device_t kdev)
87 struct drm_device *dev = device_get_softc(kdev);
88 int ret;
90 ret = drm_detach(kdev);
92 free(dev->driver, DRM_MEM_DRIVER);
94 return ret;
97 static device_method_t savage_methods[] = {
98 /* Device interface */
99 DEVMETHOD(device_probe, savage_probe),
100 DEVMETHOD(device_attach, savage_attach),
101 DEVMETHOD(device_detach, savage_detach),
103 { 0, 0 }
106 static driver_t savage_driver = {
107 "drm",
108 savage_methods,
109 sizeof(struct drm_device)
112 extern devclass_t drm_devclass;
113 DRIVER_MODULE(savage, vgapci, savage_driver, drm_devclass, 0, 0);
114 MODULE_DEPEND(savage, drm, 1, 1, 1);