OSDN Git Service

[FreeBSD] Add drm_drawable_free_all()
[android-x86/external-libdrm.git] / bsd-core / r128_drv.c
1 /* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
2  * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
3  */
4 /*-
5  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
7  * All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice (including the next
17  * paragraph) shall be included in all copies or substantial portions of the
18  * Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  *
28  * Authors:
29  *    Rickard E. (Rik) Faith <faith@valinux.com>
30  *    Gareth Hughes <gareth@valinux.com>
31  *
32  */
33
34 #include "drmP.h"
35 #include "drm.h"
36 #include "r128_drm.h"
37 #include "r128_drv.h"
38 #include "drm_pciids.h"
39
40 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
41 static drm_pci_id_list_t r128_pciidlist[] = {
42         r128_PCI_IDS
43 };
44
45 static void r128_configure(struct drm_device *dev)
46 {
47         dev->driver.buf_priv_size       = sizeof(drm_r128_buf_priv_t);
48         dev->driver.preclose            = r128_driver_preclose;
49         dev->driver.lastclose           = r128_driver_lastclose;
50         dev->driver.get_vblank_counter  = r128_get_vblank_counter;
51         dev->driver.enable_vblank       = r128_enable_vblank;
52         dev->driver.disable_vblank      = r128_disable_vblank;
53         dev->driver.irq_preinstall      = r128_driver_irq_preinstall;
54         dev->driver.irq_postinstall     = r128_driver_irq_postinstall;
55         dev->driver.irq_uninstall       = r128_driver_irq_uninstall;
56         dev->driver.irq_handler         = r128_driver_irq_handler;
57         dev->driver.dma_ioctl           = r128_cce_buffers;
58
59         dev->driver.ioctls              = r128_ioctls;
60         dev->driver.max_ioctl           = r128_max_ioctl;
61
62         dev->driver.name                = DRIVER_NAME;
63         dev->driver.desc                = DRIVER_DESC;
64         dev->driver.date                = DRIVER_DATE;
65         dev->driver.major               = DRIVER_MAJOR;
66         dev->driver.minor               = DRIVER_MINOR;
67         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
68
69         dev->driver.use_agp             = 1;
70         dev->driver.use_mtrr            = 1;
71         dev->driver.use_pci_dma         = 1;
72         dev->driver.use_sg              = 1;
73         dev->driver.use_dma             = 1;
74         dev->driver.use_irq             = 1;
75         dev->driver.use_vbl_irq         = 1;
76 }
77
78 #ifdef __FreeBSD__
79 static int
80 r128_probe(device_t dev)
81 {
82         return drm_probe(dev, r128_pciidlist);
83 }
84
85 static int
86 r128_attach(device_t nbdev)
87 {
88         struct drm_device *dev = device_get_softc(nbdev);
89
90         bzero(dev, sizeof(struct drm_device));
91         r128_configure(dev);
92         return drm_attach(nbdev, r128_pciidlist);
93 }
94
95 static device_method_t r128_methods[] = {
96         /* Device interface */
97         DEVMETHOD(device_probe,         r128_probe),
98         DEVMETHOD(device_attach,        r128_attach),
99         DEVMETHOD(device_detach,        drm_detach),
100
101         { 0, 0 }
102 };
103
104 static driver_t r128_driver = {
105         "drm",
106         r128_methods,
107         sizeof(struct drm_device)
108 };
109
110 extern devclass_t drm_devclass;
111 #if __FreeBSD_version >= 700010
112 DRIVER_MODULE(r128, vgapci, r128_driver, drm_devclass, 0, 0);
113 #else
114 DRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0);
115 #endif
116 MODULE_DEPEND(r128, drm, 1, 1, 1);
117
118 #elif defined(__NetBSD__) || defined(__OpenBSD__)
119 #ifdef _LKM
120 CFDRIVER_DECL(r128, DV_TTY, NULL);
121 #else
122 CFATTACH_DECL(r128, sizeof(struct drm_device), drm_probe, drm_attach,
123     drm_detach, drm_activate);
124 #endif
125 #endif