sis_drv.c revision 145132
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 * $FreeBSD: head/sys/dev/drm/sis_drv.c 145132 2005-04-16 03:44:47Z anholt $
28 */
29
30#include "dev/drm/drmP.h"
31#include "dev/drm/sis_drm.h"
32#include "dev/drm/sis_drv.h"
33#include "dev/drm/drm_pciids.h"
34
35/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
36static drm_pci_id_list_t sis_pciidlist[] = {
37	sis_PCI_IDS
38};
39
40extern drm_ioctl_desc_t sis_ioctls[];
41extern int sis_max_ioctl;
42
43static void sis_configure(drm_device_t *dev)
44{
45	dev->dev_priv_size = 1; /* No dev_priv */
46	dev->context_ctor = sis_init_context;
47	dev->context_dtor = sis_final_context;
48
49	dev->driver_ioctls = sis_ioctls;
50	dev->max_driver_ioctl = sis_max_ioctl;
51
52	dev->driver_name = DRIVER_NAME;
53	dev->driver_desc = DRIVER_DESC;
54	dev->driver_date = DRIVER_DATE;
55	dev->driver_major = DRIVER_MAJOR;
56	dev->driver_minor = DRIVER_MINOR;
57	dev->driver_patchlevel = DRIVER_PATCHLEVEL;
58
59	dev->use_agp = 1;
60	dev->use_mtrr = 1;
61}
62
63#ifdef __FreeBSD__
64static int
65sis_probe(device_t dev)
66{
67	return drm_probe(dev, sis_pciidlist);
68}
69
70static int
71sis_attach(device_t nbdev)
72{
73	drm_device_t *dev = device_get_softc(nbdev);
74
75	bzero(dev, sizeof(drm_device_t));
76	sis_configure(dev);
77	return drm_attach(nbdev, sis_pciidlist);
78}
79
80static device_method_t sis_methods[] = {
81	/* Device interface */
82	DEVMETHOD(device_probe,		sis_probe),
83	DEVMETHOD(device_attach,	sis_attach),
84	DEVMETHOD(device_detach,	drm_detach),
85
86	{ 0, 0 }
87};
88
89static driver_t sis_driver = {
90	"drm",
91	sis_methods,
92	sizeof(drm_device_t)
93};
94
95extern devclass_t drm_devclass;
96DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0);
97MODULE_DEPEND(sisdrm, drm, 1, 1, 1);
98
99#elif defined(__NetBSD__) || defined(__OpenBSD__)
100CFDRIVER_DECL(sis, DV_TTY, NULL);
101#endif
102