logger_interface.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 validate_context;
  33. /*
  34. *
  35. * DAL logger functionality
  36. *
  37. */
  38. struct dal_logger *dal_logger_create(struct dc_context *ctx);
  39. uint32_t dal_logger_destroy(struct dal_logger **logger);
  40. void dm_logger_write(
  41. struct dal_logger *logger,
  42. enum dc_log_type log_type,
  43. const char *msg,
  44. ...);
  45. void dm_logger_append(
  46. struct log_entry *entry,
  47. const char *msg,
  48. ...);
  49. void dm_logger_open(
  50. struct dal_logger *logger,
  51. struct log_entry *entry,
  52. enum dc_log_type log_type);
  53. void dm_logger_close(struct log_entry *entry);
  54. void dc_conn_log(struct dc_context *ctx,
  55. const struct dc_link *link,
  56. uint8_t *hex_data,
  57. int hex_data_count,
  58. enum dc_log_type event,
  59. const char *msg,
  60. ...);
  61. void dc_raw_log(struct dc_context *ctx,
  62. enum dc_log_type event,
  63. const char *msg,
  64. ...);
  65. void logger_write(struct dal_logger *logger,
  66. enum dc_log_type log_type,
  67. const char *msg,
  68. void *paralist);
  69. void pre_surface_trace(
  70. const struct dc *dc,
  71. const struct dc_surface *const *surfaces,
  72. int surface_count);
  73. void update_surface_trace(
  74. const struct dc *dc,
  75. const struct dc_surface_update *updates,
  76. int surface_count);
  77. void post_surface_trace(const struct dc *dc);
  78. void context_timing_trace(
  79. const struct dc *dc,
  80. struct resource_context *res_ctx);
  81. void context_clock_trace(
  82. const struct dc *dc,
  83. struct validate_context *context);
  84. /* Any function which is empty or have incomplete implementation should be
  85. * marked by this macro.
  86. * Note that the message will be printed exactly once for every function
  87. * it is used in order to avoid repeating of the same message. */
  88. #define DAL_LOGGER_NOT_IMPL(fmt, ...) \
  89. { \
  90. static bool print_not_impl = true; \
  91. \
  92. if (print_not_impl == true) { \
  93. print_not_impl = false; \
  94. dm_logger_write(ctx->logger, LOG_WARNING, \
  95. "DAL_NOT_IMPL: " fmt, ##__VA_ARGS__); \
  96. } \
  97. }
  98. /******************************************************************************
  99. * Convenience macros to save on typing.
  100. *****************************************************************************/
  101. #define DC_ERROR(...) \
  102. dm_logger_write(dc_ctx->logger, LOG_ERROR, \
  103. __VA_ARGS__);
  104. #define DTN_INFO(...) \
  105. dc_raw_log(dc_ctx, LOG_DTN, \
  106. __VA_ARGS__)
  107. #define DC_SYNC_INFO(...) \
  108. dm_logger_write(dc_ctx->logger, LOG_SYNC, \
  109. __VA_ARGS__);
  110. /* Connectivity log format:
  111. * [time stamp] [drm] [Major_minor] [connector name] message.....
  112. * eg:
  113. * [ 26.590965] [drm] [Conn_LKTN] [DP-1] HBRx4 pass VS=0, PE=0^
  114. * [ 26.881060] [drm] [Conn_Mode] [DP-1] {2560x1080, 2784x1111@185580Khz}^
  115. */
  116. #define CONN_DATA_DETECT(link, hex_data, hex_len, ...) \
  117. dc_conn_log(link->ctx, link, hex_data, hex_len, \
  118. LOG_EVENT_DETECTION, ##__VA_ARGS__)
  119. #define CONN_DATA_LINK_LOSS(link, hex_data, hex_len, ...) \
  120. dc_conn_log(link->ctx, link, hex_data, hex_len, \
  121. LOG_EVENT_LINK_LOSS, ##__VA_ARGS__)
  122. #define CONN_MSG_LT(link, ...) \
  123. dc_conn_log(link->ctx, link, NULL, 0, \
  124. LOG_EVENT_LINK_TRAINING, ##__VA_ARGS__)
  125. #define CONN_MSG_MODE(link, ...) \
  126. dc_conn_log(link->ctx, link, NULL, 0, \
  127. LOG_EVENT_MODE_SET, ##__VA_ARGS__)
  128. #endif /* __DAL_LOGGER_INTERFACE_H__ */