dpu_hw_pingpong.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DPU_HW_PINGPONG_H
  13. #define _DPU_HW_PINGPONG_H
  14. #include "dpu_hw_catalog.h"
  15. #include "dpu_hw_mdss.h"
  16. #include "dpu_hw_util.h"
  17. #include "dpu_hw_blk.h"
  18. struct dpu_hw_pingpong;
  19. struct dpu_hw_tear_check {
  20. /*
  21. * This is ratio of MDP VSYNC clk freq(Hz) to
  22. * refresh rate divided by no of lines
  23. */
  24. u32 vsync_count;
  25. u32 sync_cfg_height;
  26. u32 vsync_init_val;
  27. u32 sync_threshold_start;
  28. u32 sync_threshold_continue;
  29. u32 start_pos;
  30. u32 rd_ptr_irq;
  31. u8 hw_vsync_mode;
  32. };
  33. struct dpu_hw_pp_vsync_info {
  34. u32 rd_ptr_init_val; /* value of rd pointer at vsync edge */
  35. u32 rd_ptr_frame_count; /* num frames sent since enabling interface */
  36. u32 rd_ptr_line_count; /* current line on panel (rd ptr) */
  37. u32 wr_ptr_line_count; /* current line within pp fifo (wr ptr) */
  38. };
  39. /**
  40. *
  41. * struct dpu_hw_pingpong_ops : Interface to the pingpong Hw driver functions
  42. * Assumption is these functions will be called after clocks are enabled
  43. * @setup_tearcheck : program tear check values
  44. * @enable_tearcheck : enables tear check
  45. * @get_vsync_info : retries timing info of the panel
  46. * @setup_dither : function to program the dither hw block
  47. * @get_line_count: obtain current vertical line counter
  48. */
  49. struct dpu_hw_pingpong_ops {
  50. /**
  51. * enables vysnc generation and sets up init value of
  52. * read pointer and programs the tear check cofiguration
  53. */
  54. int (*setup_tearcheck)(struct dpu_hw_pingpong *pp,
  55. struct dpu_hw_tear_check *cfg);
  56. /**
  57. * enables tear check block
  58. */
  59. int (*enable_tearcheck)(struct dpu_hw_pingpong *pp,
  60. bool enable);
  61. /**
  62. * read, modify, write to either set or clear listening to external TE
  63. * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
  64. */
  65. int (*connect_external_te)(struct dpu_hw_pingpong *pp,
  66. bool enable_external_te);
  67. /**
  68. * provides the programmed and current
  69. * line_count
  70. */
  71. int (*get_vsync_info)(struct dpu_hw_pingpong *pp,
  72. struct dpu_hw_pp_vsync_info *info);
  73. /**
  74. * poll until write pointer transmission starts
  75. * @Return: 0 on success, -ETIMEDOUT on timeout
  76. */
  77. int (*poll_timeout_wr_ptr)(struct dpu_hw_pingpong *pp, u32 timeout_us);
  78. /**
  79. * Obtain current vertical line counter
  80. */
  81. u32 (*get_line_count)(struct dpu_hw_pingpong *pp);
  82. };
  83. struct dpu_hw_pingpong {
  84. struct dpu_hw_blk base;
  85. struct dpu_hw_blk_reg_map hw;
  86. /* pingpong */
  87. enum dpu_pingpong idx;
  88. const struct dpu_pingpong_cfg *caps;
  89. /* ops */
  90. struct dpu_hw_pingpong_ops ops;
  91. };
  92. /**
  93. * dpu_hw_pingpong - convert base object dpu_hw_base to container
  94. * @hw: Pointer to base hardware block
  95. * return: Pointer to hardware block container
  96. */
  97. static inline struct dpu_hw_pingpong *to_dpu_hw_pingpong(struct dpu_hw_blk *hw)
  98. {
  99. return container_of(hw, struct dpu_hw_pingpong, base);
  100. }
  101. /**
  102. * dpu_hw_pingpong_init - initializes the pingpong driver for the passed
  103. * pingpong idx.
  104. * @idx: Pingpong index for which driver object is required
  105. * @addr: Mapped register io address of MDP
  106. * @m: Pointer to mdss catalog data
  107. * Returns: Error code or allocated dpu_hw_pingpong context
  108. */
  109. struct dpu_hw_pingpong *dpu_hw_pingpong_init(enum dpu_pingpong idx,
  110. void __iomem *addr,
  111. struct dpu_mdss_cfg *m);
  112. /**
  113. * dpu_hw_pingpong_destroy - destroys pingpong driver context
  114. * should be called to free the context
  115. * @pp: Pointer to PP driver context returned by dpu_hw_pingpong_init
  116. */
  117. void dpu_hw_pingpong_destroy(struct dpu_hw_pingpong *pp);
  118. #endif /*_DPU_HW_PINGPONG_H */