]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/dev/drm/mach64_drv.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / dev / drm / mach64_drv.c
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.
8  *
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:
15  *
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.
19  *
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.
27  *
28  * Authors:
29  *    Rickard E. (Rik) Faith <faith@valinux.com>
30  *    Gareth Hughes <gareth@valinux.com>
31  */
32
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35
36
37 #include <sys/types.h>
38
39 #include "dev/drm/drmP.h"
40 #include "dev/drm/drm.h"
41 #include "dev/drm/mach64_drm.h"
42 #include "dev/drm/mach64_drv.h"
43 #include "dev/drm/drm_pciids.h"
44
45 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
46 static drm_pci_id_list_t mach64_pciidlist[] = {
47         mach64_PCI_IDS
48 };
49
50 static void mach64_configure(struct drm_device *dev)
51 {
52         dev->driver->driver_features =
53             DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
54             DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ;
55
56         dev->driver->buf_priv_size      = 1; /* No dev_priv */
57         dev->driver->load               = mach64_driver_load;
58         dev->driver->lastclose          = mach64_driver_lastclose;
59         dev->driver->get_vblank_counter = mach64_get_vblank_counter;
60         dev->driver->enable_vblank      = mach64_enable_vblank;
61         dev->driver->disable_vblank     = mach64_disable_vblank;
62         dev->driver->irq_preinstall     = mach64_driver_irq_preinstall;
63         dev->driver->irq_postinstall    = mach64_driver_irq_postinstall;
64         dev->driver->irq_uninstall      = mach64_driver_irq_uninstall;
65         dev->driver->irq_handler        = mach64_driver_irq_handler;
66         dev->driver->dma_ioctl          = mach64_dma_buffers;
67
68         dev->driver->ioctls             = mach64_ioctls;
69         dev->driver->max_ioctl          = mach64_max_ioctl;
70
71         dev->driver->name               = DRIVER_NAME;
72         dev->driver->desc               = DRIVER_DESC;
73         dev->driver->date               = DRIVER_DATE;
74         dev->driver->major              = DRIVER_MAJOR;
75         dev->driver->minor              = DRIVER_MINOR;
76         dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
77 }
78
79 static int
80 mach64_probe(device_t kdev)
81 {
82         return drm_probe(kdev, mach64_pciidlist);
83 }
84
85 static int
86 mach64_attach(device_t kdev)
87 {
88         struct drm_device *dev = device_get_softc(kdev);
89
90         dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
91             M_WAITOK | M_ZERO);
92
93         mach64_configure(dev);
94
95         return drm_attach(kdev, mach64_pciidlist);
96 }
97
98 int
99 mach64_driver_load(struct drm_device * dev, unsigned long flags)
100 {
101         return drm_vblank_init(dev, 1);
102 }
103
104 static int
105 mach64_detach(device_t kdev)
106 {
107         struct drm_device *dev = device_get_softc(kdev);
108         int ret;
109
110         ret = drm_detach(kdev);
111
112         free(dev->driver, DRM_MEM_DRIVER);
113
114         return ret;
115 }
116
117 static device_method_t mach64_methods[] = {
118         /* Device interface */
119         DEVMETHOD(device_probe,         mach64_probe),
120         DEVMETHOD(device_attach,        mach64_attach),
121         DEVMETHOD(device_detach,        mach64_detach),
122
123         { 0, 0 }
124 };
125
126 static driver_t mach64_driver = {
127         "drm",
128         mach64_methods,
129         sizeof(struct drm_device)
130 };
131
132 extern devclass_t drm_devclass;
133 #if __FreeBSD_version >= 700010
134 DRIVER_MODULE(mach64, vgapci, mach64_driver, drm_devclass, 0, 0);
135 #else
136 DRIVER_MODULE(mach64, pci, mach64_driver, drm_devclass, 0, 0);
137 #endif
138 MODULE_DEPEND(mach64, drm, 1, 1, 1);