sdc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. #ifndef SDC_H
  2. #define SDC_H
  3. #include <stdint.h>
  4. #include <sys/ioctl.h>
  5. #include "hi_nnie.h"
  6. #include "hi_type.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /**
  11. 类型转定义
  12. **/
  13. typedef char CHAR;
  14. typedef unsigned char UCHAR;
  15. typedef signed char INT8;
  16. typedef unsigned char UINT8;
  17. typedef signed short INT16;
  18. typedef unsigned short UINT16;
  19. typedef signed int INT32;
  20. typedef unsigned int UINT32;
  21. typedef signed long long INT64;
  22. typedef unsigned long long UINT64;
  23. #define ERR -1
  24. #define TRUE 1
  25. #define FALSE 0
  26. #define OK 0
  27. #define SRVFS_FT_BUFFER 2
  28. #define SRVFS_BUFF_SETWRSIZE _IO(SRVFS_FT_BUFFER,0x11)
  29. #define SRVFS_BUFF_GETWRSIZE _IOR(SRVFS_FT_BUFFER,0x12,unsigned int)
  30. #define SRVFS_BUFF_SETRDSIZE _IO(SRVFS_FT_BUFFER,0x13)
  31. #define SRVFS_BUFF_GETRDSIZE _IOR(SRVFS_FT_BUFFER,0x14,unsigned int)
  32. #define SRVFS_BUFF_GETMSGSIZE _IOR(SRVFS_FT_BUFFER,0x15,unsigned int)
  33. #define SRVFS_FT_PHYMEM 5
  34. typedef struct sdc_mem_stru
  35. {
  36. void* addr_phy;
  37. void* addr_virt;
  38. unsigned int size;
  39. }sdc_mem_s;
  40. #define SRVFS_PHYMEM_MMAP _IOR(SRVFS_FT_PHYMEM,0x00,sdc_mem_s)
  41. #define SRVFS_PHYMEM_MMAPCACHED _IOR(SRVFS_FT_PHYMEM,0x01,sdc_mem_s)
  42. #define SRVFS_PHYMEM_MUNMAP _IOW(SRVFS_FT_PHYMEM,0x02,sdc_mem_s)
  43. #define SRVFS_PHYMEM_CACHEFLUSH _IOW(SRVFS_FT_PHYMEM,0x03,sdc_mem_s)
  44. /*
  45. * SHM CACHE
  46. */
  47. #define SDC_SHM_CACHE_DEV "/dev/cache"
  48. typedef struct SDC_SHM_CACHE_Stru
  49. {
  50. void* addr_virt;
  51. unsigned long addr_phy;
  52. unsigned int size;
  53. unsigned int cookie;
  54. int ttl;
  55. }SDC_SHM_CACHE_S;
  56. #define SDC_CACHE_ALLOC _IOR(SDC_FT_CACHE,0x00, SDC_SHM_CACHE_S)
  57. #define SDC_FT_CACHE 7
  58. #define SDC_CACHE_GETPHY _IOR(SDC_FT_CACHE,0x00, SDC_SHM_CACHE_S)
  59. #define SDC_CACHE_MMAP _IOR(SDC_FT_CACHE,0x01, SDC_SHM_CACHE_S)
  60. /* 消息头的数据结构定义
  61. */
  62. #define SDC_VERSION 0x5331
  63. #define SDC_METHOD_CREATE 1
  64. #define SDC_METHOD_GET 2
  65. #define SDC_METHOD_UPDATE 3
  66. #define SDC_METHOD_DELETE 4
  67. #define SDC_CODE_200 200
  68. #define SDC_CODE_400 400
  69. #define SDC_CODE_401 401
  70. #define SDC_CODE_403 403
  71. #define SDC_CODE_500 500
  72. typedef struct sdc_common_head_stru
  73. {
  74. uint16_t version;
  75. uint8_t url_ver;
  76. #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__)
  77. #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  78. uint8_t method: 7;
  79. uint8_t response: 1;
  80. #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  81. uint8_t response: 1;
  82. uint8_t method: 7;
  83. #else
  84. #error "unknown __BYTE_ORDER__"
  85. #endif
  86. #else
  87. #error "don't define __BYTE_ORDER__ or __ORDER_LITTLE_ENDIAN__ or __ORDER_BIG_ENDIAN__"
  88. #endif
  89. uint16_t url;
  90. uint16_t code;
  91. uint16_t head_length;
  92. uint16_t trans_id;
  93. uint32_t content_length;
  94. }sdc_common_head_s;
  95. typedef struct sdc_extend_head_stru
  96. {
  97. uint16_t type;
  98. uint16_t length;
  99. uint32_t reserve;
  100. }sdc_extend_head_s;
  101. #define sdc_extend_head_length(extend_head) (((extend_head)->length + 7) & ~7)
  102. #define sdc_extend_head_next(extend_head) ((sdc_extend_head_s*)((char*)extend_head + sdc_extend_head_length(extend_head)))
  103. #define sdc_extend_head_first(common_head) ((sdc_extend_head_s*)(common_head + 1))
  104. #define sdc_for_each_extend_head(common_head, extend_head) \
  105. for( extend_head = sdc_extend_head_first(common_head); (char*)extend_head - (char*)common_head < common_head->head_length; extend_head = sdc_extend_head_next(extend_head))
  106. /**
  107. * video.iaas.sdc服务的数据结构定义
  108. */
  109. /**
  110. * YUV Channel的数据格式定义
  111. */
  112. #define SDC_URL_YUV_CHANNEL 0x00
  113. #define SDC_YVU_420SP 0x00
  114. typedef struct sdc_yuv_channel_param_stru
  115. {
  116. uint32_t channel;
  117. uint32_t width;
  118. uint32_t height;
  119. uint32_t fps;
  120. uint32_t on_off;
  121. uint32_t format; // YUV_420SP 当前发的临时版本没有这个字段,正式版本补充进去
  122. }sdc_yuv_channel_param_s;
  123. typedef struct sdc_resolution_stru
  124. {
  125. uint32_t width;
  126. uint32_t height;
  127. }sdc_resolution_s;
  128. typedef struct sdc_yuv_channel_info_stru
  129. {
  130. sdc_yuv_channel_param_s param;
  131. sdc_resolution_s max_resolution;
  132. uint32_t is_snap_channel;
  133. uint32_t src_id;
  134. uint32_t subscribe_cnt;
  135. uint32_t nResolutionModitfy;/*此通道分辨率是否支持修改,0不支持修改,1支持修改*/
  136. }sdc_yuv_channel_info_s;
  137. #define SDC_URL_YUV_DATA 0x01
  138. #define SDC_HEAD_YUV_SYNC 0x00
  139. #define SDC_HEAD_YUV_CACHED_COUNT_MAX 0x01
  140. #define SDC_HEAD_YUV_PARAM_MASK 0x02
  141. #define SDC_HEAD_YUV_CACHED_COUNT 0x10
  142. #define SDC_HEAD_YUV_PARAM_SNAP 0x13
  143. typedef struct sdc_yuv_frame_stru
  144. {
  145. uint64_t addr_phy;
  146. uint64_t addr_virt;
  147. uint32_t size;
  148. uint32_t width;
  149. uint32_t height;
  150. uint32_t stride;
  151. uint32_t format; // YUV_420SP
  152. uint32_t reserve;
  153. uint32_t cookie[4];
  154. }sdc_yuv_frame_s;
  155. typedef struct sdc_yuv_data_stru
  156. {
  157. uint32_t channel;
  158. uint32_t reserve;
  159. uint64_t pts;
  160. uint64_t pts_sys;
  161. sdc_yuv_frame_s frame;
  162. }sdc_yuv_data_s;
  163. typedef struct sdc_chan_query_stru
  164. {
  165. uint32_t channel;
  166. }sdc_chan_query_s;
  167. #define SDC_URL_VENC_DATA 0x03
  168. #define SDC_HEAD_VENC_CACHED_COUNT_MAX 0x01
  169. #define SDC_HEAD_VENC_CACHED_COUNT 0x10
  170. #define SDC_VENC_FRAME_I 0x00
  171. #define SDC_VENC_FRAME_P 0x01
  172. #define SDC_VENC_FRAME_B 0x02
  173. typedef struct sdc_venc_frame_stru
  174. {
  175. uint64_t addr_phy;
  176. uint64_t addr_virt;
  177. uint64_t size;
  178. uint32_t width;
  179. uint32_t height;
  180. uint32_t format;
  181. uint32_t frame_type;
  182. uint64_t cookie[8];
  183. }sdc_venc_frame_s;
  184. typedef struct sdc_venc_data_stru
  185. {
  186. uint32_t channel;
  187. uint32_t reserve;
  188. uint64_t ulpts;
  189. uint64_t pts_sys;
  190. sdc_venc_frame_s frame;
  191. }sdc_venc_data_s;
  192. #define SDC_URL_YUV_SNAP 0x04
  193. typedef struct sdc_yuv_snap_param_stru
  194. {
  195. uint32_t id;
  196. uint32_t num;
  197. uint32_t interval_msec;
  198. }sdc_yuv_snap_param_s;
  199. #define SDC_URL_RED_LIGHT_ENHANCED 0x05
  200. typedef struct sdc_region_stru
  201. {
  202. uint32_t x;
  203. uint32_t y;
  204. uint32_t w;
  205. uint32_t h;
  206. }sdc_region_s;
  207. typedef struct sdc_red_light_enhanced_param_stru
  208. {
  209. uint32_t level;
  210. uint32_t num;
  211. uint32_t uImgWidth; /*图像的宽度,用来计算比例*/
  212. uint32_t uImgHeight; /*图像的高度,用来计算比例*/
  213. sdc_region_s regions[0];
  214. }sdc_red_light_enhanced_param_s;
  215. /**
  216. * codec.iaas.sdc 服务接口数据结构定义
  217. */
  218. #define SDC_URL_ENCODED_JPEG 0x00
  219. typedef struct sdc_osd_stru
  220. {
  221. uint8_t format[128];
  222. uint32_t reserve;
  223. uint32_t content_len;
  224. uint8_t content[2048];
  225. }sdc_osd_s;
  226. typedef struct sdc_osd_region_stru
  227. {
  228. sdc_region_s region;
  229. sdc_osd_s osd;
  230. }sdc_osd_region_s;
  231. typedef struct sdc_encode_jpeg_param_stru
  232. {
  233. uint16_t qf;
  234. uint16_t osd_region_cnt;
  235. uint32_t reserve;
  236. sdc_region_s region;
  237. sdc_yuv_frame_s frame;
  238. sdc_osd_region_s osd_region[0];
  239. }sdc_encode_jpeg_param_s;
  240. typedef struct sdc_jpeg_frame_stru
  241. {
  242. uint64_t addr_phy;
  243. uint64_t addr_virt;
  244. uint32_t size;
  245. uint32_t reserve;
  246. uint32_t cookie[4];
  247. }sdc_jpeg_frame_s;
  248. #define SDC_URL_DECODED_YUV 0x01
  249. #define SDC_HEAD_DECODED_YUV_ACCEPT_TYPE 0x00
  250. #define SDC_BGR888 0x10
  251. #define SDC_RGB888 0x11
  252. #define SDC_URL_OSD_BOX_HEIGHT 0x02
  253. typedef struct sdc_osd_box_stru
  254. {
  255. uint32_t width;
  256. sdc_osd_s osd;
  257. }sdc_osd_box_s;
  258. #define SDC_URL_COMBINED_IMAGE 0x03
  259. #define SDC_HEAD_COMBINED_CONTENT_TYPE 0x00
  260. #define SDC_HEAD_COMBINED_JPEG_QF 0x01
  261. #define SDC_HEAD_COMBINED_OSD 0x12
  262. typedef struct sdc_combined_yuv_stru
  263. {
  264. sdc_region_s origin_region;
  265. sdc_region_s combined_region;
  266. sdc_yuv_frame_s frame;
  267. }sdc_combined_yuv_s;
  268. typedef struct sdc_combined_yuv_param_stru
  269. {
  270. uint32_t width;
  271. uint32_t height;
  272. uint32_t yuv_cnt;
  273. uint32_t reserve;
  274. sdc_combined_yuv_s yuv[0];
  275. }sdc_combined_yuv_param_s;
  276. /**
  277. * utils.iaas.sdc服务接口数据结构定义
  278. */
  279. #define SDC_URL_HARDWARE_ID 100
  280. typedef struct sdc_hardware_id_stru
  281. {
  282. char id[33];
  283. }sdc_hardware_id_s;
  284. #define SDC_URL_MMZ 101
  285. #define SDC_HEAD_MMZ_CACHED 0x00
  286. typedef struct sdc_mmz_alloc_stru
  287. {
  288. uint64_t addr_phy;
  289. uint64_t addr_virt;
  290. uint32_t size;
  291. uint32_t reserve;
  292. uint32_t cookie[4];
  293. }sdc_mmz_alloc_s;
  294. /**
  295. * appmgr.paas.sdc服务接口数据结构定义
  296. */
  297. #define SDC_URL_APP_WATCHDOG 200
  298. typedef struct appdog_op_req_stru
  299. {
  300. int32_t watchdog_time;
  301. }appdog_op_req_s;
  302. /**
  303. * event.paas.sdc服务接口数据结果定义
  304. */
  305. #define event_paas_name "/mnt/srvfs/event.paas.sdc"
  306. #define SDC_URL_PAAS_EVENTD_EVENT 0
  307. #define SDC_HEAD_SHM_CACHED_EVENT 0xFFFF
  308. typedef struct paas_event_stru
  309. {
  310. char publisher[16]; //发送事件的服务标识,调测使用
  311. char name[16]; //事件唯一标识,建议同域名定义避免冲突
  312. uint64_t src_timestamp; //发生时的时间,单位毫秒(CLOCK_MONOTONIC时间)
  313. uint64_t tran_timestamp; //服务转发的时间,单位毫秒(CLOCK_MONOTONIC时间)
  314. uint32_t id; //建议同IP地址一样管理,不同前缀对应事件分类,方便分类订阅。
  315. uint32_t length; //事件内容的长度.
  316. char data[0];
  317. }paas_event_s;
  318. typedef struct paas_shm_cached_event_stru
  319. {
  320. uint64_t addr_phy;
  321. uint32_t size;
  322. uint32_t cookie;
  323. }paas_shm_cached_event_s;
  324. typedef struct paas_event_filter_stru
  325. {
  326. char subscriber[16]; //订阅者的标识, 调测使用
  327. char name[16];
  328. char filter[256];
  329. }paas_event_filter_s;
  330. #define SDC_URL_PAAS_EVENTD_SUBSCRIBE_STAT 0X01
  331. typedef struct paas_event_subscribe_stat_stru
  332. {
  333. char name[16];
  334. uint64_t cnt;
  335. uint64_t fail_cnt;
  336. }paas_event_subscribe_stat_s;
  337. typedef struct LABEL_EVENT_DATA_STRU
  338. {
  339. paas_event_s base;
  340. char* data;
  341. }LABEL_EVENT_DATA_S;
  342. #define SDC_URL_PAAS_EVENTD_PUBLISH_STAT 0X02
  343. typedef struct paas_event_publish_stat_stru
  344. {
  345. char name[16];
  346. uint32_t subscriber_cnt;
  347. uint64_t cnt;
  348. uint64_t trans_cnt; //成功转发的次数
  349. uint64_t fail_cnt; //转发失败的次数
  350. }paas_event_publish_stat_s;
  351. /**
  352. *
  353. * algorithm.iaas.sdc
  354. */
  355. #define SDC_URL_NNIE_MODEL 0x00
  356. #define SDC_URL_NNIE_FORWARD 0x01
  357. #define SDC_URL_NNIE_FORWARD_BBOX 0x02
  358. #define MAX_MODULE_PATH 100
  359. #define NNIE_MODEL_CONTENT_MMZ 0
  360. #define NNIE_MODEL_CONTENT_FILE 1
  361. #define NNIE_NNIE_MODEL_OP 1
  362. #define SDC_HEAD_NNIE_MODEL_CONTENT_TYPE 1
  363. typedef struct sdc_nnie_forward_ctrl_stru
  364. {
  365. uint32_t netseg_id;
  366. uint32_t max_batch_num;
  367. uint32_t max_bbox_num;
  368. uint32_t reserve;
  369. }sdc_nnie_forward_ctrl_s;
  370. typedef struct sdc_nnie_forward_stru
  371. {
  372. SVP_NNIE_MODEL_S model;
  373. sdc_nnie_forward_ctrl_s forward_ctrl;
  374. SVP_SRC_BLOB_S astSrc[16];
  375. SVP_DST_BLOB_S astDst[16];
  376. }sdc_nnie_forward_s;
  377. typedef struct sdc_nnie_forward_withbox_ctrl_stru
  378. {
  379. uint32_t proposal_num;
  380. uint32_t netseg_id;
  381. uint32_t max_batch_num;
  382. uint32_t max_bbox_num;
  383. }sdc_nnie_forward_withbox_ctrl_s;
  384. typedef struct sdc_nnie_forward_withbox_stru
  385. {
  386. SVP_NNIE_MODEL_S model;
  387. sdc_nnie_forward_withbox_ctrl_s forward_ctl;
  388. SVP_SRC_BLOB_S astSrc[16];
  389. SVP_SRC_BLOB_S astBbox[16];
  390. SVP_DST_BLOB_S astDst[16];
  391. }sdc_nnie_forward_withbox_s;
  392. #ifdef __cplusplus
  393. }
  394. #endif
  395. #endif