radeon_drv.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 dri_library_name(struct drm_device *dev, char *buf)
  39. {
  40. drm_radeon_private_t *dev_priv = dev->dev_private;
  41. int family = dev_priv->flags & RADEON_FAMILY_MASK;
  42. return snprintf(buf, PAGE_SIZE, "%s\n",
  43. (family < CHIP_R200) ? "radeon" :
  44. ((family < CHIP_R300) ? "r200" :
  45. "r300"));
  46. }
  47. static int radeon_suspend(struct drm_device *dev, pm_message_t state)
  48. {
  49. drm_radeon_private_t *dev_priv = dev->dev_private;
  50. /* Disable *all* interrupts */
  51. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
  52. RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
  53. RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
  54. return 0;
  55. }
  56. static int radeon_resume(struct drm_device *dev)
  57. {
  58. drm_radeon_private_t *dev_priv = dev->dev_private;
  59. /* Restore interrupt registers */
  60. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
  61. RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
  62. RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
  63. return 0;
  64. }
  65. static struct pci_device_id pciidlist[] = {
  66. radeon_PCI_IDS
  67. };
  68. static struct drm_driver driver = {
  69. .driver_features =
  70. DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
  71. DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED,
  72. .dev_priv_size = sizeof(drm_radeon_buf_priv_t),
  73. .load = radeon_driver_load,
  74. .firstopen = radeon_driver_firstopen,
  75. .open = radeon_driver_open,
  76. .preclose = radeon_driver_preclose,
  77. .postclose = radeon_driver_postclose,
  78. .lastclose = radeon_driver_lastclose,
  79. .unload = radeon_driver_unload,
  80. .suspend = radeon_suspend,
  81. .resume = radeon_resume,
  82. .get_vblank_counter = radeon_get_vblank_counter,
  83. .enable_vblank = radeon_enable_vblank,
  84. .disable_vblank = radeon_disable_vblank,
  85. .dri_library_name = dri_library_name,
  86. .master_create = radeon_master_create,
  87. .master_destroy = radeon_master_destroy,
  88. .irq_preinstall = radeon_driver_irq_preinstall,
  89. .irq_postinstall = radeon_driver_irq_postinstall,
  90. .irq_uninstall = radeon_driver_irq_uninstall,
  91. .irq_handler = radeon_driver_irq_handler,
  92. .reclaim_buffers = drm_core_reclaim_buffers,
  93. .get_map_ofs = drm_core_get_map_ofs,
  94. .get_reg_ofs = drm_core_get_reg_ofs,
  95. .ioctls = radeon_ioctls,
  96. .dma_ioctl = radeon_cp_buffers,
  97. .fops = {
  98. .owner = THIS_MODULE,
  99. .open = drm_open,
  100. .release = drm_release,
  101. .ioctl = drm_ioctl,
  102. .mmap = drm_mmap,
  103. .poll = drm_poll,
  104. .fasync = drm_fasync,
  105. #ifdef CONFIG_COMPAT
  106. .compat_ioctl = radeon_compat_ioctl,
  107. #endif
  108. },
  109. .pci_driver = {
  110. .name = DRIVER_NAME,
  111. .id_table = pciidlist,
  112. },
  113. .name = DRIVER_NAME,
  114. .desc = DRIVER_DESC,
  115. .date = DRIVER_DATE,
  116. .major = DRIVER_MAJOR,
  117. .minor = DRIVER_MINOR,
  118. .patchlevel = DRIVER_PATCHLEVEL,
  119. };
  120. static int __init radeon_init(void)
  121. {
  122. driver.num_ioctls = radeon_max_ioctl;
  123. return drm_init(&driver);
  124. }
  125. static void __exit radeon_exit(void)
  126. {
  127. drm_exit(&driver);
  128. }
  129. module_init(radeon_init);
  130. module_exit(radeon_exit);
  131. MODULE_AUTHOR(DRIVER_AUTHOR);
  132. MODULE_DESCRIPTION(DRIVER_DESC);
  133. MODULE_LICENSE("GPL and additional rights");