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

📄 encregdrv1.c

📁 freescale i.mx31 BSP CE5.0全部源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------
--                                                                            --
--       This software is confidential and proprietary and may be used        --
--        only as expressly authorized by a licensing agreement from          --
--                                                                            --
--                            Hantro Products Oy.                             --
--                                                                            --
--      In the event of publication, the following notice is applicable:      --
--                                                                            --
--                   (C) COPYRIGHT 2003 HANTRO PRODUCTS OY                    --
--                            ALL RIGHTS RESERVED                             --
--                                                                            --
--          The entire notice above must be reproduced on all copies.         --
--                                                                            --
--------------------------------------------------------------------------------
--
--  Abstract : Encoder HW register access functions
--
-------------------------------------------------------------------------------*/

#include "ewl.h"
#include "basetype.h"
#include "encregdrv.h"
#include "EncSim.h"

/* 1. (AMBAIFE) Encoder Register Offsets   */

#define ENCREG(nr)	(nr<<2)

/* 2. Mask fields */
#define mask_1b         (u32)0x00000001
#define mask_2b         (u32)0x00000003
#define mask_3b         (u32)0x00000007
#define mask_4b         (u32)0x0000000F
#define mask_5b         (u32)0x0000001F
#define mask_7b         (u32)0x0000007F
#define mask_9b         (u32)0x000001FF
#define mask_10b        (u32)0x000003FF
#define mask_16b        (u32)0x0000FFFF

/* 3. Encoder register access drivers */

/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x00) ************************/
/******************************************************************************/

/*******************************************************************************
 Function name   : SetEncQP
 Description     : Set the first quantization parameter
 Return type     : void 
 Argument        : u32 qp
*******************************************************************************/
void SetEncQP(u32 qp)
{
    u32 val;

    ASSERT(qp > 0 && qp <= 31);
    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_5b << 17)) | (qp << 17);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncQP
 Description     : Get the first quantization parameter
 Return type     : u32 
*******************************************************************************/
u32 GetEncQP()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (val >> 17) & mask_5b;
    return val;
}

/*******************************************************************************
 Function name   : SetEncIntraDcVlcThr
 Description     : Set the threshold value for intra/inter vlc switch for DC
 Return type     : void 
 Argument        : u32 thr
*******************************************************************************/
void SetEncIntraDcVlcThr(u32 thr)
{
    u32 val;

    ASSERT(thr <= 7);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_3b << 14)) | (thr << 14);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncIntraDcVlcThr
 Description     : Get the threshold value for intra/inter vlc switch for DC
 Return type     : u32 
*******************************************************************************/
u32 GetEncIntraDcVlcThr()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = mask_3b & (val >> 14);
    return val;
}

/*******************************************************************************
 Function name   : SetEncDataPEnable
 Description     : Enable/Disable data partitioning
 Return type     : void 
 Argument        : u32 enable
*******************************************************************************/
void SetEncDataPEnable(u32 enable)
{
    u32 val;

    ASSERT(enable <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_1b << 13)) | (enable << 13);

    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncDataPEnable
 Description     : Get data partitioning enable status
 Return type     : u32 
*******************************************************************************/
u32 GetEncDataPEnable()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = mask_1b & (val >> 13);
    return val;
}

/*******************************************************************************
 Function name   : SetEncSVHEnable
 Description     : Enable/Disable SVH mode
 Return type     : void 
 Argument        : u32 enable
*******************************************************************************/
void SetEncSVHEnable(u32 enable)
{
    u32 val;

    ASSERT(enable <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_1b << 11)) | (enable << 11);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncSVHEnable
 Description     : Get SVH enable status
 Return type     : u32 
*******************************************************************************/
u32 GetEncSVHEnable()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = mask_1b & (val >> 11);
    return val;
}

/*******************************************************************************
 Function name   : SetEncAcPredEnable
 Description     : Enable the AC prediction
 Return type     : void 
 Argument        : u32 mode
*******************************************************************************/
void SetEncAcPredEnable(u32 enable)
{
    u32 val;

    ASSERT(enable <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_1b << 6)) | (enable << 6);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncAcPredEnable
 Description     : Get the AC prediction status
 Return type     : u32 
*******************************************************************************/
u32 GetEncAcPredEnable()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_1b & (val >> 6));
    return val;
}

/*******************************************************************************
 Function name   : SetEncOutsideVopMvEnable
 Description     : Enable/Disable MV pointing out of the picture
 Return type     : void 
 Argument        : u32 enable
*******************************************************************************/
void SetEncOutsideVopMvEnable(u32 enable)
{
    u32 val;

    ASSERT(enable <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_1b << 7)) | (enable << 7);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncOutsideVopMvEnable
 Description     : Get MV pointing out of the picture enable status
 Return type     : u32 
*******************************************************************************/
u32 GetEncOutsideVopMvEnable()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_1b & (val >> 7));
    return val;
}

/*******************************************************************************
 Function name   : SetEncRvlcEnable
 Description     : Enable/Disable RVLC usage
 Return type     : void 
 Argument        : u32 enable
*******************************************************************************/
void SetEncRvlcEnable(u32 enable)
{
    u32 val;

    ASSERT(enable <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_1b << 4)) | (enable << 4);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncRvlcEnable
 Description     : Get RVLC enable status
 Return type     : u32 
*******************************************************************************/
u32 GetEncRvlcEnable()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_1b & (val >> 4));
    return val;
}

/*******************************************************************************
 Function name   : SetEncRoundingCtrl
 Description     : Set the rounding value used in motion compensation
 Return type     : void 
 Argument        : u32 roundval
*******************************************************************************/
void SetEncRoundingCtrl(u32 roundval)
{
    u32 val;

    ASSERT(roundval <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_1b << 3)) | (roundval << 3);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncRoundingCtrl
 Description     : Get the rounding value used in motion compensation
 Return type     : u32 
*******************************************************************************/
u32 GetEncRoundingCtrl()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_1b & (val >> 3));
    return val;
}

/*******************************************************************************
 Function name   : SetEncStrmEndianMode
 Description     : Set the output stream endian mode
 Return type     : void 
 Argument        : u32 endian
*******************************************************************************/
void SetEncStrmEndianMode(u32 endian)
{
    u32 val;

    ASSERT(endian <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & (~(mask_1b<<5))) | (endian<<5);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : SetEncStrmEndianMode
 Description     : Get the output stream endian mode
 Return type     : u32 
*******************************************************************************/
u32 GetEncStrmEndianMode()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_1b & (val >> 5));
    return val;
}

/*******************************************************************************
 Function name   : SetEncImgEndianMode
 Description     : Set the input image endian mode
 Return type     : void 
 Argument        : u32 endian
*******************************************************************************/
void SetEncImgEndianMode(u32 endian)
{
    u32 val;

    ASSERT(endian <= 1);

    val = EWL_ReadReg(0x00);
    val = (val & ~mask_1b) | endian;
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncImgEndianMode
 Description     : Get the input image endian mode
 Return type     : u32 
*******************************************************************************/
u32 GetEncImgEndianMode()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_1b & val);
    return val;
}

/*******************************************************************************
 Function name   : SetEncModTimeBase
 Description     : Set the modulo time base
 Return type     : void 
 Argument        : u32 sec
*******************************************************************************/
void SetEncModTimeBase(u32 sec)
{
    u32 val;

    ASSERT(sec <= 127);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_7b << 25)) | (sec << 25);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncModTimeBase
 Description     : Get the current modulo time base value
 Return type     : u32 
*******************************************************************************/
u32 GetEncModTimeBase()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (val >> 25);
    return val;
}

/*******************************************************************************
 Function name   : SetEncGobFrmId
 Description     : Set the GOB frame identification field in H.263(SVH) mode
 Return type     : void 
 Argument        : u32 id
*******************************************************************************/
void SetEncGobFrmId(u32 id)
{
    u32 val;

    ASSERT(id <= 3);

    val = EWL_ReadReg(0x00);
    val = (val & ~(mask_2b << 8)) | (id << 8);
    EWL_WriteReg(0x00, val);
}

/*******************************************************************************
 Function name   : GetEncGobFrmId
 Description     : Get the current GOB frame identification field
 Return type     : u32 
*******************************************************************************/
u32 GetEncGobFrmId()
{
    u32 val;

    val = EWL_ReadReg(0x00);
    val = (mask_2b & (val >> 8));
    return val;
}

⌨️ 快捷键说明

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