r128_drv.c revision 1.2
1/*	$NetBSD: r128_drv.c,v 1.2 2018/08/27 04:58:35 riastradh Exp $	*/
2
3/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
4 * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
5 *
6 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
7 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * All Rights Reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice (including the next
18 * paragraph) shall be included in all copies or substantial portions of the
19 * Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * Authors:
30 *    Rickard E. (Rik) Faith <faith@valinux.com>
31 *    Gareth Hughes <gareth@valinux.com>
32 */
33
34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: r128_drv.c,v 1.2 2018/08/27 04:58:35 riastradh Exp $");
36
37#include <linux/module.h>
38
39#include <drm/drmP.h>
40#include <drm/r128_drm.h>
41#include "r128_drv.h"
42
43#include <drm/drm_pciids.h>
44
45static struct pci_device_id pciidlist[] = {
46	r128_PCI_IDS
47};
48
49static const struct file_operations r128_driver_fops = {
50	.owner = THIS_MODULE,
51	.open = drm_open,
52	.release = drm_release,
53	.unlocked_ioctl = drm_ioctl,
54	.mmap = drm_legacy_mmap,
55	.poll = drm_poll,
56#ifdef CONFIG_COMPAT
57	.compat_ioctl = r128_compat_ioctl,
58#endif
59	.llseek = noop_llseek,
60};
61
62static struct drm_driver driver = {
63	.driver_features =
64	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
65	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
66	.dev_priv_size = sizeof(drm_r128_buf_priv_t),
67	.load = r128_driver_load,
68	.preclose = r128_driver_preclose,
69	.lastclose = r128_driver_lastclose,
70	.set_busid = drm_pci_set_busid,
71	.get_vblank_counter = r128_get_vblank_counter,
72	.enable_vblank = r128_enable_vblank,
73	.disable_vblank = r128_disable_vblank,
74	.irq_preinstall = r128_driver_irq_preinstall,
75	.irq_postinstall = r128_driver_irq_postinstall,
76	.irq_uninstall = r128_driver_irq_uninstall,
77	.irq_handler = r128_driver_irq_handler,
78	.ioctls = r128_ioctls,
79	.dma_ioctl = r128_cce_buffers,
80	.fops = &r128_driver_fops,
81	.name = DRIVER_NAME,
82	.desc = DRIVER_DESC,
83	.date = DRIVER_DATE,
84	.major = DRIVER_MAJOR,
85	.minor = DRIVER_MINOR,
86	.patchlevel = DRIVER_PATCHLEVEL,
87};
88
89int r128_driver_load(struct drm_device *dev, unsigned long flags)
90{
91	pci_set_master(dev->pdev);
92	return drm_vblank_init(dev, 1);
93}
94
95static struct pci_driver r128_pci_driver = {
96	.name = DRIVER_NAME,
97	.id_table = pciidlist,
98};
99
100static int __init r128_init(void)
101{
102	driver.num_ioctls = r128_max_ioctl;
103
104	return drm_pci_init(&driver, &r128_pci_driver);
105}
106
107static void __exit r128_exit(void)
108{
109	drm_pci_exit(&driver, &r128_pci_driver);
110}
111
112module_init(r128_init);
113module_exit(r128_exit);
114
115MODULE_AUTHOR(DRIVER_AUTHOR);
116MODULE_DESCRIPTION(DRIVER_DESC);
117MODULE_LICENSE("GPL and additional rights");
118