Facebook
From Big Crocodile, 2 Months ago, written in C.
Embed
Download Paste or View Raw
Hits: 30
  1. #include "chains_tutorialTwoCam_Display_priv.h"
  2. #include <src/hlos/adas/include/chains.h>
  3. #include <src/hlos/common/chains_common.h>
  4.  
  5.  
  6. #define CAPTURE_SENSOR_WIDTH      (1280)
  7. #define CAPTURE_SENSOR_HEIGHT     (720)
  8. #define NUMBER_OF_CAM             (2)
  9. #define NUMBER_OF_PORT            (NUMBER_OF_CAM / 2)
  10.  
  11.  
  12. /**
  13.  *******************************************************************************
  14.  *
  15.  *  \brief  Use-case object
  16.  *
  17.  *        This structure contains all the LinksId's and create Params.
  18.  *        The same is passed to all create, start, stop functions.
  19.  *
  20.  *******************************************************************************
  21. */
  22. typedef struct {
  23.  
  24.     chains_tutorialTwoCam_DisplayObj ucObj;
  25.  
  26.     UInt32  captureOutWidth;
  27.     UInt32  captureOutHeight;
  28.     UInt32  displayWidth;
  29.     UInt32  displayHeight;
  30.  
  31.     Chains_Ctrl *chainsCfg;
  32.  
  33.     VideoSensorCreateAndStartAppPrm vidSensorPrm;
  34.  
  35.     UInt32  appCtrlLinkId;
  36.  
  37.     UInt32  displayActiveChId;
  38.     /**< CH ID which is shown on display, by default 2x2 SW Mosaic
  39.      *   is shown on display
  40.      */
  41.     UInt32  numLvdsCh;
  42.     /**< Number of channels of LVDS to enable */
  43.  
  44. } Chains_tutorialTwoCam_DisplayAppObj;
  45.  
  46.  
  47. static void chains_tutorialTwoCam_Display_SetSelectPrm(
  48.                                       SelectLink_CreateParams *pPrm)
  49. {
  50.     char ch;
  51.     Bool done  = FALSE;
  52.     Uint32 chnum  = 0;
  53.  
  54.     while(!done)
  55.     {
  56.         Vps_printf("choose");
  57.         ch = Chains_readChar();
  58.  
  59.         switch (ch)
  60.         {
  61.         case '0':
  62.             chnum = atoi(&ch);
  63.             done = FALSE;
  64.             break;
  65.         case '1':
  66.             chnum = atoi(&ch);
  67.             done = FALSE;
  68.             break;
  69.        
  70.         default:
  71.             break;
  72.         }
  73.     }
  74.  
  75.     pPrm->numOutQue = 1;
  76.     pPrm->outQueChInfo[0].outQueId = 0;
  77.     pPrm->outQueChInfo[0].numOutCh = 1;
  78.     pPrm->outQueChInfo[0].inChNum[0] = chnum;
  79.  
  80. }
  81.  
  82. /**
  83.  *******************************************************************************
  84.  * \brief Run Time Menu string.
  85.  *******************************************************************************
  86.  */
  87. char gChains_tutorialTwoCam_runTimeMenu[] = {
  88.     "\r\n "
  89.     "\r\n ===================="
  90.     "\r\n Chains Run-time Menu"
  91.     "\r\n ===================="
  92.     "\r\n "
  93.     "\r\n 0: Stop Chain"
  94.     "\r\n "
  95.     "\r\n 2: Pause Capture"
  96.     "\r\n 3: Resume Capture"
  97.     "\r\n "
  98.     "\r\n p: Print Performance Statistics "
  99.     "\r\n "
  100.     "\r\n Enter Choice: "
  101.     "\r\n "
  102. };
  103.  
  104. /**
  105.  *******************************************************************************
  106.  *
  107.  * \brief   Set link Parameters
  108.  *
  109.  *          It is called in Create function of the auto generated use-case file.
  110.  *
  111.  * \param pUcObj    [IN] Auto-generated usecase object
  112.  * \param appObj    [IN] Application specific object
  113.  *
  114.  *******************************************************************************
  115. */
  116. Void chains_tutorialTwoCam_Display_SetAppPrms(chains_tutorialTwoCam_DisplayObj *pUcObj, Void *appObj)
  117. {
  118.     Chains_tutorialTwoCam_DisplayAppObj *pObj
  119.         = (Chains_tutorialTwoCam_DisplayAppObj*)appObj;
  120.  
  121.     UInt32 portId[VIDEO_SENSOR_MAX_LVDS_CAMERAS];
  122.  
  123.     pObj->displayActiveChId = 0;
  124.  
  125.     pObj->numLvdsCh = NUMBER_OF_CAM;
  126.  
  127.     pObj->captureOutWidth  = CAPTURE_SENSOR_WIDTH;
  128.     pObj->captureOutHeight = CAPTURE_SENSOR_HEIGHT;
  129.  
  130.     ChainsCommon_GetDisplayWidthHeight(
  131.         pObj->chainsCfg->displayType,
  132.         &pObj->displayWidth,
  133.         &pObj->displayHeight
  134.         );
  135.  
  136.  
  137.     portId[0] = SC_VIDEO_SENSOR_1_2;
  138.  
  139.     ChainsCommon_SetCapturePrms(
  140.         &pUcObj->CapturePrm,
  141.         CAPTURE_SENSOR_WIDTH * 2,
  142.         CAPTURE_SENSOR_HEIGHT,
  143.         portId,
  144.         pObj->numLvdsCh / 2
  145.         );
  146.        
  147.  
  148.     chains_tutorialTwoCam_Display_SetSelectPrm(&pUcObj->SelectPrm);
  149.  
  150.     ChainsCommon_SetDisplayPrms(
  151.         &pUcObj->Display_VideoPrm,
  152.         NULL,
  153.         pObj->chainsCfg->displayType,
  154.         pObj->displayWidth,
  155.         pObj->displayHeight
  156.         );
  157.  
  158.     ChainsCommon_StartDisplayCtrl(
  159.         pObj->chainsCfg->displayType,
  160.         pObj->displayWidth,
  161.         pObj->displayHeight
  162.         );
  163.  
  164. }
  165.  
  166.  
  167. /**
  168.  *******************************************************************************
  169.  *
  170.  * \brief   Start the capture display Links
  171.  *
  172.  *          Function sends a control command to capture and display link to
  173.  *          to Start all the required links . Links are started in reverce
  174.  *          order as information of next link is required to connect.
  175.  *          System_linkStart is called with LinkId to start the links.
  176.  *
  177.  * \param   pObj  [IN] Chains_tutorialTwoCam_DisplayObj
  178.  *
  179.  * \return  SYSTEM_LINK_STATUS_SOK on success
  180.  *
  181.  *******************************************************************************
  182. */
  183.  
  184.  
  185.  
  186.  
  187. static Void chains_tutorialTwoCam_Display_StartApp(Chains_tutorialTwoCam_DisplayAppObj *pObj)
  188. {
  189.     pObj->vidSensorPrm.captureSrcId = CHAINS_CAPTURE_SRC_OV10635;
  190.     pObj->vidSensorPrm.isLVDSCaptMode = TRUE;
  191.     pObj->vidSensorPrm.numLvdsCh = 2;
  192.     pObj->vidSensorPrm.chipType = SCV;
  193.  
  194.     system("./ub964_SV.sh");
  195.  
  196.     System_linkControl(SYSTEM_LINK_ID_APP_CTRL,
  197.                                 APP_CTRL_LINK_CMD_VIDEO_SENSOR_CREATE_AND_START,
  198.                                 &pObj->vidSensorPrm,
  199.                                 sizeof(VideoSensorCreateAndStartAppPrm),
  200.                                 TRUE);
  201.  
  202.     ChainsCommon_statCollectorReset();
  203.     ChainsCommon_memPrintHeapStatus();
  204.  
  205.     chains_tutorialTwoCam_Display_Start(&pObj->ucObj);
  206.  
  207. }
  208.  
  209.  
  210. /**
  211.  *******************************************************************************
  212.  *
  213.  * \brief   Delete the capture display Links
  214.  *
  215.  *          Function sends a control command to capture and display link to
  216.  *          to delete all the prior created links
  217.  *          System_linkDelete is called with LinkId to delete the links.
  218.  *
  219.  * \param   pObj   [IN]   Chains_tutorialTwoCam_DisplayObj
  220.  *
  221.  *******************************************************************************
  222. */
  223. static Void chains_tutorialTwoCam_Display_StopAndDeleteApp(Chains_tutorialTwoCam_DisplayAppObj *pObj)
  224. {
  225.     chains_tutorialTwoCam_Display_Stop(&pObj->ucObj);
  226.     chains_tutorialTwoCam_Display_Delete(&pObj->ucObj);
  227.  
  228.     ChainsCommon_StopDisplayCtrl();
  229.  
  230.     System_linkControl(SYSTEM_LINK_ID_APP_CTRL,
  231.                         APP_CTRL_LINK_CMD_VIDEO_SENSOR_STOP_AND_DELETE,
  232.                         &pObj->vidSensorPrm,
  233.                         sizeof(VideoSensorCreateAndStartAppPrm),
  234.                         TRUE);
  235.  
  236.  
  237.     /* Print the HWI, SWI and all tasks load */
  238.     /* Reset the accumulated timer ticks */
  239.     ChainsCommon_prfLoadCalcEnable(FALSE, FALSE, FALSE);
  240. }
  241.  
  242. /**
  243.  *******************************************************************************
  244.  *
  245.  * \brief   Single Channel Capture Display usecase function
  246.  *
  247.  *          This functions executes the create, start functions
  248.  *
  249.  *          Further in a while loop displays run time menu and waits
  250.  *          for user inputs to print the statistics or to end the demo.
  251.  *
  252.  *          Once the user inputs end of demo stop and delete
  253.  *          functions are executed.
  254.  *
  255.  * \param   chainsCfg       [IN]   Chains_Ctrl
  256.  *
  257.  *******************************************************************************
  258. */
  259. Void Chains_tutorialTwoCam_Display(Chains_Ctrl *chainsCfg)
  260. {
  261.     char ch;
  262.     UInt32 done = FALSE;
  263.     Chains_tutorialTwoCam_DisplayAppObj chainsObj;
  264.     Int32 status;
  265.  
  266.     chainsObj.numLvdsCh         = 0; /* KW error fix */
  267.     chainsObj.displayActiveChId = 0; /* KW error fix */
  268.  
  269.     chainsObj.chainsCfg = chainsCfg;
  270.  
  271.     chains_tutorialTwoCam_Display_Create(&chainsObj.ucObj, &chainsObj);
  272.  
  273.     chains_tutorialTwoCam_Display_StartApp(&chainsObj);
  274.  
  275.     while(!done)
  276.     {
  277.         Vps_printf(gChains_tutorialTwoCam_runTimeMenu);
  278.  
  279.         ch = Chains_readChar();
  280.    
  281.  
  282.         switch(ch)
  283.         {
  284.             case '0':
  285.                 done = TRUE;
  286.                 break;
  287.  
  288.  
  289.             case '2':
  290.                 status = System_linkStop(chainsObj.ucObj.CaptureLinkID);
  291.                 UTILS_assert(status == SYSTEM_LINK_STATUS_SOK);
  292.                 break;
  293.  
  294.             case '3':
  295.                 status = System_linkStart(chainsObj.ucObj.CaptureLinkID);
  296.                 UTILS_assert(status == SYSTEM_LINK_STATUS_SOK);
  297.                 break;
  298.  
  299.             case 'p':
  300.             case 'P':
  301.                 ChainsCommon_PrintStatistics();
  302.                 chains_tutorialTwoCam_Display_printStatistics(&chainsObj.ucObj);
  303.                 break;
  304.             default:
  305.                 Vps_printf("\nUnsupported option '%c'. Please try again\n", ch);
  306.                 break;
  307.         }
  308.  
  309.     }
  310.  
  311.     chains_tutorialTwoCam_Display_StopAndDeleteApp(&chainsObj);
  312. }
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.