📄 d0288.c
字号:
/* ----------------------------------------------------------------------------
File Name: d0288.c
Description:
stx0288 demod driver.
Copyright (C) 2005-2006 STMicroelectronics
History:
date: 04-Aug-2005
version: 1.0.0A1
author: SD
comment: First LLA Integration
date: 01-Aug-2006
version: 1.0.0A1
author:HS, SD
comment: Changing according to new IOREG
---------------------------------------------------------------------------- */
/* Includes ---------------------------------------------------------------- */
#ifdef ST_OSLINUX
#include "stos.h"
#else
/* C libs */
#include <string.h>
#include <stdlib.h>
#include "stlite.h" /* Standard includes */
/* STAPI */
#include "sttbx.h"
#endif
#include "sttuner.h"
/* local to sttuner */
#include "stevt.h"
#include "util.h" /* generic utility functions for sttuner */
#include "dbtypes.h" /* data types for databases */
#include "sysdbase.h" /* functions to accesss system data */
#include "ioarch.h" /* I/O for this driver */
#include "ioreg.h" /* I/O for this driver */
#include "sioctl.h" /* data structure typedefs for all the the sat ioctl functions */
#include "drv0288.h" /* misc driver functions */
#include "d0288.h" /* header for this file */
#include "util288.h"
/* Device capabilities */
#define MAX_AGC 255
#define MAX_SIGNAL_QUALITY 100
#define MAX_BER 200000
#ifdef STTUNER_DRV_SAT_SCR
extern ST_ErrorCode_t scr_scrdrv_SetFrequency (STTUNER_Handle_t Handle, DEMOD_Handle_t DemodHandle, ST_DeviceName_t *DeviceName, U32 InitialFrequency, U8 LNBIndex, U8 SCRBPF );
#endif
#define STX0288_SYMBOL_RATE_MIN 1000000
#define STX0288_SYMBOL_RATE_MAX 60000000
#define STX0288_MCLK 100000000
/* private variables ------------------------------------------------------- */
#if defined(ST_OS21) || defined(ST_OSLINUX)
static semaphore_t *Lock_InitTermOpenClose; /* guard calls to the functions */
#else
static semaphore_t Lock_InitTermOpenClose; /* guard calls to the functions */
#endif
static BOOL Installed = FALSE;
/* ---------- per instance of driver ---------- */
typedef struct
{
ST_DeviceName_t *DeviceName; /* unique name for opening under */
STTUNER_Handle_t TopLevelHandle; /* access tuner, lnb etc. using this */
IOARCH_Handle_t IOHandle; /* instance access to I/O driver */
STTUNER_IOREG_DeviceMap_t DeviceMap; /* stv0288 register map & data table */
ST_Partition_t *MemoryPartition; /* which partition this data block belongs to */
void *InstanceChainPrev; /* previous data block in chain or NULL if not */
void *InstanceChainNext; /* next data block in chain or NULL if last */
U32 ExternalClock; /* External VCO */
STTUNER_TSOutputMode_t TSOutputMode;
STTUNER_SerialDataMode_t SerialDataMode;
STTUNER_BlockSyncMode_t BlockSyncMode;
STTUNER_SerialClockSource_t SerialClockSource;
STTUNER_FECMode_t FECMode;
STTUNER_DiSEqCConfig_t DiSEqCConfig; /** Added DiSEqC configuration structure to get the trace of current state**/
BOOL DISECQ_ST_ENABLE;
STTUNER_DataClockPolarity_t ClockPolarity;
STTUNER_DataClockAtParityBytes_t DataClockAtParityBytes;
STTUNER_DataFIFOMode_t DataFIFOMode; /* add block sync bit control for bug GNBvd27452*/
STTUNER_OutputFIFOConfig_t OutputFIFOConfig; /* add block sync bit control for bug GNBvd27452*/
U32 Symbolrate;
U32 DiSEqC_RxFreq;
BOOL SET_TSCLOCK;
}
D0288_InstanceData_t;
/**************extern from open.c************************/
#ifdef STTUNER_DRV_SAT_SCR
#ifdef STTUNER_DRV_SAT_SCR_LOOPTHROUGH
extern U32 DemodDrvHandleOne;
#endif
#endif
/* instance chain, the default boot value is invalid, to catch errors */
static D0288_InstanceData_t *InstanceChainTop = (D0288_InstanceData_t *)0x7fffffff;
/* API */
ST_ErrorCode_t demod_d0288_Init(ST_DeviceName_t *DeviceName, DEMOD_InitParams_t *InitParams);
ST_ErrorCode_t demod_d0288_Term(ST_DeviceName_t *DeviceName, DEMOD_TermParams_t *TermParams);
ST_ErrorCode_t demod_d0288_Open (ST_DeviceName_t *DeviceName, DEMOD_OpenParams_t *OpenParams, DEMOD_Capability_t *Capability, DEMOD_Handle_t *Handle);
ST_ErrorCode_t demod_d0288_Close(DEMOD_Handle_t Handle, DEMOD_CloseParams_t *CloseParams);
ST_ErrorCode_t demod_d0288_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber);
ST_ErrorCode_t demod_d0288_GetModulation (DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation);
ST_ErrorCode_t demod_d0288_SetModulation (DEMOD_Handle_t Handle, STTUNER_Modulation_t Modulation);
ST_ErrorCode_t demod_d0288_GetAGC (DEMOD_Handle_t Handle, S16 *Agc);
ST_ErrorCode_t demod_d0288_GetFECRates (DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates);
ST_ErrorCode_t demod_d0288_GetIQMode (DEMOD_Handle_t Handle, STTUNER_IQMode_t *IQMode); /*added for GNBvd26107->I2C failure due to direct access to demod device at API level*/
ST_ErrorCode_t demod_d0288_IsLocked (DEMOD_Handle_t Handle, BOOL *IsLocked);
ST_ErrorCode_t demod_d0288_SetFECRates (DEMOD_Handle_t Handle, STTUNER_FECRate_t FECRates);
ST_ErrorCode_t demod_d0288_Tracking (DEMOD_Handle_t Handle, BOOL ForceTracking, U32 *NewFrequency, BOOL *SignalFound);
ST_ErrorCode_t demod_d0288_ScanFrequency (DEMOD_Handle_t Handle, U32 InitialFrequency, U32 SymbolRate, U32 MaxOffset,
U32 TunerStep, U8 DerotatorStep, BOOL *ScanSuccess,
U32 *NewFrequency, U32 Mode, U32 Guard,
U32 Force, U32 Hierarchy, U32 Spectrum,
U32 FreqOff, U32 ChannelBW, S32 EchoPos);
/* added for DiSEqC API support*/
ST_ErrorCode_t demod_d0288_DiSEqC (DEMOD_Handle_t Handle,
STTUNER_DiSEqCSendPacket_t *pDiSEqCSendPacket,
STTUNER_DiSEqCResponsePacket_t *pDiSEqCResponsePacket
);
ST_ErrorCode_t demod_d0288_DiSEqCGetConfig ( DEMOD_Handle_t Handle ,STTUNER_DiSEqCConfig_t * DiSEqCConfig);
ST_ErrorCode_t demod_d0288_DiSEqCBurstOFF ( DEMOD_Handle_t Handle );
ST_ErrorCode_t demod_0288_GetSymbolrate(DEMOD_Handle_t Handle, U32 *SymbolRate);
/***************************************/
U8 Def288Val[STX288_NBREGS]=
{
0x10,0xa5,0x20,0x8e,0x8e,0x12,0x00,0x20,0x00,0x00,
0x04,0x00,0x00,0x00,0xd4,0x30,0xf2,0x7a,0x03,0x48,
0x84,0xc5,0xb7,0x9c,0x00,0xa6,0x88,0x8f,0xf0,0x80,
0x26,0x0b,0x54,0xff,0x01,0x9a,0x7f,0x00,0x00,0x46,
0x66,0x90,0xfe,0x78,0x0e,0x5d,0x00,0x00,0x1e,0x14,
0x0f,0x09,0x0c,0x05,0x2f,0x16,0xbd,0x00,0x13,0x11,
#ifdef STTUNER_DRV_SAT_5188
0x30,0x00,0x00,0x13,0x08,0x60,0x00,0x00,0x00,0x00, /* for STX5188 with 30MHz clock */
#else
0x30,0x00,0x00,0x63,0x04,0x60,0x00,0x00,0x00,0x00, /* for STX0288 with 4MHz crystal */
#endif
0x00,0x00,0x1b,0x28,0x10,0x36,0x09,0x94,0xb2,0x29,
0x64,0x2b,0x54,0x86,0x00,0x9b,0x08,0x7f,0xff,0x8d,
0x82,0x82,0x82,0x02,0x02,0x02,0x82,0x82,0x82,0x82,
0x38,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1c,0x00,0x48,0x00,0xb8,0x3a,0x10,
0x82,0x80,0x82,0x82,0x82,0x20,0x00,0x00,0x00,0xc0
};
U16 Addressarray[STX288_NBREGS]=
{
0x0000,
0x0001,
0x0002,
0x0003,
0x0004,
0x0005,
0x0006,
0x0007,
0x0008,
0x0009,
0x000a,
0x000b,
0x000c,
0x000d,
0x000e,
0x000f,
0x0010,
0x0011,
0x0012,
0x0013,
0x0014,
0x0015,
0x0016,
0x0017,
0x0018,
0x0019,
0x001a,
0x001b,
0x001c,
0x001e,
0x001f,
0x0020,
0x0021,
0x0022,
0x0023,
0x0024,
0x0025,
0x0026,
0x0027,
0x0028,
0x0029,
0x002a,
0x002b,
0x002c,
0x002d,
0x002e,
0x002f,
0x0030,
0x0031,
0x0032,
0x0033,
0x0034,
0x0035,
0x0036,
0x0037,
0x0038,
0x0039,
0x003a,
0x003b,
0x003c,
0x003d,
0x003e,
0x003f,
0x0040,
0x0041,
0x0042,
0x0043,
0x0044,
0x0045,
0x0046,
0x0047,
0x004a,
0x004b,
0x004c,
0x0050,
0x0051,
0x0052,
0x0053,
0x0054,
0x0055,
0x0056,
0x0057,
0x0058,
0x0059,
0x005a,
0x005b,
0x005c,
0x005d,
0x005e,
0x005f,
0x0060,
0x0061,
0x0062,
0x0063,
0x0064,
0x0065,
0x0066,
0x0067,
0x0068,
0x0069,
0x006a,
0x006b,
0x006c,
0x0070,
0x0071,
0x0072,
0x0074,
0x0075,
0x0076,
0x0081,
0x0082,
0x0083,
0x0084,
0x0085,
0x0088,
0x0089,
0x008a,
0x008b,
0x008c,
0x0090,
0x0091,
0x0092,
0x0093,
0x0094,
0x0097,
0x00a0,
0x00a1,
0x00b0,
0x00b1,
0x00b2,
0x00b3,
0x00b4,
0x00b5,
0x00b6,
0x00b7,
0x00b8,
0x00b9,
0x00f1,
0x00f0,
0x00f2,
};
/***************************************/
ST_ErrorCode_t demod_d0288_ioctl (DEMOD_Handle_t Handle, U32 Function, void *InParams, void *OutParams,
STTUNER_Da_Status_t *Status);
/* I/O API */
ST_ErrorCode_t demod_d0288_ioaccess(DEMOD_Handle_t Handle, IOARCH_Handle_t IOHandle,
STTUNER_IOARCH_Operation_t Operation, U16 SubAddr, U8 *Data, U32 TransferSize, U32 Timeout);
ST_ErrorCode_t demod_d0288_DiseqcInit(DEMOD_Handle_t Handle);
/* local functions --------------------------------------------------------- */
#ifdef STTUNER_DRV_SAT_SCR
ST_ErrorCode_t demod_d0288_tonedetection(DEMOD_Handle_t Handle,U32 StartFreq, U32 StopFreq, U8 *NbTones,U32 *ToneList, U8 mode,int* power_detection_level);
#endif
D0288_InstanceData_t *D0288_GetInstFromHandle(DEMOD_Handle_t Handle);
/***************************************
Name: STTUNER_DRV_DEMOD_STV0288_Install()
Description:
install a satellite device driver into the demod database.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STX0288_Install(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c STTUNER_DRV_DEMOD_STX0288_Install()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
if(Installed == TRUE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail driver already installed\n", identity));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -