18c2ecf20Sopenharmony_ci/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*- 28c2ecf20Sopenharmony_ci * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 58c2ecf20Sopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 68c2ecf20Sopenharmony_ci * All Rights Reserved. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 98c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 108c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 118c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 128c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 138c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 168c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 178c2ecf20Sopenharmony_ci * Software. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 208c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 218c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 228c2ecf20Sopenharmony_ci * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 238c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 248c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 258c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * Authors: 288c2ecf20Sopenharmony_ci * Rickard E. (Rik) Faith <faith@valinux.com> 298c2ecf20Sopenharmony_ci * Gareth Hughes <gareth@valinux.com> 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include <linux/module.h> 338c2ecf20Sopenharmony_ci#include <linux/pci.h> 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#include <drm/drm_drv.h> 368c2ecf20Sopenharmony_ci#include <drm/drm_file.h> 378c2ecf20Sopenharmony_ci#include <drm/drm_pciids.h> 388c2ecf20Sopenharmony_ci#include <drm/drm_vblank.h> 398c2ecf20Sopenharmony_ci#include <drm/r128_drm.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#include "r128_drv.h" 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistatic struct pci_device_id pciidlist[] = { 448c2ecf20Sopenharmony_ci r128_PCI_IDS 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic const struct file_operations r128_driver_fops = { 488c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 498c2ecf20Sopenharmony_ci .open = drm_open, 508c2ecf20Sopenharmony_ci .release = drm_release, 518c2ecf20Sopenharmony_ci .unlocked_ioctl = drm_ioctl, 528c2ecf20Sopenharmony_ci .mmap = drm_legacy_mmap, 538c2ecf20Sopenharmony_ci .poll = drm_poll, 548c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT 558c2ecf20Sopenharmony_ci .compat_ioctl = r128_compat_ioctl, 568c2ecf20Sopenharmony_ci#endif 578c2ecf20Sopenharmony_ci .llseek = noop_llseek, 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic struct drm_driver driver = { 618c2ecf20Sopenharmony_ci .driver_features = 628c2ecf20Sopenharmony_ci DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_LEGACY | 638c2ecf20Sopenharmony_ci DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ, 648c2ecf20Sopenharmony_ci .dev_priv_size = sizeof(drm_r128_buf_priv_t), 658c2ecf20Sopenharmony_ci .load = r128_driver_load, 668c2ecf20Sopenharmony_ci .preclose = r128_driver_preclose, 678c2ecf20Sopenharmony_ci .lastclose = r128_driver_lastclose, 688c2ecf20Sopenharmony_ci .get_vblank_counter = r128_get_vblank_counter, 698c2ecf20Sopenharmony_ci .enable_vblank = r128_enable_vblank, 708c2ecf20Sopenharmony_ci .disable_vblank = r128_disable_vblank, 718c2ecf20Sopenharmony_ci .irq_preinstall = r128_driver_irq_preinstall, 728c2ecf20Sopenharmony_ci .irq_postinstall = r128_driver_irq_postinstall, 738c2ecf20Sopenharmony_ci .irq_uninstall = r128_driver_irq_uninstall, 748c2ecf20Sopenharmony_ci .irq_handler = r128_driver_irq_handler, 758c2ecf20Sopenharmony_ci .ioctls = r128_ioctls, 768c2ecf20Sopenharmony_ci .dma_ioctl = r128_cce_buffers, 778c2ecf20Sopenharmony_ci .fops = &r128_driver_fops, 788c2ecf20Sopenharmony_ci .name = DRIVER_NAME, 798c2ecf20Sopenharmony_ci .desc = DRIVER_DESC, 808c2ecf20Sopenharmony_ci .date = DRIVER_DATE, 818c2ecf20Sopenharmony_ci .major = DRIVER_MAJOR, 828c2ecf20Sopenharmony_ci .minor = DRIVER_MINOR, 838c2ecf20Sopenharmony_ci .patchlevel = DRIVER_PATCHLEVEL, 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ciint r128_driver_load(struct drm_device *dev, unsigned long flags) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci pci_set_master(dev->pdev); 898c2ecf20Sopenharmony_ci return drm_vblank_init(dev, 1); 908c2ecf20Sopenharmony_ci} 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistatic struct pci_driver r128_pci_driver = { 938c2ecf20Sopenharmony_ci .name = DRIVER_NAME, 948c2ecf20Sopenharmony_ci .id_table = pciidlist, 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic int __init r128_init(void) 988c2ecf20Sopenharmony_ci{ 998c2ecf20Sopenharmony_ci driver.num_ioctls = r128_max_ioctl; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci return drm_legacy_pci_init(&driver, &r128_pci_driver); 1028c2ecf20Sopenharmony_ci} 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistatic void __exit r128_exit(void) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci drm_legacy_pci_exit(&driver, &r128_pci_driver); 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cimodule_init(r128_init); 1108c2ecf20Sopenharmony_cimodule_exit(r128_exit); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ciMODULE_AUTHOR(DRIVER_AUTHOR); 1138c2ecf20Sopenharmony_ciMODULE_DESCRIPTION(DRIVER_DESC); 1148c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL and additional rights"); 115