mdp_kms.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. uint32_t old_irqmask);
  30. };
  31. struct mdp_kms {
  32. struct msm_kms base;
  33. const struct mdp_kms_funcs *funcs;
  34. /* irq handling: */
  35. bool in_irq;
  36. struct list_head irq_list; /* list of mdp4_irq */
  37. uint32_t vblank_mask; /* irq bits set for userspace vblank */
  38. uint32_t cur_irq_mask; /* current irq mask */
  39. };
  40. #define to_mdp_kms(x) container_of(x, struct mdp_kms, base)
  41. static inline void mdp_kms_init(struct mdp_kms *mdp_kms,
  42. const struct mdp_kms_funcs *funcs)
  43. {
  44. mdp_kms->funcs = funcs;
  45. INIT_LIST_HEAD(&mdp_kms->irq_list);
  46. msm_kms_init(&mdp_kms->base, &funcs->base);
  47. }
  48. /*
  49. * irq helpers:
  50. */
  51. /* For transiently registering for different MDP irqs that various parts
  52. * of the KMS code need during setup/configuration. These are not
  53. * necessarily the same as what drm_vblank_get/put() are requesting, and
  54. * the hysteresis in drm_vblank_put() is not necessarily desirable for
  55. * internal housekeeping related irq usage.
  56. */
  57. struct mdp_irq {
  58. struct list_head node;
  59. uint32_t irqmask;
  60. bool registered;
  61. void (*irq)(struct mdp_irq *irq, uint32_t irqstatus);
  62. };
  63. void mdp_dispatch_irqs(struct mdp_kms *mdp_kms, uint32_t status);
  64. void mdp_update_vblank_mask(struct mdp_kms *mdp_kms, uint32_t mask, bool enable);
  65. void mdp_irq_wait(struct mdp_kms *mdp_kms, uint32_t irqmask);
  66. void mdp_irq_register(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
  67. void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
  68. void mdp_irq_update(struct mdp_kms *mdp_kms);
  69. /*
  70. * pixel format helpers:
  71. */
  72. struct mdp_format {
  73. struct msm_format base;
  74. enum mdp_bpc bpc_r, bpc_g, bpc_b;
  75. enum mdp_bpc_alpha bpc_a;
  76. uint8_t unpack[4];
  77. bool alpha_enable, unpack_tight;
  78. uint8_t cpp, unpack_count;
  79. enum mdp_fetch_type fetch_type;
  80. enum mdp_chroma_samp_type chroma_sample;
  81. bool is_yuv;
  82. };
  83. #define to_mdp_format(x) container_of(x, struct mdp_format, base)
  84. #define MDP_FORMAT_IS_YUV(mdp_format) ((mdp_format)->is_yuv)
  85. uint32_t mdp_get_formats(uint32_t *formats, uint32_t max_formats, bool rgb_only);
  86. const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format);
  87. /* MDP capabilities */
  88. #define MDP_CAP_SMP BIT(0) /* Shared Memory Pool */
  89. #define MDP_CAP_DSC BIT(1) /* VESA Display Stream Compression */
  90. #define MDP_CAP_CDM BIT(2) /* Chroma Down Module (HDMI 2.0 YUV) */
  91. /* MDP pipe capabilities */
  92. #define MDP_PIPE_CAP_HFLIP BIT(0)
  93. #define MDP_PIPE_CAP_VFLIP BIT(1)
  94. #define MDP_PIPE_CAP_SCALE BIT(2)
  95. #define MDP_PIPE_CAP_CSC BIT(3)
  96. #define MDP_PIPE_CAP_DECIMATION BIT(4)
  97. #define MDP_PIPE_CAP_SW_PIX_EXT BIT(5)
  98. static inline bool pipe_supports_yuv(uint32_t pipe_caps)
  99. {
  100. return (pipe_caps & MDP_PIPE_CAP_SCALE) &&
  101. (pipe_caps & MDP_PIPE_CAP_CSC);
  102. }
  103. enum csc_type {
  104. CSC_RGB2RGB = 0,
  105. CSC_YUV2RGB,
  106. CSC_RGB2YUV,
  107. CSC_YUV2YUV,
  108. CSC_MAX
  109. };
  110. struct csc_cfg {
  111. enum csc_type type;
  112. uint32_t matrix[9];
  113. uint32_t pre_bias[3];
  114. uint32_t post_bias[3];
  115. uint32_t pre_clamp[6];
  116. uint32_t post_clamp[6];
  117. };
  118. struct csc_cfg *mdp_get_default_csc_cfg(enum csc_type);
  119. #endif /* __MDP_KMS_H__ */