dp_debug.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _DP_DEBUG_H_
  7. #define _DP_DEBUG_H_
  8. #include "dp_panel.h"
  9. #include "dp_ctrl.h"
  10. #include "dp_link.h"
  11. #include "dp_aux.h"
  12. #include "dp_display.h"
  13. #include "dp_pll.h"
  14. #include <linux/ipc_logging.h>
  15. #define DP_IPC_LOG(fmt, ...) \
  16. do { \
  17. void *ipc_logging_context = get_ipc_log_context(); \
  18. ipc_log_string(ipc_logging_context, fmt, ##__VA_ARGS__); \
  19. } while (0)
  20. #define DP_DEBUG(fmt, ...) \
  21. do { \
  22. DP_IPC_LOG("[d][%-4d]"fmt, current->pid, ##__VA_ARGS__); \
  23. DP_DEBUG_V(fmt, ##__VA_ARGS__); \
  24. } while (0)
  25. #define DP_INFO(fmt, ...) \
  26. do { \
  27. DP_IPC_LOG("[i][%-4d]"fmt, current->pid, ##__VA_ARGS__); \
  28. DP_INFO_V(fmt, ##__VA_ARGS__); \
  29. } while (0)
  30. #define DP_WARN(fmt, ...) \
  31. do { \
  32. DP_IPC_LOG("[w][%-4d]"fmt, current->pid, ##__VA_ARGS__); \
  33. DP_WARN_V(fmt, ##__VA_ARGS__); \
  34. } while (0)
  35. #define DP_ERR(fmt, ...) \
  36. do { \
  37. DP_IPC_LOG("[e][%-4d]"fmt, current->pid, ##__VA_ARGS__); \
  38. DP_ERR_V(fmt, ##__VA_ARGS__); \
  39. } while (0)
  40. #if !defined(CONFIG_SECDP)
  41. #define DP_DEBUG_V(fmt, ...) \
  42. do { \
  43. if (drm_debug_enabled(DRM_UT_KMS)) \
  44. DRM_DEBUG("[msm-dp-debug][%-4d]"fmt, current->pid, \
  45. ##__VA_ARGS__); \
  46. else \
  47. pr_debug("[drm:%s][msm-dp-debug][%-4d]"fmt, __func__,\
  48. current->pid, ##__VA_ARGS__); \
  49. } while (0)
  50. #define DP_INFO_V(fmt, ...) \
  51. do { \
  52. if (drm_debug_enabled(DRM_UT_KMS)) \
  53. DRM_INFO("[msm-dp-info][%-4d]"fmt, current->pid, \
  54. ##__VA_ARGS__); \
  55. else \
  56. pr_info("[drm:%s][msm-dp-info][%-4d]"fmt, __func__, \
  57. current->pid, ##__VA_ARGS__); \
  58. } while (0)
  59. #define DP_WARN_V(fmt, ...) \
  60. pr_warn("[drm:%s][msm-dp-warn][%-4d]"fmt, __func__, \
  61. current->pid, ##__VA_ARGS__)
  62. #define DP_WARN_RATELIMITED_V(fmt, ...) \
  63. pr_warn_ratelimited("[drm:%s][msm-dp-warn][%-4d]"fmt, __func__, \
  64. current->pid, ##__VA_ARGS__)
  65. #define DP_ERR_V(fmt, ...) \
  66. pr_err("[drm:%s][msm-dp-err][%-4d]"fmt, __func__, \
  67. current->pid, ##__VA_ARGS__)
  68. #define DP_ERR_RATELIMITED_V(fmt, ...) \
  69. pr_err_ratelimited("[drm:%s][msm-dp-err][%-4d]"fmt, __func__, \
  70. current->pid, ##__VA_ARGS__)
  71. #else
  72. #define DP_DEBUG_V(fmt, ...) \
  73. do { \
  74. if (drm_debug_enabled(DRM_UT_KMS)) \
  75. DRM_DEBUG("[msm-dp-debug][%-4d]"fmt, current->pid, \
  76. ##__VA_ARGS__); \
  77. else \
  78. pr_debug(fmt, ##__VA_ARGS__); \
  79. } while (0)
  80. #define DP_INFO_V(fmt, ...) \
  81. do { \
  82. if (drm_debug_enabled(DRM_UT_KMS)) \
  83. DRM_INFO("[msm-dp-info][%-4d]"fmt, current->pid, \
  84. ##__VA_ARGS__); \
  85. else \
  86. pr_info(fmt, ##__VA_ARGS__); \
  87. } while (0)
  88. #define DP_WARN_V(fmt, ...) pr_warn(fmt, ##__VA_ARGS__)
  89. #define DP_WARN_RATELIMITED_V(fmt, ...) pr_warn(fmt, ##__VA_ARGS__)
  90. #define DP_ERR_V(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
  91. #define DP_ERR_RATELIMITED_V(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
  92. #endif
  93. #if defined(CONFIG_SECDP_DBG)
  94. extern bool secdp_func_trace;
  95. #define DP_ENTER(fmt, ...) \
  96. do { \
  97. if (secdp_func_trace) \
  98. pr_debug("+++ " pr_fmt(fmt), ##__VA_ARGS__); \
  99. } while (0)
  100. #define DP_LEAVE(fmt, ...) \
  101. do { \
  102. if (secdp_func_trace) \
  103. pr_debug("--- " pr_fmt(fmt), ##__VA_ARGS__); \
  104. } while (0)
  105. #else
  106. #define DP_ENTER(fmt, ...) do {} while (0)
  107. #define DP_LEAVE(fmt, ...) do {} while (0)
  108. #endif
  109. #define DEFAULT_DISCONNECT_DELAY_MS 0
  110. #define MAX_DISCONNECT_DELAY_MS 10000
  111. #define DEFAULT_CONNECT_NOTIFICATION_DELAY_MS 150
  112. #define MAX_CONNECT_NOTIFICATION_DELAY_MS 5000
  113. /**
  114. * struct dp_debug
  115. * @sim_mode: specifies whether sim mode enabled
  116. * @psm_enabled: specifies whether psm enabled
  117. * @hdcp_disabled: specifies if hdcp is disabled
  118. * @hdcp_wait_sink_sync: used to wait for sink synchronization before HDCP auth
  119. * @tpg_pattern: selects tpg pattern on the controller
  120. * @max_pclk_khz: max pclk supported
  121. * @force_encryption: enable/disable forced encryption for HDCP 2.2
  122. * @skip_uevent: skip hotplug uevent to the user space
  123. * @hdcp_status: string holding hdcp status information
  124. * @mst_sim_add_con: specifies whether new sim connector is to be added
  125. * @mst_sim_remove_con: specifies whether sim connector is to be removed
  126. * @mst_sim_remove_con_id: specifies id of sim connector to be removed
  127. * @connect_notification_delay_ms: time (in ms) to wait for any attention
  128. * messages before sending the connect notification uevent
  129. * @disconnect_delay_ms: time (in ms) to wait before turning off the mainlink
  130. * in response to HPD low of cable disconnect event
  131. */
  132. struct dp_debug {
  133. bool sim_mode;
  134. bool psm_enabled;
  135. bool hdcp_disabled;
  136. bool hdcp_wait_sink_sync;
  137. u32 tpg_pattern;
  138. u32 max_pclk_khz;
  139. bool force_encryption;
  140. bool skip_uevent;
  141. char hdcp_status[SZ_128];
  142. bool mst_sim_add_con;
  143. bool mst_sim_remove_con;
  144. int mst_sim_remove_con_id;
  145. unsigned long connect_notification_delay_ms;
  146. u32 disconnect_delay_ms;
  147. void (*abort)(struct dp_debug *dp_debug);
  148. void (*set_mst_con)(struct dp_debug *dp_debug, int con_id);
  149. };
  150. /**
  151. * struct dp_debug_in
  152. * @dev: device instance of the caller
  153. * @panel: instance of panel module
  154. * @hpd: instance of hpd module
  155. * @link: instance of link module
  156. * @aux: instance of aux module
  157. * @connector: double pointer to display connector
  158. * @catalog: instance of catalog module
  159. * @parser: instance of parser module
  160. * @ctrl: instance of controller module
  161. * @pll: instance of pll module
  162. * @display: instance of display module
  163. */
  164. struct dp_debug_in {
  165. struct device *dev;
  166. struct dp_panel *panel;
  167. struct dp_hpd *hpd;
  168. struct dp_link *link;
  169. struct dp_aux *aux;
  170. struct drm_connector **connector;
  171. struct dp_catalog *catalog;
  172. struct dp_parser *parser;
  173. struct dp_ctrl *ctrl;
  174. struct dp_pll *pll;
  175. struct dp_display *display;
  176. };
  177. /**
  178. * dp_debug_get() - configure and get the DisplayPlot debug module data
  179. *
  180. * @in: input structure containing data to initialize the debug module
  181. * return: pointer to allocated debug module data
  182. *
  183. * This function sets up the debug module and provides a way
  184. * for debugfs input to be communicated with existing modules
  185. */
  186. struct dp_debug *dp_debug_get(struct dp_debug_in *in);
  187. /**
  188. * dp_debug_put()
  189. *
  190. * Cleans up dp_debug instance
  191. *
  192. * @dp_debug: instance of dp_debug
  193. */
  194. void dp_debug_put(struct dp_debug *dp_debug);
  195. #endif /* _DP_DEBUG_H_ */