Back to home page

OSCL-LXR

 
 

    


0001 /* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
0002  * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
0003  *
0004  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
0005  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
0006  * All Rights Reserved.
0007  *
0008  * Permission is hereby granted, free of charge, to any person obtaining a
0009  * copy of this software and associated documentation files (the "Software"),
0010  * to deal in the Software without restriction, including without limitation
0011  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0012  * and/or sell copies of the Software, and to permit persons to whom the
0013  * Software is furnished to do so, subject to the following conditions:
0014  *
0015  * The above copyright notice and this permission notice (including the next
0016  * paragraph) shall be included in all copies or substantial portions of the
0017  * Software.
0018  *
0019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0020  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0022  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0023  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0024  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0025  * OTHER DEALINGS IN THE SOFTWARE.
0026  *
0027  * Authors:
0028  *    Rickard E. (Rik) Faith <faith@valinux.com>
0029  *    Gareth Hughes <gareth@valinux.com>
0030  */
0031 
0032 #include <linux/module.h>
0033 #include <linux/pci.h>
0034 
0035 #include <drm/drm_drv.h>
0036 #include <drm/drm_file.h>
0037 #include <drm/drm_pciids.h>
0038 #include <drm/drm_vblank.h>
0039 #include <drm/r128_drm.h>
0040 
0041 #include "r128_drv.h"
0042 
0043 static struct pci_device_id pciidlist[] = {
0044     r128_PCI_IDS
0045 };
0046 
0047 static const struct file_operations r128_driver_fops = {
0048     .owner = THIS_MODULE,
0049     .open = drm_open,
0050     .release = drm_release,
0051     .unlocked_ioctl = drm_ioctl,
0052     .mmap = drm_legacy_mmap,
0053     .poll = drm_poll,
0054 #ifdef CONFIG_COMPAT
0055     .compat_ioctl = r128_compat_ioctl,
0056 #endif
0057     .llseek = noop_llseek,
0058 };
0059 
0060 static struct drm_driver driver = {
0061     .driver_features =
0062         DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_LEGACY |
0063         DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ,
0064     .dev_priv_size = sizeof(drm_r128_buf_priv_t),
0065     .load = r128_driver_load,
0066     .preclose = r128_driver_preclose,
0067     .lastclose = r128_driver_lastclose,
0068     .get_vblank_counter = r128_get_vblank_counter,
0069     .enable_vblank = r128_enable_vblank,
0070     .disable_vblank = r128_disable_vblank,
0071     .irq_preinstall = r128_driver_irq_preinstall,
0072     .irq_postinstall = r128_driver_irq_postinstall,
0073     .irq_uninstall = r128_driver_irq_uninstall,
0074     .irq_handler = r128_driver_irq_handler,
0075     .ioctls = r128_ioctls,
0076     .dma_ioctl = r128_cce_buffers,
0077     .fops = &r128_driver_fops,
0078     .name = DRIVER_NAME,
0079     .desc = DRIVER_DESC,
0080     .date = DRIVER_DATE,
0081     .major = DRIVER_MAJOR,
0082     .minor = DRIVER_MINOR,
0083     .patchlevel = DRIVER_PATCHLEVEL,
0084 };
0085 
0086 int r128_driver_load(struct drm_device *dev, unsigned long flags)
0087 {
0088     struct pci_dev *pdev = to_pci_dev(dev->dev);
0089 
0090     pci_set_master(pdev);
0091     return drm_vblank_init(dev, 1);
0092 }
0093 
0094 static struct pci_driver r128_pci_driver = {
0095     .name = DRIVER_NAME,
0096     .id_table = pciidlist,
0097 };
0098 
0099 static int __init r128_init(void)
0100 {
0101     driver.num_ioctls = r128_max_ioctl;
0102 
0103     return drm_legacy_pci_init(&driver, &r128_pci_driver);
0104 }
0105 
0106 static void __exit r128_exit(void)
0107 {
0108     drm_legacy_pci_exit(&driver, &r128_pci_driver);
0109 }
0110 
0111 module_init(r128_init);
0112 module_exit(r128_exit);
0113 
0114 MODULE_AUTHOR(DRIVER_AUTHOR);
0115 MODULE_DESCRIPTION(DRIVER_DESC);
0116 MODULE_LICENSE("GPL and additional rights");