SF_OMX_Core.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2021 StarFive Technology Co., Ltd.
  4. */
  5. #ifndef OMX__CORE
  6. #define OMX__CORE
  7. #include "OMX_Types.h"
  8. #include "OMX_Core.h"
  9. #include "OMX_Component.h"
  10. #include "OMX_VideoExt.h"
  11. #include <sys/time.h>
  12. #include <stdarg.h>
  13. #include <dlfcn.h>
  14. #include <string.h>
  15. #define ENABLE_DEBUG
  16. #ifdef ENABLE_DEBUG
  17. enum
  18. {
  19. SF_LOG_ERR = 0,
  20. SF_LOG_WARN,
  21. SF_LOG_PERF,
  22. SF_LOG_INFO,
  23. SF_LOG_DEBUG,
  24. SF_LOG_ALL,
  25. };
  26. void SF_LogMsg(int level, const char *function, int line, const char *format, ...);
  27. void SF_LogMsgAppend(int level, const char *format, ...);
  28. #define LOG(level, ...) SF_LogMsg(level, __FUNCTION__, __LINE__, __VA_ARGS__);
  29. #define LOG_APPEND(level, ...) SF_LogMsgAppend(level, __VA_ARGS__);
  30. #define FunctionIn() SF_LogMsg(SF_LOG_DEBUG, __FUNCTION__, __LINE__, "FUN IN\r\n");
  31. #define FunctionOut() SF_LogMsg(SF_LOG_DEBUG, __FUNCTION__, __LINE__, "FUN OUT\r\n");
  32. #else
  33. #define FunctionIn()
  34. #define FunctionOut()
  35. #endif
  36. #define VPU_OUTPUT_BUF_NUMBER 10
  37. #define VPU_INPUT_BUF_NUMBER 5
  38. #define MAX_BUFF_NUM 32
  39. #define VERSIONMAJOR_NUMBER 1
  40. #define VERSIONMINOR_NUMBER 0
  41. #define REVISION_NUMBER 0
  42. #define STEP_NUMBER 0
  43. typedef enum SF_BUFFER_TYPE
  44. {
  45. SF_BUFFER_NOMAL = 0,
  46. SF_BUFFER_DMA,
  47. SF_BUFFER_DMA_EXTERNAL,
  48. SF_BUFFER_DMA_FD,
  49. SF_BUFFER_DMA_FD_EXTERNAL,
  50. SF_BUFFER_ALL,
  51. }SF_BUFFER_TYPE;
  52. /** This enum defines the transition states of the Component*/
  53. typedef enum OMX_TRANS_STATETYPE {
  54. OMX_TransStateInvalid,
  55. OMX_TransStateLoadedToIdle,
  56. OMX_TransStateIdleToPause,
  57. OMX_TransStatePauseToExecuting,
  58. OMX_TransStateIdleToExecuting,
  59. OMX_TransStateExecutingToIdle,
  60. OMX_TransStateExecutingToPause,
  61. OMX_TransStatePauseToIdle,
  62. OMX_TransStateIdleToLoaded,
  63. OMX_TransStateMax = 0X7FFFFFFF
  64. } OMX_TRANS_STATETYPE;
  65. typedef struct _SF_OMX_BUF_INFO
  66. {
  67. SF_BUFFER_TYPE type;
  68. OMX_U64 PhysicalAddress;
  69. OMX_S32 fd;
  70. OMX_U32 index;
  71. }SF_OMX_BUF_INFO;
  72. typedef struct _SF_OMX_COMPONENT
  73. {
  74. OMX_STRING componentName;
  75. OMX_STRING libName;
  76. OMX_VERSIONTYPE componentVersion;
  77. OMX_VERSIONTYPE specVersion;
  78. OMX_COMPONENTTYPE *pOMXComponent;
  79. OMX_ERRORTYPE (*SF_OMX_ComponentConstructor)(struct _SF_OMX_COMPONENT *hComponent);
  80. OMX_ERRORTYPE (*SF_OMX_ComponentClear)(struct _SF_OMX_COMPONENT *hComponent);
  81. OMX_PTR soHandle;
  82. // SF_COMPONENT_FUNCTIONS *functions;
  83. OMX_PTR componentImpl;
  84. // OMX_PTR functions;
  85. // Component *hSFComponentExecoder;
  86. // Component *hSFComponentFeeder;
  87. // Component *hSFComponentRender;
  88. // void *testConfig;
  89. // CNMComponentConfig *config;
  90. // void *lsnCtx;
  91. // Uint16 *pusBitCode;
  92. // CodStd bitFormat;
  93. // OMX_VIDEO_PARAM_AVCTYPE AVCComponent[2];
  94. // OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
  95. OMX_CALLBACKTYPE *callbacks;
  96. OMX_PTR pAppData;
  97. OMX_PARAM_PORTDEFINITIONTYPE portDefinition[2];
  98. OMX_HANDLETYPE portSemaphore[2];
  99. OMX_HANDLETYPE portUnloadSemaphore[2];
  100. OMX_BUFFERHEADERTYPE *pBufferArray[2][MAX_BUFF_NUM];
  101. OMX_U32 assignedBufferNum[2];
  102. OMX_STRING fwPath;
  103. OMX_STRING componentRule;
  104. OMX_STATETYPE state;
  105. OMX_STATETYPE stateBeforePause;
  106. OMX_TRANS_STATETYPE traningState;
  107. OMX_MARKTYPE markType[2];
  108. OMX_MARKTYPE propagateMarkType;
  109. OMX_BOOL memory_optimization;
  110. } SF_OMX_COMPONENT;
  111. typedef struct _SF_PORT_PRIVATE
  112. {
  113. OMX_U32 nPortnumber;
  114. } SF_PORT_PRIVATE;
  115. #define PRINT_STUCT(a, b) \
  116. do \
  117. { \
  118. printf("size = %d\r\n", sizeof(b)); \
  119. for (int i = 0; i < sizeof(b); i += sizeof(void *)) \
  120. { \
  121. for (int j = 0; j < sizeof(void *); j++) \
  122. { \
  123. printf("%02X ", *((char *)a + i + j)); \
  124. } \
  125. for (int j = 0; j < sizeof(void *); j++) \
  126. { \
  127. printf("%c", *((char *)a + i + j)); \
  128. } \
  129. printf("\r\n"); \
  130. } \
  131. } while (0)
  132. #ifdef __cplusplus
  133. extern "C"
  134. {
  135. #endif
  136. int GetNumberOfComponent();
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif