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