📄 cameradevice.cpp
字号:
ULONG ulBufSize;
static BOOL bPrpOnceConfigured = FALSE;
static prpConfigData prpConfig;
CAM_FUNCTION_ENTRY();
// Set input format and frame size config params
prpConfig.inputFormat = m_inFormat;
prpConfig.inputSize = m_inFrameSize;
if (m_inFormat == prpInputFormat_RGB16)
{
prpConfig.CSCEquation = prpCSCR2Y_A0;
}
else if (m_inFormat == prpInputFormat_UYVY422)
{
prpConfig.CSCEquation = prpCSCY2R_A0;
}
else
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Prp configuration failed. Don't Support the sensor output format.\r\n"), __WFUNCTION__));
return FALSE;
}
if (m_StrmInstances[PREVIEW].pPinDev == NULL) {
prpConfig.outputVfFormat = prpVfOutputFormat_Disabled;
DEBUGMSG(ZONE_FUNCTION, (TEXT("%s: PREVIEW pin is disabled. \r\n"), __WFUNCTION__));
}
else
{
Format = m_StrmInstances[PREVIEW].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biCompression;
switch (Format)
{
// Used by GSG in MX27 driver for RGB565
case FOURCC_YUYV:
prpConfig.outputVfFormat = prpVfOutputFormat_YUYV422;
break;
case CS_BI_BITFIELDS:
{
switch (m_StrmInstances[PREVIEW].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biBitCount)
{
case 8:
prpConfig.outputVfFormat = prpVfOutputFormat_RGB8;
break;
case 16:
prpConfig.outputVfFormat = prpVfOutputFormat_RGB16;
break;
case 32:
prpConfig.outputVfFormat = prpVfOutputFormat_RGB32;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Unsupported biBitCount for PREVIEW pin! \r\n"),__WFUNCTION__));
return FALSE;
}
}
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Invalid data format for preview.\r\n"), __WFUNCTION__));
return FALSE;
}
// Viewfinding channel output size
prpConfig.outputVfSize.width = (UINT16)m_StrmInstances[PREVIEW].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biWidth;
prpConfig.outputVfSize.height = (UINT16)abs(m_StrmInstances[PREVIEW].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biHeight);
prpConfig.outputVfStride = 0;
//----------------------------------------------------
// Re-allocate Preprocessor Buffers
//----------------------------------------------------
if (!m_pPrp->PrpDeleteVfBuffers())
{
return FALSE;
}
ulBufSize = abs(CS__DIBSIZE(m_StrmInstances[PREVIEW].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader)); // by bytes
if (!m_pPrp->PrpAllocateVfBuffers(iBufNum, ulBufSize))
{
DEBUGMSG(ZONE_ERROR,(_T("%s: Prp Buffer allocation failed.\r\n"), __WFUNCTION__));
return FALSE;
}
}
//
// CAPTURE pin configuration
//
if (m_StrmInstances[CAPTURE].pPinDev == NULL) {
prpConfig.outputEncFormat = prpEncOutputFormat_Disabled;
DEBUGMSG(ZONE_FUNCTION, (TEXT("%s: CAPTURE pin is disabled. \r\n"), __WFUNCTION__));
} else {
// Viewfind channel output format
Format = m_StrmInstances[CAPTURE].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biCompression;
switch (Format)
{
case FOURCC_YUYV:
prpConfig.outputEncFormat = prpEncOutputFormat_YUV422;
break;
case FOURCC_Y444:
prpConfig.outputEncFormat = prpEncOutputFormat_YUV444;
break;
case FOURCC_YV12:
prpConfig.outputEncFormat = prpEncOutputFormat_YUV420;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Invalid data format for Capture/Still.\r\n"), __WFUNCTION__));
return FALSE;
}
// Viewfinding channel output size
prpConfig.outputEncSize.width = (UINT16)m_StrmInstances[CAPTURE].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biWidth;
prpConfig.outputEncSize.height = (UINT16)abs(m_StrmInstances[CAPTURE].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader.biHeight);
//----------------------------------------------------
// Re-allocate Preprocessor Buffers
//----------------------------------------------------
if (!m_pPrp->PrpDeleteEncBuffers())
{
return FALSE;
}
ulBufSize = abs(CS__DIBSIZE(m_StrmInstances[CAPTURE].pPinDev->m_CsDataRangeVideo.VideoInfoHeader.bmiHeader)); // by bytes
if (!m_pPrp->PrpAllocateEncBuffers(iBufNum, ulBufSize))
{
DEBUGMSG(ZONE_ERROR,(_T("%s: Prp Buffer allocation failed.\r\n"), __WFUNCTION__));
return FALSE;
}
}
//
// The PrP features which only need configuring once
//
if (!bPrpOnceConfigured) {
// PrP frame skip control
if ( TRUE == BSPCameraIsTVin() )
{
prpConfig.CSIInputSkip = prpSkip_1of2;
}
else
{
prpConfig.CSIInputSkip = prpSkip_NoSkip;
}
prpConfig.VfOutputSkip = prpSkip_NoSkip;
prpConfig.EncOutputSkip = prpSkip_NoSkip;
// Windowing control
prpConfig.bWindowing = FALSE;
prpConfig.CSILineSkip = 0;
prpConfig.inputStride = 0;
bPrpOnceConfigured = TRUE;
}
// Configure pre-processor
if (m_pPrp->PrpConfigure(&prpConfig) == FALSE) {
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Pre-processor configuration failed! \r\n"), __WFUNCTION__));
return FALSE;
}
CAM_FUNCTION_EXIT();
return TRUE;
}
//-----------------------------------------------------------------------------
//
// Function: CameraClosePin
//
// This function de-allocates buffers for a given pin.
//
// Parameters:
// iPin
// [in] Specifies pin (STILL, CAPTURE, or PREVIEW) for
// which we can de-allocate buffers.
//
// Returns:
// TRUE if success
// FALSE if failure
//
//-----------------------------------------------------------------------------
BOOL CCameraDevice::CameraClosePin(UINT32 iPin)
{
CAM_FUNCTION_ENTRY();
DEBUGMSG(ZONE_IOCTL, (_T("+CameraClosePin\r\n")));
// Call down to Prp to deallocate buffer list
switch (iPin)
{
case PREVIEW:
if (!m_pPrp->PrpDeleteVfBuffers())
{
return FALSE;
}
break;
case CAPTURE:
if (!m_pPrp->PrpDeleteEncBuffers())
{
return FALSE;
}
break;
case STILL:
// No need to delete buffers in the Prp, as those buffers
// will be deleted by the Preview Pin.
break;
default:
DEBUGMSG(ZONE_ERROR,(_T("CameraClosePin: Invalid pin id.\r\n"))) ;
return FALSE;
}
DEBUGMSG(ZONE_IOCTL, (_T("-CameraClosePin\r\n")));
CAM_FUNCTION_EXIT();
return TRUE;
}
//-----------------------------------------------------------------------------
//
// Function: CameraSensorZoom
//
// This function sets the camera zoom value.
//
// Parameters:
// zoomVal
// [in] zoom value.
// If 2, zoom by 2x. If 1, zoom by 1x.
// All other values are invalid.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void CCameraDevice::CameraSensorZoom(DWORD zoomVal)
{
CAM_FUNCTION_ENTRY();
m_pCsi->CsiZoom(zoomVal);
m_DevProps[ENUM_ZOOM].ulCurrentValue = zoomVal;
CAM_FUNCTION_EXIT();
}
//-----------------------------------------------------------------------------
//
// Function: CameraChangeFrameRate
//
// This function sets the change camera frame rate value.
//
// Parameters:
// rateVal
// [in] Rate Value
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void CCameraDevice::CameraChangeFrameRate(DWORD rateVal)
{
CAM_FUNCTION_ENTRY();
if ( rateVal == FRAMERATE_333000 )
{
rateVal = 30;
}
else
{
rateVal = 15;
}
m_pCsi->CsiChangeFrameRate(rateVal);
CAM_FUNCTION_EXIT();
}
//-----------------------------------------------------------------------------
//
// Function: CameraSetDirectDisplay
//
// This function turns Direct Display mode on or off.
//
// Parameters:
// bDirectDisplay
// [in] If TRUE, turn Direct Display mode on.
// If FALSE, turn Direct Display mode off.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void CCameraDevice::CameraSetDirectDisplay(BOOL bDirectDisplay)
{
CAM_FUNCTION_ENTRY();
// Set Direct Display variable
m_bDirectDisplay = bDirectDisplay;
// Assure that we will reconfigure Camera driver before starting.
m_bCameraConfig = FALSE;
CAM_FUNCTION_EXIT();
}
//-----------------------------------------------------------------------------
//
// Function: CameraSetDirectCapture
//
// This function turns Direct Capture mode on or off.
//
// Parameters:
// bDirectDisplay
// [in] If TRUE, turn Direct Capture mode on.
// If FALSE, turn Direct Capture mode off.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void CCameraDevice::CameraSetDirectCapture(BOOL bDirectCapture)
{
CAM_FUNCTION_ENTRY();
// Set Direct Capture variable
m_bDirectCapture = bDirectCapture;
// Assure that we will reconfigure Camera driver before starting.
m_bCameraConfig = FALSE;
CAM_FUNCTION_EXIT();
}
//-----------------------------------------------------------------------------
//
// Function: CameraPowerUp
//
// Descriptioin: Power up the driver
//
// Parameters:
// enableMode
// [in] If TRUE, enable the clock and other hardware related resource before enable this mode.
// doing this before open the device
// If FALSE, enable the device clock only.
// doing this by power management.
//
// Returns:
// TRUE if success
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -