mdp4_irq.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. uint32_t old_irqmask)
  21. {
  22. mdp4_write(to_mdp4_kms(mdp_kms), REG_MDP4_INTR_CLEAR,
  23. irqmask ^ (irqmask & old_irqmask));
  24. mdp4_write(to_mdp4_kms(mdp_kms), REG_MDP4_INTR_ENABLE, irqmask);
  25. }
  26. static void mdp4_irq_error_handler(struct mdp_irq *irq, uint32_t irqstatus)
  27. {
  28. DRM_ERROR("errors: %08x\n", irqstatus);
  29. }
  30. void mdp4_irq_preinstall(struct msm_kms *kms)
  31. {
  32. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  33. mdp4_enable(mdp4_kms);
  34. mdp4_write(mdp4_kms, REG_MDP4_INTR_CLEAR, 0xffffffff);
  35. mdp4_write(mdp4_kms, REG_MDP4_INTR_ENABLE, 0x00000000);
  36. mdp4_disable(mdp4_kms);
  37. }
  38. int mdp4_irq_postinstall(struct msm_kms *kms)
  39. {
  40. struct mdp_kms *mdp_kms = to_mdp_kms(kms);
  41. struct mdp4_kms *mdp4_kms = to_mdp4_kms(mdp_kms);
  42. struct mdp_irq *error_handler = &mdp4_kms->error_handler;
  43. error_handler->irq = mdp4_irq_error_handler;
  44. error_handler->irqmask = MDP4_IRQ_PRIMARY_INTF_UDERRUN |
  45. MDP4_IRQ_EXTERNAL_INTF_UDERRUN;
  46. mdp_irq_register(mdp_kms, error_handler);
  47. return 0;
  48. }
  49. void mdp4_irq_uninstall(struct msm_kms *kms)
  50. {
  51. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  52. mdp4_enable(mdp4_kms);
  53. mdp4_write(mdp4_kms, REG_MDP4_INTR_ENABLE, 0x00000000);
  54. mdp4_disable(mdp4_kms);
  55. }
  56. irqreturn_t mdp4_irq(struct msm_kms *kms)
  57. {
  58. struct mdp_kms *mdp_kms = to_mdp_kms(kms);
  59. struct mdp4_kms *mdp4_kms = to_mdp4_kms(mdp_kms);
  60. struct drm_device *dev = mdp4_kms->dev;
  61. struct msm_drm_private *priv = dev->dev_private;
  62. unsigned int id;
  63. uint32_t status, enable;
  64. enable = mdp4_read(mdp4_kms, REG_MDP4_INTR_ENABLE);
  65. status = mdp4_read(mdp4_kms, REG_MDP4_INTR_STATUS) & enable;
  66. mdp4_write(mdp4_kms, REG_MDP4_INTR_CLEAR, status);
  67. VERB("status=%08x", status);
  68. mdp_dispatch_irqs(mdp_kms, status);
  69. for (id = 0; id < priv->num_crtcs; id++)
  70. if (status & mdp4_crtc_vblank(priv->crtcs[id]))
  71. drm_handle_vblank(dev, id);
  72. return IRQ_HANDLED;
  73. }
  74. int mdp4_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
  75. {
  76. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  77. mdp4_enable(mdp4_kms);
  78. mdp_update_vblank_mask(to_mdp_kms(kms),
  79. mdp4_crtc_vblank(crtc), true);
  80. mdp4_disable(mdp4_kms);
  81. return 0;
  82. }
  83. void mdp4_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
  84. {
  85. struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
  86. mdp4_enable(mdp4_kms);
  87. mdp_update_vblank_mask(to_mdp_kms(kms),
  88. mdp4_crtc_vblank(crtc), false);
  89. mdp4_disable(mdp4_kms);
  90. }