1 /* i915_drv.c -- Intel i915 driver -*- linux-c -*-
2 * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
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:
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
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.
28 * Gareth Hughes <gareth@valinux.com>
32 #include "dev/drm/drmP.h"
33 #include "dev/drm/drm.h"
34 #include "dev/drm/i915_drm.h"
35 #include "dev/drm/i915_drv.h"
36 #include "dev/drm/drm_pciids.h"
38 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
39 static drm_pci_id_list_t i915_pciidlist
[] = {
43 static int i915_suspend(device_t kdev
)
45 struct drm_device
*dev
= device_get_softc(kdev
);
47 if (!dev
|| !dev
->dev_private
) {
48 DRM_ERROR("DRM not initialized, aborting suspend.\n");
54 return (bus_generic_suspend(kdev
));
57 static int i915_resume(device_t kdev
)
59 struct drm_device
*dev
= device_get_softc(kdev
);
61 i915_restore_state(dev
);
63 return (bus_generic_resume(kdev
));
66 static void i915_configure(struct drm_device
*dev
)
68 dev
->driver
->driver_features
=
69 DRIVER_USE_AGP
| DRIVER_REQUIRE_AGP
| DRIVER_USE_MTRR
|
72 dev
->driver
->buf_priv_size
= sizeof(drm_i915_private_t
);
73 dev
->driver
->load
= i915_driver_load
;
74 dev
->driver
->unload
= i915_driver_unload
;
75 dev
->driver
->preclose
= i915_driver_preclose
;
76 dev
->driver
->lastclose
= i915_driver_lastclose
;
77 dev
->driver
->device_is_agp
= i915_driver_device_is_agp
;
78 dev
->driver
->enable_vblank
= i915_enable_vblank
;
79 dev
->driver
->disable_vblank
= i915_disable_vblank
;
80 dev
->driver
->irq_preinstall
= i915_driver_irq_preinstall
;
81 dev
->driver
->irq_postinstall
= i915_driver_irq_postinstall
;
82 dev
->driver
->irq_uninstall
= i915_driver_irq_uninstall
;
83 dev
->driver
->irq_handler
= i915_driver_irq_handler
;
85 dev
->driver
->ioctls
= i915_ioctls
;
86 dev
->driver
->max_ioctl
= i915_max_ioctl
;
88 dev
->driver
->name
= DRIVER_NAME
;
89 dev
->driver
->desc
= DRIVER_DESC
;
90 dev
->driver
->date
= DRIVER_DATE
;
91 dev
->driver
->major
= DRIVER_MAJOR
;
92 dev
->driver
->minor
= DRIVER_MINOR
;
93 dev
->driver
->patchlevel
= DRIVER_PATCHLEVEL
;
97 i915_probe(device_t kdev
)
99 return drm_probe(kdev
, i915_pciidlist
);
103 i915_attach(device_t kdev
)
105 struct drm_device
*dev
= device_get_softc(kdev
);
107 dev
->driver
= malloc(sizeof(struct drm_driver_info
), DRM_MEM_DRIVER
,
112 return drm_attach(kdev
, i915_pciidlist
);
116 i915_detach(device_t kdev
)
118 struct drm_device
*dev
= device_get_softc(kdev
);
121 ret
= drm_detach(kdev
);
123 free(dev
->driver
, DRM_MEM_DRIVER
);
128 static device_method_t i915_methods
[] = {
129 /* Device interface */
130 DEVMETHOD(device_probe
, i915_probe
),
131 DEVMETHOD(device_attach
, i915_attach
),
132 DEVMETHOD(device_suspend
, i915_suspend
),
133 DEVMETHOD(device_resume
, i915_resume
),
134 DEVMETHOD(device_detach
, i915_detach
),
139 static driver_t i915_driver
= {
140 #if __FreeBSD_version >= 700010
146 sizeof(struct drm_device
)
149 extern devclass_t drm_devclass
;
150 #if __FreeBSD_version >= 700010
151 DRIVER_MODULE(i915
, vgapci
, i915_driver
, drm_devclass
, 0, 0);
153 DRIVER_MODULE(i915
, agp
, i915_driver
, drm_devclass
, 0, 0);
155 MODULE_DEPEND(i915
, drm
, 1, 1, 1);