cx24143_fun.c
来自「QPSK Tuner details, for conexant chipset」· C语言 代码 · 共 1,929 行 · 第 1/5 页
C
1,929 行
case SYNC_WORD_NOT_PUNCTURED:
{
ulRegVal = (mpeg_out->SyncPunctMode == SYNC_WORD_PUNCTURED) ? 0x01UL : 0x00UL;
if (RegisterWrite(nim,CX24130_MPGSYNCPUNC,ulRegVal) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch(mpeg_out->FailValueWhenNoSync)
{
case FAIL_LOW_WHEN_NO_SYNC:
case FAIL_HIGH_WHEN_NO_SYNC:
{
ulRegVal = (mpeg_out->FailValueWhenNoSync == FAIL_HIGH_WHEN_NO_SYNC) ? 0x01UL : 0x00UL;
if (RegisterWrite(nim,CX24130_MPGFAILNSVAL,ulRegVal) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch(mpeg_out->ClkSmoothSel)
{
#ifdef CAMARIC_FEATURES
case PLL_ADVANCED_SMOOTHING:
{
if (DRIVER_Camaric(nim) != True)
{
/* CR9364, if board is CX24121, switch to DSS mode. */
mpeg_out->ClkSmoothSel = DDS_LEGACY_SMOOTHING;
/* Set error but continue from here. No break, it will fall through. */
DRIVER_SetError(nim,API_SETILLEGAL);
}
}
#endif /* #ifdef CAMARIC_FEATURES */
case DDS_LEGACY_SMOOTHING:
case CLK_SMOOTHING_OFF:
{
if (DRIVER_SetSmoothClock(nim,mpeg_out->ClkSmoothSel,False) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
if (DRIVER_SetRSCntlPin(nim,CX24130_MPGCNTL1SEL,mpeg_out->RSCntlPin1Sel) == False)
{
return (False);
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
if (DRIVER_SetRSCntlPin(nim,CX24130_MPGCNTL2SEL,mpeg_out->RSCntlPin2Sel) == False)
{
return (False);
}
#ifdef CAMARIC_FEATURES
/* Camaric specific settings */
if (DRIVER_Camaric(nim) == True)
{
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
if (DRIVER_SetRSCntlPin(nim,CX24123_MPGCNTL3SEL,mpeg_out->RSCntlPin3Sel) == False)
{
return (False);
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch (mpeg_out->NullDataMode)
{
case FIXED_NULL_DATA_ENABLED:
case FIXED_NULL_DATA_DISABLED:
{
ulRegVal = (mpeg_out->NullDataMode == FIXED_NULL_DATA_ENABLED) ? 0x01UL : 0x00UL;
if (RegisterWrite(nim,CX24123_MPGFIXNULLDATAEN,ulRegVal) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch (mpeg_out->NullDataValue)
{
case FIXED_NULL_DATA_HIGH:
case FIXED_NULL_DATA_LOW:
{
ulRegVal = (mpeg_out->NullDataValue == FIXED_NULL_DATA_HIGH) ? 0x01UL : 0x00UL;
if (RegisterWrite(nim,CX24123_MPGNULLDATAVAL,ulRegVal) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch (mpeg_out->ParityDataSel)
{
case RS_PARITY_DATA_LOW:
ulRegVal = 0x01UL;
break;
case RS_PARITY_DATA_HIGH:
ulRegVal = 0x02UL;
break;
case RS_PARITY_DATA_UNCHANGED:
ulRegVal = 0x00UL;
break;
default:
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
} /* switch */
if (RegisterWrite(nim,CX24123_MPGPARSEL,ulRegVal) == False) return(False);
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch (mpeg_out->ValidSignalWhenFail)
{
case VALID_SIGNAL_INACTIVE_WHEN_FAIL:
case VALID_SIGNAL_ACTIVE_WHEN_FAIL:
{
ulRegVal = (mpeg_out->ValidSignalWhenFail == VALID_SIGNAL_INACTIVE_WHEN_FAIL) ? 0x01UL : 0x00UL;
if (RegisterWrite(nim,CX24123_MPGFAILVALIDDIS,ulRegVal) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
switch (mpeg_out->StartSignalWhenFail)
{
case START_SIGNAL_INACTIVE_WHEN_FAIL:
case START_SIGNAL_ACTIVE_WHEN_FAIL:
{
ulRegVal = (mpeg_out->StartSignalWhenFail == START_SIGNAL_INACTIVE_WHEN_FAIL) ? 0x01UL : 0x00UL;
if (RegisterWrite(nim,CX24123_MPGFAILSTARTDIS,ulRegVal) == False) return(False);
break;
}
default:
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
break;
}
} /* switch(... */
} /* if (DRIVER_Camaric(nim) == True) */
#endif /* #ifdef CAMARIC_FEATURES */
/* no errors encountered, indicate such to caller */
memcpy(&nim->mpeg_out,mpeg_out,sizeof(MPEG_OUT));
return(True);
}
return(False);
} /* API_SetOutputOptions() */
/*******************************************************************************************************/
/* API_GetOutputOptions() */
/*******************************************************************************************************/
BOOL API_GetOutputOptions( /* function to return current mpeg settings to the caller */
NIM *nim, /* pointer to nim */
MPEG_OUT *mpeg_out) /* pointer to where copy of mpeg settings will be written */
{
/* validate nim and mpeg storage */
if (DRIVER_ValidateNim(nim) == False) return(False);
if (mpeg_out == NULL) DRIVER_SetError(nim,API_BADPTR);
else
{
/* copy mpeg setting to caller buffer */
memcpy(mpeg_out,&nim->mpeg_out,sizeof(MPEG_OUT));
return(True);
}
return(False);
} /* API_GetOutputOptions() */
/*******************************************************************************************************/
/* API_SetInterruptOptions() */
/*******************************************************************************************************/
BOOL API_SetInterruptOptions( /* function to set interrupt options */
NIM *nim, /* pointer to nim */
INTEROPTS interopts) /* interrupt settings */
{
ULONG ulRegVal = (ULONG)interopts;
ULONG valid_ints;
/* validate nim and mpeg storage */
if (DRIVER_ValidateNim(nim) == False) return(False);
/* test for valid interrupt settings */
valid_ints = ((ULONG)INTR_ACQ_SYNC|(ULONG)INTR_ACQ_FAILURE|(ULONG)INTR_VITERBI_LOSS|(ULONG)INTR_VITERBI_SYNC|
(ULONG)INTR_DEMOD_LOSS|(ULONG)INTR_DEMOD_SYNC);
/* or-in new interrupts */
valid_ints |= (ULONG)INTR_LNB_REPLY_READY;
/* test value to be written to demod for range error (bad range indicates invalid parameter passed) */
if (ulRegVal > valid_ints)
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
}
/* write new interrupt options to the demod */
return(RegisterWrite(nim,CX24130_INTRENABLE,ulRegVal));
} /* API_SetInterruptOptions() */
/*******************************************************************************************************/
/* API_SetSearchRangeLimit() */
/*******************************************************************************************************/
BOOL API_SetSearchRangeLimit( /* function to set LNB search range limit */
NIM *nim, /* pointer to nim */
ULONG lnboffset, /* desired LNB offset limit in hz (if in KHz, converted to Hz) */
ULONG *actual) /* returned actual LNB offset limit */
{
ULONG bins;
ULONG symbolrate;
ULONG sr;
/* validate nim */
if (DRIVER_ValidateNim(nim) == False) return(False);
/* validate input parameters */
if (lnboffset == 0UL || actual == NULL)
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
}
/* use the requested symbol rate if it is available, otherwise use the real symbol rate */
if ((symbolrate = (nim->symbol_rate_ideal * M)) == 0UL)
{
if (API_GetSymbolRate(nim,&symbolrate) == False)
{
return (False);
}
}
/* save the requested LNB offset */
nim->lnboffset = lnboffset;
/* remove excess LNB offset that the driver/hardware doesn't support */
if (lnboffset > (LNB_RANGE_HIGH * M)) lnboffset = (LNB_RANGE_HIGH * M);
/* Cobra hardware can handle up to 5MHz through binning, the LNB offset
beyond 5MHz is handled by moving the tuner PLL */
if (DRIVER_Cobra(nim) == True)
{
nim->tuner_offset = 0UL;
if (lnboffset > LNB_OFFSET_LIMIT)
{
nim->tuner_offset = (lnboffset - LNB_OFFSET_LIMIT);
lnboffset -= nim->tuner_offset;
}
}
*actual = 0UL;
sr = (symbolrate/8UL);
if (DRIVER_div_zero(nim,sr) == False) return(False);
/* compute the number of bins needed */
bins = (((ULONG)labs((LONG)lnboffset)) / (sr));
if ((bins * sr) < lnboffset) bins += 1UL;
if (bins < MIN_NO_BINS) bins = MIN_NO_BINS;
/* write number of bins to search */
if (DRIVER_Cobra(nim) == True)
{
if (bins > MAX_NO_BINS) bins = MAX_NO_BINS;
if (RegisterWrite(nim,CX24130_ACQFREQRANGE,bins) == False) return(False);
}
#ifdef CAMARIC_FEATURES
else if (DRIVER_Camaric(nim) == True)
{
if (bins > MAX_NO_BINS_CAM) bins = MAX_NO_BINS_CAM;
if (RegisterWrite(nim,CX24123_ACQFREQRANGE,bins) == False) return(False);
}
#endif /* #ifdef CAMARIC_FEATURES */
/* compute actual search rage limit, return to caller */
*actual = bins * (sr);
/* replace the previously removed excess lnboffset for Cobra */
if (DRIVER_Cobra(nim) == True)
{
*actual += nim->tuner_offset;
}
return(True);
} /* API_SetSearchRangeLimit() */
/*******************************************************************************************************/
/* API_GetSearchRangeLimit() */
/*******************************************************************************************************/
BOOL API_GetSearchRangeLimit( /* function to return current search range limit to caller */
NIM *nim, /* pointer to nim */
ULONG *lnboffset) /* returned lnb offset */
{
ULONG bins;
ULONG symbolrate;
/* validate nim */
if (DRIVER_ValidateNim(nim) == False) return(False);
/* validate input parameters */
if (lnboffset == NULL)
{
DRIVER_SetError(nim,API_BAD_PARM);
return(False);
}
if (API_GetSymbolRate(nim,&symbolrate) == True)
{
/* read number of bins currently set to search */
if (DRIVER_Cobra(nim) == True)
{
if (RegisterRead(nim,CX24130_ACQFREQRANGE,&bins) == False) return(False);
}
#ifdef CAMARIC_FEATURES
else if (DRIVER_Camaric(nim) == True)
{
if (RegisterRead(nim,CX24123_ACQFREQRANGE,&bins) == False) return(False);
}
#endif /* #ifdef CAMARIC_FEATURES */
else
{
DRIVER_SetError(nim,API_DEMOD_UNSUPPORTED);
return (False);
}
/* compute actual search range limit, return to caller */
/* *lnboffset = bins * (symbolrate/8UL) * M; <-- CR6870 */
*lnboffset = bins * (symbolrate/8UL);
/* (CR 6243) */
/* (CR 6323) removed because else would never be executed */
/* if (nim->tuner_offset >= 0) *lnboffset = ((*lnboffset) + (ULONG)nim->tuner_offset); */
/* else *lnboffset = ((*lnboffset) - (ULONG)(nim->tuner_offset * -1L)); */
*lnboffset = ((*lnboffset) + (ULONG)nim->tuner_offset);
return(True);
}
return(False);
} /* API_GetSearchRangeLimit() */
/*******************************************************************************************************/
/* API_SetModulation() */
/*******************************************************************************************************/
BOOL API_SetModulation( /* function to set the modulation type */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?