📄 cx24143drv.c
字号:
}
if(i>CNT_TIMES)
return CSQPSK_FAILURE;
*pdwBer=berest.integer;
#ifdef QPSK_DEBUG
CSTRACE( INFO_LEVEL, "[HDIQPSK] CX2414xGetBER=%d\n",berest.integer);
#endif
return CSQPSK_SUCCESS;
}
/*****************************************************************************/
/* FUNCTION: CX2414xInit */
/* PARAMETERS: bTunerIndex - tuner index */
/* DESCRIPTION: This function init cx2414x chip. */
/* RETURNS: suceess--init ok , failure--init fail. */
/*****************************************************************************/
CSQPSK_Error_t CX2414xInit(CSHDITunerIndex bTunerIndex)
{
CSQPSK_Error_t ret_val;
if (demod_initfalg)
{
return CSQPSK_SUCCESS;
}
ret_val= CX2414X_demod_init( bTunerIndex);
CX2414xSet_LNBPower(bTunerIndex,1);
/* Check for the special case of no hardware present for the demod.
A return of DEMOD_NO_HARDWARE means to continue initialization and
allows autoconfiguration of interfaces. */
if (ret_val != CSQPSK_DEVICE_UNKNOWN) //DEMOD_NO_HARDWARE
{
if (ret_val != CSQPSK_SUCCESS)
{
/* fatal error on initialization */
CSTRACE( ERROR_LEVEL, "[HDIQPSK] CX2414xInit fail \n");
return CSQPSK_FAILURE;
}
// init ok
CSTRACE( ERROR_LEVEL, "[HDIQPSK] CX2414xInit suceess \n");
demod_initfalg=1;
return CSQPSK_SUCCESS;
}
else
{
CSTRACE( ERROR_LEVEL, "[HDIQPSK] CX2414xInit fail ,no hardware \n");
return CSQPSK_FAILURE;
}
}
CSQPSK_Error_t CX2414xCheckDiSEqCFree( CSHDITunerIndex bTunerIndex )
{
ULONG ulRegVal;
BOOL Err_flag;
int i;
for( i=0; i<10; i++)
{
ulRegVal=0x00UL;
if ((Err_flag=RegisterRead(&NIMs[bTunerIndex],CX24130_LNBSENDMSG,&ulRegVal) )== False)
{
CSASSERT(Err_flag);
continue;
}
if (ulRegVal != 0x01UL)
{
// Diseqc is busy
CSSleep(10);
CSTRACE(QPSK_DEBUG_LEVEL,"[CX2414xCheckDiSEqCFree]DiSEqC is BUSY!!!\n");
}
else
{
return CSQPSK_SUCCESS;
}
}
return CSQPSK_FAILURE;
}
#if 1
CSQPSK_Error_t CX2414xSendDiSEqC10Command(CSHDITunerIndex bTunerIndex, BYTE bSwitchType, BYTE bCommittedByte, BYTE bToneBurstSel, BYTE bRepeat)
{
BYTE pbValue[4];
ULONG ulRegVal;
BOOL Err_flag;
//BYTE bRepeat_time=bRepeat;
BYTE bRepeat_time=0;
BYTE bToneburst;
// Diseqc1.0 command
pbValue[0] = 0xE0;
pbValue[1] = 0x10;
pbValue[2] = 0x38;
pbValue[3] = bCommittedByte;
bToneburst = (bCommittedByte >> 2) & 0x01;
CSTRACE( ERROR_LEVEL, "[HDIQPSK][CX2414xSendDiSEqC10Command] Send Diseqc1.0 command \n");
#if 0 // 2005/09/08
switch(bToneBurstSel)
{
case LNBBURST_MODULATED:
ulRegVal=0x01;
break;
case LNBBURST_UNMODULATED:
default:
ulRegVal=0x00;
break;
} /* switch(... */
if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,ulRegVal) )== False)
{
CSASSERT(Err_flag);
return(CSQPSK_FAILURE);
}
#else
if (0 == bSwitchType)
{
if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,(ULONG)bToneburst ))== False)
{
CSASSERT(Err_flag);
return(CSQPSK_FAILURE);
}
}
else if ((bToneBurstSel == 1) || (bToneBurstSel == 2))
{
if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,(ULONG)bToneburst-1 ))== False)
{
CSASSERT(Err_flag);
return(CSQPSK_FAILURE);
}
}
#endif
ulRegVal=0x00UL;
if ((Err_flag=RegisterRead(&NIMs[bTunerIndex],CX24130_LNBSENDMSG,&ulRegVal) )== False)
{
CSASSERT(Err_flag);
return(CSQPSK_FAILURE);
}
if (ulRegVal != 0x01UL)
{
// Diseqc is busy
CSASSERT(ulRegVal);
return(CSQPSK_FAILURE);
}
if (1 == bSwitchType)
{
pbValue[2] = 0x39;
}
if(bRepeat_time==0)
{
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
return(CSQPSK_FAILURE);
}
CSTRACE( INFO_LEVEL, "[HDIQPSK] Send Diseqc1.0 port=%x \n",bCommittedByte&0xfc);
}
else
{
while(bRepeat_time--)
{
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
return(CSQPSK_FAILURE);
}
CSSleep_ex(100);
pbValue[0] = 0xE1;
}
}
// delay to ensure the signal is stable
CSSleep(200);
return(CSQPSK_SUCCESS);
}
#else
/*****************************************************************************/
/* FUNCTION: CX2414xSendDiSEqC10Command */
/* PARAMETERS: bTunerIndex - tuner index
bSwitchType - switch type
bCommittedByte - diseqc port command
bToneBurstSel - tone burst mode
bRepeat - repeat times. */
/* DESCRIPTION: This function Send DiSEqC1.0 Command. */
/* RETURNS: suceess--send ok , failure--send fail. */
/*****************************************************************************/
CSQPSK_Error_t CX2414xSendDiSEqC10Command(CSHDITunerIndex bTunerIndex, BYTE bSwitchType, BYTE bCommittedByte, BYTE bToneBurstSel, BYTE bRepeat)
{
BYTE pbValue[4];
ULONG ulRegVal;
BOOL Err_flag;
BYTE bRepeat_time=bRepeat;
BYTE bToneburst;
LNBTONE b22KStatus;
CSTRACE(QPSK_DEBUG_LEVEL,"[CX2414xCheckDiSEqCFree]CX2414xSendDiSEqC10Command!!!\n");
// Diseqc1.0 command
pbValue[0] = 0xE0;
pbValue[1] = 0x10;
pbValue[2] = 0x38;
pbValue[3] = bCommittedByte;
bToneburst = (bCommittedByte >> 2) & 0x01;
API_GetLNBTone(&NIMs[bTunerIndex], &b22KStatus);
API_SetLNBTone(&NIMs[bTunerIndex],LNBTONE_OFF);
CSSleep(30);
if (0 == bSwitchType)
{
if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,(ULONG)bToneburst ))== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
}
else if ((bToneBurstSel == 1) || (bToneBurstSel == 2))
{
if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,(ULONG)bToneburst-1 ))== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
}
CX2414xCheckDiSEqCFree(bTunerIndex);
if (1 == bSwitchType)
{
pbValue[2] = 0x39;
}
#if 0
if(bRepeat_time==0)
{
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
}
else
{
while(bRepeat_time--)
{
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
CX2414xCheckDiSEqCFree(bTunerIndex);
CSSleep_ex(40);
pbValue[0] = 0xE1;
}
}
#else
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
CSTRACE(QPSK_DEBUG_LEVEL,"[CX2414xCheckDiSEqCFree]CX2414xSendDiSEqC10Command ERROR!!!\n");
//return(CSQPSK_FAILURE);
}
#endif
//CX2414xCheckDiSEqCFree(bTunerIndex);
CSSleep(150);
API_SetLNBTone(&NIMs[bTunerIndex],b22KStatus);
// delay to ensure the signal is stable
CSSleep(50);
return(CSQPSK_SUCCESS);
}
#endif
// not check so unuse
CSQPSK_Error_t CX2414xSendDiSEqC11Command(CSHDITunerIndex bTunerIndex, BYTE bCommittedByte, BYTE bUnCommittedByte, BYTE bRepeat)
{
BYTE pbValue[4];
ULONG ulRegVal;
BOOL Err_flag;
//BYTE bRepeat_time=bRepeat;
BYTE bRepeat_time=0;
BYTE bToneburst = (bCommittedByte >> 2) & 0x01;
LNBTONE b22KStatus;
// Diseqc1.0 command
pbValue[0] = 0xE0;
pbValue[1] = 0x10;
pbValue[2] = 0x38;
pbValue[3] = bCommittedByte;
API_GetLNBTone(&NIMs[bTunerIndex], &b22KStatus);
API_SetLNBTone(&NIMs[bTunerIndex],LNBTONE_OFF);
CSSleep(30);
CSTRACE( ERROR_LEVEL, "[HDIQPSK][CX2414xSendDiSEqC11Command] Send Diseqc1.0 command \n");
// tone burst may be lay at the end of function
ulRegVal=(ULONG)bToneburst;
if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,ulRegVal) )== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
ulRegVal=0x00UL;
if ((Err_flag=RegisterRead(&NIMs[bTunerIndex],CX24130_LNBSENDMSG,&ulRegVal) )== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
if (ulRegVal != 0x01UL)
{
// Diseqc is busy
CSASSERT(ulRegVal);
CSSleep(50);
//return(CSQPSK_FAILURE);
}
//while (1)
{
pbValue[2] = 0x38; // add for repeat 2005/09/15
pbValue[3] = bCommittedByte;// add for repeat 2005/09/15
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
/*
if ((bRepeat_time == 0) && (bRepeat >0))
{
break;
}*/
CSSleep_ex(50);
//pbValue[0] = 0xE0;
//pbValue[1] = 0x10;
pbValue[2] = 0x39;
pbValue[3] = bUnCommittedByte;
if ((Err_flag=DRIVER_SendDiseqc(&NIMs[bTunerIndex],pbValue,4,False) )== False)
{
CSASSERT(Err_flag);
//return(CSQPSK_FAILURE);
}
/*
if (bRepeat == 0)
{
break;
}
else
{
pbValue[0]= 0xE1;
CSSleep_ex(40);
bRepeat_time--;
}
*/
}
CSSleep(100);
API_SetLNBTone(&NIMs[bTunerIndex],b22KStatus);
// delay to ensure the signal is stable
CSSleep(50);
// if ((Err_flag=RegisterWrite(&NIMs[bTunerIndex],CX24130_LNBBURSTMODSEL,(ULONG)bToneburst) )== FALSE)
// {
// CSASSERT(Err_flag);
// return(CSQPSK_FAILURE);
// }
return(CSQPSK_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: CX2414xSendDiSEqCCommand */
/* PARAMETERS: bTunerIndex - tuner index
pbValue - commamd
nCommandNum - diseqc command nums */
/* DESCRIPTION: This function Send DiSEqC Command. */
/* RETURNS: suceess--send ok , failure--send fail. */
/********************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -