OSDN Git Service

[FreeBSD] Add drm_drawable_free_all()
[android-x86/external-libdrm.git] / bsd-core / sis_drv.c
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 "drmP.h"
30 #include "sis_drm.h"
31 #include "sis_drv.h"
32 #include "drm_pciids.h"
33
34 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
35 static drm_pci_id_list_t sis_pciidlist[] = {
36         sis_PCI_IDS
37 };
38
39 static void sis_configure(struct drm_device *dev)
40 {
41         dev->driver.buf_priv_size       = 1; /* No dev_priv */
42         dev->driver.context_ctor        = sis_init_context;
43         dev->driver.context_dtor        = sis_final_context;
44
45         dev->driver.ioctls              = sis_ioctls;
46         dev->driver.max_ioctl           = sis_max_ioctl;
47
48         dev->driver.name                = DRIVER_NAME;
49         dev->driver.desc                = DRIVER_DESC;
50         dev->driver.date                = DRIVER_DATE;
51         dev->driver.major               = DRIVER_MAJOR;
52         dev->driver.minor               = DRIVER_MINOR;
53         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
54
55         dev->driver.use_agp             = 1;
56         dev->driver.use_mtrr            = 1;
57 }
58
59 #ifdef __FreeBSD__
60 static int
61 sis_probe(device_t dev)
62 {
63         return drm_probe(dev, sis_pciidlist);
64 }
65
66 static int
67 sis_attach(device_t nbdev)
68 {
69         struct drm_device *dev = device_get_softc(nbdev);
70
71         bzero(dev, sizeof(struct drm_device));
72         sis_configure(dev);
73         return drm_attach(nbdev, sis_pciidlist);
74 }
75
76 static device_method_t sis_methods[] = {
77         /* Device interface */
78         DEVMETHOD(device_probe,         sis_probe),
79         DEVMETHOD(device_attach,        sis_attach),
80         DEVMETHOD(device_detach,        drm_detach),
81
82         { 0, 0 }
83 };
84
85 static driver_t sis_driver = {
86         "drm",
87         sis_methods,
88         sizeof(struct drm_device)
89 };
90
91 extern devclass_t drm_devclass;
92 #if __FreeBSD_version >= 700010
93 DRIVER_MODULE(sisdrm, vgapci, sis_driver, drm_devclass, 0, 0);
94 #else
95 DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0);
96 #endif
97 MODULE_DEPEND(sisdrm, drm, 1, 1, 1);
98
99 #elif defined(__NetBSD__) || defined(__OpenBSD__)
100 #ifdef _LKM
101 CFDRIVER_DECL(sis, DV_TTY, NULL);
102 #else
103 CFATTACH_DECL(sis, sizeof(struct drm_device), drm_probe, drm_attach, drm_detach,
104     drm_activate);
105 #endif
106 #endif