logger_interface.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright 2012-15 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef __DAL_LOGGER_INTERFACE_H__
  26. #define __DAL_LOGGER_INTERFACE_H__
  27. #include "logger_types.h"
  28. struct dc_context;
  29. struct dc_link;
  30. struct dc_surface_update;
  31. struct resource_context;
  32. struct dc_state;
  33. /*
  34. *
  35. * DAL logger functionality
  36. *
  37. */
  38. struct dal_logger *dal_logger_create(struct dc_context *ctx, uint32_t log_mask);
  39. uint32_t dal_logger_destroy(struct dal_logger **logger);
  40. void dm_logger_flush_buffer(struct dal_logger *logger, bool should_warn);
  41. void dm_logger_write(
  42. struct dal_logger *logger,
  43. enum dc_log_type log_type,
  44. const char *msg,
  45. ...);
  46. void dm_logger_append(
  47. struct log_entry *entry,
  48. const char *msg,
  49. ...);
  50. void dm_logger_open(
  51. struct dal_logger *logger,
  52. struct log_entry *entry,
  53. enum dc_log_type log_type);
  54. void dm_logger_close(struct log_entry *entry);
  55. void dc_conn_log(struct dc_context *ctx,
  56. const struct dc_link *link,
  57. uint8_t *hex_data,
  58. int hex_data_count,
  59. enum dc_log_type event,
  60. const char *msg,
  61. ...);
  62. void logger_write(struct dal_logger *logger,
  63. enum dc_log_type log_type,
  64. const char *msg,
  65. void *paralist);
  66. void pre_surface_trace(
  67. struct dc *dc,
  68. const struct dc_plane_state *const *plane_states,
  69. int surface_count);
  70. void update_surface_trace(
  71. struct dc *dc,
  72. const struct dc_surface_update *updates,
  73. int surface_count);
  74. void post_surface_trace(struct dc *dc);
  75. void context_timing_trace(
  76. struct dc *dc,
  77. struct resource_context *res_ctx);
  78. void context_clock_trace(
  79. struct dc *dc,
  80. struct dc_state *context);
  81. /* Any function which is empty or have incomplete implementation should be
  82. * marked by this macro.
  83. * Note that the message will be printed exactly once for every function
  84. * it is used in order to avoid repeating of the same message. */
  85. #define DAL_LOGGER_NOT_IMPL(fmt, ...) \
  86. { \
  87. static bool print_not_impl = true; \
  88. \
  89. if (print_not_impl == true) { \
  90. print_not_impl = false; \
  91. dm_logger_write(ctx->logger, LOG_WARNING, \
  92. "DAL_NOT_IMPL: " fmt, ##__VA_ARGS__); \
  93. } \
  94. }
  95. /******************************************************************************
  96. * Convenience macros to save on typing.
  97. *****************************************************************************/
  98. #define DC_ERROR(...) \
  99. dm_logger_write(dc_ctx->logger, LOG_ERROR, \
  100. __VA_ARGS__)
  101. #define DC_SYNC_INFO(...) \
  102. dm_logger_write(dc_ctx->logger, LOG_SYNC, \
  103. __VA_ARGS__)
  104. /* Connectivity log format:
  105. * [time stamp] [drm] [Major_minor] [connector name] message.....
  106. * eg:
  107. * [ 26.590965] [drm] [Conn_LKTN] [DP-1] HBRx4 pass VS=0, PE=0^
  108. * [ 26.881060] [drm] [Conn_Mode] [DP-1] {2560x1080, 2784x1111@185580Khz}^
  109. */
  110. #define CONN_DATA_DETECT(link, hex_data, hex_len, ...) \
  111. dc_conn_log(link->ctx, link, hex_data, hex_len, \
  112. LOG_EVENT_DETECTION, ##__VA_ARGS__)
  113. #define CONN_DATA_LINK_LOSS(link, hex_data, hex_len, ...) \
  114. dc_conn_log(link->ctx, link, hex_data, hex_len, \
  115. LOG_EVENT_LINK_LOSS, ##__VA_ARGS__)
  116. #define CONN_MSG_LT(link, ...) \
  117. dc_conn_log(link->ctx, link, NULL, 0, \
  118. LOG_EVENT_LINK_TRAINING, ##__VA_ARGS__)
  119. #define CONN_MSG_MODE(link, ...) \
  120. dc_conn_log(link->ctx, link, NULL, 0, \
  121. LOG_EVENT_MODE_SET, ##__VA_ARGS__)
  122. /*
  123. * Display Test Next logging
  124. */
  125. #define DTN_INFO_BEGIN() \
  126. dm_dtn_log_begin(dc_ctx)
  127. #define DTN_INFO(msg, ...) \
  128. dm_dtn_log_append_v(dc_ctx, msg, ##__VA_ARGS__)
  129. #define DTN_INFO_END() \
  130. dm_dtn_log_end(dc_ctx)
  131. #define PERFORMANCE_TRACE_START() \
  132. unsigned long long perf_trc_start_stmp = dm_get_timestamp(dc->ctx); \
  133. unsigned long long perf_trc_start_log_msk = dc->ctx->logger->mask; \
  134. unsigned int perf_trc_start_log_flags = dc->ctx->logger->flags.value; \
  135. if (dc->debug.performance_trace) {\
  136. dm_logger_flush_buffer(dc->ctx->logger, false);\
  137. dc->ctx->logger->mask = 1<<LOG_PERF_TRACE;\
  138. dc->ctx->logger->flags.bits.ENABLE_CONSOLE = 0;\
  139. dc->ctx->logger->flags.bits.ENABLE_BUFFER = 1;\
  140. }
  141. #define PERFORMANCE_TRACE_END() do {\
  142. unsigned long long perf_trc_end_stmp = dm_get_timestamp(dc->ctx);\
  143. if (dc->debug.performance_trace) {\
  144. dm_logger_write(dc->ctx->logger, \
  145. LOG_PERF_TRACE, \
  146. "%s duration: %d ticks\n", __func__,\
  147. perf_trc_end_stmp - perf_trc_start_stmp); \
  148. if (perf_trc_start_log_msk != 1<<LOG_PERF_TRACE) {\
  149. dc->ctx->logger->mask = perf_trc_start_log_msk;\
  150. dc->ctx->logger->flags.value = perf_trc_start_log_flags;\
  151. dm_logger_flush_buffer(dc->ctx->logger, false);\
  152. } \
  153. } \
  154. } while (0)
  155. #endif /* __DAL_LOGGER_INTERFACE_H__ */