carback.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #include "FreeRTOS.h"
  2. #include "task.h"
  3. #include "semphr.h"
  4. #include "chip.h"
  5. #include "board.h"
  6. extern void csi_init(void);
  7. static TaskHandle_t carback_task = NULL;
  8. //static SemaphoreHandle_t carback_mutex;
  9. static int carback_status = 0;
  10. #ifdef VIDEO_DECODER_RN6752
  11. extern int rn6752_init(void);
  12. #endif
  13. #ifdef VIDEO_DECODER_ARK7116
  14. extern int ark7116_init();
  15. #endif
  16. #ifdef VIDEO_DECODER_ARK7116M
  17. extern int ark7116M_init(void);
  18. #endif
  19. void notify_enter_carback(void)
  20. {
  21. if (carback_task)
  22. xTaskNotify(carback_task, 1, eSetValueWithOverwrite);
  23. }
  24. void notify_exit_carback(void)
  25. {
  26. if (carback_task)
  27. xTaskNotify(carback_task, 0, eSetValueWithOverwrite);
  28. }
  29. int get_carback_status(void)
  30. {
  31. int status;
  32. portENTER_CRITICAL();
  33. status = carback_status;
  34. portEXIT_CRITICAL();
  35. return status;
  36. }
  37. static void carback_thread(void *param)
  38. {
  39. uint32_t ulNotifiedValue;
  40. //carback_mutex = xSemaphoreCreateMutex();
  41. #if defined(VIDEO_DECODER_RN6752)
  42. rn6752_init();
  43. #elif defined(VIDEO_DECODER_ARK7116)
  44. ark7116_init();
  45. #elif defined(VIDEO_DECODER_ARK7116M)
  46. ark7116M_init();
  47. #endif
  48. #if defined(VIDEO_DECODER_MIPI)
  49. csi_init();
  50. #endif
  51. for (;;) {
  52. xTaskNotifyWait( 0x00, /* Don't clear any notification bits on entry. */
  53. 0xffffffff, /* Reset the notification value to 0 on exit. */
  54. &ulNotifiedValue, /* Notified value pass out in ulNotifiedValue. */
  55. portMAX_DELAY);
  56. if (ulNotifiedValue && !carback_status) {
  57. printf("enter carback.\n");
  58. ItuConfigPara para = {0};
  59. para.itu601 = ITU_601;//ITU_601
  60. para.out_format = ITU_Y_UV420;//ITU_Y_UV422;//ITU_Y_UV420;
  61. //para.yuv_type = ITU_Y_UV;
  62. para.scale_bypass = 0;
  63. para.in_width = VIN_WIDTH;//VIN_WIDTH;
  64. para.in_height = VIN_HEIGHT;//VIN_HEIGHT;
  65. para.out_width = ITU_OUT_WIDTH;
  66. para.out_height = ITU_OUT_HEIGHT;
  67. para.scale_out_width = ITU_OUT_WIDTH;//LCD_WIDTH;
  68. para.scale_out_height = ITU_OUT_HEIGHT;//LCD_HEIGHT;
  69. para.Input_DataMode = ITU_ITU656_601;//ITU_MIPI;
  70. para.hmirror = 0;//0:normal 1:horizontal mirror
  71. para.vflip = 0;//0:normal 1:vertical filp
  72. itu_config(&para);
  73. itu_start();
  74. carback_status = 1;
  75. } else if (!ulNotifiedValue && carback_status) {
  76. printf("exit carback.\n");
  77. itu_stop();
  78. carback_status = 0;
  79. }
  80. }
  81. }
  82. static void carback_test_thread(void *param)
  83. {
  84. for (;;) {
  85. vTaskDelay(pdMS_TO_TICKS(30000));
  86. notify_enter_carback();
  87. vTaskDelay(pdMS_TO_TICKS(10000));
  88. notify_exit_carback();
  89. }
  90. }
  91. int carback_init(void)
  92. {
  93. /* Create a task to play animation */
  94. if (xTaskCreate(carback_thread, "carback", configMINIMAL_STACK_SIZE, NULL,
  95. configMAX_PRIORITIES - 3, &carback_task) != pdPASS) {
  96. printf("create carback task fail.\n");
  97. carback_task = NULL;
  98. return -1;
  99. }
  100. xTaskCreate(carback_test_thread, "ctest", configMINIMAL_STACK_SIZE, NULL,
  101. configMAX_PRIORITIES / 2, NULL);
  102. return 0;
  103. }