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

📄 ppsdk.c

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//-----------------------------------------------------------------------------
//
// Copyright (C) 2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//-----------------------------------------------------------------------------
//
// File: ppsdk.c
//
// This module provides wrapper functions for accessing the stream interface
// for the PP driver.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include <Devload.h>
#include "csp.h"
#include "pp.h"

//-----------------------------------------------------------------------------
// External Functions

//-----------------------------------------------------------------------------
// External Variables

//-----------------------------------------------------------------------------
// Defines

//------------------------------------------------------------------------------
// Types

//------------------------------------------------------------------------------
// Global Variables

//------------------------------------------------------------------------------
// Local Variables

//------------------------------------------------------------------------------
// Local Functions

//------------------------------------------------------------------------------
//
// Function: PPOpenHandle
//
// This method creates a handle to the PP stream driver.
//
// Parameters:
//      None.
//
// Returns:
//      Handle to PP driver, which is set in this method.
//      Returns INVALID_HANDLE_VALUE if failure.
//
//------------------------------------------------------------------------------
HANDLE PPOpenHandle(void)
{
    HANDLE hPP;

    hPP = CreateFile(TEXT("POP1:"),         // name of device
        GENERIC_READ | GENERIC_WRITE,       // desired access
        FILE_SHARE_READ | FILE_SHARE_WRITE, // sharing mode
        NULL,                               // security attributes (ignored)
        OPEN_EXISTING,                      // creation disposition
        FILE_FLAG_RANDOM_ACCESS,            // flags/attributes
        NULL);                              // template file (ignored)

    // If we failed to get handle to PP
    if (hPP == INVALID_HANDLE_VALUE)
        ERRORMSG(1, (TEXT("%s:  CreateFile PP failed!\r\n"), __WFUNCTION__));

    return hPP;
}

//------------------------------------------------------------------------------
//
// Function: PPCloseHandle
//
// This method closes a handle to the PP stream driver.
//
// Parameters:
//      hPP
//          [in/out] Handle to close.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PPCloseHandle(HANDLE hPP)
{
    BOOL retVal = TRUE;

    // If we don't have handle to PP driver
    if (hPP != NULL)
        if (!CloseHandle(hPP))
            retVal = FALSE;

    return retVal;
}

//------------------------------------------------------------------------------
//
// Function: PPConfigure
//
// This method configures the Post-processor using parameters passed
// in by the caller.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
//      pPpConfigData
//          [in] Pointer to PP configuration data structure.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PPConfigure(HANDLE hPP, pPpConfigData pConfigData)
{
    BOOL retVal = TRUE;
    
    // Issue the IOCTL to configure the PP
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_CONFIGURE,         // I/O control code
        pConfigData,                // in buffer
        sizeof(ppConfigData),       // in buffer size
        NULL,                       // out buffer
        0,                          // out buffer size
        0,                          // number of bytes returned
        NULL)) {                    // ignored (=NULL)
        ERRORMSG(1, 
            (TEXT("%s: PP_IOCTL_CONFIGURE failed!\r\n"), __WFUNCTION__));
        retVal = FALSE;
    }

    return retVal;
}

//------------------------------------------------------------------------------
//
// Function: PPStart
//
// This method starts the Post-processor processing.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PPStart(HANDLE hPP)
{
    BOOL retVal = TRUE;
    
    // Issue the IOCTL to start the PP processing
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_START,             // I/O control code
        NULL,                       // in buffer
        0,                          // in buffer size
        NULL,                       // out buffer
        0,                          // out buffer size
        0,                          // number of bytes returned
        NULL)) {                    // ignored (=NULL)
        DEBUGMSG(1, 
            (TEXT("%s: PP_IOCTL_START failed!\r\n"), __WFUNCTION__));
        retVal = FALSE;
    }

    return retVal;
}

//------------------------------------------------------------------------------
//
// Function: PPStop
//
// This method stops the Post-processor processing.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PPStop(HANDLE hPP)
{
    BOOL retVal = TRUE;
    
    // Issue the IOCTL to stop the PP processing
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_STOP,              // I/O control code
        NULL,                       // in buffer
        0,                          // in buffer size
        NULL,                       // out buffer
        0,                          // out buffer size
        0,                          // number of bytes returned
        NULL)) {                    // ignored (=NULL)
        DEBUGMSG(1, 
            (TEXT("%s: PP_IOCTL_STOP failed!\r\n"), __WFUNCTION__));
        retVal = FALSE;
    }

    return retVal;
}

//------------------------------------------------------------------------------
//
// Function: PPAddBuffers
//
// This method allows the caller to add work buffers to the PP buffer queues.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
//      pBufs
//          [in] Pointer to structure containing input and output buffers.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PPAddBuffers(HANDLE hPP, pPpBuffers pBufs)
{
    BOOL retVal = TRUE;

    // Issue the IOCTL to add work buffers
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_ENQUEUE_BUFFERS,   // I/O control code
        pBufs,                      // in buffer
        sizeof(ppBuffers),          // in buffer size
        NULL,                       // out buffer
        0,                          // out buffer size
        0,                          // number of bytes returned
        NULL)) {                    // ignored (=NULL)
        DEBUGMSG(1, 
            (TEXT("%s: PP_IOCTL_ENQUEUE_BUFFERS failed!\r\n"), 
            __WFUNCTION__));
        retVal = FALSE;
    }

    return retVal;
}

//------------------------------------------------------------------------------
//
// Function: PPClearBuffers
//
// This method allows the caller to clear the work buffer queues in the 
// Post-processing driver.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL PPClearBuffers(HANDLE hPP)
{
    BOOL retVal = TRUE;

    // Issue the IOCTL to clear work buffers queue
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_CLEAR_BUFFERS,     // I/O control code
        NULL,                       // in buffer
        0,                          // in buffer size
        NULL,                       // out buffer
        0,                          // out buffer size
        0,                          // number of bytes returned
        NULL)) {                    // ignored (=NULL)
        DEBUGMSG(1, 
            (TEXT("%s: PP_IOCTL_ENQUEUE_BUFFERS failed!\r\n"), 
            __WFUNCTION__));
        retVal = FALSE;
    }

    return retVal;
}

//------------------------------------------------------------------------------
//
// Function: PPGetMaxBuffers
//
// This method retrieves the maximum number of buffers that can be
// queued in the Post-processor.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
// Returns:
//      The max buffers for the PP.  -1 if failure.
//
//------------------------------------------------------------------------------
UINT32 PPGetMaxBuffers(HANDLE hPP)
{
    UINT32 maxBufNum = -1;

    // Issue the IOCTL to get the capacity of the queue
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_GET_MAX_BUFFERS,   // I/O control code
        NULL,                       // in buffer
        0,                          // in buffer size
        &maxBufNum,                 // out buffer
        sizeof(UINT32),             // out buffer size
        0,                          // number of bytes returned
        NULL))                      // ignored (=NULL)
        ERRORMSG(1, 
            (TEXT("%s: PP_IOCTL_GET_MAX_BUFFERS failed!\r\n"), 
            __WFUNCTION__));

    return maxBufNum;
}

//------------------------------------------------------------------------------
//
// Function: PPGetFrameCount
//
// This method retrieves the frame count (number of frames processed
// since the PPStart was called) for the PP.
//
// Parameters:
//      hPP
//          [in] Handle to PP driver.
//
// Returns:
//      The frame count, -1 if failure.
//
//------------------------------------------------------------------------------
BOOL PPGetFrameCount(HANDLE hPP)
{
    UINT32 frameCnt = -1;

    // Issue the IOCTL to get number of frames processed
    if (!DeviceIoControl(hPP,       // file handle to the driver
        PP_IOCTL_GET_FRAME_COUNT,   // I/O control code
        NULL,                       // in buffer
        0,                          // in buffer size
        &frameCnt,                  // out buffer
        sizeof(UINT32),             // out buffer size
        0,                          // number of bytes returned
        NULL))                      // ignored (=NULL)
        ERRORMSG(1, 
            (TEXT("%s: PP_IOCTL_GET_FRAME_COUNT failed!\r\n"), 
            __WFUNCTION__));

    return frameCnt;
}

⌨️ 快捷键说明

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