sis_drv.c revision 152909
1/* sis.c -- sis driver -*- linux-c -*-
2 */
3/*-
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
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 * PRECISION INSIGHT 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 OTHER
25 * DEALINGS IN THE SOFTWARE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/drm/sis_drv.c 152909 2005-11-28 23:13:57Z anholt $");
31
32#include "dev/drm/drmP.h"
33#include "dev/drm/sis_drm.h"
34#include "dev/drm/sis_drv.h"
35#include "dev/drm/drm_pciids.h"
36
37/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
38static drm_pci_id_list_t sis_pciidlist[] = {
39	sis_PCI_IDS
40};
41
42static void sis_configure(drm_device_t *dev)
43{
44	dev->driver.buf_priv_size	= 1; /* No dev_priv */
45	dev->driver.context_ctor	= sis_init_context;
46	dev->driver.context_dtor	= sis_final_context;
47
48	dev->driver.ioctls		= sis_ioctls;
49	dev->driver.max_ioctl		= sis_max_ioctl;
50
51	dev->driver.name		= DRIVER_NAME;
52	dev->driver.desc		= DRIVER_DESC;
53	dev->driver.date		= DRIVER_DATE;
54	dev->driver.major		= DRIVER_MAJOR;
55	dev->driver.minor		= DRIVER_MINOR;
56	dev->driver.patchlevel		= DRIVER_PATCHLEVEL;
57
58	dev->driver.use_agp		= 1;
59	dev->driver.use_mtrr		= 1;
60}
61
62#ifdef __FreeBSD__
63static int
64sis_probe(device_t dev)
65{
66	return drm_probe(dev, sis_pciidlist);
67}
68
69static int
70sis_attach(device_t nbdev)
71{
72	drm_device_t *dev = device_get_softc(nbdev);
73
74	bzero(dev, sizeof(drm_device_t));
75	sis_configure(dev);
76	return drm_attach(nbdev, sis_pciidlist);
77}
78
79static device_method_t sis_methods[] = {
80	/* Device interface */
81	DEVMETHOD(device_probe,		sis_probe),
82	DEVMETHOD(device_attach,	sis_attach),
83	DEVMETHOD(device_detach,	drm_detach),
84
85	{ 0, 0 }
86};
87
88static driver_t sis_driver = {
89	"drm",
90	sis_methods,
91	sizeof(drm_device_t)
92};
93
94extern devclass_t drm_devclass;
95DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0);
96MODULE_DEPEND(sisdrm, drm, 1, 1, 1);
97
98#elif defined(__NetBSD__) || defined(__OpenBSD__)
99#ifdef _LKM
100CFDRIVER_DECL(sis, DV_TTY, NULL);
101#else
102CFATTACH_DECL(sis, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
103    drm_activate);
104#endif
105#endif
106