OSDN Git Service

1d784eedccda19cdd0f1e1915c5a1c37298106cb
[android-x86/external-libdrm.git] / bsd-core / via_drv.c
1 /* via_drv.c -- VIA unichrome driver -*- linux-c -*-
2  * Created: Fri Aug 12 2005 by anholt@FreeBSD.org
3  */
4 /*-
5  * Copyright 2005 Eric Anholt
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  * ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  * Authors:
27  *    Eric Anholt <anholt@FreeBSD.org>
28  *
29  */
30
31 #include "drmP.h"
32 #include "drm.h"
33 #include "via_drm.h"
34 #include "via_drv.h"
35 #include "drm_pciids.h"
36
37 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
38 static drm_pci_id_list_t via_pciidlist[] = {
39         viadrv_PCI_IDS
40 };
41
42 static void via_configure(struct drm_device *dev)
43 {
44         dev->driver.buf_priv_size       = 1;
45         dev->driver.load                = via_driver_load;
46         dev->driver.unload              = via_driver_unload;
47         dev->driver.context_ctor        = via_init_context;
48         dev->driver.context_dtor        = via_final_context;
49         dev->driver.vblank_wait         = via_driver_vblank_wait;
50         dev->driver.irq_preinstall      = via_driver_irq_preinstall;
51         dev->driver.irq_postinstall     = via_driver_irq_postinstall;
52         dev->driver.irq_uninstall       = via_driver_irq_uninstall;
53         dev->driver.irq_handler         = via_driver_irq_handler;
54         dev->driver.dma_quiescent       = via_driver_dma_quiescent;
55
56         dev->driver.ioctls              = via_ioctls;
57         dev->driver.max_ioctl           = via_max_ioctl;
58
59         dev->driver.name                = DRIVER_NAME;
60         dev->driver.desc                = DRIVER_DESC;
61         dev->driver.date                = DRIVER_DATE;
62         dev->driver.major               = DRIVER_MAJOR;
63         dev->driver.minor               = DRIVER_MINOR;
64         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
65
66         dev->driver.use_agp             = 1;
67         dev->driver.use_mtrr            = 1;
68         dev->driver.use_irq             = 1;
69         dev->driver.use_vbl_irq         = 1;
70 }
71
72 #ifdef __FreeBSD__
73 static int
74 via_probe(device_t dev)
75 {
76         return drm_probe(dev, via_pciidlist);
77 }
78
79 static int
80 via_attach(device_t nbdev)
81 {
82         struct drm_device *dev = device_get_softc(nbdev);
83
84         bzero(dev, sizeof(struct drm_device));
85         via_configure(dev);
86         return drm_attach(nbdev, via_pciidlist);
87 }
88
89 static device_method_t via_methods[] = {
90         /* Device interface */
91         DEVMETHOD(device_probe,         via_probe),
92         DEVMETHOD(device_attach,        via_attach),
93         DEVMETHOD(device_detach,        drm_detach),
94
95         { 0, 0 }
96 };
97
98 static driver_t via_driver = {
99         "drm",
100         via_methods,
101         sizeof(struct drm_device)
102 };
103
104 extern devclass_t drm_devclass;
105 DRIVER_MODULE(via, pci, via_driver, drm_devclass, 0, 0);
106 MODULE_DEPEND(via, drm, 1, 1, 1);
107
108 #elif defined(__NetBSD__) || defined(__OpenBSD__)
109 #ifdef _LKM
110 CFDRIVER_DECL(via, DV_TTY, NULL);
111 #else
112 CFATTACH_DECL(via, sizeof(struct drm_device), drm_probe, drm_attach, drm_detach,
113     drm_activate);
114 #endif
115 #endif