xenbus_client.c: correct exit path for xenbus_map_ring_valloc_hvm
[linux/fpc-iii.git] / drivers / staging / vt6655 / baseband.c
blobc26418d806fb335851bb7a688ad1294094cc8a6d
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * File: baseband.c
22 * Purpose: Implement functions to access baseband
24 * Author: Kyle Hsu
26 * Date: Aug.22, 2002
28 * Functions:
29 * BBuGetFrameTime - Calculate data frame transmitting time
30 * BBvCaculateParameter - Caculate PhyLength, PhyService and Phy Signal parameter for baseband Tx
31 * BBbReadEmbedded - Embedded read baseband register via MAC
32 * BBbWriteEmbedded - Embedded write baseband register via MAC
33 * BBbIsRegBitsOn - Test if baseband register bits on
34 * BBbIsRegBitsOff - Test if baseband register bits off
35 * BBbVT3253Init - VIA VT3253 baseband chip init code
36 * BBvReadAllRegs - Read All Baseband Registers
37 * BBvLoopbackOn - Turn on BaseBand Loopback mode
38 * BBvLoopbackOff - Turn off BaseBand Loopback mode
40 * Revision History:
41 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
42 * 08-07-2003 Bryan YC Fan: Add MAXIM2827/2825 and RFMD2959 support.
43 * 08-26-2003 Kyle Hsu : Modify BBuGetFrameTime() and BBvCalculateParameter().
44 * cancel the setting of MAC_REG_SOFTPWRCTL on BBbVT3253Init().
45 * Add the comments.
46 * 09-01-2003 Bryan YC Fan: RF & BB tables updated.
47 * Modified BBvLoopbackOn & BBvLoopbackOff().
52 #include "tmacro.h"
53 #include "tether.h"
54 #include "mac.h"
55 #include "baseband.h"
56 #include "srom.h"
57 #include "rf.h"
59 /*--------------------- Static Definitions -------------------------*/
60 //static int msglevel =MSG_LEVEL_DEBUG;
61 static int msglevel = MSG_LEVEL_INFO;
63 /*--------------------- Static Classes ----------------------------*/
65 /*--------------------- Static Variables --------------------------*/
67 /*--------------------- Static Functions --------------------------*/
69 /*--------------------- Export Variables --------------------------*/
71 /*--------------------- Static Definitions -------------------------*/
73 /*--------------------- Static Classes ----------------------------*/
75 /*--------------------- Static Variables --------------------------*/
77 #define CB_VT3253_INIT_FOR_RFMD 446
78 unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
79 {0x00, 0x30},
80 {0x01, 0x00},
81 {0x02, 0x00},
82 {0x03, 0x00},
83 {0x04, 0x00},
84 {0x05, 0x00},
85 {0x06, 0x00},
86 {0x07, 0x00},
87 {0x08, 0x70},
88 {0x09, 0x45},
89 {0x0a, 0x2a},
90 {0x0b, 0x76},
91 {0x0c, 0x00},
92 {0x0d, 0x01},
93 {0x0e, 0x80},
94 {0x0f, 0x00},
95 {0x10, 0x00},
96 {0x11, 0x00},
97 {0x12, 0x00},
98 {0x13, 0x00},
99 {0x14, 0x00},
100 {0x15, 0x00},
101 {0x16, 0x00},
102 {0x17, 0x00},
103 {0x18, 0x00},
104 {0x19, 0x00},
105 {0x1a, 0x00},
106 {0x1b, 0x9d},
107 {0x1c, 0x05},
108 {0x1d, 0x00},
109 {0x1e, 0x00},
110 {0x1f, 0x00},
111 {0x20, 0x00},
112 {0x21, 0x00},
113 {0x22, 0x00},
114 {0x23, 0x00},
115 {0x24, 0x00},
116 {0x25, 0x4a},
117 {0x26, 0x00},
118 {0x27, 0x00},
119 {0x28, 0x00},
120 {0x29, 0x00},
121 {0x2a, 0x00},
122 {0x2b, 0x00},
123 {0x2c, 0x00},
124 {0x2d, 0xa8},
125 {0x2e, 0x1a},
126 {0x2f, 0x0c},
127 {0x30, 0x26},
128 {0x31, 0x5b},
129 {0x32, 0x00},
130 {0x33, 0x00},
131 {0x34, 0x00},
132 {0x35, 0x00},
133 {0x36, 0xaa},
134 {0x37, 0xaa},
135 {0x38, 0xff},
136 {0x39, 0xff},
137 {0x3a, 0x00},
138 {0x3b, 0x00},
139 {0x3c, 0x00},
140 {0x3d, 0x0d},
141 {0x3e, 0x51},
142 {0x3f, 0x04},
143 {0x40, 0x00},
144 {0x41, 0x08},
145 {0x42, 0x00},
146 {0x43, 0x08},
147 {0x44, 0x06},
148 {0x45, 0x14},
149 {0x46, 0x05},
150 {0x47, 0x08},
151 {0x48, 0x00},
152 {0x49, 0x00},
153 {0x4a, 0x00},
154 {0x4b, 0x00},
155 {0x4c, 0x09},
156 {0x4d, 0x80},
157 {0x4e, 0x00},
158 {0x4f, 0xc5},
159 {0x50, 0x14},
160 {0x51, 0x19},
161 {0x52, 0x00},
162 {0x53, 0x00},
163 {0x54, 0x00},
164 {0x55, 0x00},
165 {0x56, 0x00},
166 {0x57, 0x00},
167 {0x58, 0x00},
168 {0x59, 0xb0},
169 {0x5a, 0x00},
170 {0x5b, 0x00},
171 {0x5c, 0x00},
172 {0x5d, 0x00},
173 {0x5e, 0x00},
174 {0x5f, 0x00},
175 {0x60, 0x44},
176 {0x61, 0x04},
177 {0x62, 0x00},
178 {0x63, 0x00},
179 {0x64, 0x00},
180 {0x65, 0x00},
181 {0x66, 0x04},
182 {0x67, 0xb7},
183 {0x68, 0x00},
184 {0x69, 0x00},
185 {0x6a, 0x00},
186 {0x6b, 0x00},
187 {0x6c, 0x00},
188 {0x6d, 0x03},
189 {0x6e, 0x01},
190 {0x6f, 0x00},
191 {0x70, 0x00},
192 {0x71, 0x00},
193 {0x72, 0x00},
194 {0x73, 0x00},
195 {0x74, 0x00},
196 {0x75, 0x00},
197 {0x76, 0x00},
198 {0x77, 0x00},
199 {0x78, 0x00},
200 {0x79, 0x00},
201 {0x7a, 0x00},
202 {0x7b, 0x00},
203 {0x7c, 0x00},
204 {0x7d, 0x00},
205 {0x7e, 0x00},
206 {0x7f, 0x00},
207 {0x80, 0x0b},
208 {0x81, 0x00},
209 {0x82, 0x3c},
210 {0x83, 0x00},
211 {0x84, 0x00},
212 {0x85, 0x00},
213 {0x86, 0x00},
214 {0x87, 0x00},
215 {0x88, 0x08},
216 {0x89, 0x00},
217 {0x8a, 0x08},
218 {0x8b, 0xa6},
219 {0x8c, 0x84},
220 {0x8d, 0x47},
221 {0x8e, 0xbb},
222 {0x8f, 0x02},
223 {0x90, 0x21},
224 {0x91, 0x0c},
225 {0x92, 0x04},
226 {0x93, 0x22},
227 {0x94, 0x00},
228 {0x95, 0x00},
229 {0x96, 0x00},
230 {0x97, 0xeb},
231 {0x98, 0x00},
232 {0x99, 0x00},
233 {0x9a, 0x00},
234 {0x9b, 0x00},
235 {0x9c, 0x00},
236 {0x9d, 0x00},
237 {0x9e, 0x00},
238 {0x9f, 0x00},
239 {0xa0, 0x00},
240 {0xa1, 0x00},
241 {0xa2, 0x00},
242 {0xa3, 0x00},
243 {0xa4, 0x00},
244 {0xa5, 0x00},
245 {0xa6, 0x10},
246 {0xa7, 0x04},
247 {0xa8, 0x10},
248 {0xa9, 0x00},
249 {0xaa, 0x8f},
250 {0xab, 0x00},
251 {0xac, 0x00},
252 {0xad, 0x00},
253 {0xae, 0x00},
254 {0xaf, 0x80},
255 {0xb0, 0x38},
256 {0xb1, 0x00},
257 {0xb2, 0x00},
258 {0xb3, 0x00},
259 {0xb4, 0xee},
260 {0xb5, 0xff},
261 {0xb6, 0x10},
262 {0xb7, 0x00},
263 {0xb8, 0x00},
264 {0xb9, 0x00},
265 {0xba, 0x00},
266 {0xbb, 0x03},
267 {0xbc, 0x00},
268 {0xbd, 0x00},
269 {0xbe, 0x00},
270 {0xbf, 0x00},
271 {0xc0, 0x10},
272 {0xc1, 0x10},
273 {0xc2, 0x18},
274 {0xc3, 0x20},
275 {0xc4, 0x10},
276 {0xc5, 0x00},
277 {0xc6, 0x22},
278 {0xc7, 0x14},
279 {0xc8, 0x0f},
280 {0xc9, 0x08},
281 {0xca, 0xa4},
282 {0xcb, 0xa7},
283 {0xcc, 0x3c},
284 {0xcd, 0x10},
285 {0xce, 0x20},
286 {0xcf, 0x00},
287 {0xd0, 0x00},
288 {0xd1, 0x10},
289 {0xd2, 0x00},
290 {0xd3, 0x00},
291 {0xd4, 0x10},
292 {0xd5, 0x33},
293 {0xd6, 0x70},
294 {0xd7, 0x01},
295 {0xd8, 0x00},
296 {0xd9, 0x00},
297 {0xda, 0x00},
298 {0xdb, 0x00},
299 {0xdc, 0x00},
300 {0xdd, 0x00},
301 {0xde, 0x00},
302 {0xdf, 0x00},
303 {0xe0, 0x00},
304 {0xe1, 0x00},
305 {0xe2, 0xcc},
306 {0xe3, 0x04},
307 {0xe4, 0x08},
308 {0xe5, 0x10},
309 {0xe6, 0x00},
310 {0xe7, 0x0e},
311 {0xe8, 0x88},
312 {0xe9, 0xd4},
313 {0xea, 0x05},
314 {0xeb, 0xf0},
315 {0xec, 0x79},
316 {0xed, 0x0f},
317 {0xee, 0x04},
318 {0xef, 0x04},
319 {0xf0, 0x00},
320 {0xf1, 0x00},
321 {0xf2, 0x00},
322 {0xf3, 0x00},
323 {0xf4, 0x00},
324 {0xf5, 0x00},
325 {0xf6, 0x00},
326 {0xf7, 0x00},
327 {0xf8, 0x00},
328 {0xf9, 0x00},
329 {0xF0, 0x00},
330 {0xF1, 0xF8},
331 {0xF0, 0x80},
332 {0xF0, 0x00},
333 {0xF1, 0xF4},
334 {0xF0, 0x81},
335 {0xF0, 0x01},
336 {0xF1, 0xF0},
337 {0xF0, 0x82},
338 {0xF0, 0x02},
339 {0xF1, 0xEC},
340 {0xF0, 0x83},
341 {0xF0, 0x03},
342 {0xF1, 0xE8},
343 {0xF0, 0x84},
344 {0xF0, 0x04},
345 {0xF1, 0xE4},
346 {0xF0, 0x85},
347 {0xF0, 0x05},
348 {0xF1, 0xE0},
349 {0xF0, 0x86},
350 {0xF0, 0x06},
351 {0xF1, 0xDC},
352 {0xF0, 0x87},
353 {0xF0, 0x07},
354 {0xF1, 0xD8},
355 {0xF0, 0x88},
356 {0xF0, 0x08},
357 {0xF1, 0xD4},
358 {0xF0, 0x89},
359 {0xF0, 0x09},
360 {0xF1, 0xD0},
361 {0xF0, 0x8A},
362 {0xF0, 0x0A},
363 {0xF1, 0xCC},
364 {0xF0, 0x8B},
365 {0xF0, 0x0B},
366 {0xF1, 0xC8},
367 {0xF0, 0x8C},
368 {0xF0, 0x0C},
369 {0xF1, 0xC4},
370 {0xF0, 0x8D},
371 {0xF0, 0x0D},
372 {0xF1, 0xC0},
373 {0xF0, 0x8E},
374 {0xF0, 0x0E},
375 {0xF1, 0xBC},
376 {0xF0, 0x8F},
377 {0xF0, 0x0F},
378 {0xF1, 0xB8},
379 {0xF0, 0x90},
380 {0xF0, 0x10},
381 {0xF1, 0xB4},
382 {0xF0, 0x91},
383 {0xF0, 0x11},
384 {0xF1, 0xB0},
385 {0xF0, 0x92},
386 {0xF0, 0x12},
387 {0xF1, 0xAC},
388 {0xF0, 0x93},
389 {0xF0, 0x13},
390 {0xF1, 0xA8},
391 {0xF0, 0x94},
392 {0xF0, 0x14},
393 {0xF1, 0xA4},
394 {0xF0, 0x95},
395 {0xF0, 0x15},
396 {0xF1, 0xA0},
397 {0xF0, 0x96},
398 {0xF0, 0x16},
399 {0xF1, 0x9C},
400 {0xF0, 0x97},
401 {0xF0, 0x17},
402 {0xF1, 0x98},
403 {0xF0, 0x98},
404 {0xF0, 0x18},
405 {0xF1, 0x94},
406 {0xF0, 0x99},
407 {0xF0, 0x19},
408 {0xF1, 0x90},
409 {0xF0, 0x9A},
410 {0xF0, 0x1A},
411 {0xF1, 0x8C},
412 {0xF0, 0x9B},
413 {0xF0, 0x1B},
414 {0xF1, 0x88},
415 {0xF0, 0x9C},
416 {0xF0, 0x1C},
417 {0xF1, 0x84},
418 {0xF0, 0x9D},
419 {0xF0, 0x1D},
420 {0xF1, 0x80},
421 {0xF0, 0x9E},
422 {0xF0, 0x1E},
423 {0xF1, 0x7C},
424 {0xF0, 0x9F},
425 {0xF0, 0x1F},
426 {0xF1, 0x78},
427 {0xF0, 0xA0},
428 {0xF0, 0x20},
429 {0xF1, 0x74},
430 {0xF0, 0xA1},
431 {0xF0, 0x21},
432 {0xF1, 0x70},
433 {0xF0, 0xA2},
434 {0xF0, 0x22},
435 {0xF1, 0x6C},
436 {0xF0, 0xA3},
437 {0xF0, 0x23},
438 {0xF1, 0x68},
439 {0xF0, 0xA4},
440 {0xF0, 0x24},
441 {0xF1, 0x64},
442 {0xF0, 0xA5},
443 {0xF0, 0x25},
444 {0xF1, 0x60},
445 {0xF0, 0xA6},
446 {0xF0, 0x26},
447 {0xF1, 0x5C},
448 {0xF0, 0xA7},
449 {0xF0, 0x27},
450 {0xF1, 0x58},
451 {0xF0, 0xA8},
452 {0xF0, 0x28},
453 {0xF1, 0x54},
454 {0xF0, 0xA9},
455 {0xF0, 0x29},
456 {0xF1, 0x50},
457 {0xF0, 0xAA},
458 {0xF0, 0x2A},
459 {0xF1, 0x4C},
460 {0xF0, 0xAB},
461 {0xF0, 0x2B},
462 {0xF1, 0x48},
463 {0xF0, 0xAC},
464 {0xF0, 0x2C},
465 {0xF1, 0x44},
466 {0xF0, 0xAD},
467 {0xF0, 0x2D},
468 {0xF1, 0x40},
469 {0xF0, 0xAE},
470 {0xF0, 0x2E},
471 {0xF1, 0x3C},
472 {0xF0, 0xAF},
473 {0xF0, 0x2F},
474 {0xF1, 0x38},
475 {0xF0, 0xB0},
476 {0xF0, 0x30},
477 {0xF1, 0x34},
478 {0xF0, 0xB1},
479 {0xF0, 0x31},
480 {0xF1, 0x30},
481 {0xF0, 0xB2},
482 {0xF0, 0x32},
483 {0xF1, 0x2C},
484 {0xF0, 0xB3},
485 {0xF0, 0x33},
486 {0xF1, 0x28},
487 {0xF0, 0xB4},
488 {0xF0, 0x34},
489 {0xF1, 0x24},
490 {0xF0, 0xB5},
491 {0xF0, 0x35},
492 {0xF1, 0x20},
493 {0xF0, 0xB6},
494 {0xF0, 0x36},
495 {0xF1, 0x1C},
496 {0xF0, 0xB7},
497 {0xF0, 0x37},
498 {0xF1, 0x18},
499 {0xF0, 0xB8},
500 {0xF0, 0x38},
501 {0xF1, 0x14},
502 {0xF0, 0xB9},
503 {0xF0, 0x39},
504 {0xF1, 0x10},
505 {0xF0, 0xBA},
506 {0xF0, 0x3A},
507 {0xF1, 0x0C},
508 {0xF0, 0xBB},
509 {0xF0, 0x3B},
510 {0xF1, 0x08},
511 {0xF0, 0x00},
512 {0xF0, 0x3C},
513 {0xF1, 0x04},
514 {0xF0, 0xBD},
515 {0xF0, 0x3D},
516 {0xF1, 0x00},
517 {0xF0, 0xBE},
518 {0xF0, 0x3E},
519 {0xF1, 0x00},
520 {0xF0, 0xBF},
521 {0xF0, 0x3F},
522 {0xF1, 0x00},
523 {0xF0, 0xC0},
524 {0xF0, 0x00},
527 #define CB_VT3253B0_INIT_FOR_RFMD 256
528 unsigned char byVT3253B0_RFMD[CB_VT3253B0_INIT_FOR_RFMD][2] = {
529 {0x00, 0x31},
530 {0x01, 0x00},
531 {0x02, 0x00},
532 {0x03, 0x00},
533 {0x04, 0x00},
534 {0x05, 0x81},
535 {0x06, 0x00},
536 {0x07, 0x00},
537 {0x08, 0x38},
538 {0x09, 0x45},
539 {0x0a, 0x2a},
540 {0x0b, 0x76},
541 {0x0c, 0x00},
542 {0x0d, 0x00},
543 {0x0e, 0x80},
544 {0x0f, 0x00},
545 {0x10, 0x00},
546 {0x11, 0x00},
547 {0x12, 0x00},
548 {0x13, 0x00},
549 {0x14, 0x00},
550 {0x15, 0x00},
551 {0x16, 0x00},
552 {0x17, 0x00},
553 {0x18, 0x00},
554 {0x19, 0x00},
555 {0x1a, 0x00},
556 {0x1b, 0x8e},
557 {0x1c, 0x06},
558 {0x1d, 0x00},
559 {0x1e, 0x00},
560 {0x1f, 0x00},
561 {0x20, 0x00},
562 {0x21, 0x00},
563 {0x22, 0x00},
564 {0x23, 0x00},
565 {0x24, 0x00},
566 {0x25, 0x4a},
567 {0x26, 0x00},
568 {0x27, 0x00},
569 {0x28, 0x00},
570 {0x29, 0x00},
571 {0x2a, 0x00},
572 {0x2b, 0x00},
573 {0x2c, 0x00},
574 {0x2d, 0x34},
575 {0x2e, 0x18},
576 {0x2f, 0x0c},
577 {0x30, 0x26},
578 {0x31, 0x5b},
579 {0x32, 0x00},
580 {0x33, 0x00},
581 {0x34, 0x00},
582 {0x35, 0x00},
583 {0x36, 0xaa},
584 {0x37, 0xaa},
585 {0x38, 0xff},
586 {0x39, 0xff},
587 {0x3a, 0xf8},
588 {0x3b, 0x00},
589 {0x3c, 0x00},
590 {0x3d, 0x09},
591 {0x3e, 0x0d},
592 {0x3f, 0x04},
593 {0x40, 0x00},
594 {0x41, 0x08},
595 {0x42, 0x00},
596 {0x43, 0x08},
597 {0x44, 0x08},
598 {0x45, 0x14},
599 {0x46, 0x05},
600 {0x47, 0x08},
601 {0x48, 0x00},
602 {0x49, 0x00},
603 {0x4a, 0x00},
604 {0x4b, 0x00},
605 {0x4c, 0x09},
606 {0x4d, 0x80},
607 {0x4e, 0x00},
608 {0x4f, 0xc5},
609 {0x50, 0x14},
610 {0x51, 0x19},
611 {0x52, 0x00},
612 {0x53, 0x00},
613 {0x54, 0x00},
614 {0x55, 0x00},
615 {0x56, 0x00},
616 {0x57, 0x00},
617 {0x58, 0x00},
618 {0x59, 0xb0},
619 {0x5a, 0x00},
620 {0x5b, 0x00},
621 {0x5c, 0x00},
622 {0x5d, 0x00},
623 {0x5e, 0x00},
624 {0x5f, 0x00},
625 {0x60, 0x39},
626 {0x61, 0x83},
627 {0x62, 0x00},
628 {0x63, 0x00},
629 {0x64, 0x00},
630 {0x65, 0x00},
631 {0x66, 0xc0},
632 {0x67, 0x49},
633 {0x68, 0x00},
634 {0x69, 0x00},
635 {0x6a, 0x00},
636 {0x6b, 0x00},
637 {0x6c, 0x00},
638 {0x6d, 0x03},
639 {0x6e, 0x01},
640 {0x6f, 0x00},
641 {0x70, 0x00},
642 {0x71, 0x00},
643 {0x72, 0x00},
644 {0x73, 0x00},
645 {0x74, 0x00},
646 {0x75, 0x00},
647 {0x76, 0x00},
648 {0x77, 0x00},
649 {0x78, 0x00},
650 {0x79, 0x00},
651 {0x7a, 0x00},
652 {0x7b, 0x00},
653 {0x7c, 0x00},
654 {0x7d, 0x00},
655 {0x7e, 0x00},
656 {0x7f, 0x00},
657 {0x80, 0x89},
658 {0x81, 0x00},
659 {0x82, 0x0e},
660 {0x83, 0x00},
661 {0x84, 0x00},
662 {0x85, 0x00},
663 {0x86, 0x00},
664 {0x87, 0x00},
665 {0x88, 0x08},
666 {0x89, 0x00},
667 {0x8a, 0x0e},
668 {0x8b, 0xa7},
669 {0x8c, 0x88},
670 {0x8d, 0x47},
671 {0x8e, 0xaa},
672 {0x8f, 0x02},
673 {0x90, 0x23},
674 {0x91, 0x0c},
675 {0x92, 0x06},
676 {0x93, 0x08},
677 {0x94, 0x00},
678 {0x95, 0x00},
679 {0x96, 0x00},
680 {0x97, 0xeb},
681 {0x98, 0x00},
682 {0x99, 0x00},
683 {0x9a, 0x00},
684 {0x9b, 0x00},
685 {0x9c, 0x00},
686 {0x9d, 0x00},
687 {0x9e, 0x00},
688 {0x9f, 0x00},
689 {0xa0, 0x00},
690 {0xa1, 0x00},
691 {0xa2, 0x00},
692 {0xa3, 0xcd},
693 {0xa4, 0x07},
694 {0xa5, 0x33},
695 {0xa6, 0x18},
696 {0xa7, 0x00},
697 {0xa8, 0x18},
698 {0xa9, 0x00},
699 {0xaa, 0x28},
700 {0xab, 0x00},
701 {0xac, 0x00},
702 {0xad, 0x00},
703 {0xae, 0x00},
704 {0xaf, 0x18},
705 {0xb0, 0x38},
706 {0xb1, 0x30},
707 {0xb2, 0x00},
708 {0xb3, 0x00},
709 {0xb4, 0x00},
710 {0xb5, 0x00},
711 {0xb6, 0x84},
712 {0xb7, 0xfd},
713 {0xb8, 0x00},
714 {0xb9, 0x00},
715 {0xba, 0x00},
716 {0xbb, 0x03},
717 {0xbc, 0x00},
718 {0xbd, 0x00},
719 {0xbe, 0x00},
720 {0xbf, 0x00},
721 {0xc0, 0x10},
722 {0xc1, 0x20},
723 {0xc2, 0x18},
724 {0xc3, 0x20},
725 {0xc4, 0x10},
726 {0xc5, 0x2c},
727 {0xc6, 0x1e},
728 {0xc7, 0x10},
729 {0xc8, 0x12},
730 {0xc9, 0x01},
731 {0xca, 0x6f},
732 {0xcb, 0xa7},
733 {0xcc, 0x3c},
734 {0xcd, 0x10},
735 {0xce, 0x00},
736 {0xcf, 0x22},
737 {0xd0, 0x00},
738 {0xd1, 0x10},
739 {0xd2, 0x00},
740 {0xd3, 0x00},
741 {0xd4, 0x10},
742 {0xd5, 0x33},
743 {0xd6, 0x80},
744 {0xd7, 0x21},
745 {0xd8, 0x00},
746 {0xd9, 0x00},
747 {0xda, 0x00},
748 {0xdb, 0x00},
749 {0xdc, 0x00},
750 {0xdd, 0x00},
751 {0xde, 0x00},
752 {0xdf, 0x00},
753 {0xe0, 0x00},
754 {0xe1, 0xB3},
755 {0xe2, 0x00},
756 {0xe3, 0x00},
757 {0xe4, 0x00},
758 {0xe5, 0x10},
759 {0xe6, 0x00},
760 {0xe7, 0x18},
761 {0xe8, 0x08},
762 {0xe9, 0xd4},
763 {0xea, 0x00},
764 {0xeb, 0xff},
765 {0xec, 0x79},
766 {0xed, 0x10},
767 {0xee, 0x30},
768 {0xef, 0x02},
769 {0xf0, 0x00},
770 {0xf1, 0x09},
771 {0xf2, 0x00},
772 {0xf3, 0x00},
773 {0xf4, 0x00},
774 {0xf5, 0x00},
775 {0xf6, 0x00},
776 {0xf7, 0x00},
777 {0xf8, 0x00},
778 {0xf9, 0x00},
779 {0xfa, 0x00},
780 {0xfb, 0x00},
781 {0xfc, 0x00},
782 {0xfd, 0x00},
783 {0xfe, 0x00},
784 {0xff, 0x00},
787 #define CB_VT3253B0_AGC_FOR_RFMD2959 195
788 // For RFMD2959
789 unsigned char byVT3253B0_AGC4_RFMD2959[CB_VT3253B0_AGC_FOR_RFMD2959][2] = {
790 {0xF0, 0x00},
791 {0xF1, 0x3E},
792 {0xF0, 0x80},
793 {0xF0, 0x00},
794 {0xF1, 0x3E},
795 {0xF0, 0x81},
796 {0xF0, 0x01},
797 {0xF1, 0x3E},
798 {0xF0, 0x82},
799 {0xF0, 0x02},
800 {0xF1, 0x3E},
801 {0xF0, 0x83},
802 {0xF0, 0x03},
803 {0xF1, 0x3B},
804 {0xF0, 0x84},
805 {0xF0, 0x04},
806 {0xF1, 0x39},
807 {0xF0, 0x85},
808 {0xF0, 0x05},
809 {0xF1, 0x38},
810 {0xF0, 0x86},
811 {0xF0, 0x06},
812 {0xF1, 0x37},
813 {0xF0, 0x87},
814 {0xF0, 0x07},
815 {0xF1, 0x36},
816 {0xF0, 0x88},
817 {0xF0, 0x08},
818 {0xF1, 0x35},
819 {0xF0, 0x89},
820 {0xF0, 0x09},
821 {0xF1, 0x35},
822 {0xF0, 0x8A},
823 {0xF0, 0x0A},
824 {0xF1, 0x34},
825 {0xF0, 0x8B},
826 {0xF0, 0x0B},
827 {0xF1, 0x34},
828 {0xF0, 0x8C},
829 {0xF0, 0x0C},
830 {0xF1, 0x33},
831 {0xF0, 0x8D},
832 {0xF0, 0x0D},
833 {0xF1, 0x32},
834 {0xF0, 0x8E},
835 {0xF0, 0x0E},
836 {0xF1, 0x31},
837 {0xF0, 0x8F},
838 {0xF0, 0x0F},
839 {0xF1, 0x30},
840 {0xF0, 0x90},
841 {0xF0, 0x10},
842 {0xF1, 0x2F},
843 {0xF0, 0x91},
844 {0xF0, 0x11},
845 {0xF1, 0x2F},
846 {0xF0, 0x92},
847 {0xF0, 0x12},
848 {0xF1, 0x2E},
849 {0xF0, 0x93},
850 {0xF0, 0x13},
851 {0xF1, 0x2D},
852 {0xF0, 0x94},
853 {0xF0, 0x14},
854 {0xF1, 0x2C},
855 {0xF0, 0x95},
856 {0xF0, 0x15},
857 {0xF1, 0x2B},
858 {0xF0, 0x96},
859 {0xF0, 0x16},
860 {0xF1, 0x2B},
861 {0xF0, 0x97},
862 {0xF0, 0x17},
863 {0xF1, 0x2A},
864 {0xF0, 0x98},
865 {0xF0, 0x18},
866 {0xF1, 0x29},
867 {0xF0, 0x99},
868 {0xF0, 0x19},
869 {0xF1, 0x28},
870 {0xF0, 0x9A},
871 {0xF0, 0x1A},
872 {0xF1, 0x27},
873 {0xF0, 0x9B},
874 {0xF0, 0x1B},
875 {0xF1, 0x26},
876 {0xF0, 0x9C},
877 {0xF0, 0x1C},
878 {0xF1, 0x25},
879 {0xF0, 0x9D},
880 {0xF0, 0x1D},
881 {0xF1, 0x24},
882 {0xF0, 0x9E},
883 {0xF0, 0x1E},
884 {0xF1, 0x24},
885 {0xF0, 0x9F},
886 {0xF0, 0x1F},
887 {0xF1, 0x23},
888 {0xF0, 0xA0},
889 {0xF0, 0x20},
890 {0xF1, 0x22},
891 {0xF0, 0xA1},
892 {0xF0, 0x21},
893 {0xF1, 0x21},
894 {0xF0, 0xA2},
895 {0xF0, 0x22},
896 {0xF1, 0x20},
897 {0xF0, 0xA3},
898 {0xF0, 0x23},
899 {0xF1, 0x20},
900 {0xF0, 0xA4},
901 {0xF0, 0x24},
902 {0xF1, 0x1F},
903 {0xF0, 0xA5},
904 {0xF0, 0x25},
905 {0xF1, 0x1E},
906 {0xF0, 0xA6},
907 {0xF0, 0x26},
908 {0xF1, 0x1D},
909 {0xF0, 0xA7},
910 {0xF0, 0x27},
911 {0xF1, 0x1C},
912 {0xF0, 0xA8},
913 {0xF0, 0x28},
914 {0xF1, 0x1B},
915 {0xF0, 0xA9},
916 {0xF0, 0x29},
917 {0xF1, 0x1B},
918 {0xF0, 0xAA},
919 {0xF0, 0x2A},
920 {0xF1, 0x1A},
921 {0xF0, 0xAB},
922 {0xF0, 0x2B},
923 {0xF1, 0x1A},
924 {0xF0, 0xAC},
925 {0xF0, 0x2C},
926 {0xF1, 0x19},
927 {0xF0, 0xAD},
928 {0xF0, 0x2D},
929 {0xF1, 0x18},
930 {0xF0, 0xAE},
931 {0xF0, 0x2E},
932 {0xF1, 0x17},
933 {0xF0, 0xAF},
934 {0xF0, 0x2F},
935 {0xF1, 0x16},
936 {0xF0, 0xB0},
937 {0xF0, 0x30},
938 {0xF1, 0x15},
939 {0xF0, 0xB1},
940 {0xF0, 0x31},
941 {0xF1, 0x15},
942 {0xF0, 0xB2},
943 {0xF0, 0x32},
944 {0xF1, 0x15},
945 {0xF0, 0xB3},
946 {0xF0, 0x33},
947 {0xF1, 0x14},
948 {0xF0, 0xB4},
949 {0xF0, 0x34},
950 {0xF1, 0x13},
951 {0xF0, 0xB5},
952 {0xF0, 0x35},
953 {0xF1, 0x12},
954 {0xF0, 0xB6},
955 {0xF0, 0x36},
956 {0xF1, 0x11},
957 {0xF0, 0xB7},
958 {0xF0, 0x37},
959 {0xF1, 0x10},
960 {0xF0, 0xB8},
961 {0xF0, 0x38},
962 {0xF1, 0x0F},
963 {0xF0, 0xB9},
964 {0xF0, 0x39},
965 {0xF1, 0x0E},
966 {0xF0, 0xBA},
967 {0xF0, 0x3A},
968 {0xF1, 0x0D},
969 {0xF0, 0xBB},
970 {0xF0, 0x3B},
971 {0xF1, 0x0C},
972 {0xF0, 0xBC},
973 {0xF0, 0x3C},
974 {0xF1, 0x0B},
975 {0xF0, 0xBD},
976 {0xF0, 0x3D},
977 {0xF1, 0x0B},
978 {0xF0, 0xBE},
979 {0xF0, 0x3E},
980 {0xF1, 0x0A},
981 {0xF0, 0xBF},
982 {0xF0, 0x3F},
983 {0xF1, 0x09},
984 {0xF0, 0x00},
987 #define CB_VT3253B0_INIT_FOR_AIROHA2230 256
988 // For AIROHA
989 unsigned char byVT3253B0_AIROHA2230[CB_VT3253B0_INIT_FOR_AIROHA2230][2] = {
990 {0x00, 0x31},
991 {0x01, 0x00},
992 {0x02, 0x00},
993 {0x03, 0x00},
994 {0x04, 0x00},
995 {0x05, 0x80},
996 {0x06, 0x00},
997 {0x07, 0x00},
998 {0x08, 0x70},
999 {0x09, 0x41},
1000 {0x0a, 0x2A},
1001 {0x0b, 0x76},
1002 {0x0c, 0x00},
1003 {0x0d, 0x00},
1004 {0x0e, 0x80},
1005 {0x0f, 0x00},
1006 {0x10, 0x00},
1007 {0x11, 0x00},
1008 {0x12, 0x00},
1009 {0x13, 0x00},
1010 {0x14, 0x00},
1011 {0x15, 0x00},
1012 {0x16, 0x00},
1013 {0x17, 0x00},
1014 {0x18, 0x00},
1015 {0x19, 0x00},
1016 {0x1a, 0x00},
1017 {0x1b, 0x8f},
1018 {0x1c, 0x09},
1019 {0x1d, 0x00},
1020 {0x1e, 0x00},
1021 {0x1f, 0x00},
1022 {0x20, 0x00},
1023 {0x21, 0x00},
1024 {0x22, 0x00},
1025 {0x23, 0x00},
1026 {0x24, 0x00},
1027 {0x25, 0x4a},
1028 {0x26, 0x00},
1029 {0x27, 0x00},
1030 {0x28, 0x00},
1031 {0x29, 0x00},
1032 {0x2a, 0x00},
1033 {0x2b, 0x00},
1034 {0x2c, 0x00},
1035 {0x2d, 0x4a},
1036 {0x2e, 0x00},
1037 {0x2f, 0x0a},
1038 {0x30, 0x26},
1039 {0x31, 0x5b},
1040 {0x32, 0x00},
1041 {0x33, 0x00},
1042 {0x34, 0x00},
1043 {0x35, 0x00},
1044 {0x36, 0xaa},
1045 {0x37, 0xaa},
1046 {0x38, 0xff},
1047 {0x39, 0xff},
1048 {0x3a, 0x79},
1049 {0x3b, 0x00},
1050 {0x3c, 0x00},
1051 {0x3d, 0x0b},
1052 {0x3e, 0x48},
1053 {0x3f, 0x04},
1054 {0x40, 0x00},
1055 {0x41, 0x08},
1056 {0x42, 0x00},
1057 {0x43, 0x08},
1058 {0x44, 0x08},
1059 {0x45, 0x14},
1060 {0x46, 0x05},
1061 {0x47, 0x09},
1062 {0x48, 0x00},
1063 {0x49, 0x00},
1064 {0x4a, 0x00},
1065 {0x4b, 0x00},
1066 {0x4c, 0x09},
1067 {0x4d, 0x73},
1068 {0x4e, 0x00},
1069 {0x4f, 0xc5},
1070 {0x50, 0x15},
1071 {0x51, 0x19},
1072 {0x52, 0x00},
1073 {0x53, 0x00},
1074 {0x54, 0x00},
1075 {0x55, 0x00},
1076 {0x56, 0x00},
1077 {0x57, 0x00},
1078 {0x58, 0x00},
1079 {0x59, 0xb0},
1080 {0x5a, 0x00},
1081 {0x5b, 0x00},
1082 {0x5c, 0x00},
1083 {0x5d, 0x00},
1084 {0x5e, 0x00},
1085 {0x5f, 0x00},
1086 {0x60, 0xe4},
1087 {0x61, 0x80},
1088 {0x62, 0x00},
1089 {0x63, 0x00},
1090 {0x64, 0x00},
1091 {0x65, 0x00},
1092 {0x66, 0x98},
1093 {0x67, 0x0a},
1094 {0x68, 0x00},
1095 {0x69, 0x00},
1096 {0x6a, 0x00},
1097 {0x6b, 0x00},
1098 //{0x6c, 0x80},
1099 {0x6c, 0x00}, //RobertYu:20050125, request by JJSue
1100 {0x6d, 0x03},
1101 {0x6e, 0x01},
1102 {0x6f, 0x00},
1103 {0x70, 0x00},
1104 {0x71, 0x00},
1105 {0x72, 0x00},
1106 {0x73, 0x00},
1107 {0x74, 0x00},
1108 {0x75, 0x00},
1109 {0x76, 0x00},
1110 {0x77, 0x00},
1111 {0x78, 0x00},
1112 {0x79, 0x00},
1113 {0x7a, 0x00},
1114 {0x7b, 0x00},
1115 {0x7c, 0x00},
1116 {0x7d, 0x00},
1117 {0x7e, 0x00},
1118 {0x7f, 0x00},
1119 {0x80, 0x8c},
1120 {0x81, 0x01},
1121 {0x82, 0x09},
1122 {0x83, 0x00},
1123 {0x84, 0x00},
1124 {0x85, 0x00},
1125 {0x86, 0x00},
1126 {0x87, 0x00},
1127 {0x88, 0x08},
1128 {0x89, 0x00},
1129 {0x8a, 0x0f},
1130 {0x8b, 0xb7},
1131 {0x8c, 0x88},
1132 {0x8d, 0x47},
1133 {0x8e, 0xaa},
1134 {0x8f, 0x02},
1135 {0x90, 0x22},
1136 {0x91, 0x00},
1137 {0x92, 0x00},
1138 {0x93, 0x00},
1139 {0x94, 0x00},
1140 {0x95, 0x00},
1141 {0x96, 0x00},
1142 {0x97, 0xeb},
1143 {0x98, 0x00},
1144 {0x99, 0x00},
1145 {0x9a, 0x00},
1146 {0x9b, 0x00},
1147 {0x9c, 0x00},
1148 {0x9d, 0x00},
1149 {0x9e, 0x00},
1150 {0x9f, 0x01},
1151 {0xa0, 0x00},
1152 {0xa1, 0x00},
1153 {0xa2, 0x00},
1154 {0xa3, 0x00},
1155 {0xa4, 0x00},
1156 {0xa5, 0x00},
1157 {0xa6, 0x10},
1158 {0xa7, 0x00},
1159 {0xa8, 0x18},
1160 {0xa9, 0x00},
1161 {0xaa, 0x00},
1162 {0xab, 0x00},
1163 {0xac, 0x00},
1164 {0xad, 0x00},
1165 {0xae, 0x00},
1166 {0xaf, 0x18},
1167 {0xb0, 0x38},
1168 {0xb1, 0x30},
1169 {0xb2, 0x00},
1170 {0xb3, 0x00},
1171 {0xb4, 0xff},
1172 {0xb5, 0x0f},
1173 {0xb6, 0xe4},
1174 {0xb7, 0xe2},
1175 {0xb8, 0x00},
1176 {0xb9, 0x00},
1177 {0xba, 0x00},
1178 {0xbb, 0x03},
1179 {0xbc, 0x01},
1180 {0xbd, 0x00},
1181 {0xbe, 0x00},
1182 {0xbf, 0x00},
1183 {0xc0, 0x18},
1184 {0xc1, 0x20},
1185 {0xc2, 0x07},
1186 {0xc3, 0x18},
1187 {0xc4, 0xff},
1188 {0xc5, 0x2c},
1189 {0xc6, 0x0c},
1190 {0xc7, 0x0a},
1191 {0xc8, 0x0e},
1192 {0xc9, 0x01},
1193 {0xca, 0x68},
1194 {0xcb, 0xa7},
1195 {0xcc, 0x3c},
1196 {0xcd, 0x10},
1197 {0xce, 0x00},
1198 {0xcf, 0x25},
1199 {0xd0, 0x40},
1200 {0xd1, 0x12},
1201 {0xd2, 0x00},
1202 {0xd3, 0x00},
1203 {0xd4, 0x10},
1204 {0xd5, 0x28},
1205 {0xd6, 0x80},
1206 {0xd7, 0x2A},
1207 {0xd8, 0x00},
1208 {0xd9, 0x00},
1209 {0xda, 0x00},
1210 {0xdb, 0x00},
1211 {0xdc, 0x00},
1212 {0xdd, 0x00},
1213 {0xde, 0x00},
1214 {0xdf, 0x00},
1215 {0xe0, 0x00},
1216 {0xe1, 0xB3},
1217 {0xe2, 0x00},
1218 {0xe3, 0x00},
1219 {0xe4, 0x00},
1220 {0xe5, 0x10},
1221 {0xe6, 0x00},
1222 {0xe7, 0x1C},
1223 {0xe8, 0x00},
1224 {0xe9, 0xf4},
1225 {0xea, 0x00},
1226 {0xeb, 0xff},
1227 {0xec, 0x79},
1228 {0xed, 0x20},
1229 {0xee, 0x30},
1230 {0xef, 0x01},
1231 {0xf0, 0x00},
1232 {0xf1, 0x3e},
1233 {0xf2, 0x00},
1234 {0xf3, 0x00},
1235 {0xf4, 0x00},
1236 {0xf5, 0x00},
1237 {0xf6, 0x00},
1238 {0xf7, 0x00},
1239 {0xf8, 0x00},
1240 {0xf9, 0x00},
1241 {0xfa, 0x00},
1242 {0xfb, 0x00},
1243 {0xfc, 0x00},
1244 {0xfd, 0x00},
1245 {0xfe, 0x00},
1246 {0xff, 0x00},
1249 #define CB_VT3253B0_INIT_FOR_UW2451 256
1250 //For UW2451
1251 unsigned char byVT3253B0_UW2451[CB_VT3253B0_INIT_FOR_UW2451][2] = {
1252 {0x00, 0x31},
1253 {0x01, 0x00},
1254 {0x02, 0x00},
1255 {0x03, 0x00},
1256 {0x04, 0x00},
1257 {0x05, 0x81},
1258 {0x06, 0x00},
1259 {0x07, 0x00},
1260 {0x08, 0x38},
1261 {0x09, 0x45},
1262 {0x0a, 0x28},
1263 {0x0b, 0x76},
1264 {0x0c, 0x00},
1265 {0x0d, 0x00},
1266 {0x0e, 0x80},
1267 {0x0f, 0x00},
1268 {0x10, 0x00},
1269 {0x11, 0x00},
1270 {0x12, 0x00},
1271 {0x13, 0x00},
1272 {0x14, 0x00},
1273 {0x15, 0x00},
1274 {0x16, 0x00},
1275 {0x17, 0x00},
1276 {0x18, 0x00},
1277 {0x19, 0x00},
1278 {0x1a, 0x00},
1279 {0x1b, 0x8f},
1280 {0x1c, 0x0f},
1281 {0x1d, 0x00},
1282 {0x1e, 0x00},
1283 {0x1f, 0x00},
1284 {0x20, 0x00},
1285 {0x21, 0x00},
1286 {0x22, 0x00},
1287 {0x23, 0x00},
1288 {0x24, 0x00},
1289 {0x25, 0x4a},
1290 {0x26, 0x00},
1291 {0x27, 0x00},
1292 {0x28, 0x00},
1293 {0x29, 0x00},
1294 {0x2a, 0x00},
1295 {0x2b, 0x00},
1296 {0x2c, 0x00},
1297 {0x2d, 0x18},
1298 {0x2e, 0x00},
1299 {0x2f, 0x0a},
1300 {0x30, 0x26},
1301 {0x31, 0x5b},
1302 {0x32, 0x00},
1303 {0x33, 0x00},
1304 {0x34, 0x00},
1305 {0x35, 0x00},
1306 {0x36, 0xaa},
1307 {0x37, 0xaa},
1308 {0x38, 0xff},
1309 {0x39, 0xff},
1310 {0x3a, 0x00},
1311 {0x3b, 0x00},
1312 {0x3c, 0x00},
1313 {0x3d, 0x03},
1314 {0x3e, 0x1d},
1315 {0x3f, 0x04},
1316 {0x40, 0x00},
1317 {0x41, 0x08},
1318 {0x42, 0x00},
1319 {0x43, 0x08},
1320 {0x44, 0x08},
1321 {0x45, 0x14},
1322 {0x46, 0x05},
1323 {0x47, 0x09},
1324 {0x48, 0x00},
1325 {0x49, 0x00},
1326 {0x4a, 0x00},
1327 {0x4b, 0x00},
1328 {0x4c, 0x09},
1329 {0x4d, 0x90},
1330 {0x4e, 0x00},
1331 {0x4f, 0xc5},
1332 {0x50, 0x15},
1333 {0x51, 0x19},
1334 {0x52, 0x00},
1335 {0x53, 0x00},
1336 {0x54, 0x00},
1337 {0x55, 0x00},
1338 {0x56, 0x00},
1339 {0x57, 0x00},
1340 {0x58, 0x00},
1341 {0x59, 0xb0},
1342 {0x5a, 0x00},
1343 {0x5b, 0x00},
1344 {0x5c, 0x00},
1345 {0x5d, 0x00},
1346 {0x5e, 0x00},
1347 {0x5f, 0x00},
1348 {0x60, 0xb3},
1349 {0x61, 0x81},
1350 {0x62, 0x00},
1351 {0x63, 0x00},
1352 {0x64, 0x00},
1353 {0x65, 0x00},
1354 {0x66, 0x57},
1355 {0x67, 0x6c},
1356 {0x68, 0x00},
1357 {0x69, 0x00},
1358 {0x6a, 0x00},
1359 {0x6b, 0x00},
1360 //{0x6c, 0x80},
1361 {0x6c, 0x00}, //RobertYu:20050125, request by JJSue
1362 {0x6d, 0x03},
1363 {0x6e, 0x01},
1364 {0x6f, 0x00},
1365 {0x70, 0x00},
1366 {0x71, 0x00},
1367 {0x72, 0x00},
1368 {0x73, 0x00},
1369 {0x74, 0x00},
1370 {0x75, 0x00},
1371 {0x76, 0x00},
1372 {0x77, 0x00},
1373 {0x78, 0x00},
1374 {0x79, 0x00},
1375 {0x7a, 0x00},
1376 {0x7b, 0x00},
1377 {0x7c, 0x00},
1378 {0x7d, 0x00},
1379 {0x7e, 0x00},
1380 {0x7f, 0x00},
1381 {0x80, 0x8c},
1382 {0x81, 0x00},
1383 {0x82, 0x0e},
1384 {0x83, 0x00},
1385 {0x84, 0x00},
1386 {0x85, 0x00},
1387 {0x86, 0x00},
1388 {0x87, 0x00},
1389 {0x88, 0x08},
1390 {0x89, 0x00},
1391 {0x8a, 0x0e},
1392 {0x8b, 0xa7},
1393 {0x8c, 0x88},
1394 {0x8d, 0x47},
1395 {0x8e, 0xaa},
1396 {0x8f, 0x02},
1397 {0x90, 0x00},
1398 {0x91, 0x00},
1399 {0x92, 0x00},
1400 {0x93, 0x00},
1401 {0x94, 0x00},
1402 {0x95, 0x00},
1403 {0x96, 0x00},
1404 {0x97, 0xe3},
1405 {0x98, 0x00},
1406 {0x99, 0x00},
1407 {0x9a, 0x00},
1408 {0x9b, 0x00},
1409 {0x9c, 0x00},
1410 {0x9d, 0x00},
1411 {0x9e, 0x00},
1412 {0x9f, 0x00},
1413 {0xa0, 0x00},
1414 {0xa1, 0x00},
1415 {0xa2, 0x00},
1416 {0xa3, 0x00},
1417 {0xa4, 0x00},
1418 {0xa5, 0x00},
1419 {0xa6, 0x10},
1420 {0xa7, 0x00},
1421 {0xa8, 0x18},
1422 {0xa9, 0x00},
1423 {0xaa, 0x00},
1424 {0xab, 0x00},
1425 {0xac, 0x00},
1426 {0xad, 0x00},
1427 {0xae, 0x00},
1428 {0xaf, 0x18},
1429 {0xb0, 0x18},
1430 {0xb1, 0x30},
1431 {0xb2, 0x00},
1432 {0xb3, 0x00},
1433 {0xb4, 0x00},
1434 {0xb5, 0x00},
1435 {0xb6, 0x00},
1436 {0xb7, 0x00},
1437 {0xb8, 0x00},
1438 {0xb9, 0x00},
1439 {0xba, 0x00},
1440 {0xbb, 0x03},
1441 {0xbc, 0x01},
1442 {0xbd, 0x00},
1443 {0xbe, 0x00},
1444 {0xbf, 0x00},
1445 {0xc0, 0x10},
1446 {0xc1, 0x20},
1447 {0xc2, 0x00},
1448 {0xc3, 0x20},
1449 {0xc4, 0x00},
1450 {0xc5, 0x2c},
1451 {0xc6, 0x1c},
1452 {0xc7, 0x10},
1453 {0xc8, 0x10},
1454 {0xc9, 0x01},
1455 {0xca, 0x68},
1456 {0xcb, 0xa7},
1457 {0xcc, 0x3c},
1458 {0xcd, 0x09},
1459 {0xce, 0x00},
1460 {0xcf, 0x20},
1461 {0xd0, 0x40},
1462 {0xd1, 0x10},
1463 {0xd2, 0x00},
1464 {0xd3, 0x00},
1465 {0xd4, 0x20},
1466 {0xd5, 0x28},
1467 {0xd6, 0xa0},
1468 {0xd7, 0x2a},
1469 {0xd8, 0x00},
1470 {0xd9, 0x00},
1471 {0xda, 0x00},
1472 {0xdb, 0x00},
1473 {0xdc, 0x00},
1474 {0xdd, 0x00},
1475 {0xde, 0x00},
1476 {0xdf, 0x00},
1477 {0xe0, 0x00},
1478 {0xe1, 0xd3},
1479 {0xe2, 0xc0},
1480 {0xe3, 0x00},
1481 {0xe4, 0x00},
1482 {0xe5, 0x10},
1483 {0xe6, 0x00},
1484 {0xe7, 0x12},
1485 {0xe8, 0x12},
1486 {0xe9, 0x34},
1487 {0xea, 0x00},
1488 {0xeb, 0xff},
1489 {0xec, 0x79},
1490 {0xed, 0x20},
1491 {0xee, 0x30},
1492 {0xef, 0x01},
1493 {0xf0, 0x00},
1494 {0xf1, 0x3e},
1495 {0xf2, 0x00},
1496 {0xf3, 0x00},
1497 {0xf4, 0x00},
1498 {0xf5, 0x00},
1499 {0xf6, 0x00},
1500 {0xf7, 0x00},
1501 {0xf8, 0x00},
1502 {0xf9, 0x00},
1503 {0xfa, 0x00},
1504 {0xfb, 0x00},
1505 {0xfc, 0x00},
1506 {0xfd, 0x00},
1507 {0xfe, 0x00},
1508 {0xff, 0x00},
1511 #define CB_VT3253B0_AGC 193
1512 // For AIROHA
1513 unsigned char byVT3253B0_AGC[CB_VT3253B0_AGC][2] = {
1514 {0xF0, 0x00},
1515 {0xF1, 0x00},
1516 {0xF0, 0x80},
1517 {0xF0, 0x01},
1518 {0xF1, 0x00},
1519 {0xF0, 0x81},
1520 {0xF0, 0x02},
1521 {0xF1, 0x02},
1522 {0xF0, 0x82},
1523 {0xF0, 0x03},
1524 {0xF1, 0x04},
1525 {0xF0, 0x83},
1526 {0xF0, 0x03},
1527 {0xF1, 0x04},
1528 {0xF0, 0x84},
1529 {0xF0, 0x04},
1530 {0xF1, 0x06},
1531 {0xF0, 0x85},
1532 {0xF0, 0x05},
1533 {0xF1, 0x06},
1534 {0xF0, 0x86},
1535 {0xF0, 0x06},
1536 {0xF1, 0x06},
1537 {0xF0, 0x87},
1538 {0xF0, 0x07},
1539 {0xF1, 0x08},
1540 {0xF0, 0x88},
1541 {0xF0, 0x08},
1542 {0xF1, 0x08},
1543 {0xF0, 0x89},
1544 {0xF0, 0x09},
1545 {0xF1, 0x0A},
1546 {0xF0, 0x8A},
1547 {0xF0, 0x0A},
1548 {0xF1, 0x0A},
1549 {0xF0, 0x8B},
1550 {0xF0, 0x0B},
1551 {0xF1, 0x0C},
1552 {0xF0, 0x8C},
1553 {0xF0, 0x0C},
1554 {0xF1, 0x0C},
1555 {0xF0, 0x8D},
1556 {0xF0, 0x0D},
1557 {0xF1, 0x0E},
1558 {0xF0, 0x8E},
1559 {0xF0, 0x0E},
1560 {0xF1, 0x0E},
1561 {0xF0, 0x8F},
1562 {0xF0, 0x0F},
1563 {0xF1, 0x10},
1564 {0xF0, 0x90},
1565 {0xF0, 0x10},
1566 {0xF1, 0x10},
1567 {0xF0, 0x91},
1568 {0xF0, 0x11},
1569 {0xF1, 0x12},
1570 {0xF0, 0x92},
1571 {0xF0, 0x12},
1572 {0xF1, 0x12},
1573 {0xF0, 0x93},
1574 {0xF0, 0x13},
1575 {0xF1, 0x14},
1576 {0xF0, 0x94},
1577 {0xF0, 0x14},
1578 {0xF1, 0x14},
1579 {0xF0, 0x95},
1580 {0xF0, 0x15},
1581 {0xF1, 0x16},
1582 {0xF0, 0x96},
1583 {0xF0, 0x16},
1584 {0xF1, 0x16},
1585 {0xF0, 0x97},
1586 {0xF0, 0x17},
1587 {0xF1, 0x18},
1588 {0xF0, 0x98},
1589 {0xF0, 0x18},
1590 {0xF1, 0x18},
1591 {0xF0, 0x99},
1592 {0xF0, 0x19},
1593 {0xF1, 0x1A},
1594 {0xF0, 0x9A},
1595 {0xF0, 0x1A},
1596 {0xF1, 0x1A},
1597 {0xF0, 0x9B},
1598 {0xF0, 0x1B},
1599 {0xF1, 0x1C},
1600 {0xF0, 0x9C},
1601 {0xF0, 0x1C},
1602 {0xF1, 0x1C},
1603 {0xF0, 0x9D},
1604 {0xF0, 0x1D},
1605 {0xF1, 0x1E},
1606 {0xF0, 0x9E},
1607 {0xF0, 0x1E},
1608 {0xF1, 0x1E},
1609 {0xF0, 0x9F},
1610 {0xF0, 0x1F},
1611 {0xF1, 0x20},
1612 {0xF0, 0xA0},
1613 {0xF0, 0x20},
1614 {0xF1, 0x20},
1615 {0xF0, 0xA1},
1616 {0xF0, 0x21},
1617 {0xF1, 0x22},
1618 {0xF0, 0xA2},
1619 {0xF0, 0x22},
1620 {0xF1, 0x22},
1621 {0xF0, 0xA3},
1622 {0xF0, 0x23},
1623 {0xF1, 0x24},
1624 {0xF0, 0xA4},
1625 {0xF0, 0x24},
1626 {0xF1, 0x24},
1627 {0xF0, 0xA5},
1628 {0xF0, 0x25},
1629 {0xF1, 0x26},
1630 {0xF0, 0xA6},
1631 {0xF0, 0x26},
1632 {0xF1, 0x26},
1633 {0xF0, 0xA7},
1634 {0xF0, 0x27},
1635 {0xF1, 0x28},
1636 {0xF0, 0xA8},
1637 {0xF0, 0x28},
1638 {0xF1, 0x28},
1639 {0xF0, 0xA9},
1640 {0xF0, 0x29},
1641 {0xF1, 0x2A},
1642 {0xF0, 0xAA},
1643 {0xF0, 0x2A},
1644 {0xF1, 0x2A},
1645 {0xF0, 0xAB},
1646 {0xF0, 0x2B},
1647 {0xF1, 0x2C},
1648 {0xF0, 0xAC},
1649 {0xF0, 0x2C},
1650 {0xF1, 0x2C},
1651 {0xF0, 0xAD},
1652 {0xF0, 0x2D},
1653 {0xF1, 0x2E},
1654 {0xF0, 0xAE},
1655 {0xF0, 0x2E},
1656 {0xF1, 0x2E},
1657 {0xF0, 0xAF},
1658 {0xF0, 0x2F},
1659 {0xF1, 0x30},
1660 {0xF0, 0xB0},
1661 {0xF0, 0x30},
1662 {0xF1, 0x30},
1663 {0xF0, 0xB1},
1664 {0xF0, 0x31},
1665 {0xF1, 0x32},
1666 {0xF0, 0xB2},
1667 {0xF0, 0x32},
1668 {0xF1, 0x32},
1669 {0xF0, 0xB3},
1670 {0xF0, 0x33},
1671 {0xF1, 0x34},
1672 {0xF0, 0xB4},
1673 {0xF0, 0x34},
1674 {0xF1, 0x34},
1675 {0xF0, 0xB5},
1676 {0xF0, 0x35},
1677 {0xF1, 0x36},
1678 {0xF0, 0xB6},
1679 {0xF0, 0x36},
1680 {0xF1, 0x36},
1681 {0xF0, 0xB7},
1682 {0xF0, 0x37},
1683 {0xF1, 0x38},
1684 {0xF0, 0xB8},
1685 {0xF0, 0x38},
1686 {0xF1, 0x38},
1687 {0xF0, 0xB9},
1688 {0xF0, 0x39},
1689 {0xF1, 0x3A},
1690 {0xF0, 0xBA},
1691 {0xF0, 0x3A},
1692 {0xF1, 0x3A},
1693 {0xF0, 0xBB},
1694 {0xF0, 0x3B},
1695 {0xF1, 0x3C},
1696 {0xF0, 0xBC},
1697 {0xF0, 0x3C},
1698 {0xF1, 0x3C},
1699 {0xF0, 0xBD},
1700 {0xF0, 0x3D},
1701 {0xF1, 0x3E},
1702 {0xF0, 0xBE},
1703 {0xF0, 0x3E},
1704 {0xF1, 0x3E},
1705 {0xF0, 0xBF},
1706 {0xF0, 0x00},
1709 const unsigned short awcFrameTime[MAX_RATE] =
1710 {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
1712 /*--------------------- Static Functions --------------------------*/
1714 static
1715 unsigned long
1716 s_ulGetRatio(PSDevice pDevice);
1718 static
1719 void
1720 s_vChangeAntenna(
1721 PSDevice pDevice
1724 static
1725 void
1726 s_vChangeAntenna(
1727 PSDevice pDevice
1730 if (pDevice->dwRxAntennaSel == 0) {
1731 pDevice->dwRxAntennaSel = 1;
1732 if (pDevice->bTxRxAntInv == true)
1733 BBvSetRxAntennaMode(pDevice->PortOffset, ANT_A);
1734 else
1735 BBvSetRxAntennaMode(pDevice->PortOffset, ANT_B);
1736 } else {
1737 pDevice->dwRxAntennaSel = 0;
1738 if (pDevice->bTxRxAntInv == true)
1739 BBvSetRxAntennaMode(pDevice->PortOffset, ANT_B);
1740 else
1741 BBvSetRxAntennaMode(pDevice->PortOffset, ANT_A);
1743 if (pDevice->dwTxAntennaSel == 0) {
1744 pDevice->dwTxAntennaSel = 1;
1745 BBvSetTxAntennaMode(pDevice->PortOffset, ANT_B);
1746 } else {
1747 pDevice->dwTxAntennaSel = 0;
1748 BBvSetTxAntennaMode(pDevice->PortOffset, ANT_A);
1752 /*--------------------- Export Variables --------------------------*/
1754 * Description: Calculate data frame transmitting time
1756 * Parameters:
1757 * In:
1758 * byPreambleType - Preamble Type
1759 * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
1760 * cbFrameLength - Baseband Type
1761 * wRate - Tx Rate
1762 * Out:
1764 * Return Value: FrameTime
1767 unsigned int
1768 BBuGetFrameTime(
1769 unsigned char byPreambleType,
1770 unsigned char byPktType,
1771 unsigned int cbFrameLength,
1772 unsigned short wRate
1775 unsigned int uFrameTime;
1776 unsigned int uPreamble;
1777 unsigned int uTmp;
1778 unsigned int uRateIdx = (unsigned int) wRate;
1779 unsigned int uRate = 0;
1781 if (uRateIdx > RATE_54M) {
1782 ASSERT(0);
1783 return 0;
1786 uRate = (unsigned int)awcFrameTime[uRateIdx];
1788 if (uRateIdx <= 3) { //CCK mode
1790 if (byPreambleType == 1) {//Short
1791 uPreamble = 96;
1792 } else {
1793 uPreamble = 192;
1795 uFrameTime = (cbFrameLength * 80) / uRate; //?????
1796 uTmp = (uFrameTime * uRate) / 80;
1797 if (cbFrameLength != uTmp) {
1798 uFrameTime++;
1801 return uPreamble + uFrameTime;
1802 } else {
1803 uFrameTime = (cbFrameLength * 8 + 22) / uRate; //????????
1804 uTmp = ((uFrameTime * uRate) - 22) / 8;
1805 if (cbFrameLength != uTmp) {
1806 uFrameTime++;
1808 uFrameTime = uFrameTime * 4; //???????
1809 if (byPktType != PK_TYPE_11A) {
1810 uFrameTime += 6; //??????
1812 return 20 + uFrameTime; //??????
1817 * Description: Calculate Length, Service, and Signal fields of Phy for Tx
1819 * Parameters:
1820 * In:
1821 * pDevice - Device Structure
1822 * cbFrameLength - Tx Frame Length
1823 * wRate - Tx Rate
1824 * Out:
1825 * pwPhyLen - pointer to Phy Length field
1826 * pbyPhySrv - pointer to Phy Service field
1827 * pbyPhySgn - pointer to Phy Signal field
1829 * Return Value: none
1832 void
1833 BBvCalculateParameter(
1834 PSDevice pDevice,
1835 unsigned int cbFrameLength,
1836 unsigned short wRate,
1837 unsigned char byPacketType,
1838 unsigned short *pwPhyLen,
1839 unsigned char *pbyPhySrv,
1840 unsigned char *pbyPhySgn
1843 unsigned int cbBitCount;
1844 unsigned int cbUsCount = 0;
1845 unsigned int cbTmp;
1846 bool bExtBit;
1847 unsigned char byPreambleType = pDevice->byPreambleType;
1848 bool bCCK = pDevice->bCCK;
1850 cbBitCount = cbFrameLength * 8;
1851 bExtBit = false;
1853 switch (wRate) {
1854 case RATE_1M:
1855 cbUsCount = cbBitCount;
1856 *pbyPhySgn = 0x00;
1857 break;
1859 case RATE_2M:
1860 cbUsCount = cbBitCount / 2;
1861 if (byPreambleType == 1)
1862 *pbyPhySgn = 0x09;
1863 else // long preamble
1864 *pbyPhySgn = 0x01;
1865 break;
1867 case RATE_5M:
1868 if (bCCK == false)
1869 cbBitCount++;
1870 cbUsCount = (cbBitCount * 10) / 55;
1871 cbTmp = (cbUsCount * 55) / 10;
1872 if (cbTmp != cbBitCount)
1873 cbUsCount++;
1874 if (byPreambleType == 1)
1875 *pbyPhySgn = 0x0a;
1876 else // long preamble
1877 *pbyPhySgn = 0x02;
1878 break;
1880 case RATE_11M:
1882 if (bCCK == false)
1883 cbBitCount++;
1884 cbUsCount = cbBitCount / 11;
1885 cbTmp = cbUsCount * 11;
1886 if (cbTmp != cbBitCount) {
1887 cbUsCount++;
1888 if ((cbBitCount - cbTmp) <= 3)
1889 bExtBit = true;
1891 if (byPreambleType == 1)
1892 *pbyPhySgn = 0x0b;
1893 else // long preamble
1894 *pbyPhySgn = 0x03;
1895 break;
1897 case RATE_6M:
1898 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1899 *pbyPhySgn = 0x9B; //1001 1011
1900 } else {//11g, 2.4GHZ
1901 *pbyPhySgn = 0x8B; //1000 1011
1903 break;
1905 case RATE_9M:
1906 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1907 *pbyPhySgn = 0x9F; //1001 1111
1908 } else {//11g, 2.4GHZ
1909 *pbyPhySgn = 0x8F; //1000 1111
1911 break;
1913 case RATE_12M:
1914 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1915 *pbyPhySgn = 0x9A; //1001 1010
1916 } else {//11g, 2.4GHZ
1917 *pbyPhySgn = 0x8A; //1000 1010
1919 break;
1921 case RATE_18M:
1922 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1923 *pbyPhySgn = 0x9E; //1001 1110
1924 } else {//11g, 2.4GHZ
1925 *pbyPhySgn = 0x8E; //1000 1110
1927 break;
1929 case RATE_24M:
1930 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1931 *pbyPhySgn = 0x99; //1001 1001
1932 } else {//11g, 2.4GHZ
1933 *pbyPhySgn = 0x89; //1000 1001
1935 break;
1937 case RATE_36M:
1938 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1939 *pbyPhySgn = 0x9D; //1001 1101
1940 } else {//11g, 2.4GHZ
1941 *pbyPhySgn = 0x8D; //1000 1101
1943 break;
1945 case RATE_48M:
1946 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1947 *pbyPhySgn = 0x98; //1001 1000
1948 } else {//11g, 2.4GHZ
1949 *pbyPhySgn = 0x88; //1000 1000
1951 break;
1953 case RATE_54M:
1954 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1955 *pbyPhySgn = 0x9C; //1001 1100
1956 } else {//11g, 2.4GHZ
1957 *pbyPhySgn = 0x8C; //1000 1100
1959 break;
1961 default:
1962 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
1963 *pbyPhySgn = 0x9C; //1001 1100
1964 } else {//11g, 2.4GHZ
1965 *pbyPhySgn = 0x8C; //1000 1100
1967 break;
1970 if (byPacketType == PK_TYPE_11B) {
1971 *pbyPhySrv = 0x00;
1972 if (bExtBit)
1973 *pbyPhySrv = *pbyPhySrv | 0x80;
1974 *pwPhyLen = (unsigned short)cbUsCount;
1975 } else {
1976 *pbyPhySrv = 0x00;
1977 *pwPhyLen = (unsigned short)cbFrameLength;
1982 * Description: Read a byte from BASEBAND, by embedded programming
1984 * Parameters:
1985 * In:
1986 * dwIoBase - I/O base address
1987 * byBBAddr - address of register in Baseband
1988 * Out:
1989 * pbyData - data read
1991 * Return Value: true if succeeded; false if failed.
1994 bool BBbReadEmbedded(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char *pbyData)
1996 unsigned short ww;
1997 unsigned char byValue;
1999 // BB reg offset
2000 VNSvOutPortB(dwIoBase + MAC_REG_BBREGADR, byBBAddr);
2002 // turn on REGR
2003 MACvRegBitsOn(dwIoBase, MAC_REG_BBREGCTL, BBREGCTL_REGR);
2004 // W_MAX_TIMEOUT is the timeout period
2005 for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
2006 VNSvInPortB(dwIoBase + MAC_REG_BBREGCTL, &byValue);
2007 if (byValue & BBREGCTL_DONE)
2008 break;
2011 // get BB data
2012 VNSvInPortB(dwIoBase + MAC_REG_BBREGDATA, pbyData);
2014 if (ww == W_MAX_TIMEOUT) {
2015 DBG_PORT80(0x30);
2016 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " DBG_PORT80(0x30)\n");
2017 return false;
2019 return true;
2023 * Description: Write a Byte to BASEBAND, by embedded programming
2025 * Parameters:
2026 * In:
2027 * dwIoBase - I/O base address
2028 * byBBAddr - address of register in Baseband
2029 * byData - data to write
2030 * Out:
2031 * none
2033 * Return Value: true if succeeded; false if failed.
2036 bool BBbWriteEmbedded(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byData)
2038 unsigned short ww;
2039 unsigned char byValue;
2041 // BB reg offset
2042 VNSvOutPortB(dwIoBase + MAC_REG_BBREGADR, byBBAddr);
2043 // set BB data
2044 VNSvOutPortB(dwIoBase + MAC_REG_BBREGDATA, byData);
2046 // turn on BBREGCTL_REGW
2047 MACvRegBitsOn(dwIoBase, MAC_REG_BBREGCTL, BBREGCTL_REGW);
2048 // W_MAX_TIMEOUT is the timeout period
2049 for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
2050 VNSvInPortB(dwIoBase + MAC_REG_BBREGCTL, &byValue);
2051 if (byValue & BBREGCTL_DONE)
2052 break;
2055 if (ww == W_MAX_TIMEOUT) {
2056 DBG_PORT80(0x31);
2057 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " DBG_PORT80(0x31)\n");
2058 return false;
2060 return true;
2064 * Description: Test if all bits are set for the Baseband register
2066 * Parameters:
2067 * In:
2068 * dwIoBase - I/O base address
2069 * byBBAddr - address of register in Baseband
2070 * byTestBits - TestBits
2071 * Out:
2072 * none
2074 * Return Value: true if all TestBits are set; false otherwise.
2077 bool BBbIsRegBitsOn(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byTestBits)
2079 unsigned char byOrgData;
2081 BBbReadEmbedded(dwIoBase, byBBAddr, &byOrgData);
2082 return (byOrgData & byTestBits) == byTestBits;
2086 * Description: Test if all bits are clear for the Baseband register
2088 * Parameters:
2089 * In:
2090 * dwIoBase - I/O base address
2091 * byBBAddr - address of register in Baseband
2092 * byTestBits - TestBits
2093 * Out:
2094 * none
2096 * Return Value: true if all TestBits are clear; false otherwise.
2099 bool BBbIsRegBitsOff(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byTestBits)
2101 unsigned char byOrgData;
2103 BBbReadEmbedded(dwIoBase, byBBAddr, &byOrgData);
2104 return (byOrgData & byTestBits) == 0;
2108 * Description: VIA VT3253 Baseband chip init function
2110 * Parameters:
2111 * In:
2112 * dwIoBase - I/O base address
2113 * byRevId - Revision ID
2114 * byRFType - RF type
2115 * Out:
2116 * none
2118 * Return Value: true if succeeded; false if failed.
2122 bool BBbVT3253Init(PSDevice pDevice)
2124 bool bResult = true;
2125 int ii;
2126 unsigned long dwIoBase = pDevice->PortOffset;
2127 unsigned char byRFType = pDevice->byRFType;
2128 unsigned char byLocalID = pDevice->byLocalID;
2130 if (byRFType == RF_RFMD2959) {
2131 if (byLocalID <= REV_ID_VT3253_A1) {
2132 for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++) {
2133 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253InitTab_RFMD[ii][0], byVT3253InitTab_RFMD[ii][1]);
2135 } else {
2136 for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++) {
2137 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_RFMD[ii][0], byVT3253B0_RFMD[ii][1]);
2139 for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++) {
2140 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]);
2142 VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23);
2143 MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0);
2145 pDevice->abyBBVGA[0] = 0x18;
2146 pDevice->abyBBVGA[1] = 0x0A;
2147 pDevice->abyBBVGA[2] = 0x0;
2148 pDevice->abyBBVGA[3] = 0x0;
2149 pDevice->ldBmThreshold[0] = -70;
2150 pDevice->ldBmThreshold[1] = -50;
2151 pDevice->ldBmThreshold[2] = 0;
2152 pDevice->ldBmThreshold[3] = 0;
2153 } else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S)) {
2154 for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) {
2155 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]);
2157 for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
2158 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2160 pDevice->abyBBVGA[0] = 0x1C;
2161 pDevice->abyBBVGA[1] = 0x10;
2162 pDevice->abyBBVGA[2] = 0x0;
2163 pDevice->abyBBVGA[3] = 0x0;
2164 pDevice->ldBmThreshold[0] = -70;
2165 pDevice->ldBmThreshold[1] = -48;
2166 pDevice->ldBmThreshold[2] = 0;
2167 pDevice->ldBmThreshold[3] = 0;
2168 } else if (byRFType == RF_UW2451) {
2169 for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) {
2170 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]);
2172 for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
2173 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2175 VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23);
2176 MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0);
2178 pDevice->abyBBVGA[0] = 0x14;
2179 pDevice->abyBBVGA[1] = 0x0A;
2180 pDevice->abyBBVGA[2] = 0x0;
2181 pDevice->abyBBVGA[3] = 0x0;
2182 pDevice->ldBmThreshold[0] = -60;
2183 pDevice->ldBmThreshold[1] = -50;
2184 pDevice->ldBmThreshold[2] = 0;
2185 pDevice->ldBmThreshold[3] = 0;
2186 } else if (byRFType == RF_UW2452) {
2187 for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) {
2188 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]);
2190 // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2191 //bResult &= BBbWriteEmbedded(dwIoBase,0x09,0x41);
2192 // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2193 //bResult &= BBbWriteEmbedded(dwIoBase,0x0a,0x28);
2194 // Select VC1/VC2, CR215 = 0x02->0x06
2195 bResult &= BBbWriteEmbedded(dwIoBase, 0xd7, 0x06);
2197 //{{RobertYu:20050125, request by Jack
2198 bResult &= BBbWriteEmbedded(dwIoBase, 0x90, 0x20);
2199 bResult &= BBbWriteEmbedded(dwIoBase, 0x97, 0xeb);
2200 //}}
2202 //{{RobertYu:20050221, request by Jack
2203 bResult &= BBbWriteEmbedded(dwIoBase, 0xa6, 0x00);
2204 bResult &= BBbWriteEmbedded(dwIoBase, 0xa8, 0x30);
2205 //}}
2206 bResult &= BBbWriteEmbedded(dwIoBase, 0xb0, 0x58);
2208 for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
2209 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2211 //VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); // RobertYu: 20050104, 20050131 disable PA_Delay
2212 //MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); // RobertYu: 20050104, 20050131 disable PA_Delay
2214 pDevice->abyBBVGA[0] = 0x14;
2215 pDevice->abyBBVGA[1] = 0x0A;
2216 pDevice->abyBBVGA[2] = 0x0;
2217 pDevice->abyBBVGA[3] = 0x0;
2218 pDevice->ldBmThreshold[0] = -60;
2219 pDevice->ldBmThreshold[1] = -50;
2220 pDevice->ldBmThreshold[2] = 0;
2221 pDevice->ldBmThreshold[3] = 0;
2222 //}} RobertYu
2224 } else if (byRFType == RF_VT3226) {
2225 for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) {
2226 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]);
2228 for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
2229 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2231 pDevice->abyBBVGA[0] = 0x1C;
2232 pDevice->abyBBVGA[1] = 0x10;
2233 pDevice->abyBBVGA[2] = 0x0;
2234 pDevice->abyBBVGA[3] = 0x0;
2235 pDevice->ldBmThreshold[0] = -70;
2236 pDevice->ldBmThreshold[1] = -48;
2237 pDevice->ldBmThreshold[2] = 0;
2238 pDevice->ldBmThreshold[3] = 0;
2239 // Fix VT3226 DFC system timing issue
2240 MACvSetRFLE_LatchBase(dwIoBase);
2241 //{{ RobertYu: 20050104
2242 } else if (byRFType == RF_AIROHA7230) {
2243 for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) {
2244 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]);
2247 //{{ RobertYu:20050223, request by JerryChung
2248 // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2249 //bResult &= BBbWriteEmbedded(dwIoBase,0x09,0x41);
2250 // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2251 //bResult &= BBbWriteEmbedded(dwIoBase,0x0a,0x28);
2252 // Select VC1/VC2, CR215 = 0x02->0x06
2253 bResult &= BBbWriteEmbedded(dwIoBase, 0xd7, 0x06);
2254 //}}
2256 for (ii = 0; ii < CB_VT3253B0_AGC; ii++) {
2257 bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2259 pDevice->abyBBVGA[0] = 0x1C;
2260 pDevice->abyBBVGA[1] = 0x10;
2261 pDevice->abyBBVGA[2] = 0x0;
2262 pDevice->abyBBVGA[3] = 0x0;
2263 pDevice->ldBmThreshold[0] = -70;
2264 pDevice->ldBmThreshold[1] = -48;
2265 pDevice->ldBmThreshold[2] = 0;
2266 pDevice->ldBmThreshold[3] = 0;
2267 //}} RobertYu
2268 } else {
2269 // No VGA Table now
2270 pDevice->bUpdateBBVGA = false;
2271 pDevice->abyBBVGA[0] = 0x1C;
2274 if (byLocalID > REV_ID_VT3253_A1) {
2275 BBbWriteEmbedded(dwIoBase, 0x04, 0x7F);
2276 BBbWriteEmbedded(dwIoBase, 0x0D, 0x01);
2279 return bResult;
2283 * Description: Read All Baseband Registers
2285 * Parameters:
2286 * In:
2287 * dwIoBase - I/O base address
2288 * pbyBBRegs - Point to struct that stores Baseband Registers
2289 * Out:
2290 * none
2292 * Return Value: none
2295 void BBvReadAllRegs(unsigned long dwIoBase, unsigned char *pbyBBRegs)
2297 int ii;
2298 unsigned char byBase = 1;
2299 for (ii = 0; ii < BB_MAX_CONTEXT_SIZE; ii++) {
2300 BBbReadEmbedded(dwIoBase, (unsigned char)(ii*byBase), pbyBBRegs);
2301 pbyBBRegs += byBase;
2306 * Description: Turn on BaseBand Loopback mode
2308 * Parameters:
2309 * In:
2310 * dwIoBase - I/O base address
2311 * bCCK - If CCK is set
2312 * Out:
2313 * none
2315 * Return Value: none
2319 void BBvLoopbackOn(PSDevice pDevice)
2321 unsigned char byData;
2322 unsigned long dwIoBase = pDevice->PortOffset;
2324 //CR C9 = 0x00
2325 BBbReadEmbedded(dwIoBase, 0xC9, &pDevice->byBBCRc9);//CR201
2326 BBbWriteEmbedded(dwIoBase, 0xC9, 0);
2327 BBbReadEmbedded(dwIoBase, 0x4D, &pDevice->byBBCR4d);//CR77
2328 BBbWriteEmbedded(dwIoBase, 0x4D, 0x90);
2330 //CR 88 = 0x02(CCK), 0x03(OFDM)
2331 BBbReadEmbedded(dwIoBase, 0x88, &pDevice->byBBCR88);//CR136
2333 if (pDevice->uConnectionRate <= RATE_11M) { //CCK
2334 // Enable internal digital loopback: CR33 |= 0000 0001
2335 BBbReadEmbedded(dwIoBase, 0x21, &byData);//CR33
2336 BBbWriteEmbedded(dwIoBase, 0x21, (unsigned char)(byData | 0x01));//CR33
2337 // CR154 = 0x00
2338 BBbWriteEmbedded(dwIoBase, 0x9A, 0); //CR154
2340 BBbWriteEmbedded(dwIoBase, 0x88, 0x02);//CR239
2341 } else { //OFDM
2342 // Enable internal digital loopback:CR154 |= 0000 0001
2343 BBbReadEmbedded(dwIoBase, 0x9A, &byData);//CR154
2344 BBbWriteEmbedded(dwIoBase, 0x9A, (unsigned char)(byData | 0x01));//CR154
2345 // CR33 = 0x00
2346 BBbWriteEmbedded(dwIoBase, 0x21, 0); //CR33
2348 BBbWriteEmbedded(dwIoBase, 0x88, 0x03);//CR239
2351 //CR14 = 0x00
2352 BBbWriteEmbedded(dwIoBase, 0x0E, 0);//CR14
2354 // Disable TX_IQUN
2355 BBbReadEmbedded(pDevice->PortOffset, 0x09, &pDevice->byBBCR09);
2356 BBbWriteEmbedded(pDevice->PortOffset, 0x09, (unsigned char)(pDevice->byBBCR09 & 0xDE));
2360 * Description: Turn off BaseBand Loopback mode
2362 * Parameters:
2363 * In:
2364 * pDevice - Device Structure
2366 * Out:
2367 * none
2369 * Return Value: none
2372 void BBvLoopbackOff(PSDevice pDevice)
2374 unsigned char byData;
2375 unsigned long dwIoBase = pDevice->PortOffset;
2377 BBbWriteEmbedded(dwIoBase, 0xC9, pDevice->byBBCRc9);//CR201
2378 BBbWriteEmbedded(dwIoBase, 0x88, pDevice->byBBCR88);//CR136
2379 BBbWriteEmbedded(dwIoBase, 0x09, pDevice->byBBCR09);//CR136
2380 BBbWriteEmbedded(dwIoBase, 0x4D, pDevice->byBBCR4d);//CR77
2382 if (pDevice->uConnectionRate <= RATE_11M) { // CCK
2383 // Set the CR33 Bit2 to disable internal Loopback.
2384 BBbReadEmbedded(dwIoBase, 0x21, &byData);//CR33
2385 BBbWriteEmbedded(dwIoBase, 0x21, (unsigned char)(byData & 0xFE));//CR33
2386 } else { // OFDM
2387 BBbReadEmbedded(dwIoBase, 0x9A, &byData);//CR154
2388 BBbWriteEmbedded(dwIoBase, 0x9A, (unsigned char)(byData & 0xFE));//CR154
2390 BBbReadEmbedded(dwIoBase, 0x0E, &byData);//CR14
2391 BBbWriteEmbedded(dwIoBase, 0x0E, (unsigned char)(byData | 0x80));//CR14
2395 * Description: Set ShortSlotTime mode
2397 * Parameters:
2398 * In:
2399 * pDevice - Device Structure
2400 * Out:
2401 * none
2403 * Return Value: none
2406 void
2407 BBvSetShortSlotTime(PSDevice pDevice)
2409 unsigned char byBBRxConf = 0;
2410 unsigned char byBBVGA = 0;
2412 BBbReadEmbedded(pDevice->PortOffset, 0x0A, &byBBRxConf);//CR10
2414 if (pDevice->bShortSlotTime) {
2415 byBBRxConf &= 0xDF;//1101 1111
2416 } else {
2417 byBBRxConf |= 0x20;//0010 0000
2420 // patch for 3253B0 Baseband with Cardbus module
2421 BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byBBVGA);
2422 if (byBBVGA == pDevice->abyBBVGA[0]) {
2423 byBBRxConf |= 0x20;//0010 0000
2426 BBbWriteEmbedded(pDevice->PortOffset, 0x0A, byBBRxConf);//CR10
2429 void BBvSetVGAGainOffset(PSDevice pDevice, unsigned char byData)
2431 unsigned char byBBRxConf = 0;
2433 BBbWriteEmbedded(pDevice->PortOffset, 0xE7, byData);
2435 BBbReadEmbedded(pDevice->PortOffset, 0x0A, &byBBRxConf);//CR10
2436 // patch for 3253B0 Baseband with Cardbus module
2437 if (byData == pDevice->abyBBVGA[0]) {
2438 byBBRxConf |= 0x20;//0010 0000
2439 } else if (pDevice->bShortSlotTime) {
2440 byBBRxConf &= 0xDF;//1101 1111
2441 } else {
2442 byBBRxConf |= 0x20;//0010 0000
2444 pDevice->byBBVGACurrent = byData;
2445 BBbWriteEmbedded(pDevice->PortOffset, 0x0A, byBBRxConf);//CR10
2449 * Description: Baseband SoftwareReset
2451 * Parameters:
2452 * In:
2453 * dwIoBase - I/O base address
2454 * Out:
2455 * none
2457 * Return Value: none
2460 void
2461 BBvSoftwareReset(unsigned long dwIoBase)
2463 BBbWriteEmbedded(dwIoBase, 0x50, 0x40);
2464 BBbWriteEmbedded(dwIoBase, 0x50, 0);
2465 BBbWriteEmbedded(dwIoBase, 0x9C, 0x01);
2466 BBbWriteEmbedded(dwIoBase, 0x9C, 0);
2470 * Description: Baseband Power Save Mode ON
2472 * Parameters:
2473 * In:
2474 * dwIoBase - I/O base address
2475 * Out:
2476 * none
2478 * Return Value: none
2481 void
2482 BBvPowerSaveModeON(unsigned long dwIoBase)
2484 unsigned char byOrgData;
2486 BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData);
2487 byOrgData |= BIT0;
2488 BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData);
2492 * Description: Baseband Power Save Mode OFF
2494 * Parameters:
2495 * In:
2496 * dwIoBase - I/O base address
2497 * Out:
2498 * none
2500 * Return Value: none
2503 void
2504 BBvPowerSaveModeOFF(unsigned long dwIoBase)
2506 unsigned char byOrgData;
2508 BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData);
2509 byOrgData &= ~(BIT0);
2510 BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData);
2514 * Description: Set Tx Antenna mode
2516 * Parameters:
2517 * In:
2518 * pDevice - Device Structure
2519 * byAntennaMode - Antenna Mode
2520 * Out:
2521 * none
2523 * Return Value: none
2527 void
2528 BBvSetTxAntennaMode(unsigned long dwIoBase, unsigned char byAntennaMode)
2530 unsigned char byBBTxConf;
2532 BBbReadEmbedded(dwIoBase, 0x09, &byBBTxConf);//CR09
2533 if (byAntennaMode == ANT_DIVERSITY) {
2534 // bit 1 is diversity
2535 byBBTxConf |= 0x02;
2536 } else if (byAntennaMode == ANT_A) {
2537 // bit 2 is ANTSEL
2538 byBBTxConf &= 0xF9; // 1111 1001
2539 } else if (byAntennaMode == ANT_B) {
2540 byBBTxConf &= 0xFD; // 1111 1101
2541 byBBTxConf |= 0x04;
2543 BBbWriteEmbedded(dwIoBase, 0x09, byBBTxConf);//CR09
2547 * Description: Set Rx Antenna mode
2549 * Parameters:
2550 * In:
2551 * pDevice - Device Structure
2552 * byAntennaMode - Antenna Mode
2553 * Out:
2554 * none
2556 * Return Value: none
2560 void
2561 BBvSetRxAntennaMode(unsigned long dwIoBase, unsigned char byAntennaMode)
2563 unsigned char byBBRxConf;
2565 BBbReadEmbedded(dwIoBase, 0x0A, &byBBRxConf);//CR10
2566 if (byAntennaMode == ANT_DIVERSITY) {
2567 byBBRxConf |= 0x01;
2569 } else if (byAntennaMode == ANT_A) {
2570 byBBRxConf &= 0xFC; // 1111 1100
2571 } else if (byAntennaMode == ANT_B) {
2572 byBBRxConf &= 0xFE; // 1111 1110
2573 byBBRxConf |= 0x02;
2575 BBbWriteEmbedded(dwIoBase, 0x0A, byBBRxConf);//CR10
2579 * Description: BBvSetDeepSleep
2581 * Parameters:
2582 * In:
2583 * pDevice - Device Structure
2584 * Out:
2585 * none
2587 * Return Value: none
2590 void
2591 BBvSetDeepSleep(unsigned long dwIoBase, unsigned char byLocalID)
2593 BBbWriteEmbedded(dwIoBase, 0x0C, 0x17);//CR12
2594 BBbWriteEmbedded(dwIoBase, 0x0D, 0xB9);//CR13
2597 void
2598 BBvExitDeepSleep(unsigned long dwIoBase, unsigned char byLocalID)
2600 BBbWriteEmbedded(dwIoBase, 0x0C, 0x00);//CR12
2601 BBbWriteEmbedded(dwIoBase, 0x0D, 0x01);//CR13
2604 static
2605 unsigned long
2606 s_ulGetRatio(PSDevice pDevice)
2608 unsigned long ulRatio = 0;
2609 unsigned long ulMaxPacket;
2610 unsigned long ulPacketNum;
2612 //This is a thousand-ratio
2613 ulMaxPacket = pDevice->uNumSQ3[RATE_54M];
2614 if (pDevice->uNumSQ3[RATE_54M] != 0) {
2615 ulPacketNum = pDevice->uNumSQ3[RATE_54M];
2616 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2617 //ulRatio = (pDevice->uNumSQ3[RATE_54M] * 1000 / pDevice->uDiversityCnt);
2618 ulRatio += TOP_RATE_54M;
2620 if (pDevice->uNumSQ3[RATE_48M] > ulMaxPacket) {
2621 ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M];
2622 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2623 //ulRatio = (pDevice->uNumSQ3[RATE_48M] * 1000 / pDevice->uDiversityCnt);
2624 ulRatio += TOP_RATE_48M;
2625 ulMaxPacket = pDevice->uNumSQ3[RATE_48M];
2627 if (pDevice->uNumSQ3[RATE_36M] > ulMaxPacket) {
2628 ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
2629 pDevice->uNumSQ3[RATE_36M];
2630 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2631 //ulRatio = (pDevice->uNumSQ3[RATE_36M] * 1000 / pDevice->uDiversityCnt);
2632 ulRatio += TOP_RATE_36M;
2633 ulMaxPacket = pDevice->uNumSQ3[RATE_36M];
2635 if (pDevice->uNumSQ3[RATE_24M] > ulMaxPacket) {
2636 ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
2637 pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M];
2638 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2639 //ulRatio = (pDevice->uNumSQ3[RATE_24M] * 1000 / pDevice->uDiversityCnt);
2640 ulRatio += TOP_RATE_24M;
2641 ulMaxPacket = pDevice->uNumSQ3[RATE_24M];
2643 if (pDevice->uNumSQ3[RATE_18M] > ulMaxPacket) {
2644 ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
2645 pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] +
2646 pDevice->uNumSQ3[RATE_18M];
2647 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2648 //ulRatio = (pDevice->uNumSQ3[RATE_18M] * 1000 / pDevice->uDiversityCnt);
2649 ulRatio += TOP_RATE_18M;
2650 ulMaxPacket = pDevice->uNumSQ3[RATE_18M];
2652 if (pDevice->uNumSQ3[RATE_12M] > ulMaxPacket) {
2653 ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] +
2654 pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] +
2655 pDevice->uNumSQ3[RATE_18M] + pDevice->uNumSQ3[RATE_12M];
2656 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2657 //ulRatio = (pDevice->uNumSQ3[RATE_12M] * 1000 / pDevice->uDiversityCnt);
2658 ulRatio += TOP_RATE_12M;
2659 ulMaxPacket = pDevice->uNumSQ3[RATE_12M];
2661 if (pDevice->uNumSQ3[RATE_11M] > ulMaxPacket) {
2662 ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
2663 pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] -
2664 pDevice->uNumSQ3[RATE_6M] - pDevice->uNumSQ3[RATE_9M];
2665 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2666 //ulRatio = (pDevice->uNumSQ3[RATE_11M] * 1000 / pDevice->uDiversityCnt);
2667 ulRatio += TOP_RATE_11M;
2668 ulMaxPacket = pDevice->uNumSQ3[RATE_11M];
2670 if (pDevice->uNumSQ3[RATE_9M] > ulMaxPacket) {
2671 ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
2672 pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] -
2673 pDevice->uNumSQ3[RATE_6M];
2674 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2675 //ulRatio = (pDevice->uNumSQ3[RATE_9M] * 1000 / pDevice->uDiversityCnt);
2676 ulRatio += TOP_RATE_9M;
2677 ulMaxPacket = pDevice->uNumSQ3[RATE_9M];
2679 if (pDevice->uNumSQ3[RATE_6M] > ulMaxPacket) {
2680 ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
2681 pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M];
2682 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2683 //ulRatio = (pDevice->uNumSQ3[RATE_6M] * 1000 / pDevice->uDiversityCnt);
2684 ulRatio += TOP_RATE_6M;
2685 ulMaxPacket = pDevice->uNumSQ3[RATE_6M];
2687 if (pDevice->uNumSQ3[RATE_5M] > ulMaxPacket) {
2688 ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] -
2689 pDevice->uNumSQ3[RATE_2M];
2690 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2691 //ulRatio = (pDevice->uNumSQ3[RATE_5M] * 1000 / pDevice->uDiversityCnt);
2692 ulRatio += TOP_RATE_55M;
2693 ulMaxPacket = pDevice->uNumSQ3[RATE_5M];
2695 if (pDevice->uNumSQ3[RATE_2M] > ulMaxPacket) {
2696 ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M];
2697 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2698 //ulRatio = (pDevice->uNumSQ3[RATE_2M] * 1000 / pDevice->uDiversityCnt);
2699 ulRatio += TOP_RATE_2M;
2700 ulMaxPacket = pDevice->uNumSQ3[RATE_2M];
2702 if (pDevice->uNumSQ3[RATE_1M] > ulMaxPacket) {
2703 ulPacketNum = pDevice->uDiversityCnt;
2704 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
2705 //ulRatio = (pDevice->uNumSQ3[RATE_1M] * 1000 / pDevice->uDiversityCnt);
2706 ulRatio += TOP_RATE_1M;
2709 return ulRatio;
2712 void
2713 BBvClearAntDivSQ3Value(PSDevice pDevice)
2715 unsigned int ii;
2717 pDevice->uDiversityCnt = 0;
2718 for (ii = 0; ii < MAX_RATE; ii++) {
2719 pDevice->uNumSQ3[ii] = 0;
2724 * Description: Antenna Diversity
2726 * Parameters:
2727 * In:
2728 * pDevice - Device Structure
2729 * byRSR - RSR from received packet
2730 * bySQ3 - SQ3 value from received packet
2731 * Out:
2732 * none
2734 * Return Value: none
2738 void
2739 BBvAntennaDiversity(PSDevice pDevice, unsigned char byRxRate, unsigned char bySQ3)
2741 if ((byRxRate >= MAX_RATE) || (pDevice->wAntDiversityMaxRate >= MAX_RATE)) {
2742 return;
2744 pDevice->uDiversityCnt++;
2745 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
2747 pDevice->uNumSQ3[byRxRate]++;
2749 if (pDevice->byAntennaState == 0) {
2750 if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
2751 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ulDiversityNValue=[%d],54M-[%d]\n",
2752 (int)pDevice->ulDiversityNValue, (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate]);
2754 if (pDevice->uNumSQ3[pDevice->wAntDiversityMaxRate] < pDevice->uDiversityCnt/2) {
2755 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
2756 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "SQ3_State0, rate = [%08x]\n", (int)pDevice->ulRatio_State0);
2758 if (pDevice->byTMax == 0)
2759 return;
2760 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "1.[%08x], uNumSQ3[%d]=%d, %d\n",
2761 (int)pDevice->ulRatio_State0, (int)pDevice->wAntDiversityMaxRate,
2762 (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], (int)pDevice->uDiversityCnt);
2764 s_vChangeAntenna(pDevice);
2765 pDevice->byAntennaState = 1;
2766 del_timer(&pDevice->TimerSQ3Tmax3);
2767 del_timer(&pDevice->TimerSQ3Tmax2);
2768 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
2769 add_timer(&pDevice->TimerSQ3Tmax1);
2771 } else {
2772 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
2773 add_timer(&pDevice->TimerSQ3Tmax3);
2775 BBvClearAntDivSQ3Value(pDevice);
2778 } else { //byAntennaState == 1
2780 if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
2781 del_timer(&pDevice->TimerSQ3Tmax1);
2783 pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
2784 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "RX:SQ3_State1, rate0 = %08x,rate1 = %08x\n",
2785 (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1);
2787 if (pDevice->ulRatio_State1 < pDevice->ulRatio_State0) {
2788 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "2.[%08x][%08x], uNumSQ3[%d]=%d, %d\n",
2789 (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1,
2790 (int)pDevice->wAntDiversityMaxRate,
2791 (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], (int)pDevice->uDiversityCnt);
2793 s_vChangeAntenna(pDevice);
2794 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
2795 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
2796 add_timer(&pDevice->TimerSQ3Tmax3);
2797 add_timer(&pDevice->TimerSQ3Tmax2);
2799 pDevice->byAntennaState = 0;
2800 BBvClearAntDivSQ3Value(pDevice);
2802 } //byAntennaState
2807 * Description:
2808 * Timer for SQ3 antenna diversity
2810 * Parameters:
2811 * In:
2812 * Out:
2813 * none
2815 * Return Value: none
2819 void
2820 TimerSQ3CallBack(
2821 void *hDeviceContext
2824 PSDevice pDevice = (PSDevice)hDeviceContext;
2826 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "TimerSQ3CallBack...");
2827 spin_lock_irq(&pDevice->lock);
2829 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "3.[%08x][%08x], %d\n", (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1, (int)pDevice->uDiversityCnt);
2831 s_vChangeAntenna(pDevice);
2832 pDevice->byAntennaState = 0;
2833 BBvClearAntDivSQ3Value(pDevice);
2835 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
2836 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
2837 add_timer(&pDevice->TimerSQ3Tmax3);
2838 add_timer(&pDevice->TimerSQ3Tmax2);
2840 spin_unlock_irq(&pDevice->lock);
2841 return;
2846 * Description:
2847 * Timer for SQ3 antenna diversity
2849 * Parameters:
2850 * In:
2851 * pvSysSpec1
2852 * hDeviceContext - Pointer to the adapter
2853 * pvSysSpec2
2854 * pvSysSpec3
2855 * Out:
2856 * none
2858 * Return Value: none
2862 void
2863 TimerState1CallBack(
2864 void *hDeviceContext
2867 PSDevice pDevice = (PSDevice)hDeviceContext;
2869 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "TimerState1CallBack...");
2871 spin_lock_irq(&pDevice->lock);
2872 if (pDevice->uDiversityCnt < pDevice->ulDiversityMValue/100) {
2873 s_vChangeAntenna(pDevice);
2874 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
2875 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
2876 add_timer(&pDevice->TimerSQ3Tmax3);
2877 add_timer(&pDevice->TimerSQ3Tmax2);
2878 } else {
2879 pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
2880 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "SQ3_State1, rate0 = %08x,rate1 = %08x\n",
2881 (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1);
2883 if (pDevice->ulRatio_State1 < pDevice->ulRatio_State0) {
2884 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "2.[%08x][%08x], uNumSQ3[%d]=%d, %d\n",
2885 (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1,
2886 (int)pDevice->wAntDiversityMaxRate,
2887 (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], (int)pDevice->uDiversityCnt);
2889 s_vChangeAntenna(pDevice);
2891 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
2892 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
2893 add_timer(&pDevice->TimerSQ3Tmax3);
2894 add_timer(&pDevice->TimerSQ3Tmax2);
2897 pDevice->byAntennaState = 0;
2898 BBvClearAntDivSQ3Value(pDevice);
2899 spin_unlock_irq(&pDevice->lock);
2901 return;