test_dsp_vi.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #include <stdio.h>
  2. #include <sys/mman.h>
  3. #include <sys/stat.h>
  4. #include <sys/types.h>
  5. #include "csi_dsp_api.h"
  6. #include "csi_dsp_task_defs.h"
  7. #include "csi_dsp_post_process_defs.h"
  8. #define PAYLOAD_SIZE 32
  9. struct message{
  10. int cmd;
  11. char message[PAYLOAD_SIZE];
  12. };
  13. static void isp_algo_result_handler(void *context,void *data)
  14. {
  15. csi_dsp_report_item_t *msg=(csi_dsp_report_item_t *)data;
  16. printf("report recived:%x\n",msg->type);
  17. switch(msg->type)
  18. {
  19. case CSI_DSP_REPORT_ISP_ERR:
  20. printf("ISP error:%d\n",msg->data[0]);
  21. break;
  22. case CSI_DSP_REPORT_RY_ERR:
  23. printf("Post ISP error\n",msg->data[0]);
  24. break;
  25. case CSI_DSP_REPORT_ALGO_ERR:
  26. printf("algo err\n");
  27. break;
  28. case CSI_DSP_REPORT_VI_PRE_ERR:
  29. break;
  30. case CSI_DSP_REPORT_RESULT:
  31. break;
  32. case CSI_DSP_REPORT_HEARTBEAT_ERR:
  33. printf("heartbeat not detect\n");
  34. break;
  35. default:
  36. break;
  37. }
  38. }
  39. // void vi_callback( void *context,void * data)
  40. // {}
  41. int main(int argc, char *argv[])
  42. {
  43. void *instance = csi_dsp_create_instance(0);
  44. if(!instance)
  45. {
  46. printf("create fail\n");
  47. return -1;
  48. }
  49. void *vi_task= csi_dsp_create_task(instance,CSI_DSP_TASK_HW_TO_HW);
  50. if(!vi_task)
  51. {
  52. printf("task create fail\n");
  53. return -1;
  54. }
  55. if(csi_dsp_create_reporter(instance))
  56. {
  57. printf("reporter create fail\n");
  58. return -1;
  59. }
  60. struct csi_dsp_task_fe_para config_params =
  61. {
  62. .frontend_type = CSI_DSP_FE_TYPE_ISP,
  63. .task_id = -1,
  64. {
  65. .isp_param.id=0,
  66. .isp_param.hor=640,
  67. .isp_param.ver=480,
  68. .isp_param.data_fmt=CSI_DSP_IMG_FMT_RAW12_ALGIN,
  69. .isp_param.line_in_entry=640*2,
  70. .isp_param.line_stride=640*2,
  71. .isp_param.buffer_size=640*2*16*2,
  72. .isp_param.buffer_addr=0xb0000000,
  73. }
  74. };
  75. if(csi_dsp_task_config_frontend(vi_task,&config_params))
  76. {
  77. printf("isp config fail\n");
  78. return -1;
  79. }
  80. struct csi_dsp_task_be_para post_config =
  81. {
  82. .backend_type = CSI_DSP_BE_TYPE_POST_ISP,
  83. .task_id = -1,
  84. {
  85. .post_isp_param.id=0,
  86. .post_isp_param.hor=640,
  87. .post_isp_param.ver=480,
  88. .post_isp_param.data_fmt=CSI_DSP_IMG_FMT_RAW12_ALGIN,
  89. .post_isp_param.line_in_entry=640*2,
  90. .post_isp_param.line_stride=640*2,
  91. .post_isp_param.buffer_size=640*2*16*2,
  92. .post_isp_param.buffer_addr=0xb0000000,
  93. }
  94. };
  95. if(csi_dsp_task_config_backend(vi_task,&post_config))
  96. {
  97. printf("post-isp config fail\n");
  98. return -1;
  99. }
  100. struct csi_dsp_algo_config_par alog_config={
  101. .algo_id=0,
  102. };
  103. if(csi_dsp_task_config_algo(vi_task,&alog_config))
  104. {
  105. printf("algo kernel config fail\n");
  106. return -1;
  107. }
  108. if(csi_dsp_task_register_cb(vi_task,isp_algo_result_handler,NULL,32))
  109. {
  110. printf("algo kernel start fail\n");
  111. return -1;
  112. }
  113. if(csi_dsp_task_start(vi_task))
  114. {
  115. printf("task start fail\n");
  116. return -1;
  117. }
  118. while(1)
  119. {
  120. ;
  121. }
  122. return 0;
  123. }
  124. // int test(int argc, char *argv[])
  125. // {
  126. // unsigned char comm_task[] = XRP_PS_NSID_INITIALIZER;
  127. // struct dsp_instnace *instance = create_dsp_instance(0,comm_task);
  128. // if(!instance)
  129. // {
  130. // printf("create fail\n");
  131. // return -1;
  132. // }
  133. // if(dsp_ps_create_reporter(instance))
  134. // {
  135. // printf("reporter create fail\n");
  136. // return -1;
  137. // }
  138. // unsigned char isp_task[] = XRP_PS_NSID_ISP_ALGO;
  139. // struct csi_dsp_ps_task_handler *vi_task= csi_dsp_create_task(instance,isp_task,1);
  140. // if(!vi_task)
  141. // {
  142. // printf("task create fail\n");
  143. // return -1;
  144. // }
  145. // sisp_config_par isp_config =
  146. // {
  147. // .id=0,
  148. // .hor=640,
  149. // .ver=480,
  150. // .data_fmt=IMG_RAW12_FORMAT_ALGIN1,
  151. // .line_in_entry=640*2,
  152. // .line_stride=640*2,
  153. // .buffer_size=640*2*16*2,
  154. // .buffer_addr=0xb0000000,
  155. // };
  156. // struct csi_dsp_task_fe_para *fe_cfg=malloc(sizeof(struct csi_dsp_task_fe_para)+sizeof(sisp_config_par)-1);
  157. // fe_cfg->frontend_type=CSI_DSP_FE_TYPE_ISP;
  158. // memcpy(fe_cfg->para_data,&isp_config,siezof(sisp_config_par));
  159. // if(csi_dsp_task_config_frontend(vi_task,fe_cfg))
  160. // {
  161. // printf("isp config fail\n");
  162. // return -1;
  163. // }
  164. // spost_isp_config_par post_config =
  165. // {
  166. // .id=0,
  167. // .hor=640,
  168. // .ver=480,
  169. // .data_fmt=IMG_RAW12_FORMAT_ALGIN1,
  170. // .line_in_entry=640*2,
  171. // .line_stride=640*2,
  172. // .buffer_size=640*2*16*2,
  173. // .buffer_addr=0xb0000000,
  174. // };
  175. // struct csi_dsp_task_be_para *be_cfg=malloc(sizeof(struct csi_dsp_task_be_para)+sizeof(spost_isp_config_par)-1);
  176. // be_cfg->CSI_DSP_BE_TYPE_POST_ISP;
  177. // memcpy(fe_cfg->para_data,&post_config,siezof(sisp_config_par));
  178. // if(csi_dsp_task_config_backend(vi_task,&be_cfg))
  179. // {
  180. // printf("post-isp config fail\n");
  181. // return -1;
  182. // }
  183. // salgo_config_par alog_config={
  184. // .algo_id=0,
  185. // };
  186. // if(csi_dsp_task_config_algo(vi_task,&alog_config))
  187. // {
  188. // printf("algo kernel config fail\n");
  189. // return -1;
  190. // }
  191. // vi_task->report_id=1;
  192. // if(csi_dsp_task_start(vi_task,isp_algo_result_handler,NULL,32))
  193. // {
  194. // printf("algo kernel start fail\n");
  195. // return -1;
  196. // }
  197. // while(1)
  198. // {
  199. // ;
  200. // }
  201. // csi_dsp_task_stop(vi_task);
  202. // csi_dsp_destroy_task(vi_task);
  203. // csi_dsp_delete_instance(vi_task);
  204. // return 0;
  205. // }