OSDN Git Service

rtl8723au: Remove some trailing white space
[android-x86/external-modules-rtl8723au.git] / hal / HalHWImg8723A_RF.c
1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 *
19 ******************************************************************************/
20
21 #include "odm_precomp.h"
22
23 #if (RTL8723A_SUPPORT == 1)
24 static bool
25 CheckCondition(
26     const u4Byte  Condition,
27     const u4Byte  Hex
28     )
29 {
30     u4Byte _board     = (Hex & 0x000000FF);
31     u4Byte _interface = (Hex & 0x0000FF00) >> 8;
32     u4Byte _platform  = (Hex & 0x00FF0000) >> 16;
33     u4Byte cond = Condition;
34
35     if ( Condition == 0xCDCDCDCD )
36         return TRUE;
37
38     cond = Condition & 0x000000FF;
39     if ( (_board == cond) && cond != 0x00)
40         return FALSE;
41
42     cond = Condition & 0x0000FF00;
43     cond = cond >> 8;
44     if ( (_interface & cond) == 0 && cond != 0x07)
45         return FALSE;
46
47     cond = Condition & 0x00FF0000;
48     cond = cond >> 16;
49     if ( (_platform & cond) == 0 && cond != 0x0F)
50         return FALSE;
51     return TRUE;
52 }
53
54
55 /******************************************************************************
56 *                           RadioA_1T.TXT
57 ******************************************************************************/
58
59 u4Byte Array_RadioA_1T_8723A[] = {
60                 0x000, 0x00030159,
61                 0x001, 0x00031284,
62                 0x002, 0x00098000,
63         0xFF0F011F, 0xABCD,
64                 0x003, 0x00018C63,
65         0xCDCDCDCD, 0xCDCD,
66                 0x003, 0x00039C63,
67         0xFF0F011F, 0xDEAD,
68                 0x004, 0x000210E7,
69                 0x009, 0x0002044F,
70                 0x00A, 0x0001A3F1,
71                 0x00B, 0x00014787,
72                 0x00C, 0x000896FE,
73                 0x00D, 0x0000E02C,
74                 0x00E, 0x00039CE7,
75                 0x00F, 0x00000451,
76                 0x019, 0x00000000,
77                 0x01A, 0x00030355,
78                 0x01B, 0x00060A00,
79                 0x01C, 0x000FC378,
80                 0x01D, 0x000A1250,
81                 0x01E, 0x0000024F,
82                 0x01F, 0x00000000,
83                 0x020, 0x0000B614,
84                 0x021, 0x0006C000,
85                 0x022, 0x00000000,
86                 0x023, 0x00001558,
87                 0x024, 0x00000060,
88                 0x025, 0x00000483,
89                 0x026, 0x0004F000,
90                 0x027, 0x000EC7D9,
91                 0x028, 0x00057730,
92                 0x029, 0x00004783,
93                 0x02A, 0x00000001,
94                 0x02B, 0x00021334,
95                 0x02A, 0x00000000,
96                 0x02B, 0x00000054,
97                 0x02A, 0x00000001,
98                 0x02B, 0x00000808,
99                 0x02B, 0x00053333,
100                 0x02C, 0x0000000C,
101                 0x02A, 0x00000002,
102                 0x02B, 0x00000808,
103                 0x02B, 0x0005B333,
104                 0x02C, 0x0000000D,
105                 0x02A, 0x00000003,
106                 0x02B, 0x00000808,
107                 0x02B, 0x00063333,
108                 0x02C, 0x0000000D,
109                 0x02A, 0x00000004,
110                 0x02B, 0x00000808,
111                 0x02B, 0x0006B333,
112                 0x02C, 0x0000000D,
113                 0x02A, 0x00000005,
114                 0x02B, 0x00000808,
115                 0x02B, 0x00073333,
116                 0x02C, 0x0000000D,
117                 0x02A, 0x00000006,
118                 0x02B, 0x00000709,
119                 0x02B, 0x0005B333,
120                 0x02C, 0x0000000D,
121                 0x02A, 0x00000007,
122                 0x02B, 0x00000709,
123                 0x02B, 0x00063333,
124                 0x02C, 0x0000000D,
125                 0x02A, 0x00000008,
126                 0x02B, 0x0000060A,
127                 0x02B, 0x0004B333,
128                 0x02C, 0x0000000D,
129                 0x02A, 0x00000009,
130                 0x02B, 0x0000060A,
131                 0x02B, 0x00053333,
132                 0x02C, 0x0000000D,
133                 0x02A, 0x0000000A,
134                 0x02B, 0x0000060A,
135                 0x02B, 0x0005B333,
136                 0x02C, 0x0000000D,
137                 0x02A, 0x0000000B,
138                 0x02B, 0x0000060A,
139                 0x02B, 0x00063333,
140                 0x02C, 0x0000000D,
141                 0x02A, 0x0000000C,
142                 0x02B, 0x0000060A,
143                 0x02B, 0x0006B333,
144                 0x02C, 0x0000000D,
145                 0x02A, 0x0000000D,
146                 0x02B, 0x0000060A,
147                 0x02B, 0x00073333,
148                 0x02C, 0x0000000D,
149                 0x02A, 0x0000000E,
150                 0x02B, 0x0000050B,
151                 0x02B, 0x00066666,
152                 0x02C, 0x0000001A,
153                 0x02A, 0x000E0000,
154                 0x010, 0x0004000F,
155                 0x011, 0x000E31FC,
156                 0x010, 0x0006000F,
157                 0x011, 0x000FF9F8,
158                 0x010, 0x0002000F,
159                 0x011, 0x000203F9,
160                 0x010, 0x0003000F,
161                 0x011, 0x000FF500,
162                 0x010, 0x00000000,
163                 0x011, 0x00000000,
164                 0x010, 0x0008000F,
165                 0x011, 0x0003F100,
166                 0x010, 0x0009000F,
167                 0x011, 0x00023100,
168                 0x012, 0x00032000,
169                 0x012, 0x00071000,
170                 0x012, 0x000B0000,
171                 0x012, 0x000FC000,
172                 0x013, 0x000287B3,
173                 0x013, 0x000244B7,
174                 0x013, 0x000204AB,
175                 0x013, 0x0001C49F,
176                 0x013, 0x00018493,
177                 0x013, 0x0001429B,
178                 0x013, 0x00010299,
179                 0x013, 0x0000C29C,
180                 0x013, 0x000081A0,
181                 0x013, 0x000040AC,
182                 0x013, 0x00000020,
183                 0x014, 0x0001944C,
184                 0x014, 0x00059444,
185                 0x014, 0x0009944C,
186                 0x014, 0x000D9444,
187         0xFF0F011F, 0xABCD,
188                 0x015, 0x0000F424,
189                 0x015, 0x0004F424,
190                 0x015, 0x0008F424,
191                 0x015, 0x000CF424,
192         0xCDCDCDCD, 0xCDCD,
193                 0x015, 0x0000F474,
194                 0x015, 0x0004F477,
195                 0x015, 0x0008F455,
196                 0x015, 0x000CF455,
197         0xFF0F011F, 0xDEAD,
198                 0x016, 0x00000339,
199                 0x016, 0x00040339,
200                 0x016, 0x00080339,
201         0xFF0F011F, 0xABCD,
202                 0x016, 0x000C0356,
203         0xCDCDCDCD, 0xCDCD,
204                 0x016, 0x000C0366,
205         0xFF0F011F, 0xDEAD,
206                 0x000, 0x00010159,
207                 0x018, 0x0000F401,
208                 0x0FE, 0x00000000,
209                 0x0FE, 0x00000000,
210                 0x01F, 0x00000003,
211                 0x0FE, 0x00000000,
212                 0x0FE, 0x00000000,
213                 0x01E, 0x00000247,
214                 0x01F, 0x00000000,
215                 0x000, 0x00030159,
216
217 };
218
219 void
220 ODM_ReadAndConfig_RadioA_1T_8723A(
221         IN   PDM_ODM_T  pDM_Odm
222         )
223 {
224         #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = Array[i]; v2 = Array[i+1]; } while(0)
225
226         u4Byte     hex         = 0;
227         u4Byte     i           = 0;
228         u2Byte     count       = 0;
229         pu4Byte    ptr_array   = NULL;
230         u1Byte     platform    = pDM_Odm->SupportPlatform;
231         u1Byte     interfaceValue   = pDM_Odm->SupportInterface;
232         u1Byte     board       = pDM_Odm->BoardType;
233         u4Byte     ArrayLen    = sizeof(Array_RadioA_1T_8723A)/sizeof(u4Byte);
234         pu4Byte    Array       = Array_RadioA_1T_8723A;
235
236
237         hex += board;
238         hex += interfaceValue << 8;
239         hex += platform << 16;
240         hex += 0xFF000000;
241
242         for (i = 0; i < ArrayLen; i += 2 )
243         {
244             u4Byte v1 = Array[i];
245             u4Byte v2 = Array[i+1];
246
247             // This (offset, data) pair meets the condition.
248             if ( v1 < 0xCDCDCDCD )
249             {
250                     odm_ConfigRF_RadioA_8723A(pDM_Odm, v1, v2);
251                     continue;
252                 }
253                 else
254                 { // This line is the start line of branch.
255                     if ( !CheckCondition(Array[i], hex) )
256                     { // Discard the following (offset, data) pairs.
257                         READ_NEXT_PAIR(v1, v2, i);
258                         while (v2 != 0xDEAD &&
259                                v2 != 0xCDEF &&
260                                v2 != 0xCDCD && i < ArrayLen -2)
261                         {
262                             READ_NEXT_PAIR(v1, v2, i);
263                         }
264                         i -= 2; // prevent from for-loop += 2
265                     }
266                     else // Configure matched pairs and skip to end of if-else.
267                     {
268                         READ_NEXT_PAIR(v1, v2, i);
269                         while (v2 != 0xDEAD &&
270                                v2 != 0xCDEF &&
271                                v2 != 0xCDCD && i < ArrayLen -2)
272                         {
273                                 odm_ConfigRF_RadioA_8723A(pDM_Odm, v1, v2);
274                                 READ_NEXT_PAIR(v1, v2, i);
275                         }
276
277                         while (v2 != 0xDEAD && i < ArrayLen -2)
278                         {
279                             READ_NEXT_PAIR(v1, v2, i);
280                         }
281
282                     }
283                 }
284         }
285
286 }
287
288
289 #endif // end of HWIMG_SUPPORT