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

📄 reg0297.c

📁 st7710的tuner标准驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
    U16 Value;
    U8 temp[1];
    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297_WBAGC_1, 2, temp);
    temp[1]=temp[1]&0x03;
     Value = MAC0297_MAKEWORD(temp[1],temp[0]);
   
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> AGC2 %u\n", identity, Value));
#endif

    return (Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_SetSymbolRate()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297_SetSymbolRate(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, unsigned long Value)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_SetSymbolRate()";
#endif
    long    ExtClk;
    U8      temp[4];
    /**/
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> SR %u\n", identity, Value));
#endif
    ExtClk = DeviceMap->RegExtClk;
    
    if (ExtClk != 0)
    {
        Value   /= 1000;
        ExtClk  /= 2;
        Value   *= 131072L;
        Value   /= ExtClk;
        Value   *= 8192L;
        Value   *= 2;
       
        temp[0]=(int)(MAC0297_B0(Value));
        temp[1]=(int)(MAC0297_B1(Value));
        temp[2]=(int)(MAC0297_B2(Value));
        temp[3]=(int)(MAC0297_B3(Value));
        STTUNER_IOREG_SetContigousRegisters(DeviceMap, IOHandle, R0297_STLOOP_5, temp, 4);
    }
    else
    {
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
        STTBX_Print(("%s fail RegExtClk = 0 !\n", identity));
#endif
        return;
    }
}

/* ----------------------------------------------------------------------------
Name: Reg0297_GetSymbolRate()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
unsigned long Reg0297_GetSymbolRate(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_GetSymbolRate()";
#endif
    unsigned long   Value;
    long            ExtClk;
    U8 temp[3];

    /**/
    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297_STLOOP_5, 4, temp);

    Value = temp[0] + (temp[1])*256L;
    Value += (temp[2])*65536L + (temp[3])*16777216L;

    ExtClk   = DeviceMap->RegExtClk;

    Value   /= 4;
    Value   /= 8192L;
    Value   *= ExtClk;
    Value   /= 131072L;
    Value   *= 1000;

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> SR %u\n", identity, Value));
#endif

    return(Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_SetSweepRate()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297_SetSweepRate(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, unsigned long Value)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_SetSweepRate()";
#endif
    long   long_tmp;
    long   RegSymbolRate ;

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> SWEEP %u\n", identity, Value));
#endif

    RegSymbolRate = Reg0297_GetSymbolRate(DeviceMap, IOHandle);        /* in Baud/s */
    if ( RegSymbolRate == 0 || Value == 0 )
    {
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
        STTBX_Print(("%s fail SymbolRate = 0 !\n", identity));
#endif
    }
    else
    {
        RegSymbolRate      /= 1000;

        long_tmp = Value * 262144L;
        long_tmp /= RegSymbolRate;
        long_tmp *= 1024;
        /* rounding */
        if(long_tmp >= 0)
            long_tmp += 500000 ;
        else
            long_tmp -= 500000 ;
        long_tmp /= 1000000 ;
        STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_SWEEP_LO, (int)(MAC0297_B0(long_tmp)));
        STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_SWEEP_HI, (int)(MAC0297_B1(long_tmp)));
    }
}

/* ----------------------------------------------------------------------------
Name: Reg0297_SetFrequencyOffset()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297_SetFrequencyOffset(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, long Value)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_SetFrequencyOffset()";
#endif
    long    long_tmp;
    U8      temp[3],try1;

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> FrequencyOffset %d\n", identity, Value));
#endif
    long_tmp = Value * 26844L ;                 /* (2**28)/10000 */
    if(long_tmp < 0) long_tmp += 0x10000000 ;
    long_tmp &= 0x0FFFFFFF ;

    try1=STTUNER_IOREG_GetRegister(DeviceMap,IOHandle,R0297_CRL_6);
    temp[0]=(int)(MAC0297_B0(long_tmp));
    temp[1]=(int)(MAC0297_B1(long_tmp));
    temp[2]=(int)(MAC0297_B2(long_tmp));
    try1=try1&0xF0;
    temp[3]=try1|(int)(MAC0297_B3(long_tmp));
    STTUNER_IOREG_SetContigousRegisters(DeviceMap, IOHandle, R0297_CRL_6, temp, 4);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_GetFrequencyOffset()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
long Reg0297_GetFrequencyOffset(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_GetFrequencyOffset()";
#endif
    long    Value;
    U8 temp[3];

    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297_CRL_6, 4, temp);
    temp[3]=temp[3]&0x0F;
    Value = temp[0] + (temp[1])*256L;
    Value += (temp[2])*65536L + (temp[3])*16777216L;

    if (Value >= 0x08000000)
    {
        Value -= 0x10000000 ;                   /* 0x10000000 = 2**28  */
    }
    Value /= 2684354L ;                      /* (2**28)/100 */
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> FrequencyOffset %d\n", identity, Value));
#endif
    return(Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_GetSTV0297Id()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
U8 Reg0297_GetSTV0297Id(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_GetSTV0297Id()";
#endif
    U8    Value=0xFF;

    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_VERSION, Value);      /* To Prevent I2C access Pb */
    Value =   STTUNER_IOREG_GetField(DeviceMap, IOHandle, F0297_VERSION);

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> Version %x\n", identity, Value));
#endif
    return(Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_StartBlkCounter()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297_StartBlkCounter(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_CT_HOLD, 0);
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_CT_CLEAR, 0);
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_CT_CLEAR, 1);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_StopBlkCounter()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297_StopBlkCounter(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297_CT_HOLD, 1);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_GetBlkCounter()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
U16 Reg0297_GetBlkCounter(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_GetBlkCounter()";
#endif
    U16    Value;
    U8 temp[1];
    U16 val;

    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297_RS_DESC_0, 2, temp);
    val=temp[1];
    Value = temp[0]+ (val<< 8);

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> BlkCounter %u\n", identity, Value));
#endif
    return(Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_GetCorrBlk()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
U16 Reg0297_GetCorrBlk(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_GetCorrBlk()";
#endif
    U16    Value,val;
    U8 temp[1];
    
    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297_RS_DESC_2, 2, temp);
    val=temp[1];
    Value = temp[0] + (val<< 8);

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> CorrBlk %u\n", identity, Value));
#endif
    return(Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297_GetUncorrBlk()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
U16 Reg0297_GetUncorrBlk(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    const char *identity = "STTUNER reg0297.c Reg0297_GetUncorrBlk()";
#endif
    U16    Value,val;
    U8 temp[1];
    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297_RS_DESC_4, 2, temp);
    val=temp[1];
    Value = temp[0]+ (val<< 8);

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297
    STTBX_Print(("%s ==> UncorrBlk %u\n", identity, Value));
#endif
    return(Value);
}

⌨️ 快捷键说明

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