📄 demod.c
字号:
/*****************************************************************************File Name : demod.cDescription : Wrapper layer for DEMOD component. All DEMOD function calls resolve to a device-specific implementation of the DEMOD layer e.g., STV0299. Each DEMOD module must be imported via a function table that should be externally referenced in this module.Copyright (C) 2000 STMicroelectronicsRevision History : 24/01/00 Created module in anticipation of support for multiple DEMOD devices connected.Reference :ST API Definition "TUNER Driver API" DVD-API-06*****************************************************************************//* Includes --------------------------------------------------------------- */#include <string.h> /* C libs */ #include <stdio.h>#include "stlite.h" /* Standard includes */#include "stddefs.h"#include "sttuner.h" /* STAPI Error codes, etc */#include "stcommon.h"#include "demod.h" /* DEMOD Device API */#include "sttbx.h"/* Private types/constants ------------------------------------------------ *//* Imported DEMOD modules */#ifdef INCLUDE_stv199 /* STV0199 */extern DEMOD_MapTable_t __STV0199MapTable;#define STV0199MAPTABLE &__STV0199MapTable#else#define STV0199MAPTABLE NULL#endif#ifdef INCLUDE_stv299 /* STV0299 */extern DEMOD_MapTable_t __STV0299MapTable;#define STV0299MAPTABLE &__STV0299MapTable#else#define STV0299MAPTABLE NULL#endif/* Private variables ------------------------------------------------------ *//* Private macros --------------------------------------------------------- *//* Private function prototypes -------------------------------------------- *//* Supported devices */static DEMOD_MapTable_t *DemodMapTable[] ={ STV0199MAPTABLE, /* DEMOD_DEVICE_STV0199 */ STV0299MAPTABLE /* DEMOD_DEVICE_STV0299 */};/* API routines ----------------------------------------------------------- *//*****************************************************************************Name: DEMOD_Init()Description: Initializes the DEMOD device.Parameters: InitParams_p, pointer to init params to for guiding the initialization process for this device.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device. DEMOD_ERROR_BAD_PARAMETER, one or more params were invalid.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_Init(DEMOD_InitParams_t *InitParams_p, DEMOD_Handle_t *Handle_p, DEMOD_Capability_t *Capability_p){ DEMOD_ErrorCode_t Error; DEMOD_MapTable_t *MapTable_p; /* Check whether or not the device is supported */ if (InitParams_p->DemodType < DEMOD_DEVICE_UNKNOWN) { MapTable_p = DemodMapTable[InitParams_p->DemodType]; /* Call device initialization for required DEMOD */ if (MapTable_p != NULL) Error = MapTable_p->DEMOD_Init(InitParams_p, Handle_p, Capability_p); else Error = DEMOD_ERROR_BAD_PARAMETER; } else Error = DEMOD_ERROR_BAD_PARAMETER; return Error;} /* DEMOD_Init() *//*****************************************************************************Name: DEMOD_Term()Description: Performs any necessary operations that are required to cleanup after the DEMOD device.Parameters: Demod_p, pointer to the DEMOD device.Return Value: DEMOD_NO_ERROR, the operation completed without error. Other error codes TBD.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_Term(DEMOD_Handle_t Handle){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_Term(Handle);} /* DEMOD_Term() *//*****************************************************************************Name: DEMOD_IsAnalogCarrier()Description: This routine checks for an analog carrier on the current frequency by setting the symbol rate to 5M (never a digital signal).Parameters: Demod_p, pointer to the DEMOD device. IsAnalog_p, pointer to area to store result: TRUE - is analog FALSE - is not analogReturn Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_IsAnalogCarrier(DEMOD_Handle_t Handle, BOOL *IsAnalog_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_IsAnalogCarrier( Handle, IsAnalog_p);} /* DEMOD_IsAnalogCarrier() *//*****************************************************************************Name: DEMOD_GetSignalQuality()Description: Obtains a signal quality setting for the current lock.Parameters: Demod_p, pointer to the DEMOD device. SignalQuality_p, pointer to area to store the signal quality value. Ber_p, pointer to area to store the bit error rate.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_GetSignalQuality( Handle, SignalQuality_p, Ber_p);} /* DEMOD_GetSignalQuality() *//*****************************************************************************Name: DEMOD_IsLocked()Description: Checks the LK register i.e., are we demodulating a digital carrier.Parameters: Demod_p, pointer to the DEMOD device. IsLocked_p, pointer to area to store result (bool): TRUE -- we are locked. FALSE -- no lock.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_IsLocked( Handle, IsLocked_p);} /* DEMOD_IsLocked() *//*****************************************************************************Name: DEMOD_Tracking()Description: This routine checks the carrier against a certain threshold value and will perform derotator centering, if necessary -- using the ForceTracking option ensures that derotator centering is always performed when this routine is called. This routine should be periodically called once a lock has been established in order to maintain the lock.Parameters: Demod_p, pointer to the DEMOD device. ForceTracking, boolean to control whether to always perform derotator centering, regardless of the carrier. NewFrequency_p, pointer to area where to store the new frequency value -- it may be changed when trying to optimize the derotator. SignalFound_p, indicates that whether or not we're still locked after optimization.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_Tracking(DEMOD_Handle_t Handle, BOOL ForceTracking, U32 *NewFrequency_p, BOOL *SignalFound_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_Tracking( Handle, ForceTracking, NewFrequency_p, SignalFound_p);} /* DEMOD_Tracking() *//*****************************************************************************Name: DEMOD_ScanFrequency()Description: This routine will attempt to scan and find a QPSK signal based on the passed in parameters.Parameters: Demod_p, pointer to the DEMOD device. InitialFrequency, IF value to commence scan (in kHz). SymbolRate, required symbol bit rate (in Hz). MaxLNBOffset, maximum allowed LNB offset (in Hz). TunerStep, Tuner's step value -- enables override of TNR device's internal setting. DerotatorStep, derotator step (usually 6). ScanSuccess_p, boolean that indicates QPSK search success. NewFrequency_p, pointer to area to store locked frequency.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device. DEMOD_ERROR_BAD_PARAMETER, one or more params were invalid during computation.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_ScanFrequency(DEMOD_Handle_t Handle, U32 InitialFrequency, U32 SymbolRate, U32 MaxLNBOffset, U32 TunerStep, U8 DerotatorStep, BOOL *ScanSuccess_p, U32 *NewFrequency_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_ScanFrequency( Handle, InitialFrequency, SymbolRate, MaxLNBOffset, TunerStep, DerotatorStep, ScanSuccess_p, NewFrequency_p);} /* DEMOD_ScanFrequency() *//*****************************************************************************Name: DEMOD_GetModulation()Description: This routine returns the modulation scheme in use by this device. ** Currently only QPSK is supported.Parameters: Demod_p, pointer to the DEMOD device. Modulation_p, pointer to area to store modulation scheme.Return Value: DEMOD_NO_ERROR, the operation completed without error.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_GetModulation(DEMOD_Handle_t Handle, DEMOD_Modulation_t *Modulation_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_GetModulation( Handle, Modulation_p);} /* DEMOD_GetModulation() *//*****************************************************************************Name: DEMOD_GetAGC()Description: Obtains the current value from the AGC integrator register and computes a look-up of power output.Parameters: Demod_p, pointer to the DEMOD device. AGC_p, pointer to area to store power output value.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_GetAGC(DEMOD_Handle_t Handle, U32 *AGC_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_GetAGC( Handle, AGC_p);} /* DEMOD_GetAGC() *//*****************************************************************************Name: DEMOD_GetFECRate()Description: Checks the VEN rate register to deduce the forward error correction setting that is currently in use.Parameters: Demod_p, pointer to the DEMOD device. FECRate_p, pointer to area to store FEC rates in use.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_GetFECRate(DEMOD_Handle_t Handle, DEMOD_FECRate_t *FECRate_p){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_GetFECRate( Handle, FECRate_p);} /* DEMOD_GetFECRates() *//*****************************************************************************Name: DEMOD_SetFECRates()Description: Sets the FEC rates to be used during demodulation.Parameters: Demod_p, pointer to DEMOD device. FECRates, bitmask of FEC rates to be applied.Return Value: DEMOD_NO_ERROR, the operation completed without error. STI2C_xxx, there was a problem accessing the device.See Also: Nothing.*****************************************************************************/DEMOD_ErrorCode_t DEMOD_SetFECRates(DEMOD_Handle_t Handle, DEMOD_FECRate_t FECRates){ return (*((DEMOD_MapTable_t **)Handle))->DEMOD_SetFECRates( Handle, FECRates);} /* DEMOD_SetFECRates() *//* End of demod.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -