Sync with HEAD.
[dragonfly.git] / sys / dev / drm / savage_drv.c
blobc7edb60f1f3d7d712a5554cc981858d532617f80
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>
28 * $DragonFly: src/sys/dev/drm/savage_drv.c,v 1.1 2008/04/05 18:12:29 hasso Exp $
31 #include "drmP.h"
32 #include "drm.h"
33 #include "savage_drm.h"
34 #include "savage_drv.h"
35 #include "drm_pciids.h"
37 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
38 static drm_pci_id_list_t savage_pciidlist[] = {
39 savage_PCI_IDS
42 static void savage_configure(drm_device_t *dev)
44 dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t);
45 dev->driver.load = savage_driver_load;
46 dev->driver.firstopen = savage_driver_firstopen;
47 dev->driver.lastclose = savage_driver_lastclose;
48 dev->driver.unload = savage_driver_unload;
49 dev->driver.reclaim_buffers_locked = savage_reclaim_buffers;
50 dev->driver.dma_ioctl = savage_bci_buffers;
52 dev->driver.ioctls = savage_ioctls;
53 dev->driver.max_ioctl = savage_max_ioctl;
55 dev->driver.name = DRIVER_NAME;
56 dev->driver.desc = DRIVER_DESC;
57 dev->driver.date = DRIVER_DATE;
58 dev->driver.major = DRIVER_MAJOR;
59 dev->driver.minor = DRIVER_MINOR;
60 dev->driver.patchlevel = DRIVER_PATCHLEVEL;
62 dev->driver.use_agp = 1;
63 dev->driver.use_mtrr = 1;
64 dev->driver.use_pci_dma = 1;
65 dev->driver.use_dma = 1;
68 #if defined(__FreeBSD__) || defined(__DragonFly__)
69 static int
70 savage_probe(device_t dev)
72 return drm_probe(dev, savage_pciidlist);
75 static int
76 savage_attach(device_t nbdev)
78 drm_device_t *dev = device_get_softc(nbdev);
80 bzero(dev, sizeof(drm_device_t));
81 savage_configure(dev);
82 return drm_attach(nbdev, savage_pciidlist);
85 static device_method_t savage_methods[] = {
86 /* Device interface */
87 DEVMETHOD(device_probe, savage_probe),
88 DEVMETHOD(device_attach, savage_attach),
89 DEVMETHOD(device_detach, drm_detach),
91 { 0, 0 }
94 static driver_t savage_driver = {
95 "drm",
96 savage_methods,
97 sizeof(drm_device_t)
100 extern devclass_t drm_devclass;
101 #if __FreeBSD_version >= 700010
102 DRIVER_MODULE(savage, vgapci, savage_driver, drm_devclass, 0, 0);
103 #else
104 DRIVER_MODULE(savage, pci, savage_driver, drm_devclass, 0, 0);
105 #endif
106 MODULE_DEPEND(savage, drm, 1, 1, 1);
108 #elif defined(__NetBSD__) || defined(__OpenBSD__)
109 CFDRIVER_DECL(savage, DV_TTY, NULL);
110 #endif