carback.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #if VIN_WIDTH != LCD_WIDTH || VIN_HEIGHT != LCD_HEIGHT
  63. para.scale_bypass = 0;//0:scale enable 1:scale bypass
  64. #else
  65. para.scale_bypass = 1;
  66. #endif
  67. if(para.scale_bypass == 0)
  68. {
  69. para.in_width = VIN_WIDTH;//VIN_WIDTH;
  70. para.in_height = VIN_HEIGHT;//VIN_HEIGHT;
  71. #ifdef REVERSE_TRACK
  72. para.out_width = 704;
  73. para.out_height = 440;
  74. #else
  75. para.out_width = LCD_WIDTH;
  76. para.out_height = LCD_HEIGHT;
  77. #endif
  78. para.scale_out_width = LCD_WIDTH;//LCD_WIDTH;
  79. para.scale_out_height = LCD_HEIGHT;//LCD_HEIGHT;
  80. }
  81. else if(para.scale_bypass == 1)
  82. {
  83. para.in_width = VIN_WIDTH;//VIN_WIDTH;
  84. para.in_height = VIN_HEIGHT;//VIN_HEIGHT;
  85. #ifdef REVERSE_TRACK
  86. para.out_width = 704;
  87. para.out_height = 440;
  88. #else
  89. para.out_width = VIN_WIDTH;//LCD_WIDTH;
  90. para.out_height = VIN_HEIGHT;//LCD_HEIGHT;
  91. #endif
  92. para.scale_out_width = VIN_WIDTH;//LCD_WIDTH;
  93. para.scale_out_height = VIN_HEIGHT;//LCD_HEIGHT;
  94. }
  95. para.Input_DataMode = ITU_ITU656_601;//ITU_MIPI;
  96. para.hmirror = 0;//0:normal 1:horizontal mirror
  97. para.vflip = 0;//0:normal 1:vertical filp
  98. itu_config(&para);
  99. itu_start();
  100. carback_status = 1;
  101. } else if (!ulNotifiedValue && carback_status) {
  102. printf("exit carback.\n");
  103. itu_stop();
  104. carback_status = 0;
  105. }
  106. }
  107. }
  108. static void carback_test_thread(void *param)
  109. {
  110. for (;;) {
  111. vTaskDelay(pdMS_TO_TICKS(30000));
  112. notify_enter_carback();
  113. vTaskDelay(pdMS_TO_TICKS(10000));
  114. notify_exit_carback();
  115. }
  116. }
  117. int carback_init(void)
  118. {
  119. /* Create a task to play animation */
  120. if (xTaskCreate(carback_thread, "carback", configMINIMAL_STACK_SIZE, NULL,
  121. configMAX_PRIORITIES - 3, &carback_task) != pdPASS) {
  122. printf("create carback task fail.\n");
  123. carback_task = NULL;
  124. return -1;
  125. }
  126. xTaskCreate(carback_test_thread, "ctest", configMINIMAL_STACK_SIZE, NULL,
  127. configMAX_PRIORITIES / 2, NULL);
  128. return 0;
  129. }