savage_drv.c revision 1.2
1/* $NetBSD: savage_drv.c,v 1.2 2018/08/27 04:58:36 riastradh Exp $ */ 2 3/* savage_drv.c -- Savage driver for Linux 4 * 5 * Copyright 2004 Felix Kuehling 6 * All Rights Reserved. 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sub license, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice (including the 16 * next paragraph) shall be included in all copies or substantial portions 17 * of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR 23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 */ 27 28#include <sys/cdefs.h> 29__KERNEL_RCSID(0, "$NetBSD: savage_drv.c,v 1.2 2018/08/27 04:58:36 riastradh Exp $"); 30 31#include <linux/module.h> 32 33#include <drm/drmP.h> 34#include <drm/savage_drm.h> 35#include "savage_drv.h" 36 37#include <drm/drm_pciids.h> 38 39static struct pci_device_id pciidlist[] = { 40 savage_PCI_IDS 41}; 42 43static const struct file_operations savage_driver_fops = { 44 .owner = THIS_MODULE, 45 .open = drm_open, 46 .release = drm_release, 47 .unlocked_ioctl = drm_ioctl, 48 .mmap = drm_legacy_mmap, 49 .poll = drm_poll, 50#ifdef CONFIG_COMPAT 51 .compat_ioctl = drm_compat_ioctl, 52#endif 53 .llseek = noop_llseek, 54}; 55 56static struct drm_driver driver = { 57 .driver_features = 58 DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA, 59 .dev_priv_size = sizeof(drm_savage_buf_priv_t), 60 .load = savage_driver_load, 61 .firstopen = savage_driver_firstopen, 62 .preclose = savage_reclaim_buffers, 63 .lastclose = savage_driver_lastclose, 64 .unload = savage_driver_unload, 65 .set_busid = drm_pci_set_busid, 66 .ioctls = savage_ioctls, 67 .dma_ioctl = savage_bci_buffers, 68 .fops = &savage_driver_fops, 69 .name = DRIVER_NAME, 70 .desc = DRIVER_DESC, 71 .date = DRIVER_DATE, 72 .major = DRIVER_MAJOR, 73 .minor = DRIVER_MINOR, 74 .patchlevel = DRIVER_PATCHLEVEL, 75}; 76 77static struct pci_driver savage_pci_driver = { 78 .name = DRIVER_NAME, 79 .id_table = pciidlist, 80}; 81 82static int __init savage_init(void) 83{ 84 driver.num_ioctls = savage_max_ioctl; 85 return drm_pci_init(&driver, &savage_pci_driver); 86} 87 88static void __exit savage_exit(void) 89{ 90 drm_pci_exit(&driver, &savage_pci_driver); 91} 92 93module_init(savage_init); 94module_exit(savage_exit); 95 96MODULE_AUTHOR(DRIVER_AUTHOR); 97MODULE_DESCRIPTION(DRIVER_DESC); 98MODULE_LICENSE("GPL and additional rights"); 99