dsp_demo.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. int main(int argc, char *argv[])
  14. {
  15. printf("Dsp Post Process Test Start !\n");
  16. void *instance = csi_dsp_create_instance(0);
  17. if(!instance)
  18. {
  19. printf("create fail\n");
  20. return -1;
  21. }
  22. void *task= csi_dsp_create_task(instance,CSI_DSP_TASK_SW_TO_SW);
  23. if(!task)
  24. {
  25. printf("task create fail\n");
  26. return -1;
  27. }
  28. #if 0
  29. csi_dsp_algo_load_req_t alog_config={
  30. .algo_id=0,
  31. };
  32. if(csi_dsp_task_load_algo(task,&alog_config))
  33. {
  34. printf("algo kernel load fail\n");
  35. return -1;
  36. }
  37. #else
  38. if(csi_dsp_task_acquire_algo(task,"dsp_dummy_algo_pisl"))
  39. {
  40. printf("algo kernel load fail\n");
  41. return -1;
  42. }
  43. #endif
  44. struct csi_sw_task_req* req=NULL;
  45. req =csi_dsp_task_create_request(task);
  46. if(req==NULL)
  47. {
  48. printf("req create fail\n");
  49. return -1;
  50. }
  51. struct csi_dsp_buffer buf1 =
  52. {
  53. .buf_id = 0,
  54. .dir = CSI_DSP_BUFFER_IN,
  55. .type = CSI_DSP_BUF_ALLOC_DRV,
  56. .plane_count = 1,
  57. .width =640,
  58. .height =480,
  59. .planes[0].stride= 640,
  60. .planes[0].size= 640*480,
  61. };
  62. if(csi_dsp_request_add_buffer(req,&buf1))
  63. {
  64. printf("%s,add buffer:%d\n",__FUNCTION__,buf1.buf_id);
  65. csi_dsp_task_release_request(req);
  66. return -1;
  67. }
  68. int i=0;
  69. for(i=0;i<buf1.planes[0].size/4;i++)
  70. {
  71. ((int *)(buf1.planes[0].buf_vir))[i]=rand();
  72. }
  73. struct csi_dsp_buffer buf2 =
  74. {
  75. .buf_id = 1,
  76. .dir = CSI_DSP_BUFFER_OUT,
  77. .type = CSI_DSP_BUF_ALLOC_DRV,
  78. .plane_count = 1,
  79. .width =640,
  80. .height =480,
  81. .planes[0].stride= 640,
  82. .planes[0].size= 640*480,
  83. };
  84. if(csi_dsp_request_add_buffer(req,&buf2))
  85. {
  86. printf("%s,add buffer:%d\n",__FUNCTION__,buf1.buf_id);
  87. csi_dsp_task_release_request(req);
  88. return -1;
  89. }
  90. struct setting{
  91. int with;
  92. int height;
  93. }setting_config;
  94. setting_config.height = 480;
  95. setting_config.with =640;
  96. if(csi_dsp_request_set_property(req,&setting_config,sizeof(setting_config)))
  97. {
  98. printf("%s,seting req fail:%d\n",__FUNCTION__);
  99. csi_dsp_task_release_request(req);
  100. return -1;
  101. }
  102. if(csi_dsp_request_enqueue(req))
  103. {
  104. printf("%s,req enqueu fail:%d\n",__FUNCTION__);
  105. csi_dsp_task_release_request(req);
  106. return -1;
  107. }
  108. req = csi_dsp_request_dequeue(task);
  109. if(req==NULL && req->status != CSI_DSP_SW_REQ_DONE)
  110. {
  111. printf("%s,req dequeue fail:%d\n",__FUNCTION__);
  112. return -1;
  113. }
  114. if(memcmp((void*)buf1.planes[0].buf_vir,(void *)buf2.planes[0].buf_vir,buf1.planes[0].size))
  115. {
  116. printf("%s,cmp fail\n",__FUNCTION__);
  117. csi_dsp_task_release_request(req);
  118. csi_dsp_destroy_task(task);
  119. csi_dsp_delete_instance(instance);
  120. return -1;
  121. }
  122. csi_dsp_task_release_request(req);
  123. csi_dsp_destroy_task(task);
  124. csi_dsp_delete_instance(instance);
  125. printf("%s,Test Pass!\n",__FUNCTION__);
  126. return 0;
  127. }