radeon_irq_kms.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  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, sublicense,
  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 shall be included in
  14. * all copies or substantial portions 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 NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include "drmP.h"
  29. #include "radeon_drm.h"
  30. #include "radeon_reg.h"
  31. #include "radeon.h"
  32. #include "atom.h"
  33. irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS)
  34. {
  35. struct drm_device *dev = (struct drm_device *) arg;
  36. struct radeon_device *rdev = dev->dev_private;
  37. return radeon_irq_process(rdev);
  38. }
  39. void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
  40. {
  41. struct radeon_device *rdev = dev->dev_private;
  42. unsigned i;
  43. /* Disable *all* interrupts */
  44. rdev->irq.sw_int = false;
  45. for (i = 0; i < 2; i++) {
  46. rdev->irq.crtc_vblank_int[i] = false;
  47. }
  48. radeon_irq_set(rdev);
  49. /* Clear bits */
  50. radeon_irq_process(rdev);
  51. }
  52. int radeon_driver_irq_postinstall_kms(struct drm_device *dev)
  53. {
  54. struct radeon_device *rdev = dev->dev_private;
  55. dev->max_vblank_count = 0x001fffff;
  56. rdev->irq.sw_int = true;
  57. radeon_irq_set(rdev);
  58. return 0;
  59. }
  60. void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
  61. {
  62. struct radeon_device *rdev = dev->dev_private;
  63. unsigned i;
  64. if (rdev == NULL) {
  65. return;
  66. }
  67. /* Disable *all* interrupts */
  68. rdev->irq.sw_int = false;
  69. for (i = 0; i < 2; i++) {
  70. rdev->irq.crtc_vblank_int[i] = false;
  71. }
  72. radeon_irq_set(rdev);
  73. }
  74. int radeon_irq_kms_init(struct radeon_device *rdev)
  75. {
  76. int r = 0;
  77. r = drm_vblank_init(rdev->ddev, 2);
  78. if (r) {
  79. return r;
  80. }
  81. drm_irq_install(rdev->ddev);
  82. rdev->irq.installed = true;
  83. DRM_INFO("radeon: irq initialized.\n");
  84. return 0;
  85. }
  86. void radeon_irq_kms_fini(struct radeon_device *rdev)
  87. {
  88. if (rdev->irq.installed) {
  89. rdev->irq.installed = false;
  90. drm_irq_uninstall(rdev->ddev);
  91. }
  92. }