dpu_encoder.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2013 Red Hat
  4. * Author: Rob Clark <robdclark@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __DPU_ENCODER_H__
  19. #define __DPU_ENCODER_H__
  20. #include <drm/drm_crtc.h>
  21. #include "dpu_hw_mdss.h"
  22. #define DPU_ENCODER_FRAME_EVENT_DONE BIT(0)
  23. #define DPU_ENCODER_FRAME_EVENT_ERROR BIT(1)
  24. #define DPU_ENCODER_FRAME_EVENT_PANEL_DEAD BIT(2)
  25. #define DPU_ENCODER_FRAME_EVENT_IDLE BIT(3)
  26. #define IDLE_TIMEOUT (66 - 16/2)
  27. /**
  28. * Encoder functions and data types
  29. * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
  30. * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
  31. * @display_num_of_h_tiles: Number of horizontal tiles in case of split
  32. * interface
  33. * @topology: Topology of the display
  34. */
  35. struct dpu_encoder_hw_resources {
  36. enum dpu_intf_mode intfs[INTF_MAX];
  37. bool needs_cdm;
  38. u32 display_num_of_h_tiles;
  39. };
  40. /**
  41. * dpu_encoder_kickoff_params - info encoder requires at kickoff
  42. * @affected_displays: bitmask, bit set means the ROI of the commit lies within
  43. * the bounds of the physical display at the bit index
  44. */
  45. struct dpu_encoder_kickoff_params {
  46. unsigned long affected_displays;
  47. };
  48. /**
  49. * dpu_encoder_get_hw_resources - Populate table of required hardware resources
  50. * @encoder: encoder pointer
  51. * @hw_res: resource table to populate with encoder required resources
  52. * @conn_state: report hw reqs based on this proposed connector state
  53. */
  54. void dpu_encoder_get_hw_resources(struct drm_encoder *encoder,
  55. struct dpu_encoder_hw_resources *hw_res,
  56. struct drm_connector_state *conn_state);
  57. /**
  58. * dpu_encoder_register_vblank_callback - provide callback to encoder that
  59. * will be called on the next vblank.
  60. * @encoder: encoder pointer
  61. * @cb: callback pointer, provide NULL to deregister and disable IRQs
  62. * @data: user data provided to callback
  63. */
  64. void dpu_encoder_register_vblank_callback(struct drm_encoder *encoder,
  65. void (*cb)(void *), void *data);
  66. /**
  67. * dpu_encoder_register_frame_event_callback - provide callback to encoder that
  68. * will be called after the request is complete, or other events.
  69. * @encoder: encoder pointer
  70. * @cb: callback pointer, provide NULL to deregister
  71. * @data: user data provided to callback
  72. */
  73. void dpu_encoder_register_frame_event_callback(struct drm_encoder *encoder,
  74. void (*cb)(void *, u32), void *data);
  75. /**
  76. * dpu_encoder_prepare_for_kickoff - schedule double buffer flip of the ctl
  77. * path (i.e. ctl flush and start) at next appropriate time.
  78. * Immediately: if no previous commit is outstanding.
  79. * Delayed: Block until next trigger can be issued.
  80. * @encoder: encoder pointer
  81. * @params: kickoff time parameters
  82. */
  83. void dpu_encoder_prepare_for_kickoff(struct drm_encoder *encoder,
  84. struct dpu_encoder_kickoff_params *params);
  85. /**
  86. * dpu_encoder_trigger_kickoff_pending - Clear the flush bits from previous
  87. * kickoff and trigger the ctl prepare progress for command mode display.
  88. * @encoder: encoder pointer
  89. */
  90. void dpu_encoder_trigger_kickoff_pending(struct drm_encoder *encoder);
  91. /**
  92. * dpu_encoder_kickoff - trigger a double buffer flip of the ctl path
  93. * (i.e. ctl flush and start) immediately.
  94. * @encoder: encoder pointer
  95. */
  96. void dpu_encoder_kickoff(struct drm_encoder *encoder);
  97. /**
  98. * dpu_encoder_wait_for_event - Waits for encoder events
  99. * @encoder: encoder pointer
  100. * @event: event to wait for
  101. * MSM_ENC_COMMIT_DONE - Wait for hardware to have flushed the current pending
  102. * frames to hardware at a vblank or ctl_start
  103. * Encoders will map this differently depending on the
  104. * panel type.
  105. * vid mode -> vsync_irq
  106. * cmd mode -> ctl_start
  107. * MSM_ENC_TX_COMPLETE - Wait for the hardware to transfer all the pixels to
  108. * the panel. Encoders will map this differently
  109. * depending on the panel type.
  110. * vid mode -> vsync_irq
  111. * cmd mode -> pp_done
  112. * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
  113. */
  114. int dpu_encoder_wait_for_event(struct drm_encoder *drm_encoder,
  115. enum msm_event_wait event);
  116. /*
  117. * dpu_encoder_get_intf_mode - get interface mode of the given encoder
  118. * @encoder: Pointer to drm encoder object
  119. */
  120. enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder);
  121. /**
  122. * dpu_encoder_virt_restore - restore the encoder configs
  123. * @encoder: encoder pointer
  124. */
  125. void dpu_encoder_virt_restore(struct drm_encoder *encoder);
  126. /**
  127. * dpu_encoder_init - initialize virtual encoder object
  128. * @dev: Pointer to drm device structure
  129. * @disp_info: Pointer to display information structure
  130. * Returns: Pointer to newly created drm encoder
  131. */
  132. struct drm_encoder *dpu_encoder_init(
  133. struct drm_device *dev,
  134. int drm_enc_mode);
  135. /**
  136. * dpu_encoder_setup - setup dpu_encoder for the display probed
  137. * @dev: Pointer to drm device structure
  138. * @enc: Pointer to the drm_encoder
  139. * @disp_info: Pointer to the display info
  140. */
  141. int dpu_encoder_setup(struct drm_device *dev, struct drm_encoder *enc,
  142. struct msm_display_info *disp_info);
  143. /**
  144. * dpu_encoder_prepare_commit - prepare encoder at the very beginning of an
  145. * atomic commit, before any registers are written
  146. * @drm_enc: Pointer to previously created drm encoder structure
  147. */
  148. void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc);
  149. /**
  150. * dpu_encoder_set_idle_timeout - set the idle timeout for video
  151. * and command mode encoders.
  152. * @drm_enc: Pointer to previously created drm encoder structure
  153. * @idle_timeout: idle timeout duration in milliseconds
  154. */
  155. void dpu_encoder_set_idle_timeout(struct drm_encoder *drm_enc,
  156. u32 idle_timeout);
  157. #endif /* __DPU_ENCODER_H__ */