|
视频捕捉部分主要代码:
- if ( !DeviceIoControl(hCamDrv, IOCTL_VDC_PREVIEW_START, &PreviewArgs, sizeof(VDC_START_ARGS), NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[CAMTEST:ERROR] IOCTL_CAM_PREVIEW_START Failed\n"));
- goto CleanUp;
- }
- Init_Display_DMA();
- i = 0;
- while(i <= 5000)// i <= 100
- {
-
- RETAILMSG(0,(L"WAIT FOR CAPTURE FINISH...\n"));
- if ( !DeviceIoControl(hCamDrv, IOCTL_VDC_WAIT_CAPTURE_FINISH, NULL, 0, &dwCurrentFrameNum, sizeof(DWORD), &dwBytes, NULL) )
- {
- RETAILMSG(1,(L"[CAMTEST:ERROR] TIME OUT!\n"));
- }
- else
- {
- RETAILMSG(0,((L"CurrentFrame=%d\n"), dwCurrentFrameNum));
- // skip the first frame, usually, the first frame is not good.
- if(i > 0)
- {
- Display_Frame_DMA((DWORD)BufInfo[dwCurrentFrameNum].pY,
- (DWORD)BufInfo[dwCurrentFrameNum].pCb,
- (DWORD)BufInfo[dwCurrentFrameNum].pCr);
- }
- }
- i++;
- }
复制代码
初始化显示:
Init_Display_DMA()
- void Init_Display_DMA()
- {
- SVEARG_FIMD_WIN_MODE tParamMode;
- SVEARG_FIMD_WIN_FRAMEBUFFER tParamFB;
- SVEARG_POST_PARAMETER tParamPost;
- SVEARG_POST_BUFFER tParamBuffer;
- DWORD dwWinNum, dwBytes;
- hVideoDrv = CreateFile( L"VDE0:", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
- if (hVideoDrv == INVALID_HANDLE_VALUE)
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] VDE0 Open Device Failed\n"));
- Deinit_Display_DMA();
- }
- // Request FIMD Win0 H/W Resource to Video Engine Driver for Local Path
- if ( !DeviceIoControl(hVideoDrv, IOCTL_SVE_RSC_REQUEST_FIMD_WIN0, NULL, 0, NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] IOCTL_SVE_RSC_REQUEST_FIMD_WIN0 Failed\n"));
- Deinit_Display_DMA();
- }
- // Request Post Processor H/W Resource to Video Engine Driver for Local Path
- if ( !DeviceIoControl(hVideoDrv, IOCTL_SVE_RSC_REQUEST_POST, NULL, 0, NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] IOCTL_SVE_RSC_REQUEST_POST Failed\n"));
- Deinit_Display_DMA();
- }
- // Configure Window0
- tParamMode.dwWinMode = DISP_WIN0_DMA;
- tParamMode.dwBPP = LCD_BPP;
- tParamMode.dwWidth = LCD_X; //LCD_X;
- tParamMode.dwHeight = LCD_Y; //LCD_Y;
- tParamMode.dwOffsetX = 120;
- tParamMode.dwOffsetY = 120;
- if ( !DeviceIoControl(hVideoDrv, IOCTL_SVE_FIMD_SET_WINDOW_MODE, &tParamMode, sizeof(SVEARG_FIMD_WIN_MODE), NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] IOCTL_SVE_FIMD_SET_WINDOW_MODE Failed\n"));
- Deinit_Display_DMA();
- }
- // Set Window0 Framebuffer
- tParamFB.dwWinNum = DISP_WIN0;
- tParamFB.dwFrameBuffer = DEST_FB_ADDR;
- tParamFB.bWaitForVSync = FALSE;
- if ( !DeviceIoControl(hVideoDrv, IOCTL_SVE_FIMD_SET_WINDOW_FRAMEBUFFER, &tParamFB, sizeof(SVEARG_FIMD_WIN_FRAMEBUFFER), NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] IOCTL_SVE_FIMD_SET_WINDOW_FRAMEBUFFER Failed\n"));
- Deinit_Display_DMA();
- }
- // Window0 Enable
- dwWinNum = DISP_WIN0;
- if ( !DeviceIoControl(hVideoDrv, IOCTL_SVE_FIMD_SET_WINDOW_ENABLE, &dwWinNum, sizeof(DWORD), NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] IOCTL_SVE_FIMD_SET_WINDOW_ENABLE Failed\n"));
- Deinit_Display_DMA();
- }
- // Set processing parameters
- tParamPost.dwOpMode = POST_PER_FRAME_MODE;
- tParamPost.dwScanMode = POST_PROGRESSIVE;
- tParamPost.dwRotFlipMode = MAKELONG(POST_0_NOFLIP, POST_0_NOFLIP);
- tParamPost.dwSrcType = POST_SRC_NV12;
- tParamPost.dwSrcBaseWidth = LCD_X;
- tParamPost.dwSrcBaseHeight = LCD_Y;
- tParamPost.dwSrcWidth = LCD_X;
- tParamPost.dwSrcHeight = LCD_Y;
- tParamPost.dwSrcOffsetX = 0;
- tParamPost.dwSrcOffsetY = 0;
- tParamPost.dwDstType = POST_DST_RGB24;
- tParamPost.dwDstBaseWidth = LCD_X;
- tParamPost.dwDstBaseHeight = LCD_Y;
- tParamPost.dwDstWidth = LCD_X;
- tParamPost.dwDstHeight = LCD_Y; //1090
- tParamPost.dwDstOffsetX = 0;
- tParamPost.dwDstOffsetY = 0;
- if ( !DeviceIoControl(hVideoDrv, IOCTL_SVE_POST_SET_PROCESSING_PARAM, &tParamPost, sizeof(SVEARG_POST_PARAMETER), NULL, 0, &dwBytes, NULL) )
- {
- RETAILMSG(CAMTEST_ERR,(L"[VDE:ERR] IOCTL_SVE_POST_SET_PROCESSING_PARAM Failed\n"));
- Deinit_Display_DMA();
- }
- }
复制代码 |
|