radeon_drv.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /**
  2. * \file radeon_drv.c
  3. * ATI Radeon driver
  4. *
  5. * \author Gareth Hughes <gareth@valinux.com>
  6. */
  7. /*
  8. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  9. * All Rights Reserved.
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice (including the next
  19. * paragraph) shall be included in all copies or substantial portions of the
  20. * Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  25. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  26. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  27. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  28. * OTHER DEALINGS IN THE SOFTWARE.
  29. */
  30. #include "drmP.h"
  31. #include "drm.h"
  32. #include "radeon_drm.h"
  33. #include "radeon_drv.h"
  34. #include "drm_pciids.h"
  35. int radeon_no_wb;
  36. MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
  37. module_param_named(no_wb, radeon_no_wb, int, 0444);
  38. static int radeon_suspend(struct drm_device *dev, pm_message_t state)
  39. {
  40. drm_radeon_private_t *dev_priv = dev->dev_private;
  41. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
  42. return 0;
  43. /* Disable *all* interrupts */
  44. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
  45. RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
  46. RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
  47. return 0;
  48. }
  49. static int radeon_resume(struct drm_device *dev)
  50. {
  51. drm_radeon_private_t *dev_priv = dev->dev_private;
  52. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
  53. return 0;
  54. /* Restore interrupt registers */
  55. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
  56. RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
  57. RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
  58. return 0;
  59. }
  60. static struct pci_device_id pciidlist[] = {
  61. radeon_PCI_IDS
  62. };
  63. static struct drm_driver driver = {
  64. .driver_features =
  65. DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
  66. DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED,
  67. .dev_priv_size = sizeof(drm_radeon_buf_priv_t),
  68. .load = radeon_driver_load,
  69. .firstopen = radeon_driver_firstopen,
  70. .open = radeon_driver_open,
  71. .preclose = radeon_driver_preclose,
  72. .postclose = radeon_driver_postclose,
  73. .lastclose = radeon_driver_lastclose,
  74. .unload = radeon_driver_unload,
  75. .suspend = radeon_suspend,
  76. .resume = radeon_resume,
  77. .get_vblank_counter = radeon_get_vblank_counter,
  78. .enable_vblank = radeon_enable_vblank,
  79. .disable_vblank = radeon_disable_vblank,
  80. .master_create = radeon_master_create,
  81. .master_destroy = radeon_master_destroy,
  82. .irq_preinstall = radeon_driver_irq_preinstall,
  83. .irq_postinstall = radeon_driver_irq_postinstall,
  84. .irq_uninstall = radeon_driver_irq_uninstall,
  85. .irq_handler = radeon_driver_irq_handler,
  86. .reclaim_buffers = drm_core_reclaim_buffers,
  87. .get_map_ofs = drm_core_get_map_ofs,
  88. .get_reg_ofs = drm_core_get_reg_ofs,
  89. .ioctls = radeon_ioctls,
  90. .dma_ioctl = radeon_cp_buffers,
  91. .fops = {
  92. .owner = THIS_MODULE,
  93. .open = drm_open,
  94. .release = drm_release,
  95. .ioctl = drm_ioctl,
  96. .mmap = drm_mmap,
  97. .poll = drm_poll,
  98. .fasync = drm_fasync,
  99. #ifdef CONFIG_COMPAT
  100. .compat_ioctl = radeon_compat_ioctl,
  101. #endif
  102. },
  103. .pci_driver = {
  104. .name = DRIVER_NAME,
  105. .id_table = pciidlist,
  106. },
  107. .name = DRIVER_NAME,
  108. .desc = DRIVER_DESC,
  109. .date = DRIVER_DATE,
  110. .major = DRIVER_MAJOR,
  111. .minor = DRIVER_MINOR,
  112. .patchlevel = DRIVER_PATCHLEVEL,
  113. };
  114. static int __init radeon_init(void)
  115. {
  116. driver.num_ioctls = radeon_max_ioctl;
  117. return drm_init(&driver);
  118. }
  119. static void __exit radeon_exit(void)
  120. {
  121. drm_exit(&driver);
  122. }
  123. module_init(radeon_init);
  124. module_exit(radeon_exit);
  125. MODULE_AUTHOR(DRIVER_AUTHOR);
  126. MODULE_DESCRIPTION(DRIVER_DESC);
  127. MODULE_LICENSE("GPL and additional rights");