⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cameradevice.cpp

📁 Samsung公司S3C6400芯片的BSP源码包
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        break;

    case CSPROPERTY_TYPE_SET:

        if ( NULL == ( pCsPropVidProcAmpInput = reinterpret_cast<PCSPROPERTY_VIDEOPROCAMP_S>( ValidateBuffer( pInBuf, InBufLen, sizeof (CSPROPERTY_VIDEOPROCAMP_S), &dwError ) ) ) )
        {
            return dwError;
        }

        if ( FALSE == pSensorProp->fSetSupported )
        {
            SetLastError(ERROR_INVALID_OPERATION);
            break;
        }

        // CSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL and CSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO are mutually exclusive
        if( pCsPropVidProcAmpInput->Flags != CSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL && 
            pCsPropVidProcAmpInput->Flags != CSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO )
        {
            SetLastError(ERROR_INVALID_OPERATION);
            break;
        }

        lValue = pCsPropVidProcAmpInput->Value;
        lFlags = pCsPropVidProcAmpInput->Flags;

        if( pCsPropVidProcAmpInput->Flags & ~pSensorProp->ulCapabilities )
        {
            break;
        }

        if( CSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL == pCsPropVidProcAmpInput->Flags )
        {
            if ( lValue < pSensorProp->pRangeNStep->Bounds.SignedMinimum ||
                lValue > pSensorProp->pRangeNStep->Bounds.SignedMaximum ||
                0 != ((lValue - pSensorProp->pRangeNStep->Bounds.SignedMinimum) % pSensorProp->pRangeNStep->SteppingDelta) )
            {
                break;
            }
        }

        dwError = m_PDDFuncTbl.PDD_HandleVidProcAmpChanges( m_PDDContext, csProp.Id, lFlags, lValue );
        break;

    case CSPROPERTY_TYPE_DEFAULTVALUES:

        GetDefaultValues( pOutBuf, OutBufLen, pdwBytesTransferred, pSensorProp, &dwError );
        break;

    case CSPROPERTY_TYPE_BASICSUPPORT:

        GetBasicSupportInfo( pOutBuf, OutBufLen, pdwBytesTransferred, pSensorProp, &dwError );
        break;

    default :
        DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Request\r\n"), this));
        return dwError;
    }

    return dwError;
}

DWORD
CCameraDevice::AdapterHandleCamControlRequests(
    PUCHAR pInBuf,              // Warning: This is an unsafe buffer, access with care
    DWORD  InBufLen,
    PUCHAR pOutBuf,             // Warning: This is an unsafe buffer, access with care
    DWORD  OutBufLen,
    PDWORD pdwBytesTransferred  // Warning: This is an unsafe buffer, access with care
    )
{
    // Note: This whole function is wrapped in a __try/__except block

    DEBUGMSG( ZONE_IOCTL, ( _T("CAM_IOControl(%08x): HandleCamControlRequests\r\n"), this ) );
    DWORD dwError = ERROR_INVALID_PARAMETER;
    LONG  lValue  = 0;
    LONG  lFlags  = 0;
    PSENSOR_PROPERTY pSensorProp = NULL;
    PCSPROPERTY_CAMERACONTROL_S pCsPropCamControlOutput = NULL;
    PCSPROPERTY_CAMERACONTROL_S pCsPropCamControlInput  = NULL;

    CSPROPERTY   csProp = {0};
    if( !CeSafeCopyMemory( &csProp, pInBuf, sizeof( CSPROPERTY )))
    {
        return dwError;
    }

    *pdwBytesTransferred = 0;

    // we support PROPSETID_Pin, so just return success
    if ( CSPROPERTY_TYPE_SETSUPPORT == csProp.Flags )
    {
        return ERROR_SUCCESS;
    }

    if ( csProp.Id < CSPROPERTY_CAMERACONTROL_PAN || csProp.Id > CSPROPERTY_CAMERACONTROL_FLASH )
    {
        DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Property\r\n"), this));
        return dwError;
    }

    if ( ERROR_SUCCESS != m_PDDFuncTbl.PDD_GetAdapterInfo( m_PDDContext, &m_AdapterInfo ) )
    {
        return dwError;
    }

    pSensorProp = m_AdapterInfo.SensorProps + (csProp.Id + (NUM_VIDEOPROCAMP_ITEMS));

    switch( csProp.Flags )
    {
    case CSPROPERTY_TYPE_GET:

        if ( NULL == ( pCsPropCamControlInput = reinterpret_cast<PCSPROPERTY_CAMERACONTROL_S>( ValidateBuffer( pInBuf, InBufLen, sizeof(CSPROPERTY_CAMERACONTROL_S), &dwError ) ) ) )
        {
            return dwError;
        }

        if ( FALSE == pSensorProp->fGetSupported )
        {
            SetLastError(ERROR_INVALID_OPERATION);
            break;
        }

        *pdwBytesTransferred = sizeof(CSPROPERTY_CAMERACONTROL_S);
        if( NULL == ( pCsPropCamControlOutput = reinterpret_cast<PCSPROPERTY_CAMERACONTROL_S>(ValidateBuffer( pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError ) ) ) )
        {
            dwError = ERROR_MORE_DATA;
            break;
        }

        //Copy the CSPROPERTY structure to the output buffer just in case!
        memcpy( pCsPropCamControlOutput, pCsPropCamControlInput, sizeof(CSPROPERTY) );

        pCsPropCamControlOutput->Value         = pSensorProp->ulCurrentValue;
        pCsPropCamControlOutput->Flags         = pSensorProp->ulFlags;
        pCsPropCamControlOutput->Capabilities  = pSensorProp->ulCapabilities;

        dwError = ERROR_SUCCESS;
        break;

    case CSPROPERTY_TYPE_SET:

        if ( NULL == ( pCsPropCamControlInput = reinterpret_cast<PCSPROPERTY_CAMERACONTROL_S>( ValidateBuffer( pInBuf, InBufLen, sizeof(CSPROPERTY_CAMERACONTROL_S), &dwError ) ) ) )
        {
            return dwError;
        }

        if ( FALSE == pSensorProp->fSetSupported )
        {
            SetLastError(ERROR_INVALID_OPERATION);
            break;
        }

        // CSPROPERTY_CAMERACONTROL_FLAGS_MANUAL and CSPROPERTY_CAMERACONTROL_FLAGS_AUTO are mutually exclusive
        if( pCsPropCamControlInput->Flags != CSPROPERTY_CAMERACONTROL_FLAGS_MANUAL && 
            pCsPropCamControlInput->Flags != CSPROPERTY_CAMERACONTROL_FLAGS_AUTO )
        {
            SetLastError(ERROR_INVALID_OPERATION);
            break;
        }

        lValue = pCsPropCamControlInput->Value;
        lFlags = pCsPropCamControlInput->Flags;

        if( lFlags & ~pSensorProp->ulCapabilities )
        {
            break;
        }
        
        if( CSPROPERTY_CAMERACONTROL_FLAGS_MANUAL == lFlags )
        {
            if ( lValue < pSensorProp->pRangeNStep->Bounds.SignedMinimum ||
                lValue > pSensorProp->pRangeNStep->Bounds.SignedMaximum ||
                0 != ((lValue - pSensorProp->pRangeNStep->Bounds.SignedMinimum) % pSensorProp->pRangeNStep->SteppingDelta) )
            {
                break;
            }

        }

        dwError = m_PDDFuncTbl.PDD_HandleCamControlChanges( m_PDDContext, csProp.Id + (NUM_VIDEOPROCAMP_ITEMS), lFlags, lValue );                                                                                             
        
        break;

    case CSPROPERTY_TYPE_DEFAULTVALUES:

        GetDefaultValues( pOutBuf, OutBufLen, pdwBytesTransferred, pSensorProp, &dwError );
        break;

    case CSPROPERTY_TYPE_BASICSUPPORT:

        GetBasicSupportInfo( pOutBuf, OutBufLen, pdwBytesTransferred, pSensorProp, &dwError );
        break;

    default :
        DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Request\r\n"), this));
        return dwError;
    }

    return dwError;
}

DWORD
CCameraDevice::AdapterHandleVideoControlRequests(
    PUCHAR pInBuf,                  // Warning: This is an unsafe buffer, access with care
    DWORD  InBufLen,
    PUCHAR pOutBuf,                 // Warning: This is an unsafe buffer, access with care
    DWORD  OutBufLen,
    PDWORD pdwBytesTransferred      // Warning: This is an unsafe buffer, access with care
    )
{
    // Note: This whole function is wrapped in a __try/__except block
    DEBUGMSG( ZONE_IOCTL, (_T("CAM_IOControl(%08x): HandleVideoControlRequests\r\n"), this ) );

    DWORD dwError = ERROR_INVALID_PARAMETER;
    LONG  lValue  = 0;
    ULONG ulCaps  = 0;
    LONG lIndex = 0;

    PCSPROPERTY_VIDEOCONTROL_CAPS_S pCsPropVideoControlCapsOutput = NULL;
    PCSPROPERTY_VIDEOCONTROL_CAPS_S pCsPropVideoControlCapsInput  = NULL;
    PCSPROPERTY_VIDEOCONTROL_MODE_S pCsPropVideoControlModeInput  = NULL;

    CSPROPERTY csProp = {0};

    if( !CeSafeCopyMemory( &csProp, pInBuf, sizeof( CSPROPERTY )))
    {
        return dwError;
    }

    *pdwBytesTransferred = 0;

    // we support PROPSETID_Pin, so just return success
    if ( CSPROPERTY_TYPE_SETSUPPORT == csProp.Flags )
    {
        return ERROR_SUCCESS;
    }

    switch( csProp.Id )
    {
    case CSPROPERTY_VIDEOCONTROL_CAPS:
        if( NULL == ( pCsPropVideoControlCapsInput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer( pInBuf, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S), &dwError ) ) ) )
        {
            break;
        }

        lIndex = pCsPropVideoControlCapsInput->StreamIndex;
        if ( false == IsValidPin( lIndex ) )
        {
            DEBUGMSG( ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid PinId\r\n"), this ) );
            break;
        }

        switch ( csProp.Flags )
        {
        case CSPROPERTY_TYPE_GET:
            *pdwBytesTransferred = sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S);
            if ( NULL == ( pCsPropVideoControlCapsOutput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>( ValidateBuffer( pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError ) ) ) )
            {
                dwError = ERROR_MORE_DATA;
                break;
            }

            //Copy the CSPROPERTY structure to the output buffer just in case!
            memcpy( pCsPropVideoControlCapsOutput, pCsPropVideoControlCapsInput, sizeof( CSPROPERTY ) );

            pCsPropVideoControlCapsOutput->StreamIndex      = lIndex;

            if( true == GetPDDPinInfo() )
            {
                pCsPropVideoControlCapsOutput->VideoControlCaps = m_pStrmInstances[lIndex].VideoCaps.CurrentVideoControlCaps;

                dwError = ERROR_SUCCESS;
            }
            break;

        case CSPROPERTY_TYPE_SET:
            lIndex = pCsPropVideoControlCapsInput->StreamIndex;

            ulCaps = pCsPropVideoControlCapsInput->VideoControlCaps;
            if ( ulCaps & ~( CS_VideoControlFlag_FlipHorizontal        |
                             CS_VideoControlFlag_FlipVertical          |
                             CS_VideoControlFlag_ExternalTriggerEnable |
                             CS_VideoControlFlag_Trigger ) )
            {
                DEBUGMSG( ZONE_IOCTL, ( _T("CAM_IOControl(%08x): Invalid flag specified as Video Control Caps.\r\n"), this ) );
                break;
            }

            if( false == IsValidPin( lIndex ))
            {
                DEBUGMSG( ZONE_IOCTL, ( _T("CAM_IOControl(%08x): Invalid pin index.\r\n"), this ) );
                break;
            }

            dwError = m_PDDFuncTbl.PDD_HandleVideoControlCapsChanges( m_PDDContext, lIndex ,ulCaps );            
            break;

        case CSPROPERTY_TYPE_DEFAULTVALUES:
            *pdwBytesTransferred = sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S);

            if ( NULL == ( pCsPropVideoControlCapsOutput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>( ValidateBuffer( pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError ) ) ) )
            {
                dwError = ERROR_MORE_DATA;
                break;
            }

            lIndex = pCsPropVideoControlCapsInput->StreamIndex;
            if( false == IsValidPin( lIndex ))
            {
                DEBUGMSG( ZONE_IOCTL, ( _T("CAM_IOControl(%08x): Invalid pin index.\r\n"), this ) );
                break;
            }

            //Copy the CSPROPERTY structure to the output buffer just in case!
            memcpy( pCsPropVideoControlCapsOutput, pCsPropVideoControlCapsInput, sizeof ( CSPROPERTY ) );

            pCsPropVideoControlCapsOutput->StreamIndex      = lIndex;

            pCsPropVideoControlCapsOutput->VideoControlCaps =  m_pStrmInstances[lIndex].VideoCaps.DefaultVideoControlCaps;

            dwError = ERROR_SUCCESS;

            break;

        default:
            DEBUGMSG( ZONE_IOCTL, ( _T("CAM_IOControl(%08x): Invalid Request\r\n"), this ) );
            break;
        }

        break;

    case CSPROPERTY_VIDEOCONTROL_MODE:
        if( NULL == ( pCsPropVideoControlModeInput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_MODE_S>(ValidateBuffer( pInBuf, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_MODE_S), &dwError ) ) ) )
        {
            break;
        }

        lIndex = pCsPropVideoControlModeInput->StreamIndex;
        if ( false == IsValidPin( lIndex ) )
        {
            DEBUGMSG( ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid PinId\r\n"), this ) );
            break;
        }

        switch( csProp.Flags )
        {
        case CSPROPERTY_TYPE_SET:
            ulCaps = pCsPropVideoControlModeInput->Mode;
            if ( ulCaps != CS_VideoControlFlag_Trigger )
            {
                DEBUGMSG( ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid flag specified as Video Control Mode.\r\n"), this ) );
                break;
            }

            //Only STILL pin supports CS_VideoControlFlag_Trigger for the current CAMERA MDD
            if ( m_pStrmInstances[lIndex].pPinDev &&  (  lIndex == STILL ) )
            {
                if( CSSTATE_STOP == m_pStrmInstances[lIndex].pPinDev->GetState() )
                {
                    dwError = ERROR_INVALID_STATE;
                }
                else
                {
                    m_pStrmInstances[lIndex].pPinDev->IncrementStillCount();
                    m_pStrmInstances[lIndex].pPinDev->SetState( CSSTATE_RUN, NULL );
                    dwError = m_PDDFuncTbl.PDD_TakeStillPicture( m_PDDContext, NULL );
                }
            }
            else
            {
                DEBUGMSG( ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid pin for Trigger.\r\n"), this ) );
            }

            break ;

        default :
            DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Request\r\n"), this)) ;
            break ;
        }

    default:
        DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Property\r\n"), this)) ;
        return dwError ;
    }

    return dwError;
}

DWORD
CCameraDevice::AdapterHandleDroppedFramesRequests(
    PUCHAR pInBuf,              // Warning: This is an unsafe buffer, access with care
    DWORD  InBufLen,
    PUCHAR pOutBuf,             // Warning: This is an unsafe buffer, access with care
    DWORD  OutBufLen,
    PDWORD pdwBytesTransferred  // Warning: This is an unsafe buffer, access with care
    )
{
    // Note: This whole function is wrapped in a __try/__except block
    DEBUGMSG( ZONE_IOCTL, (_T("CAM_IOControl(%08x): HandleDroppedFramesRequests\r\n"), this ) );

    DWORD dwError = ERROR_INVALID_PARAMETER;
    LONG  lValue  = 0;
    ULONG ulCaps  = 0;

    CSPROPERTY csProp;
    CSPROPERTY_DROPPEDFRAMES_CURRENT_S csPropDroppedFramesOutput = {0};

    //if( !CeSafeCopyMemory( &csProp, pInBuf, InBufLen ))
    if( !CeSafeCopyMemory( &csProp, pInBuf, sizeof(CSPROPERTY)) )
    {
        return dwError;
    }

    *pdwBytesTransferred = 0;

    switch( csProp.Id )
    {
    case CSPROPERTY_DROPPEDFRAMES_CURRENT:

        switch ( csProp.Flags )
        {
        case CSPROPERTY_TYPE_GET:
            *pdwBytesTransferred = sizeof(CSPROPERTY_DROPPEDFRAMES_CURRENT_S);
            if( OutBufLen < *pdwBytesTransferred )
            {
                dwError = ERROR_MORE_DATA;
                break;
            }

            if( NULL == pOutBuf )
            {
                break;
            }

            //Copy the CSPROPERTY structure to the output buffer just in case!
            memcpy( &csPropDroppedFramesOutput, &csProp, sizeof( CSPROPERTY ) );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -