pp_io.cpp

来自「i.mx27 soc for wince 6.0」· C++ 代码 · 共 499 行 · 第 1/2 页

CPP
499
字号
// This function reads data from the device identified by the open context.
//
// Parameters:
//      hOpenContext 
//          [in] Handle to the open context of the device. The XXX_Open 
//          function creates and returns this identifier.
//
//      pBuffer 
//          [out] Pointer to the buffer that stores the data read from the 
//          device. This buffer should be at least Count bytes long. 
//
//      Count 
//          [in] Number of bytes to read from the device into pBuffer. 
//
// Returns:  
//      Returns zero to indicate end-of-file. Returns -1 to indicate an 
//      error. Returns the number of bytes read to indicate success.
//
//------------------------------------------------------------------------------
DWORD POP_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
    PP_FUNCTION_ENTRY();
    PP_FUNCTION_EXIT();
    return 0;
}

//------------------------------------------------------------------------------
//
// Function: POP_Write
//
// This function writes data to the device.
//
// Parameters:
//      hOpenContext 
//          [in] Handle to the open context of the device. The XXX_Open 
//          function creates and returns this identifier.
//
//      pBuffer 
//          [out] Pointer to the buffer that contains the data to write. 
//
//      Count 
//          [in] Number of bytes to read from the device into pBuffer. 
//
// Returns: 
//      The number of bytes written indicates success. A value of -1
//      indicates failure.
//
//------------------------------------------------------------------------------
DWORD POP_Write(DWORD hOpenContext, LPCVOID pBuffer, DWORD Count)
{
    PP_FUNCTION_ENTRY();
    PP_FUNCTION_EXIT();
    return 0;
}

//------------------------------------------------------------------------------
//
// Function: POP_Seek
//
// This function moves the data pointer in the device.
//
// Parameters:
//      hOpenContext 
//          [in] Handle to the open context of the device. The XXX_Open 
//          function creates and returns this identifier.
//
//      Amount 
//          [in] Number of bytes to move the data pointer in the device. 
//          A positive value moves the data pointer toward the end of the 
//          file, and a negative value moves it toward the beginning.
//
//      Type 
//          [in] Starting point for the data pointer. 
//
// Returns: 
//      The new data pointer for the device indicates success. A value of -1 
//      indicates failure.
//
//------------------------------------------------------------------------------
DWORD POP_Seek(DWORD hOpenContext, long Amount, WORD Type)
{
    PP_FUNCTION_ENTRY();
    PP_FUNCTION_EXIT();
    return (DWORD)-1;
}

//------------------------------------------------------------------------------
//
// Function: POP_PowerUp
//
// This function restores power to a device.
//
// Parameters:
//      hDeviceContext 
//          [in] Handle to the device context.
//
// Returns:  
//      None.
//
//------------------------------------------------------------------------------
void POP_PowerUp(DWORD hDeviceContext)
{
    PP_FUNCTION_ENTRY();
    PP_FUNCTION_EXIT();
}

//------------------------------------------------------------------------------
//
// Function: POP_PowerDown
//
// This function suspends power to the device. It is useful only with 
// devices that can power down under software control.
//
// Parameters:
//      hDeviceContext 
//          [in] Handle to the device context.
//
// Returns:  
//      None.
//
//------------------------------------------------------------------------------
void POP_PowerDown(DWORD hDeviceContext)
{
    PP_FUNCTION_ENTRY();
    PP_FUNCTION_EXIT();
}

//------------------------------------------------------------------------------
//
// Function: POP_IOControl
//
// This function sends a command to a device.
//
// Parameters:
//      hOpenContext
//          [in] Handle to the open context of the device. The XXX_Open 
//          function creates and returns this identifier.
//
//      dwCode
//          [in] I/O control operation to perform. These codes are 
//          device-specific and are usually exposed to developers through 
//          a header file.
//
//      pBufIn
//          [in] Pointer to the buffer containing data to transfer to the 
//          device. 
//
//      dwLenIn
//          [in] Number of bytes of data in the buffer specified for pBufIn.
//
//      pBufOut
//          [out] Pointer to the buffer used to transfer the output data 
//          from the device.
//
//      dwLenOut
//          [in] Maximum number of bytes in the buffer specified by pBufOut.
//
//      pdwActualOut
//          [out] Pointer to the DWORD buffer that this function uses to 
//          return the actual number of bytes received from the device.
//
// Returns:
//      The new data pointer for the device indicates success. A value of -1 
//      indicates failure.
//
//------------------------------------------------------------------------------
BOOL POP_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, 
    DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
    ppConfigData *pConfigData;
    pPpBuffers pBufs;
    UINT32 *pMaxBuffers, *pFrameCount;
    BOOL bRet = FALSE;
    
    // hOpenContext is a pointer to PpClass instance!
    PpClass *pPp = (PpClass *)hOpenContext;

    switch (dwCode) {
        case PP_IOCTL_CONFIGURE:
            pConfigData = (pPpConfigData)pBufIn;
            bRet = pPp->PpConfigure(pConfigData);
            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_CONFIGURE occurred\r\n"),  
                __WFUNCTION__));
            break;

        case PP_IOCTL_START:
            bRet = pPp->PpStart();
            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_START occurred\r\n"), 
                __WFUNCTION__));
            break;

        case PP_IOCTL_STOP:
            bRet = pPp->PpStop();
            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_STOP occurred\r\n"), 
                __WFUNCTION__));
            break;

        case PP_IOCTL_ENQUEUE_BUFFERS:
            pBufs = (pPpBuffers)pBufIn;

            // No need to marshall output buffer pointer since it is
            // user's pointer already

            bRet = pPp->PpEnqueueBuffers(pBufs);

            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_ENQUEUE_BUFFERS occurred\r\n"), 
                __WFUNCTION__));

            break;

        case PP_IOCTL_CLEAR_BUFFERS:
            pPp->PpClearBuffers();
            bRet = TRUE;
            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_CLEAR_BUFFERS occurred\r\n"), 
                __WFUNCTION__));
            break;

        case PP_IOCTL_GET_MAX_BUFFERS:
            pMaxBuffers = (UINT32 *)pBufOut;
            *pMaxBuffers = pPp->PpGetMaxBuffers();
            bRet = TRUE;
            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_GET_MAX_BUFFERS occurred\r\n"), 
                __WFUNCTION__));
            break;

        case PP_IOCTL_GET_FRAME_COUNT:
            pFrameCount = (UINT32 *)pBufOut;
            *pFrameCount = pPp->PpGetFrameCount();
            bRet = TRUE;
            DEBUGMSG(ZONE_IOCTL, 
                (TEXT("%s: PP_IOCTL_GET_FRAME_COUNT occurred\r\n"), 
                __WFUNCTION__));
            break;

        default:
            DEBUGMSG(ZONE_WARN, (TEXT("%s: No matching IOCTL.\r\n")));
            break;
    }

    return bRet;
}

⌨️ 快捷键说明

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