📄 d0297.c
字号:
/* ----------------------------------------------------------------------------
File Name: d0297.c (was d0299.c)
Description:
stv0297 demod driver.
Copyright (C) 1999-2001 STMicroelectronics
date: 01-October-2001
version: 3.2.0
author: from STV0299 and MB validation drivers.
comment: Write for multi-instance/multi-FrontEnd.
Revision History:
Reference:
ST API Definition "TUNER Driver API" DVD-API-06
---------------------------------------------------------------------------- */
/* Includes ---------------------------------------------------------------- */
/* C libs */
#include <string.h>
#include "stlite.h" /* Standard includes */
#include "stcommon.h"
/* STAPI */
#include "sttbx.h"
#include "stevt.h"
#include "sttuner.h"
/* local to sttuner */
#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 "reg0297.h" /* register mappings for the stv0297 */
#include "drv0297.h" /* misc driver functions */
#include "d0297.h" /* header for this file */
#include "cioctl.h" /* data structure typedefs for all the the cable ioctl functions */
/* Private types/constants ------------------------------------------------ */
/* Device capabilities */
#define STV0297_MAX_AGC 1023
#define STV0297_MAX_SIGNAL_QUALITY 100
/* Device ID */
#define STV0297_DEVICE_VERSION 2 /* Latest Version of STV0297 */
#define STV0297_SYMBOLMIN 870000; /* # 1 MegaSymbols/sec */
#define STV0297_SYMBOLMAX 11700000; /* # 11 MegaSymbols/sec */
/* 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;
extern U16 Address[]=
{
0x00,
0x01,
0x03,
0x04,
0x07,
0x08,
0x20,
0x21,
0x22,
0x23,
0x24,
0x25,
0x30,
0x31,
0x32,
0x33,
0x34,
0x35,
0x36,
0x37,
0x38,
0x40,
0x41,
0x42,
0x43,
0x44,
0x45,
0x46,
0x49,
0x4A,
0x4B,
0x52,
0x53,
0x55,
0x56,
0x57,
0x58,
0x59,
0x5A,
0x5B,
0x60,
0x61,
0x62,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6A,
0x6B,
0x70,
0x71,
0x72,
0x73,
0x74,
0x80,
0x81,
0x82,
0x83,
0x84,
0x85,
0x86,
0x87,
0x88,
0x89,
0x90,
0x91,
0xA0,
0xA1,
0xA2,
0xB0,
0xB1,
0xC0,
0xC1,
0xC2,
0xD0,
0xD1,
0xD2,
0xD3,
0xD4,
0xD5,
0xDE,
0xDF,
};
extern U8 DefVal[]=
{
0x09,
0x69,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x40,
0x08,
0xFF,
0x33,
0x00,
0x44,
0x29,
0x33,
0x80,
0x00,
0x00,
0x1A,
0x00,
0x02,
0x20,
0x00,
0x00,
0x00,
0x04,
0x00,
0x00,
0x30,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x5E,
0x04,
0x00,
0x38,
0x06,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x02,
0x00,
0xFF,
0x04,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x04,
0x80,
0x00,
0x63,
0x00,
0x00,
0x01,
0x04,
0x00,
0x00,
0x00,
0x91,
0x0B,
0x43,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
};
/* ---------- 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; /* stv0297 register map & data table */
D0297_StateBlock_t StateBlock; /* driver search/state information */
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_SerialClockSource_t SerialClockSource;
STTUNER_FECMode_t FECMode;
}
D0297_InstanceData_t;
/* instance chain, the default boot value is invalid, to catch errors */
static D0297_InstanceData_t *InstanceChainTop = (D0297_InstanceData_t *)0x7fffffff;
/* functions --------------------------------------------------------------- */
/* API */
ST_ErrorCode_t demod_d0297_Init(ST_DeviceName_t *DeviceName, DEMOD_InitParams_t *InitParams);
ST_ErrorCode_t demod_d0297_Term(ST_DeviceName_t *DeviceName, DEMOD_TermParams_t *TermParams);
ST_ErrorCode_t demod_d0297_Open (ST_DeviceName_t *DeviceName, DEMOD_OpenParams_t *OpenParams, DEMOD_Capability_t *Capability, DEMOD_Handle_t *Handle);
ST_ErrorCode_t demod_d0297_Close(DEMOD_Handle_t Handle, DEMOD_CloseParams_t *CloseParams);
ST_ErrorCode_t demod_d0297_IsAnalogCarrier (DEMOD_Handle_t Handle, BOOL *IsAnalog);
ST_ErrorCode_t demod_d0297_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber_p);
ST_ErrorCode_t demod_d0297_GetModulation (DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation);
ST_ErrorCode_t demod_d0297_GetAGC (DEMOD_Handle_t Handle, S16 *Agc);
ST_ErrorCode_t demod_d0297_GetFECRates (DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates);
ST_ErrorCode_t demod_d0297_IsLocked (DEMOD_Handle_t Handle, BOOL *IsLocked);
ST_ErrorCode_t demod_d0297_SetFECRates (DEMOD_Handle_t Handle, STTUNER_FECRate_t FECRates);
ST_ErrorCode_t demod_d0297_Tracking (DEMOD_Handle_t Handle, BOOL ForceTracking, U32 *NewFrequency, BOOL *SignalFound);
ST_ErrorCode_t demod_d0297_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);
/* access device specific low-level functions */
ST_ErrorCode_t demod_d0297_ioctl (DEMOD_Handle_t Handle, U32 Function, void *InParams, void *OutParams,
STTUNER_Da_Status_t *Status);
/* repeater/passthrough port for other drivers to use, type: STTUNER_IOARCH_RedirFn_t */
ST_ErrorCode_t demod_d0297_ioaccess (DEMOD_Handle_t Handle, IOARCH_Handle_t IOHandle,
STTUNER_IOARCH_Operation_t Operation, U16 SubAddr,
U8 *Data, U32 TransferSize, U32 Timeout);
/* local functions --------------------------------------------------------- */
D0297_InstanceData_t *D0297_GetInstFromHandle(DEMOD_Handle_t Handle);
/* ----------------------------------------------------------------------------
Name: STTUNER_DRV_DEMOD_STV0297_Install()
Description:
install a cable device driver into the demod database.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STV0297_Install(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
const char *identity = "STTUNER d0297.c STTUNER_DRV_DEMOD_STV0297_Install()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
if(Installed == TRUE)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("%s fail driver already installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("%s installing cable:demod:STV0297...", identity));
#endif
/* mark ID in database */
Demod->ID = STTUNER_DEMOD_STV0297;
/* map API */
Demod->demod_Init = demod_d0297_Init;
Demod->demod_Term = demod_d0297_Term;
Demod->demod_Open = demod_d0297_Open;
Demod->demod_Close = demod_d0297_Close;
Demod->demod_IsAnalogCarrier = demod_d0297_IsAnalogCarrier;
Demod->demod_GetSignalQuality = demod_d0297_GetSignalQuality;
Demod->demod_GetModulation = demod_d0297_GetModulation;
Demod->demod_GetAGC = demod_d0297_GetAGC;
Demod->demod_GetFECRates = demod_d0297_GetFECRates;
Demod->demod_IsLocked = demod_d0297_IsLocked ;
Demod->demod_SetFECRates = demod_d0297_SetFECRates;
Demod->demod_Tracking = demod_d0297_Tracking;
Demod->demod_ScanFrequency = demod_d0297_ScanFrequency;
Demod->demod_ioaccess = demod_d0297_ioaccess;
Demod->demod_ioctl = demod_d0297_ioctl;
InstanceChainTop = NULL;
#if defined (ST_OS21) || defined(ST_OSLINUX)
Lock_InitTermOpenClose = semaphore_create_fifo(1);
#else
semaphore_init_fifo(&Lock_InitTermOpenClose, 1);
#endif
Installed = TRUE;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("ok\n"));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: STTUNER_DRV_DEMOD_STV0297_UnInstall()
Description:
install a cable device driver into the demod database.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STV0297_UnInstall(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
const char *identity = "STTUNER d0297.c STTUNER_DRV_DEMOD_STV0297_UnInstall()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("%s fail driver not installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
if(Demod->ID != STTUNER_DEMOD_STV0297)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("%s fail incorrect driver type\n", identity));
#endif
return(STTUNER_ERROR_ID);
}
/* has all memory been freed, by Term() */
if(InstanceChainTop != NULL)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("%s fail at least one instance not terminated\n", identity));
#endif
return(ST_ERROR_OPEN_HANDLE);
}
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("%s uninstalling cable:demod:STV0297...", identity));
#endif
/* mark ID in database */
Demod->ID = STTUNER_NO_DRIVER;
/* unmap API */
Demod->demod_Init = NULL;
Demod->demod_Term = NULL;
Demod->demod_Open = NULL;
Demod->demod_Close = NULL;
Demod->demod_IsAnalogCarrier = NULL;
Demod->demod_GetSignalQuality = NULL;
Demod->demod_GetModulation = NULL;
Demod->demod_GetAGC = NULL;
Demod->demod_GetFECRates = NULL;
Demod->demod_IsLocked = NULL;
Demod->demod_SetFECRates = NULL;
Demod->demod_Tracking = NULL;
Demod->demod_ScanFrequency = NULL;
Demod->demod_ioaccess = NULL;
Demod->demod_ioctl = NULL;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_D0297
STTBX_Print(("<"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -