📄 encregdrv6.c
字号:
/*------------------------------------------------------------------------------
-- --
-- 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_4b (u32)0x0000000F
#define mask_16b (u32)0x0000FFFF
#define mask_24b (u32)0x00FFFFFF
/* 3. Encoder register access drivers */
/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x7C) ************************/
/******************************************************************************/
/*******************************************************************************
Function name : SetEncDeltaQp1
Description : Set the delta qp 1
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp1(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b << 24)) | ((delta & mask_4b) << 24);
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp1
Description : Get the delta qp 1
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp1()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val >> 24));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/*******************************************************************************
Function name : SetEncDeltaQp2
Description : Set the delta qp 2
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp2(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b << 20)) | ((delta & mask_4b) << 20);
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp2
Description : Get the delta qp 2
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp2()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val >> 20));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/*******************************************************************************
Function name : SetEncDeltaQp3
Description : Set the delta qp 3
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp3(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b << 16)) | ((delta & mask_4b) << 16);
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp3
Description : Get the delta qp 3
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp3()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val >> 16));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/*******************************************************************************
Function name : SetEncDeltaQp4
Description : Set the delta qp 4
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp4(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b << 12)) | ((delta & mask_4b) << 12);
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp4
Description : Get the delta qp 4
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp4()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val >> 12));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/*******************************************************************************
Function name : SetEncDeltaQp5
Description : Set the delta qp 5
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp5(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b << 8)) | ((delta & mask_4b) << 8);
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp5
Description : Get the delta qp 5
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp5()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val >> 8));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/*******************************************************************************
Function name : SetEncDeltaQp6
Description : Set the delta qp 6
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp6(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b << 4)) | ((delta & mask_4b) << 4);
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp6
Description : Get the delta qp 6
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp6()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val >> 4));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/*******************************************************************************
Function name : SetEncDeltaQp7
Description : Set the delta qp 7
Return type : void
Argument : i32 delta
*******************************************************************************/
void SetEncDeltaQp7(i32 delta)
{
u32 val;
ASSERT(delta >= -8 && delta <= 7);
val = EWL_ReadReg(0x7C);
val = (val & ~(mask_4b)) | ((delta & mask_4b));
EWL_WriteReg(0x7C, val);
}
/*******************************************************************************
Function name : GetEncDeltaQp7
Description : Get the delta qp 7
Return type : i32
*******************************************************************************/
i32 GetEncDeltaQp7()
{
u32 val;
val = EWL_ReadReg(0x7C);
val = (mask_4b & (val));
if(val > 7)
return (i32) (((~0) << 4) | val); /* negative number */
else
return (i32) val; /* positive number */
}
/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x80) ************************/
/******************************************************************************/
/*******************************************************************************
Function name : SetEncStuffingLim
Description : Set the stuffing limit
Return type : void
Argument : u32 bits
*******************************************************************************/
void SetEncStuffingLim(u32 bits)
{
u32 val;
ASSERT(bits <= ((1 << 16) - 1));
val = EWL_ReadReg(0x80);
val = (val & ~(mask_16b << 16)) | (bits << 16);
EWL_WriteReg(0x80, val);
}
/*******************************************************************************
Function name : GetEncStuffingLim
Description : Get the stuffing limit (or zero count at the end of a vop)
Return type : u32
*******************************************************************************/
u32 GetEncStuffingLim()
{
u32 val;
val = EWL_ReadReg(0x80);
val = (val >> 16);
return val;
}
/*******************************************************************************
Function name : GetEncQPSum
Description : Get the macro blocks QP sum
Return type : u32
*******************************************************************************/
u32 GetEncQpSum()
{
u32 val;
val = EWL_ReadReg(0x80);
val = (val & mask_16b);
return val;
}
/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x84) ************************/
/******************************************************************************/
/*******************************************************************************
Function name : SetEncGobMask
Description : Set the GOB insertion bitmask
Return type : void
Argument : u32 bitmask
*******************************************************************************/
void SetEncGobMask(u32 bitmask)
{
u32 val;
ASSERT(bitmask <= ((1 << 24) - 1));
val = EWL_ReadReg(0x84);
val = (val & (~mask_24b)) | bitmask;
EWL_WriteReg(0x84, val);
}
/*******************************************************************************
Function name : GetEncGobMask
Description : Get the GOB insertion mask
Return type : u32
*******************************************************************************/
u32 GetEncGobMask()
{
u32 val;
val = EWL_ReadReg(0x84);
val = (val & mask_24b);
return val;
}
/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x88) ************************/
/******************************************************************************/
/*******************************************************************************
Function name : GetEncId
Description : Get ASIC's ID
Return type : u32
*******************************************************************************/
u32 GetEncId()
{
u32 val;
val = EWL_ReadReg(0x88);
return val;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -