Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmalomx_logging.c 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "interface/vmcs_host/khronos/IL/OMX_Core.h"
  26. #include "interface/vmcs_host/khronos/IL/OMX_Component.h"
  27. #include "interface/vmcs_host/khronos/IL/OMX_Video.h"
  28. #include "interface/vmcs_host/khronos/IL/OMX_Audio.h"
  29. #include "interface/vmcs_host/khronos/IL/OMX_Broadcom.h"
  30. #include "mmalomx_logging.h"
  31. #include "mmalomx.h"
  32. #include "mmalomx_util_params.h"
  33. #include "interface/vcos/vcos_types.h"
  34. VCOS_LOG_CAT_T mmalomx_log_category;
  35. static VCOS_LOG_LEVEL_T mmalomx_log_level = VCOS_LOG_ERROR;
  36. #define MMALOMX_SAT(a,b,c) ((a)<(b)?(a):(a)>(c)?(c):(a))
  37. void mmalomx_logging_init(void)
  38. {
  39. vcos_log_set_level(VCOS_LOG_CATEGORY, mmalomx_log_level);
  40. vcos_log_register("mmalomx", VCOS_LOG_CATEGORY);
  41. }
  42. void mmalomx_logging_deinit(void)
  43. {
  44. mmalomx_log_level = mmalomx_log_category.level;
  45. vcos_log_unregister(VCOS_LOG_CATEGORY);
  46. }
  47. const char *mmalomx_param_to_string(OMX_INDEXTYPE param)
  48. {
  49. static const struct {
  50. const char *string;
  51. const OMX_INDEXTYPE param;
  52. } param_to_names[] =
  53. {
  54. {"OMX_IndexParamPriorityMgmt", OMX_IndexParamPriorityMgmt},
  55. {"OMX_IndexParamAudioInit", OMX_IndexParamAudioInit},
  56. {"OMX_IndexParamImageInit", OMX_IndexParamImageInit},
  57. {"OMX_IndexParamVideoInit", OMX_IndexParamVideoInit},
  58. {"OMX_IndexParamOtherInit", OMX_IndexParamOtherInit},
  59. {"OMX_IndexParamPortDefinition", OMX_IndexParamPortDefinition},
  60. {"OMX_IndexParamCompBufferSupplier", OMX_IndexParamCompBufferSupplier},
  61. {"OMX_IndexParamAudioPortFormat", OMX_IndexParamAudioPortFormat},
  62. {"OMX_IndexParamVideoPortFormat", OMX_IndexParamVideoPortFormat},
  63. {"OMX_IndexParamImagePortFormat", OMX_IndexParamImagePortFormat},
  64. {"OMX_IndexParamOtherPortFormat", OMX_IndexParamOtherPortFormat},
  65. {"OMX_IndexParamAudioPcm", OMX_IndexParamAudioPcm},
  66. {"OMX_IndexParamAudioAac", OMX_IndexParamAudioAac},
  67. {"OMX_IndexParamAudioMp3", OMX_IndexParamAudioMp3},
  68. {"OMX_IndexParamVideoMpeg2", OMX_IndexParamVideoMpeg2},
  69. {"OMX_IndexParamVideoMpeg4", OMX_IndexParamVideoMpeg4},
  70. {"OMX_IndexParamVideoWmv", OMX_IndexParamVideoWmv},
  71. {"OMX_IndexParamVideoRv", OMX_IndexParamVideoRv},
  72. {"OMX_IndexParamVideoAvc", OMX_IndexParamVideoAvc},
  73. {"OMX_IndexParamVideoH263", OMX_IndexParamVideoH263},
  74. {"OMX_IndexParamStandardComponentRole", OMX_IndexParamStandardComponentRole},
  75. {"OMX_IndexParamContentURI", OMX_IndexParamContentURI},
  76. {"OMX_IndexParamCommonSensorMode", OMX_IndexParamCommonSensorMode},
  77. {"OMX_IndexConfigCommonWhiteBalance", OMX_IndexConfigCommonWhiteBalance},
  78. {"OMX_IndexConfigCommonDigitalZoom", OMX_IndexConfigCommonDigitalZoom},
  79. {"OMX_IndexConfigCommonExposureValue", OMX_IndexConfigCommonExposureValue},
  80. {"OMX_IndexConfigCapturing", OMX_IndexConfigCapturing},
  81. {"OMX_IndexAutoPauseAfterCapture", OMX_IndexAutoPauseAfterCapture},
  82. {"OMX_IndexConfigCommonRotate", OMX_IndexConfigCommonRotate},
  83. {"OMX_IndexConfigCommonMirror", OMX_IndexConfigCommonMirror},
  84. {"OMX_IndexConfigCommonScale", OMX_IndexConfigCommonScale},
  85. {"OMX_IndexConfigCommonInputCrop", OMX_IndexConfigCommonInputCrop},
  86. {"OMX_IndexConfigCommonOutputCrop", OMX_IndexConfigCommonOutputCrop},
  87. {"OMX_IndexParamNumAvailableStreams", OMX_IndexParamNumAvailableStreams},
  88. {"OMX_IndexParamActiveStream", OMX_IndexParamActiveStream},
  89. {"OMX_IndexParamVideoBitrate", OMX_IndexParamVideoBitrate},
  90. {"OMX_IndexParamVideoProfileLevelQuerySupported", OMX_IndexParamVideoProfileLevelQuerySupported},
  91. {"OMX_IndexParam unknown", (OMX_INDEXTYPE)0}
  92. };
  93. const char *name = mmalomx_parameter_name_omx((uint32_t)param);
  94. int i;
  95. if (name)
  96. return name;
  97. for(i = 0; param_to_names[i].param &&
  98. param_to_names[i].param != param; i++);
  99. return param_to_names[i].string;
  100. }
  101. const char *mmalomx_cmd_to_string(OMX_COMMANDTYPE cmd)
  102. {
  103. static const char *names[] = {
  104. "OMX_CommandStateSet", "OMX_CommandFlush", "OMX_CommandPortDisable",
  105. "OMX_CommandPortEnable", "OMX_CommandMarkBuffer", "OMX_Command unknown"
  106. };
  107. return names[MMALOMX_SAT((int)cmd, 0, (int)vcos_countof(names)-1)];
  108. }
  109. const char *mmalomx_state_to_string(OMX_STATETYPE state)
  110. {
  111. static const char *names[] = {
  112. "OMX_StateInvalid", "OMX_StateLoaded", "OMX_StateIdle",
  113. "OMX_StateExecuting", "OMX_StatePause", "OMX_StateWaitForResources",
  114. "OMX_State unknown"
  115. };
  116. return names[MMALOMX_SAT((int)state, 0, (int)vcos_countof(names)-1)];
  117. }
  118. const char *mmalomx_event_to_string(OMX_EVENTTYPE event)
  119. {
  120. static const char *names[] = {
  121. "OMX_EventCmdComplete", "OMX_EventError", "OMX_EventMark",
  122. "OMX_EventPortSettingsChanged", "OMX_EventBufferFlag",
  123. "OMX_EventResourcesAcquired", "OMX_EventComponentResumed",
  124. "OMX_EventDynamicResourcesAvailable", "OMX_EventPortFormatDetected",
  125. "OMX_Event unknown"
  126. };
  127. return names[MMALOMX_SAT((int)event, 0, (int)vcos_countof(names)-1)];
  128. }
  129. const char *mmalomx_error_to_string(OMX_ERRORTYPE error)
  130. {
  131. static const char *names[] = {
  132. "OMX_ErrorInsufficientResources", "OMX_ErrorUndefined",
  133. "OMX_ErrorInvalidComponentName", "OMX_ErrorComponentNotFound",
  134. "OMX_ErrorInvalidComponent", "OMX_ErrorBadParameter",
  135. "OMX_ErrorNotImplemented", "OMX_ErrorUnderflow",
  136. "OMX_ErrorOverflow", "OMX_ErrorHardware", "OMX_ErrorInvalidState",
  137. "OMX_ErrorStreamCorrupt", "OMX_ErrorPortsNotCompatible",
  138. "OMX_ErrorResourcesLost", "OMX_ErrorNoMore", "OMX_ErrorVersionMismatch",
  139. "OMX_ErrorNotReady", "OMX_ErrorTimeout", "OMX_ErrorSameState",
  140. "OMX_ErrorResourcesPreempted", "OMX_ErrorPortUnresponsiveDuringAllocation",
  141. "OMX_ErrorPortUnresponsiveDuringDeallocation",
  142. "OMX_ErrorPortUnresponsiveDuringStop", "OMX_ErrorIncorrectStateTransition",
  143. "OMX_ErrorIncorrectStateOperation", "OMX_ErrorUnsupportedSetting",
  144. "OMX_ErrorUnsupportedIndex", "OMX_ErrorBadPortIndex",
  145. "OMX_ErrorPortUnpopulated", "OMX_ErrorComponentSuspended",
  146. "OMX_ErrorDynamicResourcesUnavailable", "OMX_ErrorMbErrorsInFrame",
  147. "OMX_ErrorFormatNotDetected", "OMX_ErrorContentPipeOpenFailed",
  148. "OMX_ErrorContentPipeCreationFailed", "OMX_ErrorSeperateTablesUsed",
  149. "OMX_ErrorTunnelingUnsupported",
  150. "OMX_Error unkown"
  151. };
  152. if(error == OMX_ErrorNone) return "OMX_ErrorNone";
  153. error -= OMX_ErrorInsufficientResources;
  154. return names[MMALOMX_SAT((int)error, 0, (int)vcos_countof(names)-1)];
  155. }