SF_OMX_Core.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 12
  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_NOMAL_EXTERNAL,
  47. SF_BUFFER_DMA,
  48. SF_BUFFER_DMA_EXTERNAL,
  49. SF_BUFFER_DMA_FD,
  50. SF_BUFFER_DMA_FD_EXTERNAL,
  51. SF_BUFFER_ALL,
  52. }SF_BUFFER_TYPE;
  53. /** This enum defines the transition states of the Component*/
  54. typedef enum OMX_TRANS_STATETYPE {
  55. OMX_TransStateInvalid,
  56. OMX_TransStateLoadedToIdle,
  57. OMX_TransStateIdleToPause,
  58. OMX_TransStatePauseToExecuting,
  59. OMX_TransStateIdleToExecuting,
  60. OMX_TransStateExecutingToIdle,
  61. OMX_TransStateExecutingToPause,
  62. OMX_TransStatePauseToIdle,
  63. OMX_TransStateIdleToLoaded,
  64. OMX_TransStateMax = 0X7FFFFFFF
  65. } OMX_TRANS_STATETYPE;
  66. typedef struct _SF_OMX_BUF_INFO
  67. {
  68. SF_BUFFER_TYPE type;
  69. OMX_PTR remap_vaddr;
  70. OMX_U64 PhysicalAddress;
  71. OMX_S32 fd;
  72. OMX_U32 index;
  73. }SF_OMX_BUF_INFO;
  74. typedef struct _SF_OMX_COMPONENT
  75. {
  76. OMX_STRING componentName;
  77. OMX_STRING libName;
  78. OMX_VERSIONTYPE componentVersion;
  79. OMX_VERSIONTYPE specVersion;
  80. OMX_COMPONENTTYPE *pOMXComponent;
  81. OMX_ERRORTYPE (*SF_OMX_ComponentConstructor)(struct _SF_OMX_COMPONENT *hComponent);
  82. OMX_ERRORTYPE (*SF_OMX_ComponentClear)(struct _SF_OMX_COMPONENT *hComponent);
  83. OMX_PTR soHandle;
  84. // SF_COMPONENT_FUNCTIONS *functions;
  85. OMX_PTR componentImpl;
  86. // OMX_PTR functions;
  87. // Component *hSFComponentExecoder;
  88. // Component *hSFComponentFeeder;
  89. // Component *hSFComponentRender;
  90. // void *testConfig;
  91. // CNMComponentConfig *config;
  92. // void *lsnCtx;
  93. // Uint16 *pusBitCode;
  94. // CodStd bitFormat;
  95. // OMX_VIDEO_PARAM_AVCTYPE AVCComponent[2];
  96. // OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
  97. OMX_CALLBACKTYPE *callbacks;
  98. OMX_PTR pAppData;
  99. OMX_PARAM_PORTDEFINITIONTYPE portDefinition[2];
  100. OMX_HANDLETYPE portSemaphore[2];
  101. OMX_HANDLETYPE portUnloadSemaphore[2];
  102. OMX_HANDLETYPE portFlushSemaphore[2];
  103. OMX_BUFFERHEADERTYPE *pBufferArray[2][MAX_BUFF_NUM];
  104. OMX_U32 assignedBufferNum[2];
  105. OMX_U32 handlingBufferNum[2];
  106. OMX_STRING fwPath;
  107. OMX_STRING componentRule;
  108. OMX_STATETYPE state;
  109. OMX_STATETYPE stateBeforePause;
  110. OMX_TRANS_STATETYPE traningState;
  111. OMX_MARKTYPE markType[2];
  112. OMX_MARKTYPE propagateMarkType;
  113. OMX_BOOL memory_optimization;
  114. OMX_BOOL bPortFlushing[2];
  115. } SF_OMX_COMPONENT;
  116. typedef struct _SF_PORT_PRIVATE
  117. {
  118. OMX_U32 nPortnumber;
  119. } SF_PORT_PRIVATE;
  120. #define OMX_ALIGN32(_x) (((_x)+0x1f)&~0x1f)
  121. #define OMX_ALIGN16(_x) (((_x)+0xf)&~0xf)
  122. #define OMX_ALIGN2(_x) (((_x)+0x1)&~0x1)
  123. #define PRINT_STUCT(a, b) \
  124. do \
  125. { \
  126. printf("size = %d\r\n", sizeof(b)); \
  127. for (int i = 0; i < sizeof(b); i += sizeof(void *)) \
  128. { \
  129. for (int j = 0; j < sizeof(void *); j++) \
  130. { \
  131. printf("%02X ", *((char *)a + i + j)); \
  132. } \
  133. for (int j = 0; j < sizeof(void *); j++) \
  134. { \
  135. printf("%c", *((char *)a + i + j)); \
  136. } \
  137. printf("\r\n"); \
  138. } \
  139. } while (0)
  140. #ifdef __cplusplus
  141. extern "C"
  142. {
  143. #endif
  144. int GetNumberOfComponent();
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148. #endif