test_dsp_vi.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. // void vi_callback( void *context,void * data)
  14. // {}
  15. int main(int argc, char *argv[])
  16. {
  17. void *instance = csi_dsp_create_instance(0);
  18. if(!instance)
  19. {
  20. printf("create fail\n");
  21. return -1;
  22. }
  23. void *vi_task= csi_dsp_create_task(instance,CSI_DSP_TASK_HW_TO_HW);
  24. if(!vi_task)
  25. {
  26. printf("task create fail\n");
  27. return -1;
  28. }
  29. if(csi_dsp_create_reporter(instance))
  30. {
  31. printf("reporter create fail\n");
  32. return -1;
  33. }
  34. struct csi_dsp_task_fe_para config_params =
  35. {
  36. .frontend_type = CSI_DSP_FE_TYPE_ISP,
  37. .task_id = -1,
  38. {
  39. .isp_param.id=0,
  40. .isp_param.hor=640,
  41. .isp_param.ver=480,
  42. .isp_param.data_fmt=CSI_DSP_IMG_FMT_RAW12_ALGIN,
  43. .isp_param.line_in_entry=640*2,
  44. .isp_param.line_stride=640*2,
  45. .isp_param.buffer_size=640*2*16*2,
  46. .isp_param.buffer_addr=0xb0000000,
  47. }
  48. };
  49. if(csi_dsp_task_config_frontend(vi_task,&config_params))
  50. {
  51. printf("isp config fail\n");
  52. return -1;
  53. }
  54. struct csi_dsp_task_be_para post_config =
  55. {
  56. .backend_type = CSI_DSP_BE_TYPE_POST_ISP,
  57. .task_id = -1,
  58. {
  59. .post_isp_param.id=0,
  60. .post_isp_param.hor=640,
  61. .post_isp_param.ver=480,
  62. .post_isp_param.data_fmt=CSI_DSP_IMG_FMT_RAW12_ALGIN,
  63. .post_isp_param.line_in_entry=640*2,
  64. .post_isp_param.line_stride=640*2,
  65. .post_isp_param.buffer_size=640*2*16*2,
  66. .post_isp_param.buffer_addr=0xb0000000,
  67. }
  68. };
  69. if(csi_dsp_task_config_backend(vi_task,&post_config))
  70. {
  71. printf("post-isp config fail\n");
  72. return -1;
  73. }
  74. struct csi_dsp_algo_config_par alog_config={
  75. .algo_id=0,
  76. };
  77. if(csi_dsp_task_config_algo(vi_task,&alog_config))
  78. {
  79. printf("algo kernel config fail\n");
  80. return -1;
  81. }
  82. if(csi_dsp_task_register_cb(vi_task,isp_algo_result_handler,NULL,32))
  83. {
  84. printf("algo kernel start fail\n");
  85. return -1;
  86. }
  87. if(csi_dsp_task_start(vi_task))
  88. {
  89. printf("task start fail\n");
  90. return -1;
  91. }
  92. while(1)
  93. {
  94. ;
  95. }
  96. return 0;
  97. }
  98. // int test(int argc, char *argv[])
  99. // {
  100. // unsigned char comm_task[] = XRP_PS_NSID_INITIALIZER;
  101. // struct dsp_instnace *instance = create_dsp_instance(0,comm_task);
  102. // if(!instance)
  103. // {
  104. // printf("create fail\n");
  105. // return -1;
  106. // }
  107. // if(dsp_ps_create_reporter(instance))
  108. // {
  109. // printf("reporter create fail\n");
  110. // return -1;
  111. // }
  112. // unsigned char isp_task[] = XRP_PS_NSID_ISP_ALGO;
  113. // struct csi_dsp_ps_task_handler *vi_task= csi_dsp_create_task(instance,isp_task,1);
  114. // if(!vi_task)
  115. // {
  116. // printf("task create fail\n");
  117. // return -1;
  118. // }
  119. // sisp_config_par isp_config =
  120. // {
  121. // .id=0,
  122. // .hor=640,
  123. // .ver=480,
  124. // .data_fmt=IMG_RAW12_FORMAT_ALGIN1,
  125. // .line_in_entry=640*2,
  126. // .line_stride=640*2,
  127. // .buffer_size=640*2*16*2,
  128. // .buffer_addr=0xb0000000,
  129. // };
  130. // struct csi_dsp_task_fe_para *fe_cfg=malloc(sizeof(struct csi_dsp_task_fe_para)+sizeof(sisp_config_par)-1);
  131. // fe_cfg->frontend_type=CSI_DSP_FE_TYPE_ISP;
  132. // memcpy(fe_cfg->para_data,&isp_config,siezof(sisp_config_par));
  133. // if(csi_dsp_task_config_frontend(vi_task,fe_cfg))
  134. // {
  135. // printf("isp config fail\n");
  136. // return -1;
  137. // }
  138. // spost_isp_config_par post_config =
  139. // {
  140. // .id=0,
  141. // .hor=640,
  142. // .ver=480,
  143. // .data_fmt=IMG_RAW12_FORMAT_ALGIN1,
  144. // .line_in_entry=640*2,
  145. // .line_stride=640*2,
  146. // .buffer_size=640*2*16*2,
  147. // .buffer_addr=0xb0000000,
  148. // };
  149. // struct csi_dsp_task_be_para *be_cfg=malloc(sizeof(struct csi_dsp_task_be_para)+sizeof(spost_isp_config_par)-1);
  150. // be_cfg->CSI_DSP_BE_TYPE_POST_ISP;
  151. // memcpy(fe_cfg->para_data,&post_config,siezof(sisp_config_par));
  152. // if(csi_dsp_task_config_backend(vi_task,&be_cfg))
  153. // {
  154. // printf("post-isp config fail\n");
  155. // return -1;
  156. // }
  157. // salgo_config_par alog_config={
  158. // .algo_id=0,
  159. // };
  160. // if(csi_dsp_task_config_algo(vi_task,&alog_config))
  161. // {
  162. // printf("algo kernel config fail\n");
  163. // return -1;
  164. // }
  165. // vi_task->report_id=1;
  166. // if(csi_dsp_task_start(vi_task,isp_algo_result_handler,NULL,32))
  167. // {
  168. // printf("algo kernel start fail\n");
  169. // return -1;
  170. // }
  171. // while(1)
  172. // {
  173. // ;
  174. // }
  175. // csi_dsp_task_stop(vi_task);
  176. // csi_dsp_destroy_task(vi_task);
  177. // csi_dsp_delete_instance(vi_task);
  178. // return 0;
  179. // }