Forked from git://github.com/merbanan/rtl_433.git
[rtl-433.git] / include / tuner_r820t.h
1 #ifndef _R820T_TUNER_H
2 #define _R820T_TUNER_H
3
4 #define R820T_I2C_ADDR          0x34
5 #define R820T_CHECK_ADDR        0x00
6 #define R820T_CHECK_VAL         0x69
7
8 #define R820T_IF_FREQ           3570000
9
10 //***************************************************************
11 //*                       INCLUDES.H
12 //***************************************************************
13 #define VERSION   "R820T_v1.49_ASTRO"
14 #define VER_NUM  49
15
16 #define USE_16M_XTAL            FALSE
17 #define R828_Xtal               28800
18
19 #define USE_DIPLEXER            FALSE
20 #define TUNER_CLK_OUT           TRUE
21
22 #ifndef _UINT_X_
23 #define _UINT_X_ 1
24 typedef unsigned char  UINT8;
25 typedef unsigned short UINT16;
26 typedef unsigned int   UINT32;
27 #endif
28
29 #define TRUE    1
30 #define FALSE   0
31
32 #define FUNCTION_SUCCESS        0
33 #define FUNCTION_ERROR          -1
34
35 typedef enum _R828_ErrCode
36 {
37         RT_Success,
38         RT_Fail
39 }R828_ErrCode;
40
41 typedef enum _Rafael_Chip_Type  //Don't modify chip list
42 {
43         R828 = 0,
44         R828D,
45         R828S,
46         R820T,
47         R820C,
48         R620D,
49         R620S
50 }Rafael_Chip_Type;
51 //----------------------------------------------------------//
52 //                   R828 Parameter                        //
53 //----------------------------------------------------------//
54
55 extern UINT8 R828_ADDRESS;
56
57 #define DIP_FREQ          320000
58 #define IMR_TRIAL    9
59 #define VCO_pwr_ref   0x02
60
61 extern UINT32 R828_IF_khz;
62 extern UINT32 R828_CAL_LO_khz;
63 extern UINT8  R828_IMR_point_num;
64 extern UINT8  R828_IMR_done_flag;
65 extern UINT8  Rafael_Chip;
66
67 typedef enum _R828_Standard_Type  //Don't remove standand list!!
68 {
69         NTSC_MN = 0,
70         PAL_I,
71         PAL_DK,
72         PAL_B_7M,       //no use
73         PAL_BGH_8M,     //for PAL B/G, PAL G/H
74         SECAM_L,
75         SECAM_L1_INV,   //for SECAM L'
76         SECAM_L1,       //no use
77         ATV_SIZE,
78         DVB_T_6M = ATV_SIZE,
79         DVB_T_7M,
80         DVB_T_7M_2,
81         DVB_T_8M,
82         DVB_T2_6M,
83         DVB_T2_7M,
84         DVB_T2_7M_2,
85         DVB_T2_8M,
86         DVB_T2_1_7M,
87         DVB_T2_10M,
88         DVB_C_8M,
89         DVB_C_6M,
90         ISDB_T,
91         DTMB,
92         R828_ATSC,
93         FM,
94         STD_SIZE
95 }R828_Standard_Type;
96
97 extern UINT8  R828_Fil_Cal_flag[STD_SIZE];
98
99 typedef enum _R828_SetFreq_Type
100 {
101         FAST_MODE = TRUE,
102         NORMAL_MODE = FALSE
103 }R828_SetFreq_Type;
104
105 typedef enum _R828_LoopThrough_Type
106 {
107         LOOP_THROUGH = TRUE,
108         SIGLE_IN     = FALSE
109 }R828_LoopThrough_Type;
110
111
112 typedef enum _R828_InputMode_Type
113 {
114         AIR_IN = 0,
115         CABLE_IN_1,
116         CABLE_IN_2
117 }R828_InputMode_Type;
118
119 typedef enum _R828_IfAgc_Type
120 {
121         IF_AGC1 = 0,
122         IF_AGC2
123 }R828_IfAgc_Type;
124
125 typedef enum _R828_GPIO_Type
126 {
127         HI_SIG = TRUE,
128         LO_SIG = FALSE
129 }R828_GPIO_Type;
130
131 typedef struct _R828_Set_Info
132 {
133         UINT32        RF_Hz;
134         UINT32        RF_KHz;
135         R828_Standard_Type R828_Standard;
136         R828_LoopThrough_Type RT_Input;
137         R828_InputMode_Type   RT_InputMode;
138         R828_IfAgc_Type R828_IfAgc_Select; 
139 }R828_Set_Info;
140
141 typedef struct _R828_RF_Gain_Info
142 {
143         UINT8   RF_gain1;
144         UINT8   RF_gain2;
145         UINT8   RF_gain_comb;
146 }R828_RF_Gain_Info;
147
148 typedef enum _R828_RF_Gain_TYPE
149 {
150         RF_AUTO = 0,
151         RF_MANUAL
152 }R828_RF_Gain_TYPE;
153
154 typedef struct _R828_I2C_LEN_TYPE
155 {
156         UINT8 RegAddr;
157         UINT8 Data[50];
158         UINT8 Len;
159 }R828_I2C_LEN_TYPE;
160
161 typedef struct _R828_I2C_TYPE
162 {
163         UINT8 RegAddr;
164         UINT8 Data;
165 }R828_I2C_TYPE;
166 //----------------------------------------------------------//
167 //                   R828 Function                         //
168 //----------------------------------------------------------//
169 R828_ErrCode R828_Init(void *pTuner);
170 R828_ErrCode R828_Standby(void *pTuner, R828_LoopThrough_Type R828_LoopSwitch);
171 R828_ErrCode R828_GPIO(void *pTuner, R828_GPIO_Type R828_GPIO_Conrl);
172 R828_ErrCode R828_SetStandard(void *pTuner, R828_Standard_Type RT_Standard);
173 R828_ErrCode R828_SetFrequency(void *pTuner, R828_Set_Info R828_INFO, R828_SetFreq_Type R828_SetFreqMode);
174 R828_ErrCode R828_GetRfGain(void *pTuner, R828_RF_Gain_Info *pR828_rf_gain);
175 R828_ErrCode R828_SetRfGain(void *pTuner, int gain);
176 R828_ErrCode R828_RfGainMode(void *pTuner, int manual);
177
178 int
179 r820t_SetRfFreqHz(
180         void *pTuner,
181         unsigned long RfFreqHz
182         );
183
184 int
185 r820t_SetStandardMode(
186         void *pTuner,
187         int StandardMode
188         );
189
190 int
191 r820t_SetStandby(
192         void *pTuner,
193         int LoopThroughType
194         );
195
196 #endif /* _R820T_TUNER_H */