OSDN Git Service

Use headers copied from kernel instead of shared-core
[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->driver_features =
45             DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ;
46
47         dev->driver->buf_priv_size      = 1;
48         dev->driver->load               = via_driver_load;
49         dev->driver->unload             = via_driver_unload;
50         dev->driver->context_ctor       = via_init_context;
51         dev->driver->context_dtor       = via_final_context;
52         dev->driver->get_vblank_counter = via_get_vblank_counter;
53         dev->driver->enable_vblank      = via_enable_vblank;
54         dev->driver->disable_vblank     = via_disable_vblank;
55         dev->driver->irq_preinstall     = via_driver_irq_preinstall;
56         dev->driver->irq_postinstall    = via_driver_irq_postinstall;
57         dev->driver->irq_uninstall      = via_driver_irq_uninstall;
58         dev->driver->irq_handler        = via_driver_irq_handler;
59         dev->driver->dma_quiescent      = via_driver_dma_quiescent;
60
61         dev->driver->ioctls             = via_ioctls;
62         dev->driver->max_ioctl          = via_max_ioctl;
63
64         dev->driver->name               = DRIVER_NAME;
65         dev->driver->desc               = DRIVER_DESC;
66         dev->driver->date               = DRIVER_DATE;
67         dev->driver->major              = DRIVER_MAJOR;
68         dev->driver->minor              = DRIVER_MINOR;
69         dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
70 }
71
72 static int
73 via_probe(device_t kdev)
74 {
75         return drm_probe(kdev, via_pciidlist);
76 }
77
78 static int
79 via_attach(device_t kdev)
80 {
81         struct drm_device *dev = device_get_softc(kdev);
82
83         dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
84             M_WAITOK | M_ZERO);
85
86         via_configure(dev);
87
88         return drm_attach(kdev, via_pciidlist);
89 }
90
91 static int
92 via_detach(device_t kdev)
93 {
94         struct drm_device *dev = device_get_softc(kdev);
95         int ret;
96
97         ret = drm_detach(kdev);
98
99         free(dev->driver, DRM_MEM_DRIVER);
100
101         return ret;
102 }
103
104 static device_method_t via_methods[] = {
105         /* Device interface */
106         DEVMETHOD(device_probe,         via_probe),
107         DEVMETHOD(device_attach,        via_attach),
108         DEVMETHOD(device_detach,        via_detach),
109
110         { 0, 0 }
111 };
112
113 static driver_t via_driver = {
114         "drm",
115         via_methods,
116         sizeof(struct drm_device)
117 };
118
119 extern devclass_t drm_devclass;
120 DRIVER_MODULE(via, pci, via_driver, drm_devclass, 0, 0);
121 MODULE_DEPEND(via, drm, 1, 1, 1);