mdp_kms.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #ifndef __MDP_KMS_H__
  18. #define __MDP_KMS_H__
  19. #include <linux/clk.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/regulator/consumer.h>
  22. #include "msm_drv.h"
  23. #include "msm_kms.h"
  24. #include "mdp_common.xml.h"
  25. struct mdp_kms;
  26. struct mdp_kms_funcs {
  27. struct msm_kms_funcs base;
  28. void (*set_irqmask)(struct mdp_kms *mdp_kms, uint32_t irqmask);
  29. };
  30. struct mdp_kms {
  31. struct msm_kms base;
  32. const struct mdp_kms_funcs *funcs;
  33. /* irq handling: */
  34. bool in_irq;
  35. struct list_head irq_list; /* list of mdp4_irq */
  36. uint32_t vblank_mask; /* irq bits set for userspace vblank */
  37. };
  38. #define to_mdp_kms(x) container_of(x, struct mdp_kms, base)
  39. static inline void mdp_kms_init(struct mdp_kms *mdp_kms,
  40. const struct mdp_kms_funcs *funcs)
  41. {
  42. mdp_kms->funcs = funcs;
  43. INIT_LIST_HEAD(&mdp_kms->irq_list);
  44. msm_kms_init(&mdp_kms->base, &funcs->base);
  45. }
  46. /*
  47. * irq helpers:
  48. */
  49. /* For transiently registering for different MDP irqs that various parts
  50. * of the KMS code need during setup/configuration. These are not
  51. * necessarily the same as what drm_vblank_get/put() are requesting, and
  52. * the hysteresis in drm_vblank_put() is not necessarily desirable for
  53. * internal housekeeping related irq usage.
  54. */
  55. struct mdp_irq {
  56. struct list_head node;
  57. uint32_t irqmask;
  58. bool registered;
  59. void (*irq)(struct mdp_irq *irq, uint32_t irqstatus);
  60. };
  61. void mdp_dispatch_irqs(struct mdp_kms *mdp_kms, uint32_t status);
  62. void mdp_update_vblank_mask(struct mdp_kms *mdp_kms, uint32_t mask, bool enable);
  63. void mdp_irq_wait(struct mdp_kms *mdp_kms, uint32_t irqmask);
  64. void mdp_irq_register(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
  65. void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
  66. /*
  67. * pixel format helpers:
  68. */
  69. struct mdp_format {
  70. struct msm_format base;
  71. enum mdp_bpc bpc_r, bpc_g, bpc_b;
  72. enum mdp_bpc_alpha bpc_a;
  73. uint8_t unpack[4];
  74. bool alpha_enable, unpack_tight;
  75. uint8_t cpp, unpack_count;
  76. };
  77. #define to_mdp_format(x) container_of(x, struct mdp_format, base)
  78. uint32_t mdp_get_formats(uint32_t *formats, uint32_t max_formats);
  79. const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format);
  80. #endif /* __MDP_KMS_H__ */