Merge from vendor branch LESS:
[dragonfly.git] / sys / dev / drm / i915_drv.c
1 /* i915_drv.c -- Intel i915 driver -*- linux-c -*-
2  * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
3  */
4 /*-
5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6  * All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the next
16  * paragraph) shall be included in all copies or substantial portions of the
17  * Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Authors:
28  *    Gareth Hughes <gareth@valinux.com>
29  *
30  * $DragonFly: src/sys/dev/drm/i915_drv.c,v 1.1 2008/04/05 18:12:29 hasso Exp $
31  */
32
33 #include "drmP.h"
34 #include "drm.h"
35 #include "i915_drm.h"
36 #include "i915_drv.h"
37 #include "drm_pciids.h"
38
39 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
40 static drm_pci_id_list_t i915_pciidlist[] = {
41         i915_PCI_IDS
42 };
43
44 static void i915_configure(drm_device_t *dev)
45 {
46         dev->driver.buf_priv_size       = 1;    /* No dev_priv */
47         dev->driver.load                = i915_driver_load;
48         dev->driver.preclose            = i915_driver_preclose;
49         dev->driver.lastclose           = i915_driver_lastclose;
50         dev->driver.device_is_agp       = i915_driver_device_is_agp;
51         dev->driver.vblank_wait         = i915_driver_vblank_wait;
52         dev->driver.vblank_wait2        = i915_driver_vblank_wait2;
53         dev->driver.irq_preinstall      = i915_driver_irq_preinstall;
54         dev->driver.irq_postinstall     = i915_driver_irq_postinstall;
55         dev->driver.irq_uninstall       = i915_driver_irq_uninstall;
56         dev->driver.irq_handler         = i915_driver_irq_handler;
57
58         dev->driver.ioctls              = i915_ioctls;
59         dev->driver.max_ioctl           = i915_max_ioctl;
60
61         dev->driver.name                = DRIVER_NAME;
62         dev->driver.desc                = DRIVER_DESC;
63         dev->driver.date                = DRIVER_DATE;
64         dev->driver.major               = DRIVER_MAJOR;
65         dev->driver.minor               = DRIVER_MINOR;
66         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
67
68         dev->driver.use_agp             = 1;
69         dev->driver.require_agp         = 1;
70         dev->driver.use_mtrr            = 1;
71         dev->driver.use_irq             = 1;
72         dev->driver.use_vbl_irq         = 1;
73         dev->driver.use_vbl_irq2        = 1;
74 }
75
76 #if defined(__FreeBSD__) || defined(__DragonFly__)
77 static int
78 i915_probe(device_t dev)
79 {
80         return drm_probe(dev, i915_pciidlist);
81 }
82
83 static int
84 i915_attach(device_t nbdev)
85 {
86         drm_device_t *dev = device_get_softc(nbdev);
87
88         bzero(dev, sizeof(drm_device_t));
89         i915_configure(dev);
90         return drm_attach(nbdev, i915_pciidlist);
91 }
92
93 static device_method_t i915_methods[] = {
94         /* Device interface */
95         DEVMETHOD(device_probe,         i915_probe),
96         DEVMETHOD(device_attach,        i915_attach),
97         DEVMETHOD(device_detach,        drm_detach),
98
99         { 0, 0 }
100 };
101
102 static driver_t i915_driver = {
103 #if __FreeBSD_version >= 700010
104         "drm",
105 #else
106         "drmsub",
107 #endif
108         i915_methods,
109         sizeof(drm_device_t)
110 };
111
112 extern devclass_t drm_devclass;
113 #if __FreeBSD_version >= 700010
114 DRIVER_MODULE(i915, vgapci, i915_driver, drm_devclass, 0, 0);
115 #else
116 DRIVER_MODULE(i915, agp, i915_driver, drm_devclass, 0, 0);
117 #endif
118 MODULE_DEPEND(i915, drm, 1, 1, 1);
119
120 #elif defined(__NetBSD__) || defined(__OpenBSD__)
121 CFDRIVER_DECL(i915, DV_TTY, NULL);
122 #endif