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

📄 dda_previeweriom.c

📁 the preview code includes auto focus, auto whitebalance. it is on TI DM6437 platform
💻 C
字号:
/*******************************************************************************
**+--------------------------------------------------------------------------+**
**|                            ****                                          |**
**|                            ****                                          |**
**|                            ******o***                                    |**
**|                      ********_///_****                                   |**
**|                      ***** /_//_/ ****                                   |**
**|                       ** ** (__/ ****                                    |**
**|                           *********                                      |**
**|                            ****                                          |**
**|                            ***                                           |**
**|                                                                          |**
**|         Copyright (c) 2006-2010 Texas Instruments Incorporated           |**
**|                        ALL RIGHTS RESERVED                               |**
**|                                                                          |**
**| Permission is hereby granted to licensees of Texas Instruments           |**
**| Incorporated (TI) products to use this computer program for the sole     |**
**| purpose of implementing a licensee product based on TI products.         |**
**| No other rights to reproduce, use, or disseminate this computer          |**
**| program, whether in part or in whole, are granted.                       |**
**|                                                                          |**
**| TI makes no representation or warranties with respect to the             |**
**| performance of this computer program, and specifically disclaims         |**
**| any responsibility for any damages, special or consequential,            |**
**| connected with the use of this program.                                  |**
**|                                                                          |**
**+--------------------------------------------------------------------------+**
*******************************************************************************/

/**
 *  \file   dda_prevIom.c
 *
 *  \brief  PREV IOM layer Functions
 *
 *  This file contains the Implementation details of IOM layer functions
 *
 *  (C) Copyright 2010, Texas Instruments, Inc
 *
 *  \author     EI2
 *
 *  \version    0.1             Created
 *              1.0             First Release
 */

/******************************************************************************
  Header File Inclusion
 ******************************************************************************/
#include <tistdtypes.h>
#include <std.h>
#include <iom.h>
#include <psp_common.h>

#include "psp_previewer.h"
#include "psp_previewerApi.h"

#include "dda_previewer.h"

/******************************************************************************
  Internal Functions
 ******************************************************************************/
/**
 *  \brief getIomErrorCode
 *
 * This function converts PSP error codes to appropriate IOM error code.
 *
 * \param  pspCode          [IN]    PSP Error code.
 * \return IOM ERROR CODE   [OUT]   Equivalent IOM error code. For unrecoganized
 *                                  error code IOM_EBADIO is returned.
 */
static Int getIomErrorCode(PSP_Result pspCode);

/*-----------------------------------------------------------------------------
  Mini Driver Function interface table
  ----------------------------------------------------------------------------*/
/**
 * \brief Mini Driver Function interface table
 *
 *
 */
IOM_Fxns PREVMD_FXNS =
{
    &PREV_mdBindDev,
    &PREV_mdUnBindDev,
    &PREV_mdControlChan,
    &PREV_mdCreateChan,
    &PREV_mdDeleteChan,
    IOM_SUBMITCHANNOTIMPL,
};



/******************************************************************************
  Functions
 ******************************************************************************/

/**
 * \brief  PREV_mdBindDev()
 * It is called by DEV_init() to bind and initialize the instance.
 */
/* ARGSUSED */
Int PREV_mdBindDev(Ptr *devp, Int devid, Ptr devParams)
{
    PSP_Result bindResult = PSP_E_DRIVER_INIT;

    /* call the prevCreate function*/
    bindResult = PSP_prevCreate((PSP_Handle*) devp);
    return(getIomErrorCode(bindResult));
}



/**
 * \brief PREV_mdCreateChan
 * It creates the channel for the data transfer by setting up some params.
 */
/* ARGSUSED */
Int PREV_mdCreateChan(Ptr *chanp, Ptr devp, String name, Int mode,
    Ptr chanParams, IOM_TiomCallback cbFxn, Ptr cbArg)
{
    PSP_Result  createChannelResult = PSP_E_DRIVER_INIT;

    if (IOM_INOUT != mode)
    {
        createChannelResult = PSP_E_INVAL_PARAM;
    }
    /* call the prevOpen function*/
    createChannelResult = PSP_prevOpen((PSP_Handle*)chanp, (PSP_Handle) devp,
        (PSP_previewerChannelCreateMode*)chanParams);
    return(getIomErrorCode(createChannelResult));
}



/**
 * \brief  PREV_mdControlChan
 * It is used to do the ioctl operation.
 */
Int PREV_mdControlChan(Ptr chanp, Uns cmd, Ptr arg)
{
    PSP_Result  controlChannelResult = PSP_E_DRIVER_INIT;
    /*Call the IOctl function which execute the dynamic configuration */
    controlChannelResult = PSP_prevIoctl((PSP_Handle)chanp,
        (PSP_previewerControlCmd)cmd, arg);
    return(getIomErrorCode(controlChannelResult));
}



/**
 * \brief  PREV_mdDeleteChan
 * It deletes an OSD Planes/VENC Channel.
 */
Int PREV_mdDeleteChan(Ptr chanp)
{
    PSP_Result  deleteChannelResult = PSP_E_DRIVER_INIT;
    /* call the prevDelete function*/
    deleteChannelResult = PSP_prevClose((PSP_Handle)chanp);
    return(getIomErrorCode(deleteChannelResult));
}



/**
 * \brief PREV_mdUnBindDev
 * It called to unbind device.
 */
Int PREV_mdUnBindDev(Ptr devp)
{
    PSP_Result  unbindResult = PSP_E_DRIVER_INIT;
    /* call the prevDelete function*/
    unbindResult = PSP_prevDelete((PSP_Handle)devp);
    return(getIomErrorCode(unbindResult));
}



/**
 * \brief getIomErrorCode
 * It is used to get the IOM Error Code.
 */
static Int getIomErrorCode(PSP_Result pspCode)
{
    /*-------------------------------------------------------------------------
      IOM Error code look up table
      -----------------------------------------------------------------------*/
    /**
     * The following mapping shows the mapping done from PSP_Result to IOM error
     * code.
     *
     * PSP_SOK                  (0)   IOM_COMPLETED            0
     * PSP_SINPROGRESS          (1)   IOM_PENDING              1
     * PSP_E_DRIVER_INIT        (-1)  IOM_ETIMEOUTUNREC      -11
     * PSP_E_NO_MEMORY          (-2)  IOM_EALLOC              -5
     * PSP_E_RESOURCES          (-3)  IOM_EALLOC              -5
     * PSP_E_INVAL_STATE        (-4)  IOM_EBADMODE            -7
     * PSP_E_INVAL_PARAM        (-5)  IOM_EBADARGS           -10
     * PSP_E_NOT_SUPPORTED      (-6)  IOM_ENOTIMPL            -9
     * PSP_E_IO_CANCEL_FAIL     (-7)  IOM_ETIMEOUT            -2
     * PSP_E_FIFO_NOT_ENABLED   (-8)  IOM_EBADMODE            -7
     * PSP_E_INVALID_MODE       (-9)  IOM_EBADMODE            -7
     * PSP_E_INVALID_CMD        (-10) IOM_EBADARGS           -10
     *
     */
    Int iomErrorCodeList[12] =
    {
        IOM_EBADARGS,
        IOM_EBADMODE,
        IOM_EBADMODE,
        IOM_ETIMEOUT,
        IOM_ENOTIMPL,
        IOM_EBADARGS,
        IOM_EBADMODE,
        IOM_EALLOC,
        IOM_EALLOC,
        IOM_ETIMEOUTUNREC,
        IOM_COMPLETED,
        IOM_PENDING
    };

    /* Mapping of psp level error code with the iom layer code. The maximum
       error code return from the below layer is 10 so taking the error code */
    Int iomCode = pspCode + 10;
    /* Mapping the error code with its equivalent IOM layer error code */
    if ((12 > iomCode)  && (iomCode >= 0))
    {
        iomCode = iomErrorCodeList[iomCode];
    }
    else
    {
        iomCode = IOM_EBADIO;
    }
    return(iomCode);
}

⌨️ 快捷键说明

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