cam_debug_util.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundataion. All rights reserved.
  4. */
  5. #include <linux/io.h>
  6. #include <linux/module.h>
  7. #include "cam_debug_util.h"
  8. static uint debug_mdl;
  9. module_param(debug_mdl, uint, 0644);
  10. const char *cam_get_module_name(unsigned int module_id)
  11. {
  12. const char *name = NULL;
  13. switch (module_id) {
  14. case CAM_CDM:
  15. name = "CAM-CDM";
  16. break;
  17. case CAM_CORE:
  18. name = "CAM-CORE";
  19. break;
  20. case CAM_CRM:
  21. name = "CAM-CRM";
  22. break;
  23. case CAM_CPAS:
  24. name = "CAM-CPAS";
  25. break;
  26. case CAM_ISP:
  27. name = "CAM-ISP";
  28. break;
  29. case CAM_SENSOR:
  30. name = "CAM-SENSOR";
  31. break;
  32. case CAM_SMMU:
  33. name = "CAM-SMMU";
  34. break;
  35. case CAM_SYNC:
  36. name = "CAM-SYNC";
  37. break;
  38. case CAM_ICP:
  39. name = "CAM-ICP";
  40. break;
  41. case CAM_JPEG:
  42. name = "CAM-JPEG";
  43. break;
  44. case CAM_FD:
  45. name = "CAM-FD";
  46. break;
  47. case CAM_LRME:
  48. name = "CAM-LRME";
  49. break;
  50. case CAM_FLASH:
  51. name = "CAM-FLASH";
  52. break;
  53. case CAM_ACTUATOR:
  54. name = "CAM-ACTUATOR";
  55. break;
  56. case CAM_CCI:
  57. name = "CAM-CCI";
  58. break;
  59. case CAM_CSIPHY:
  60. name = "CAM-CSIPHY";
  61. break;
  62. case CAM_EEPROM:
  63. name = "CAM-EEPROM";
  64. break;
  65. case CAM_UTIL:
  66. name = "CAM-UTIL";
  67. break;
  68. case CAM_CTXT:
  69. name = "CAM-CTXT";
  70. break;
  71. case CAM_HFI:
  72. name = "CAM-HFI";
  73. break;
  74. case CAM_OIS:
  75. name = "CAM-OIS";
  76. break;
  77. case CAM_IRQ_CTRL:
  78. name = "CAM-IRQ-CTRL";
  79. break;
  80. case CAM_MEM:
  81. name = "CAM-MEM";
  82. break;
  83. case CAM_PERF:
  84. name = "CAM-PERF";
  85. break;
  86. case CAM_REQ:
  87. name = "CAM-REQ";
  88. break;
  89. case CAM_CUSTOM:
  90. name = "CAM-CUSTOM";
  91. case CAM_OPE:
  92. name = "CAM-OPE";
  93. break;
  94. case CAM_PRESIL:
  95. name = "CAM-PRESIL";
  96. break;
  97. default:
  98. name = "CAM";
  99. break;
  100. }
  101. return name;
  102. }
  103. void cam_debug_log(unsigned int module_id, const char *func, const int line,
  104. const char *fmt, ...)
  105. {
  106. char str_buffer[STR_BUFFER_MAX_LENGTH];
  107. va_list args;
  108. va_start(args, fmt);
  109. if (debug_mdl & module_id) {
  110. vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
  111. pr_info("CAM_DBG: %s: %s: %d: %s\n",
  112. cam_get_module_name(module_id),
  113. func, line, str_buffer);
  114. }
  115. va_end(args);
  116. }