mdp4_irq.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "msm_drv.h"
  18. #include "mdp4_kms.h"
  19. void mdp4_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask)
  20. {
  21. mdp4_write(to_mdp4_kms(mdp_kms), REG_MDP4_INTR_ENABLE, irqmask);
  22. }
  23. static void mdp4_irq_error_handler(struct mdp_irq *irq, uint32_t irqstatus)
  24. {
  25. DRM_ERROR("errors: %08x\n", irqstatus);
  26. }
  27. void mdp4_irq_preinstall(struct msm_kms *kms)
  28. {
  29. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  30. mdp4_write(mdp4_kms, REG_MDP4_INTR_CLEAR, 0xffffffff);
  31. }
  32. int mdp4_irq_postinstall(struct msm_kms *kms)
  33. {
  34. struct mdp_kms *mdp_kms = to_mdp_kms(kms);
  35. struct mdp4_kms *mdp4_kms = to_mdp4_kms(mdp_kms);
  36. struct mdp_irq *error_handler = &mdp4_kms->error_handler;
  37. error_handler->irq = mdp4_irq_error_handler;
  38. error_handler->irqmask = MDP4_IRQ_PRIMARY_INTF_UDERRUN |
  39. MDP4_IRQ_EXTERNAL_INTF_UDERRUN;
  40. mdp_irq_register(mdp_kms, error_handler);
  41. return 0;
  42. }
  43. void mdp4_irq_uninstall(struct msm_kms *kms)
  44. {
  45. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  46. mdp4_write(mdp4_kms, REG_MDP4_INTR_ENABLE, 0x00000000);
  47. }
  48. irqreturn_t mdp4_irq(struct msm_kms *kms)
  49. {
  50. struct mdp_kms *mdp_kms = to_mdp_kms(kms);
  51. struct mdp4_kms *mdp4_kms = to_mdp4_kms(mdp_kms);
  52. struct drm_device *dev = mdp4_kms->dev;
  53. struct msm_drm_private *priv = dev->dev_private;
  54. unsigned int id;
  55. uint32_t status;
  56. status = mdp4_read(mdp4_kms, REG_MDP4_INTR_STATUS);
  57. mdp4_write(mdp4_kms, REG_MDP4_INTR_CLEAR, status);
  58. VERB("status=%08x", status);
  59. mdp_dispatch_irqs(mdp_kms, status);
  60. for (id = 0; id < priv->num_crtcs; id++)
  61. if (status & mdp4_crtc_vblank(priv->crtcs[id]))
  62. drm_handle_vblank(dev, id);
  63. return IRQ_HANDLED;
  64. }
  65. int mdp4_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
  66. {
  67. mdp_update_vblank_mask(to_mdp_kms(kms),
  68. mdp4_crtc_vblank(crtc), true);
  69. return 0;
  70. }
  71. void mdp4_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
  72. {
  73. mdp_update_vblank_mask(to_mdp_kms(kms),
  74. mdp4_crtc_vblank(crtc), false);
  75. }