i915_drv.c revision 145132
1145132Sanholt/* i915_drv.c -- ATI Radeon driver -*- linux-c -*-
2145132Sanholt * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
3145132Sanholt */
4145132Sanholt/*-
5145132Sanholt * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6145132Sanholt * All Rights Reserved.
7145132Sanholt *
8145132Sanholt * Permission is hereby granted, free of charge, to any person obtaining a
9145132Sanholt * copy of this software and associated documentation files (the "Software"),
10145132Sanholt * to deal in the Software without restriction, including without limitation
11145132Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12145132Sanholt * and/or sell copies of the Software, and to permit persons to whom the
13145132Sanholt * Software is furnished to do so, subject to the following conditions:
14145132Sanholt *
15145132Sanholt * The above copyright notice and this permission notice (including the next
16145132Sanholt * paragraph) shall be included in all copies or substantial portions of the
17145132Sanholt * Software.
18145132Sanholt *
19145132Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20145132Sanholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21145132Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22145132Sanholt * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23145132Sanholt * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24145132Sanholt * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25145132Sanholt * OTHER DEALINGS IN THE SOFTWARE.
26145132Sanholt *
27145132Sanholt * Authors:
28145132Sanholt *    Gareth Hughes <gareth@valinux.com>
29145132Sanholt *
30145132Sanholt * $FreeBSD: head/sys/dev/drm/i915_drv.c 145132 2005-04-16 03:44:47Z anholt $
31145132Sanholt */
32145132Sanholt
33145132Sanholt#include "drmP.h"
34145132Sanholt#include "drm.h"
35145132Sanholt#include "i915_drm.h"
36145132Sanholt#include "i915_drv.h"
37145132Sanholt#include "drm_pciids.h"
38145132Sanholt
39145132Sanholt/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
40145132Sanholtstatic drm_pci_id_list_t i915_pciidlist[] = {
41145132Sanholt	i915_PCI_IDS
42145132Sanholt};
43145132Sanholt
44145132Sanholtextern drm_ioctl_desc_t i915_ioctls[];
45145132Sanholtextern int i915_max_ioctl;
46145132Sanholt
47145132Sanholtstatic void i915_configure(drm_device_t *dev)
48145132Sanholt{
49145132Sanholt	dev->dev_priv_size = 1;	/* No dev_priv */
50145132Sanholt	dev->prerelease = i915_driver_prerelease;
51145132Sanholt	dev->pretakedown = i915_driver_pretakedown;
52145132Sanholt	dev->irq_preinstall = i915_driver_irq_preinstall;
53145132Sanholt	dev->irq_postinstall = i915_driver_irq_postinstall;
54145132Sanholt	dev->irq_uninstall = i915_driver_irq_uninstall;
55145132Sanholt	dev->irq_handler = i915_driver_irq_handler;
56145132Sanholt
57145132Sanholt	dev->driver_ioctls = i915_ioctls;
58145132Sanholt	dev->max_driver_ioctl = i915_max_ioctl;
59145132Sanholt
60145132Sanholt	dev->driver_name = DRIVER_NAME;
61145132Sanholt	dev->driver_desc = DRIVER_DESC;
62145132Sanholt	dev->driver_date = DRIVER_DATE;
63145132Sanholt	dev->driver_major = DRIVER_MAJOR;
64145132Sanholt	dev->driver_minor = DRIVER_MINOR;
65145132Sanholt	dev->driver_patchlevel = DRIVER_PATCHLEVEL;
66145132Sanholt
67145132Sanholt	dev->use_agp = 1;
68145132Sanholt	dev->require_agp = 1;
69145132Sanholt	dev->use_mtrr = 1;
70145132Sanholt	dev->use_irq = 1;
71145132Sanholt}
72145132Sanholt
73145132Sanholt#ifdef __FreeBSD__
74145132Sanholtstatic int
75145132Sanholti915_probe(device_t dev)
76145132Sanholt{
77145132Sanholt	return drm_probe(dev, i915_pciidlist);
78145132Sanholt}
79145132Sanholt
80145132Sanholtstatic int
81145132Sanholti915_attach(device_t nbdev)
82145132Sanholt{
83145132Sanholt	drm_device_t *dev = device_get_softc(nbdev);
84145132Sanholt
85145132Sanholt	bzero(dev, sizeof(drm_device_t));
86145132Sanholt	i915_configure(dev);
87145132Sanholt	return drm_attach(nbdev, i915_pciidlist);
88145132Sanholt}
89145132Sanholt
90145132Sanholtstatic device_method_t i915_methods[] = {
91145132Sanholt	/* Device interface */
92145132Sanholt	DEVMETHOD(device_probe,		i915_probe),
93145132Sanholt	DEVMETHOD(device_attach,	i915_attach),
94145132Sanholt	DEVMETHOD(device_detach,	drm_detach),
95145132Sanholt
96145132Sanholt	{ 0, 0 }
97145132Sanholt};
98145132Sanholt
99145132Sanholtstatic driver_t i915_driver = {
100145132Sanholt	"drmsub",
101145132Sanholt	i915_methods,
102145132Sanholt	sizeof(drm_device_t)
103145132Sanholt};
104145132Sanholt
105145132Sanholtextern devclass_t drm_devclass;
106145132SanholtDRIVER_MODULE(i915, pci, i915_driver, drm_devclass, 0, 0);
107145132SanholtMODULE_DEPEND(i915, drm, 1, 1, 1);
108145132Sanholt
109145132Sanholt#elif defined(__NetBSD__) || defined(__OpenBSD__)
110145132SanholtCFDRIVER_DECL(i915, DV_TTY, NULL);
111145132Sanholt#endif
112