via_drv.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
  3. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sub license,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the
  13. * next paragraph) shall be included in all copies or substantial portions
  14. * of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  19. * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. */
  24. #include <linux/module.h>
  25. #include <drm/drmP.h>
  26. #include <drm/via_drm.h>
  27. #include "via_drv.h"
  28. #include <drm/drm_pciids.h>
  29. static int via_driver_open(struct drm_device *dev, struct drm_file *file)
  30. {
  31. struct via_file_private *file_priv;
  32. DRM_DEBUG_DRIVER("\n");
  33. file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
  34. if (!file_priv)
  35. return -ENOMEM;
  36. file->driver_priv = file_priv;
  37. INIT_LIST_HEAD(&file_priv->obj_list);
  38. return 0;
  39. }
  40. static void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
  41. {
  42. struct via_file_private *file_priv = file->driver_priv;
  43. kfree(file_priv);
  44. }
  45. static struct pci_device_id pciidlist[] = {
  46. viadrv_PCI_IDS
  47. };
  48. static const struct file_operations via_driver_fops = {
  49. .owner = THIS_MODULE,
  50. .open = drm_open,
  51. .release = drm_release,
  52. .unlocked_ioctl = drm_ioctl,
  53. .mmap = drm_legacy_mmap,
  54. .poll = drm_poll,
  55. #ifdef CONFIG_COMPAT
  56. .compat_ioctl = drm_compat_ioctl,
  57. #endif
  58. .llseek = noop_llseek,
  59. };
  60. static struct drm_driver driver = {
  61. .driver_features =
  62. DRIVER_USE_AGP | DRIVER_HAVE_IRQ |
  63. DRIVER_IRQ_SHARED,
  64. .load = via_driver_load,
  65. .unload = via_driver_unload,
  66. .open = via_driver_open,
  67. .preclose = via_reclaim_buffers_locked,
  68. .postclose = via_driver_postclose,
  69. .set_busid = drm_pci_set_busid,
  70. .context_dtor = via_final_context,
  71. .get_vblank_counter = via_get_vblank_counter,
  72. .enable_vblank = via_enable_vblank,
  73. .disable_vblank = via_disable_vblank,
  74. .irq_preinstall = via_driver_irq_preinstall,
  75. .irq_postinstall = via_driver_irq_postinstall,
  76. .irq_uninstall = via_driver_irq_uninstall,
  77. .irq_handler = via_driver_irq_handler,
  78. .dma_quiescent = via_driver_dma_quiescent,
  79. .lastclose = via_lastclose,
  80. .ioctls = via_ioctls,
  81. .fops = &via_driver_fops,
  82. .name = DRIVER_NAME,
  83. .desc = DRIVER_DESC,
  84. .date = DRIVER_DATE,
  85. .major = DRIVER_MAJOR,
  86. .minor = DRIVER_MINOR,
  87. .patchlevel = DRIVER_PATCHLEVEL,
  88. };
  89. static struct pci_driver via_pci_driver = {
  90. .name = DRIVER_NAME,
  91. .id_table = pciidlist,
  92. };
  93. static int __init via_init(void)
  94. {
  95. driver.num_ioctls = via_max_ioctl;
  96. via_init_command_verifier();
  97. return drm_pci_init(&driver, &via_pci_driver);
  98. }
  99. static void __exit via_exit(void)
  100. {
  101. drm_pci_exit(&driver, &via_pci_driver);
  102. }
  103. module_init(via_init);
  104. module_exit(via_exit);
  105. MODULE_AUTHOR(DRIVER_AUTHOR);
  106. MODULE_DESCRIPTION(DRIVER_DESC);
  107. MODULE_LICENSE("GPL and additional rights");