gr-baz Package
rtl2832-tuner_r820t.h
Go to the documentation of this file.
00001 #ifndef __TUNER_R820T_H
00002 #define __TUNER_R820T_H
00003 
00004 #include "rtl2832.h"
00005 
00006 ////////////////////////////////////////
00007 
00008 #ifndef _UINT_X_
00009 #define _UINT_X_ 1
00010 typedef unsigned char  UINT8;
00011 typedef unsigned short UINT16;
00012 typedef unsigned int   UINT32;
00013 #endif
00014 
00015 #define TRUE    1
00016 #define FALSE   0
00017 
00018 typedef enum _R828_ErrCode
00019 {
00020         RT_Success,
00021         RT_Fail
00022 }R828_ErrCode;
00023 
00024 //----------------------------------------------------------//
00025 //                   R828 Parameter                        //
00026 //----------------------------------------------------------//
00027 
00028 typedef enum _R828_Standard_Type  //Don't remove standand list!!
00029 {
00030         NTSC_MN = 0,
00031         PAL_I,
00032         PAL_DK,
00033         PAL_B_7M,       //no use
00034         PAL_BGH_8M,     //for PAL B/G, PAL G/H
00035         SECAM_L,
00036         SECAM_L1_INV,   //for SECAM L'
00037         SECAM_L1,       //no use
00038         ATV_SIZE,
00039         DVB_T_6M = ATV_SIZE,
00040         DVB_T_7M,
00041         DVB_T_7M_2,
00042         DVB_T_8M,
00043         DVB_T2_6M,
00044         DVB_T2_7M,
00045         DVB_T2_7M_2,
00046         DVB_T2_8M,
00047         DVB_T2_1_7M,
00048         DVB_T2_10M,
00049         DVB_C_8M,
00050         DVB_C_6M,
00051         ISDB_T,
00052         DTMB,
00053         R828_ATSC,
00054         FM,
00055         STD_SIZE
00056 }R828_Standard_Type;
00057 
00058 typedef enum _R828_SetFreq_Type
00059 {
00060         FAST_MODE = TRUE,
00061         NORMAL_MODE = FALSE
00062 }R828_SetFreq_Type;
00063 
00064 typedef enum _R828_LoopThrough_Type
00065 {
00066         LOOP_THROUGH = TRUE,
00067         SIGLE_IN     = FALSE
00068 }R828_LoopThrough_Type;
00069 
00070 typedef enum _R828_InputMode_Type
00071 {
00072         AIR_IN = 0,
00073         CABLE_IN_1,
00074         CABLE_IN_2
00075 }R828_InputMode_Type;
00076 
00077 typedef enum _R828_IfAgc_Type
00078 {
00079         IF_AGC1 = 0,
00080         IF_AGC2
00081 }R828_IfAgc_Type;
00082 
00083 typedef enum _R828_GPIO_Type
00084 {
00085         HI_SIG = TRUE,
00086         LO_SIG = FALSE
00087 }R828_GPIO_Type;
00088 
00089 typedef struct _R828_Set_Info
00090 {
00091         UINT32        RF_Hz;
00092         UINT32        RF_KHz;
00093         R828_Standard_Type R828_Standard;
00094         R828_LoopThrough_Type RT_Input;
00095         R828_InputMode_Type   RT_InputMode;
00096         R828_IfAgc_Type R828_IfAgc_Select;
00097 }R828_Set_Info;
00098 
00099 typedef struct _R828_RF_Gain_Info
00100 {
00101         UINT8   RF_gain1;
00102         UINT8   RF_gain2;
00103         UINT8   RF_gain_comb;
00104 }R828_RF_Gain_Info;
00105 
00106 typedef enum _R828_RF_Gain_TYPE
00107 {
00108         RF_AUTO = 0,
00109         RF_MANUAL
00110 }R828_RF_Gain_TYPE;
00111 
00112 typedef struct _R828_I2C_LEN_TYPE
00113 {
00114         UINT8 RegAddr;
00115         UINT8 Data[50];
00116         UINT8 Len;
00117 }R828_I2C_LEN_TYPE;
00118 
00119 typedef struct _R828_I2C_TYPE
00120 {
00121         UINT8 RegAddr;
00122         UINT8 Data;
00123 }R828_I2C_TYPE;
00124 
00125 typedef struct _R828_SectType
00126 {
00127         UINT8 Phase_Y;
00128         UINT8 Gain_X;
00129         UINT16 Value;
00130 }R828_SectType;
00131 
00132 typedef enum _BW_Type
00133 {
00134         BW_6M = 0,
00135         BW_7M,
00136         BW_8M,
00137         BW_1_7M,
00138         BW_10M,
00139         BW_200K
00140 }BW_Type;
00141 
00142 typedef struct _Sys_Info_Type
00143 {
00144         UINT16          IF_KHz;
00145         BW_Type         BW;
00146         UINT32          FILT_CAL_LO;
00147         UINT8           FILT_GAIN;
00148         UINT8           IMG_R;
00149         UINT8           FILT_Q;
00150         UINT8           HP_COR;
00151         UINT8       EXT_ENABLE;
00152         UINT8       LOOP_THROUGH;
00153         UINT8       LT_ATT;
00154         UINT8       FLT_EXT_WIDEST;
00155         UINT8       POLYFIL_CUR;
00156 }Sys_Info_Type;
00157 
00158 typedef struct _Freq_Info_Type
00159 {
00160         UINT8           OPEN_D;
00161         UINT8           RF_MUX_PLOY;
00162         UINT8           TF_C;
00163         UINT8           XTAL_CAP20P;
00164         UINT8           XTAL_CAP10P;
00165         UINT8           XTAL_CAP0P;
00166         UINT8           IMR_MEM;
00167 }Freq_Info_Type;
00168 
00169 typedef struct _SysFreq_Info_Type
00170 {
00171         UINT8           LNA_TOP;
00172         UINT8           LNA_VTH_L;
00173         UINT8           MIXER_TOP;
00174         UINT8           MIXER_VTH_L;
00175         UINT8      AIR_CABLE1_IN;
00176         UINT8      CABLE2_IN;
00177         UINT8           PRE_DECT;
00178         UINT8      LNA_DISCHARGE;
00179         UINT8      CP_CUR;
00180         UINT8      DIV_BUF_CUR;
00181         UINT8      FILTER_CUR;
00182 }SysFreq_Info_Type;
00183 
00184 ////////////////////////////////////////
00185 
00186 namespace RTL2832_NAMESPACE { namespace TUNERS_NAMESPACE
00187 {
00188 class r820t : public RTL2832_NAMESPACE::tuner_skeleton
00189 {
00190 IMPLEMENT_INLINE_TUNER_FACTORY(r820t)
00191 public:
00192         //UINT8  R828_ADDRESS;
00193         UINT32 R828_IF_khz;
00194         UINT32 R828_CAL_LO_khz;
00195         UINT8  R828_IMR_point_num;
00196         UINT8  R828_IMR_done_flag;
00197         //UINT8  Rafael_Chip;
00198         UINT8 R828_Arry[27];
00199 public:
00200         R828_SectType IMR_Data[5];
00201         R828_I2C_TYPE R828_I2C;
00202         R828_I2C_LEN_TYPE R828_I2C_Len;
00203         UINT8  R828_Fil_Cal_flag[STD_SIZE];
00204         UINT8 R828_Fil_Cal_code[STD_SIZE];
00205         UINT8 Xtal_cap_sel;
00206         UINT8 Xtal_cap_sel_tmp;
00207         SysFreq_Info_Type SysFreq_Info1;
00208         Sys_Info_Type Sys_Info1;
00209         //static Freq_Info_Type R828_Freq_Info;
00210         Freq_Info_Type Freq_Info1;
00211 public:
00212         r820t(demod* p);
00213 public:
00214         inline virtual const char* name() const
00215         { return "Rafael Micro R820T"; }
00216 public:
00217         int initialise(tuner::PPARAMS params = NULL);
00218         int set_frequency(double freq);
00219         int set_bandwidth(double bw);
00220         int set_gain(double gain);
00221 };
00222 
00223 } }
00224 
00225 //----------------------------------------------------------//
00226 //                   R828 Functions                         //
00227 //----------------------------------------------------------//
00228 
00229 R828_ErrCode R828_Init(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner);
00230 R828_ErrCode R828_Standby(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, R828_LoopThrough_Type R828_LoopSwitch);
00231 R828_ErrCode R828_GPIO(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, R828_GPIO_Type R828_GPIO_Conrl);
00232 R828_ErrCode R828_SetStandard(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, R828_Standard_Type RT_Standard);
00233 R828_ErrCode R828_SetFrequency(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, R828_Set_Info R828_INFO, R828_SetFreq_Type R828_SetFreqMode);
00234 R828_ErrCode R828_GetRfGain(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, R828_RF_Gain_Info *pR828_rf_gain);
00235 R828_ErrCode R828_SetRfGain(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, int gain);
00236 R828_ErrCode R828_RfGainMode(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, int manual);
00237 int r820t_SetRfFreqHz(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, unsigned long RfFreqHz);
00238 int r820t_SetStandardMode(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, int StandardMode);
00239 int r820t_SetStandby(RTL2832_NAMESPACE::TUNERS_NAMESPACE::r820t* pTuner, int LoopThroughType);
00240 
00241 #endif /* __TUNER_R820T_H */