blob: 349ac3d3b8480c13d91c850f917819774f92edbf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
2 * \file radeon_drv.c
3 * ATI Radeon driver
4 *
5 * \author Gareth Hughes <gareth@valinux.com>
6 */
7
8/*
9 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
10 * All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice (including the next
20 * paragraph) shall be included in all copies or substantial portions of the
21 * Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 * OTHER DEALINGS IN THE SOFTWARE.
30 */
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "drmP.h"
33#include "drm.h"
34#include "radeon_drm.h"
35#include "radeon_drv.h"
36
37#include "drm_pciids.h"
38
Dave Airlie689b9d72005-09-30 17:09:07 +100039int radeon_no_wb;
40
41MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n");
42module_param_named(no_wb, radeon_no_wb, int, 0444);
43
Dave Airlie732052e2005-11-11 22:07:35 +110044static int dri_library_name(struct drm_device *dev, char *buf)
45{
46 drm_radeon_private_t *dev_priv = dev->dev_private;
Dave Airlie54a56ac2006-09-22 04:25:09 +100047 int family = dev_priv->flags & RADEON_FAMILY_MASK;
Dave Airlie732052e2005-11-11 22:07:35 +110048
49 return snprintf(buf, PAGE_SIZE, "%s\n",
50 (family < CHIP_R200) ? "radeon" :
51 ((family < CHIP_R300) ? "r200" :
52 "r300"));
53}
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55static struct pci_device_id pciidlist[] = {
56 radeon_PCI_IDS
57};
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059static struct drm_driver driver = {
Dave Airlieb5e89ed2005-09-25 14:28:13 +100060 .driver_features =
61 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
62 DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED |
Dave Airlieddbee332007-07-11 12:16:01 +100063 DRIVER_IRQ_VBL | DRIVER_IRQ_VBL2,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .dev_priv_size = sizeof(drm_radeon_buf_priv_t),
Dave Airlie22eae942005-11-10 22:16:34 +110065 .load = radeon_driver_load,
66 .firstopen = radeon_driver_firstopen,
67 .open = radeon_driver_open,
68 .preclose = radeon_driver_preclose,
69 .postclose = radeon_driver_postclose,
70 .lastclose = radeon_driver_lastclose,
71 .unload = radeon_driver_unload,
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 .vblank_wait = radeon_driver_vblank_wait,
Dave Airlieddbee332007-07-11 12:16:01 +100073 .vblank_wait2 = radeon_driver_vblank_wait2,
Dave Airlie732052e2005-11-11 22:07:35 +110074 .dri_library_name = dri_library_name,
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 .irq_preinstall = radeon_driver_irq_preinstall,
76 .irq_postinstall = radeon_driver_irq_postinstall,
77 .irq_uninstall = radeon_driver_irq_uninstall,
78 .irq_handler = radeon_driver_irq_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 .reclaim_buffers = drm_core_reclaim_buffers,
80 .get_map_ofs = drm_core_get_map_ofs,
81 .get_reg_ofs = drm_core_get_reg_ofs,
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 .ioctls = radeon_ioctls,
83 .dma_ioctl = radeon_cp_buffers,
84 .fops = {
Dave Airlieb5e89ed2005-09-25 14:28:13 +100085 .owner = THIS_MODULE,
86 .open = drm_open,
87 .release = drm_release,
88 .ioctl = drm_ioctl,
89 .mmap = drm_mmap,
90 .poll = drm_poll,
91 .fasync = drm_fasync,
Dave Airlie9a186642005-06-23 21:29:18 +100092#ifdef CONFIG_COMPAT
Dave Airlieb5e89ed2005-09-25 14:28:13 +100093 .compat_ioctl = radeon_compat_ioctl,
Dave Airlie9a186642005-06-23 21:29:18 +100094#endif
Dave Airlie22eae942005-11-10 22:16:34 +110095 },
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 .pci_driver = {
Dave Airlie22eae942005-11-10 22:16:34 +110098 .name = DRIVER_NAME,
99 .id_table = pciidlist,
100 },
101
102 .name = DRIVER_NAME,
103 .desc = DRIVER_DESC,
104 .date = DRIVER_DATE,
105 .major = DRIVER_MAJOR,
106 .minor = DRIVER_MINOR,
107 .patchlevel = DRIVER_PATCHLEVEL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108};
109
110static int __init radeon_init(void)
111{
112 driver.num_ioctls = radeon_max_ioctl;
113 return drm_init(&driver);
114}
115
116static void __exit radeon_exit(void)
117{
118 drm_exit(&driver);
119}
120
121module_init(radeon_init);
122module_exit(radeon_exit);
123
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000124MODULE_AUTHOR(DRIVER_AUTHOR);
125MODULE_DESCRIPTION(DRIVER_DESC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126MODULE_LICENSE("GPL and additional rights");