⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lnb299.c

📁 这是DVB tuner驱动部分和其它相关的源码和一些技术资料文档.
💻 C
字号:
/*****************************************************************************File Name   : lnb299.c.cDescription : ST LNBP implementation of the SAT API for STV0299.Copyright (C) 1999 STMicroelectronicsReference   :ST API Definition "TUNER Driver API" DVD-API-06*****************************************************************************/#define SAT_PROTOTYPE static            /* Local pre-include defs *//* 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 "sat.h"                        /* SAT Device API */#include "stv299.h"#include "reg0299.h"#include "driv0299.h"#include "demod.h"                      #include "tnr.h"                        /* Private types/constants ------------------------------------------------ */typedef struct{    SAT_MapTable_t          *MapTable_p;    /* Maptable */    ST_Partition_t          *MemoryPartition;    SAT_Config_t            Config;         /* SAT device configuration */    STV0299_ControlBlock_t  *Device;} SAT_ControlBlock_t;/* DEMOD control block */typedef struct{    DEMOD_MapTable_t        *MapTable_p;    /* Maptable */    ST_Partition_t          *MemoryPartition;    STV0299_ControlBlock_t  STV0299ControlBlock;} DEMOD_ControlBlock_t;/* Private variables ------------------------------------------------------ */extern SAT_MapTable_t __STV0299LNBMapTable;/* Private macros --------------------------------------------------------- */#define SAT_HANDLE(x)          ((SAT_ControlBlock_t *)x)#define STV0299_HANDLE(x)      (((SAT_ControlBlock_t *)x)->Device)/* Extracts a 299 control block from a DEMOD handle */#define STV0299_HANDLE2(x)   (&((DEMOD_ControlBlock_t *)x)->STV0299ControlBlock)/* Private function prototypes -------------------------------------------- *//* API routines ----------------------------------------------------------- *//*****************************************************************************Name: SAT_Init()Description:    Initializes the SAT device for the ST LNBP.Parameters:    InitParams_p,   pointer to the initialization parameters.Return Value:    SAT_NO_ERROR,               the operation completed without error.    SAT_ERROR_BAD_PARAMETER,    one or more parameters were invalid.    SAT_ERROR_LNB_HW,           a hardware error in the LNB circuit.See Also:    SAT_Term()*****************************************************************************/static SAT_ErrorCode_t SAT_Init(SAT_InitParams_t *InitParams_p,                                SAT_Handle_t *Handle_p,                                SAT_Capability_t *Capability_p){    SAT_ErrorCode_t Error = SAT_NO_ERROR;    SAT_ControlBlock_t *Sat_p;    /* Allocate control block memory */    Sat_p = memory_allocate(InitParams_p->MemoryPartition,                            sizeof(SAT_ControlBlock_t));    /* Ensure allocation succeeded */    if (Sat_p == NULL)        return ST_ERROR_NO_MEMORY;    /* Set map table information */    Sat_p->MapTable_p = &__STV0299LNBMapTable;    Sat_p->MemoryPartition = InitParams_p->MemoryPartition;    /* Set capabilities of the LNBP */    Capability_p->LNBShortCircuitDetect = TRUE;    Capability_p->LNBPowerAvailable = TRUE;    Capability_p->PolarizationSelect = SAT_PLR_ALL;    /* Set latest LNBP configuration */    Sat_p->Config.LNBStatus = SAT_LNB_ON;    Sat_p->Config.ToneState = SAT_TONE_OFF;    /* Initialize STV0299 hardware */    STV0299_HANDLE(Sat_p) = STV0299_HANDLE2(InitParams_p->DemodHandle_p);        SetLnb(STV0299_HANDLE(Sat_p), 0);   /* LNB tone off */    /* Allocate the handle */    *Handle_p = Sat_p;    /* Check to ensure there is no problem with the LNB circuit */    if (Error == ST_NO_ERROR && Sat_p->Config.LNBStatus == SAT_LNB_SHORT_CIRCUIT)        Error = SAT_ERROR_LNB_HW;    /* Ensure device communications is working */    if (Error != ST_NO_ERROR)    {        /* Deallocate control block */        memory_deallocate(InitParams_p->MemoryPartition,                          Sat_p);    }    return Error;} /* SAT_Init() *//*****************************************************************************Name: SAT_Term()Description:    Performs any required tidying up in order to cleanly terminate the    SAT device.Parameters:    Sat_p,          pointer to the SAT device.Return Value:    SAT_NO_ERROR,   the operation completed without error.See Also:    SAT_Init()*****************************************************************************/static SAT_ErrorCode_t SAT_Term(SAT_Handle_t Handle){    memory_deallocate(SAT_HANDLE(Handle)->MemoryPartition,                      Handle);    return ST_NO_ERROR;} /* SAT_Term() *//*****************************************************************************Name: SAT_GetConfig()Description:    Obtains the current SAT device configuration and stores it in the    configuration structure for the SAT device.Parameters:    Sat_p,          pointer to the SAT device.    SatConfig_p,    pointer to area to store current SAT config.Return Value:    SAT_NO_ERROR,   the operation completed without error.    STI2C_xxxx,     there was a problem accessing the device.See Also:    SAT_SetConfig()*****************************************************************************/static SAT_ErrorCode_t SAT_GetConfig(SAT_Handle_t Handle,                                     SAT_Config_t *SatConfig_p){        SAT_ErrorCode_t Error = SAT_NO_ERROR;        if((Handle == NULL) || (SatConfig_p == NULL))    {        Error = SAT_ERROR_BAD_PARAMETER;    }    else    {        SatConfig_p -> LNBStatus = SAT_HANDLE(Handle)->Config.LNBStatus;        SatConfig_p -> Polarization = SAT_HANDLE(Handle)->Config.Polarization ;        SatConfig_p -> ToneState = SAT_HANDLE(Handle)->Config.ToneState;    }        return Error;} /* SAT_GetConfig() *//*****************************************************************************Name: SAT_SetConfig()Description:    Configures the SAT device's power/tone/polarization.Parameters:    Sat_p, pointer to the SAT device.    Config_p, pointer to the new device configuration.Return Value:    SAT_NO_ERROR,               the operation completed successfully.    SAT_ERROR_BAD_PARAMETER,    one of the parametes was invalid.    STI2C_xxxx,                 there was a problem accessing the device.See Also:    SAT_GetConfig()*****************************************************************************/static SAT_ErrorCode_t SAT_SetConfig(SAT_Handle_t Handle,                                     SAT_Config_t *Config_p){    SAT_ErrorCode_t Error = SAT_NO_ERROR;    /* Check power setting is valid */    if ((Config_p->LNBStatus == SAT_LNB_ON || /* Valid LNB */         Config_p->LNBStatus == SAT_LNB_OFF) &&        (Config_p->Polarization == SAT_PLR_HORIZONTAL || /* Valid PLR */         Config_p->Polarization == SAT_PLR_VERTICAL) &&        (Config_p->ToneState >= SAT_TONE_DEFAULT &&         Config_p->ToneState <= SAT_TONE_22KHZ)) /* Valid TONE */    {        /* Check the new settings differ from the old ones -- this         * can save time.         */        if (SAT_HANDLE(Handle)->Config.LNBStatus != Config_p->LNBStatus ||            SAT_HANDLE(Handle)->Config.Polarization != Config_p->Polarization ||            SAT_HANDLE(Handle)->Config.ToneState != Config_p->ToneState)        {            /* Select LNB band */            switch (Config_p->ToneState)            {                case SAT_TONE_OFF:      /* No tone */                    SetLnb(STV0299_HANDLE(Handle), 0);                    SAT_HANDLE(Handle)->Config.ToneState = SAT_TONE_OFF;                    break;                case SAT_TONE_22KHZ:  /* 22KHz tone */                    SetLnb(STV0299_HANDLE(Handle), 1);                    SAT_HANDLE(Handle)->Config.ToneState = SAT_TONE_22KHZ;                    break;                default:                    break;            }            /* Select polarization */            switch (Config_p->Polarization)            {                case SAT_PLR_VERTICAL: /* OP_2 controls -- 18V (high) */                    SetPolarization(STV0299_HANDLE(Handle), VERTICAL);                    SAT_HANDLE(Handle)->Config.Polarization = SAT_PLR_VERTICAL;                    break;                case SAT_PLR_HORIZONTAL:  /* OP_2 controls -- 13V (low) */                    SetPolarization(STV0299_HANDLE(Handle), HORIZONTAL);                    SAT_HANDLE(Handle)->Config.Polarization = SAT_PLR_HORIZONTAL;                    break;                default:                    break;            }        }    }    else    {        /* One or more parameters are invalid */        Error = SAT_ERROR_BAD_PARAMETER;    }    return Error;} /* SAT_SetConfig() *//* Exported Map Table ------------------------------------------------------------ */SAT_MapTable_t __STV0299LNBMapTable ={    SAT_Init,    SAT_Term,    SAT_GetConfig,    SAT_SetConfig};/* End of lnb299.c.c */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -