Merge commit 'crater/master'
[dragonfly.git] / sys / dev / drm / mach64_drv.c
blob8abf99097d082118e8e8d68b4d97d789f00965b6
1 /* mach64_drv.c -- ATI Rage 128 driver -*- linux-c -*-
2 * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
3 */
4 /*-
5 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
7 * All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice (including the next
17 * paragraph) shall be included in all copies or substantial portions of the
18 * Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
28 * Authors:
29 * Rickard E. (Rik) Faith <faith@valinux.com>
30 * Gareth Hughes <gareth@valinux.com>
33 #include <sys/types.h>
35 #include "dev/drm/drmP.h"
36 #include "dev/drm/drm.h"
37 #include "dev/drm/mach64_drm.h"
38 #include "dev/drm/mach64_drv.h"
39 #include "dev/drm/drm_pciids.h"
41 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
42 static drm_pci_id_list_t mach64_pciidlist[] = {
43 mach64_PCI_IDS
46 static void mach64_configure(struct drm_device *dev)
48 dev->driver->driver_features =
49 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
50 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ;
52 dev->driver->buf_priv_size = 1; /* No dev_priv */
53 dev->driver->load = mach64_driver_load;
54 dev->driver->lastclose = mach64_driver_lastclose;
55 dev->driver->get_vblank_counter = mach64_get_vblank_counter;
56 dev->driver->enable_vblank = mach64_enable_vblank;
57 dev->driver->disable_vblank = mach64_disable_vblank;
58 dev->driver->irq_preinstall = mach64_driver_irq_preinstall;
59 dev->driver->irq_postinstall = mach64_driver_irq_postinstall;
60 dev->driver->irq_uninstall = mach64_driver_irq_uninstall;
61 dev->driver->irq_handler = mach64_driver_irq_handler;
62 dev->driver->dma_ioctl = mach64_dma_buffers;
64 dev->driver->ioctls = mach64_ioctls;
65 dev->driver->max_ioctl = mach64_max_ioctl;
67 dev->driver->name = DRIVER_NAME;
68 dev->driver->desc = DRIVER_DESC;
69 dev->driver->date = DRIVER_DATE;
70 dev->driver->major = DRIVER_MAJOR;
71 dev->driver->minor = DRIVER_MINOR;
72 dev->driver->patchlevel = DRIVER_PATCHLEVEL;
75 static int
76 mach64_probe(device_t kdev)
78 return drm_probe(kdev, mach64_pciidlist);
81 static int
82 mach64_attach(device_t kdev)
84 struct drm_device *dev = device_get_softc(kdev);
86 dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
87 M_WAITOK | M_ZERO);
89 mach64_configure(dev);
91 return drm_attach(kdev, mach64_pciidlist);
94 int
95 mach64_driver_load(struct drm_device * dev, unsigned long flags)
97 return drm_vblank_init(dev, 1);
100 static int
101 mach64_detach(device_t kdev)
103 struct drm_device *dev = device_get_softc(kdev);
104 int ret;
106 ret = drm_detach(kdev);
108 free(dev->driver, DRM_MEM_DRIVER);
110 return ret;
113 static device_method_t mach64_methods[] = {
114 /* Device interface */
115 DEVMETHOD(device_probe, mach64_probe),
116 DEVMETHOD(device_attach, mach64_attach),
117 DEVMETHOD(device_detach, mach64_detach),
119 { 0, 0 }
122 static driver_t mach64_driver = {
123 "drm",
124 mach64_methods,
125 sizeof(struct drm_device)
128 extern devclass_t drm_devclass;
129 DRIVER_MODULE(mach64, vgapci, mach64_driver, drm_devclass, 0, 0);
130 MODULE_DEPEND(mach64, drm, 1, 1, 1);