1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include "mac.h"
26#include "baseband.h"
27#include "rf.h"
28#include "usbpipe.h"
29
30static u8 vnt_vt3184_agc[] = {
31 0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x06, 0x06,
32 0x08, 0x08, 0x0a, 0x0a, 0x0c, 0x0c, 0x0e, 0x0e,
33 0x10, 0x10, 0x12, 0x12, 0x14, 0x14, 0x16, 0x16,
34 0x18, 0x18, 0x1a, 0x1a, 0x1c, 0x1c, 0x1e, 0x1e,
35 0x20, 0x20, 0x22, 0x22, 0x24, 0x24, 0x26, 0x26,
36 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c, 0x2e, 0x2e,
37 0x30, 0x30, 0x32, 0x32, 0x34, 0x34, 0x36, 0x36,
38 0x38, 0x38, 0x3a, 0x3a, 0x3c, 0x3c, 0x3e, 0x3e
39};
40
41static u8 vnt_vt3184_al2230[] = {
42 0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
43 0x70, 0x45, 0x2a, 0x76, 0x00, 0x00, 0x80, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x8e, 0x0a, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00,
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x0c,
48 0x26, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa,
49 0xff, 0xff, 0x79, 0x00, 0x00, 0x0b, 0x48, 0x04,
50 0x00, 0x08, 0x00, 0x08, 0x08, 0x14, 0x05, 0x09,
51 0x00, 0x00, 0x00, 0x00, 0x09, 0x73, 0x00, 0xc5,
52 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 0x00, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0xe4, 0x80, 0x00, 0x00, 0x00, 0x00, 0x98, 0x0a,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x8c, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x08, 0x00, 0x1f, 0xb7, 0x88, 0x47, 0xaa, 0x00,
60 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
63 0x18, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x18,
64 0x38, 0x30, 0x00, 0x00, 0xff, 0x0f, 0xe4, 0xe2,
65 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00,
66 0x18, 0x20, 0x07, 0x18, 0xff, 0xff, 0x0e, 0x0a,
67 0x0e, 0x00, 0x82, 0xa7, 0x3c, 0x10, 0x30, 0x05,
68 0x40, 0x12, 0x00, 0x00, 0x10, 0x28, 0x80, 0x2a,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70 0x00, 0xf3, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12,
71 0x00, 0xf4, 0x00, 0xff, 0x79, 0x20, 0x30, 0x05,
72 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
74};
75
76
77static u8 vnt_vt3184_vt3226d0[] = {
78 0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
79 0x70, 0x45, 0x2a, 0x76, 0x00, 0x00, 0x80, 0x00,
80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81 0x00, 0x00, 0x00, 0x8e, 0x0a, 0x00, 0x00, 0x00,
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00,
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x0c,
84 0x26, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa,
85 0xff, 0xff, 0x79, 0x00, 0x00, 0x0b, 0x48, 0x04,
86 0x00, 0x08, 0x00, 0x08, 0x08, 0x14, 0x05, 0x09,
87 0x00, 0x00, 0x00, 0x00, 0x09, 0x73, 0x00, 0xc5,
88 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 0x00, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
90 0xe4, 0x80, 0x00, 0x00, 0x00, 0x00, 0x98, 0x0a,
91 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00,
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
94 0x8c, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
95 0x08, 0x00, 0x1f, 0xb7, 0x88, 0x47, 0xaa, 0x00,
96 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xeb,
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
99 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
100 0x38, 0x30, 0x00, 0x00, 0xff, 0x0f, 0xe4, 0xe2,
101 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00,
102 0x18, 0x20, 0x07, 0x18, 0xff, 0xff, 0x10, 0x0a,
103 0x0e, 0x00, 0x84, 0xa7, 0x3c, 0x10, 0x24, 0x05,
104 0x40, 0x12, 0x00, 0x00, 0x10, 0x28, 0x80, 0x2a,
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106 0x00, 0xf3, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10,
107 0x00, 0xf4, 0x00, 0xff, 0x79, 0x20, 0x30, 0x08,
108 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
110};
111
112static const u16 vnt_frame_time[MAX_RATE] = {
113 10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
114};
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
131 unsigned int frame_length, u16 tx_rate)
132{
133 unsigned int frame_time;
134 unsigned int preamble;
135 unsigned int tmp;
136 unsigned int rate = 0;
137
138 if (tx_rate > RATE_54M)
139 return 0;
140
141 rate = (unsigned int)vnt_frame_time[tx_rate];
142
143 if (tx_rate <= 3) {
144 if (preamble_type == 1)
145 preamble = 96;
146 else
147 preamble = 192;
148
149 frame_time = (frame_length * 80) / rate;
150 tmp = (frame_time * rate) / 80;
151
152 if (frame_length != tmp)
153 frame_time++;
154
155 return preamble + frame_time;
156 }
157 frame_time = (frame_length * 8 + 22) / rate;
158 tmp = ((frame_time * rate) - 22) / 8;
159
160 if (frame_length != tmp)
161 frame_time++;
162
163 frame_time = frame_time * 4;
164
165 if (pkt_type != PK_TYPE_11A)
166 frame_time += 6;
167 return 20 + frame_time;
168}
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
188 u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy)
189{
190 u32 bit_count;
191 u32 count = 0;
192 u32 tmp;
193 int ext_bit;
194 u8 preamble_type = priv->preamble_type;
195
196 bit_count = frame_length * 8;
197 ext_bit = false;
198
199 switch (tx_rate) {
200 case RATE_1M:
201 count = bit_count;
202
203 phy->signal = 0x00;
204
205 break;
206 case RATE_2M:
207 count = bit_count / 2;
208
209 if (preamble_type == 1)
210 phy->signal = 0x09;
211 else
212 phy->signal = 0x01;
213
214 break;
215 case RATE_5M:
216 count = (bit_count * 10) / 55;
217 tmp = (count * 55) / 10;
218
219 if (tmp != bit_count)
220 count++;
221
222 if (preamble_type == 1)
223 phy->signal = 0x0a;
224 else
225 phy->signal = 0x02;
226
227 break;
228 case RATE_11M:
229 count = bit_count / 11;
230 tmp = count * 11;
231
232 if (tmp != bit_count) {
233 count++;
234
235 if ((bit_count - tmp) <= 3)
236 ext_bit = true;
237 }
238
239 if (preamble_type == 1)
240 phy->signal = 0x0b;
241 else
242 phy->signal = 0x03;
243
244 break;
245 case RATE_6M:
246 if (pkt_type == PK_TYPE_11A)
247 phy->signal = 0x9b;
248 else
249 phy->signal = 0x8b;
250
251 break;
252 case RATE_9M:
253 if (pkt_type == PK_TYPE_11A)
254 phy->signal = 0x9f;
255 else
256 phy->signal = 0x8f;
257
258 break;
259 case RATE_12M:
260 if (pkt_type == PK_TYPE_11A)
261 phy->signal = 0x9a;
262 else
263 phy->signal = 0x8a;
264
265 break;
266 case RATE_18M:
267 if (pkt_type == PK_TYPE_11A)
268 phy->signal = 0x9e;
269 else
270 phy->signal = 0x8e;
271
272 break;
273 case RATE_24M:
274 if (pkt_type == PK_TYPE_11A)
275 phy->signal = 0x99;
276 else
277 phy->signal = 0x89;
278
279 break;
280 case RATE_36M:
281 if (pkt_type == PK_TYPE_11A)
282 phy->signal = 0x9d;
283 else
284 phy->signal = 0x8d;
285
286 break;
287 case RATE_48M:
288 if (pkt_type == PK_TYPE_11A)
289 phy->signal = 0x98;
290 else
291 phy->signal = 0x88;
292
293 break;
294 case RATE_54M:
295 if (pkt_type == PK_TYPE_11A)
296 phy->signal = 0x9c;
297 else
298 phy->signal = 0x8c;
299 break;
300 default:
301 if (pkt_type == PK_TYPE_11A)
302 phy->signal = 0x9c;
303 else
304 phy->signal = 0x8c;
305 break;
306 }
307
308 if (pkt_type == PK_TYPE_11B) {
309 phy->service = 0x00;
310 if (ext_bit)
311 phy->service |= 0x80;
312 phy->len = cpu_to_le16((u16)count);
313 } else {
314 phy->service = 0x00;
315 phy->len = cpu_to_le16((u16)frame_length);
316 }
317}
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
333{
334 switch (antenna_mode) {
335 case ANT_TXA:
336 case ANT_TXB:
337 break;
338 case ANT_RXA:
339 priv->bb_rx_conf &= 0xFC;
340 break;
341 case ANT_RXB:
342 priv->bb_rx_conf &= 0xFE;
343 priv->bb_rx_conf |= 0x02;
344 break;
345 }
346
347 vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD,
348 (u16)antenna_mode, 0, 0, NULL);
349}
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365int vnt_vt3184_init(struct vnt_private *priv)
366{
367 int status;
368 u16 length;
369 u8 *addr;
370 u8 *agc;
371 u16 length_agc;
372 u8 array[256];
373 u8 data;
374
375 status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
376 MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE,
377 priv->eeprom);
378 if (status != STATUS_SUCCESS)
379 return false;
380
381 priv->rf_type = priv->eeprom[EEP_OFS_RFTYPE];
382
383 dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->rf_type);
384
385 if ((priv->rf_type == RF_AL2230) ||
386 (priv->rf_type == RF_AL2230S)) {
387 priv->bb_rx_conf = vnt_vt3184_al2230[10];
388 length = sizeof(vnt_vt3184_al2230);
389 addr = vnt_vt3184_al2230;
390 agc = vnt_vt3184_agc;
391 length_agc = sizeof(vnt_vt3184_agc);
392
393 priv->bb_vga[0] = 0x1C;
394 priv->bb_vga[1] = 0x10;
395 priv->bb_vga[2] = 0x0;
396 priv->bb_vga[3] = 0x0;
397
398 } else if (priv->rf_type == RF_AIROHA7230) {
399 priv->bb_rx_conf = vnt_vt3184_al2230[10];
400 length = sizeof(vnt_vt3184_al2230);
401 addr = vnt_vt3184_al2230;
402 agc = vnt_vt3184_agc;
403 length_agc = sizeof(vnt_vt3184_agc);
404
405 addr[0xd7] = 0x06;
406
407 priv->bb_vga[0] = 0x1c;
408 priv->bb_vga[1] = 0x10;
409 priv->bb_vga[2] = 0x0;
410 priv->bb_vga[3] = 0x0;
411
412 } else if ((priv->rf_type == RF_VT3226) ||
413 (priv->rf_type == RF_VT3226D0)) {
414 priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
415 length = sizeof(vnt_vt3184_vt3226d0);
416 addr = vnt_vt3184_vt3226d0;
417 agc = vnt_vt3184_agc;
418 length_agc = sizeof(vnt_vt3184_agc);
419
420 priv->bb_vga[0] = 0x20;
421 priv->bb_vga[1] = 0x10;
422 priv->bb_vga[2] = 0x0;
423 priv->bb_vga[3] = 0x0;
424
425
426 vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
427 SOFTPWRCTL_RFLEOPT);
428 } else if (priv->rf_type == RF_VT3342A0) {
429 priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
430 length = sizeof(vnt_vt3184_vt3226d0);
431 addr = vnt_vt3184_vt3226d0;
432 agc = vnt_vt3184_agc;
433 length_agc = sizeof(vnt_vt3184_agc);
434
435 priv->bb_vga[0] = 0x20;
436 priv->bb_vga[1] = 0x10;
437 priv->bb_vga[2] = 0x0;
438 priv->bb_vga[3] = 0x0;
439
440
441 vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
442 SOFTPWRCTL_RFLEOPT);
443 } else {
444 return true;
445 }
446
447 memcpy(array, addr, length);
448
449 vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
450 MESSAGE_REQUEST_BBREG, length, array);
451
452 memcpy(array, agc, length_agc);
453
454 vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
455 MESSAGE_REQUEST_BBAGC, length_agc, array);
456
457 if ((priv->rf_type == RF_VT3226) ||
458 (priv->rf_type == RF_VT3342A0)) {
459 vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
460 MAC_REG_ITRTMSET, 0x23);
461 vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
462 } else if (priv->rf_type == RF_VT3226D0) {
463 vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
464 MAC_REG_ITRTMSET, 0x11);
465 vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
466 }
467
468 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f);
469 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
470
471 vnt_rf_table_download(priv);
472
473
474 vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4,
475 MESSAGE_REQUEST_MEM, sizeof(data), &data);
476
477 data |= 0x2;
478
479 vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4,
480 MESSAGE_REQUEST_MEM, sizeof(data), &data);
481
482 return true;
483}
484
485
486
487
488
489
490
491
492
493
494
495
496
497void vnt_set_short_slot_time(struct vnt_private *priv)
498{
499 u8 bb_vga = 0;
500
501 if (priv->short_slot_time)
502 priv->bb_rx_conf &= 0xdf;
503 else
504 priv->bb_rx_conf |= 0x20;
505
506 vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga);
507
508 if (bb_vga == priv->bb_vga[0])
509 priv->bb_rx_conf |= 0x20;
510
511 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
512}
513
514void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
515{
516 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data);
517
518
519 if (priv->short_slot_time)
520 priv->bb_rx_conf &= 0xdf;
521 else
522 priv->bb_rx_conf |= 0x20;
523
524 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
525}
526
527
528
529
530
531
532
533
534
535
536
537
538
539void vnt_set_deep_sleep(struct vnt_private *priv)
540{
541 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);
542 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);
543}
544
545void vnt_exit_deep_sleep(struct vnt_private *priv)
546{
547 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);
548 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
549}
550
551void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
552{
553 u8 cr_201 = 0x0, cr_206 = 0x0;
554 u8 ed_inx = priv->bb_pre_ed_index;
555
556 switch (priv->rf_type) {
557 case RF_AL2230:
558 case RF_AL2230S:
559 case RF_AIROHA7230:
560 if (scanning) {
561 ed_inx = 0;
562 cr_206 = 0x30;
563 break;
564 }
565
566 if (priv->bb_pre_ed_rssi <= 45) {
567 ed_inx = 20;
568 cr_201 = 0xff;
569 } else if (priv->bb_pre_ed_rssi <= 46) {
570 ed_inx = 19;
571 cr_201 = 0x1a;
572 } else if (priv->bb_pre_ed_rssi <= 47) {
573 ed_inx = 18;
574 cr_201 = 0x15;
575 } else if (priv->bb_pre_ed_rssi <= 49) {
576 ed_inx = 17;
577 cr_201 = 0xe;
578 } else if (priv->bb_pre_ed_rssi <= 51) {
579 ed_inx = 16;
580 cr_201 = 0x9;
581 } else if (priv->bb_pre_ed_rssi <= 53) {
582 ed_inx = 15;
583 cr_201 = 0x6;
584 } else if (priv->bb_pre_ed_rssi <= 55) {
585 ed_inx = 14;
586 cr_201 = 0x3;
587 } else if (priv->bb_pre_ed_rssi <= 56) {
588 ed_inx = 13;
589 cr_201 = 0x2;
590 cr_206 = 0xa0;
591 } else if (priv->bb_pre_ed_rssi <= 57) {
592 ed_inx = 12;
593 cr_201 = 0x2;
594 cr_206 = 0x20;
595 } else if (priv->bb_pre_ed_rssi <= 58) {
596 ed_inx = 11;
597 cr_201 = 0x1;
598 cr_206 = 0xa0;
599 } else if (priv->bb_pre_ed_rssi <= 59) {
600 ed_inx = 10;
601 cr_201 = 0x1;
602 cr_206 = 0x54;
603 } else if (priv->bb_pre_ed_rssi <= 60) {
604 ed_inx = 9;
605 cr_201 = 0x1;
606 cr_206 = 0x18;
607 } else if (priv->bb_pre_ed_rssi <= 61) {
608 ed_inx = 8;
609 cr_206 = 0xe3;
610 } else if (priv->bb_pre_ed_rssi <= 62) {
611 ed_inx = 7;
612 cr_206 = 0xb9;
613 } else if (priv->bb_pre_ed_rssi <= 63) {
614 ed_inx = 6;
615 cr_206 = 0x93;
616 } else if (priv->bb_pre_ed_rssi <= 64) {
617 ed_inx = 5;
618 cr_206 = 0x79;
619 } else if (priv->bb_pre_ed_rssi <= 65) {
620 ed_inx = 4;
621 cr_206 = 0x62;
622 } else if (priv->bb_pre_ed_rssi <= 66) {
623 ed_inx = 3;
624 cr_206 = 0x51;
625 } else if (priv->bb_pre_ed_rssi <= 67) {
626 ed_inx = 2;
627 cr_206 = 0x43;
628 } else if (priv->bb_pre_ed_rssi <= 68) {
629 ed_inx = 1;
630 cr_206 = 0x36;
631 } else {
632 ed_inx = 0;
633 cr_206 = 0x30;
634 }
635 break;
636
637 case RF_VT3226:
638 case RF_VT3226D0:
639 if (scanning) {
640 ed_inx = 0;
641 cr_206 = 0x24;
642 break;
643 }
644
645 if (priv->bb_pre_ed_rssi <= 41) {
646 ed_inx = 22;
647 cr_201 = 0xff;
648 } else if (priv->bb_pre_ed_rssi <= 42) {
649 ed_inx = 21;
650 cr_201 = 0x36;
651 } else if (priv->bb_pre_ed_rssi <= 43) {
652 ed_inx = 20;
653 cr_201 = 0x26;
654 } else if (priv->bb_pre_ed_rssi <= 45) {
655 ed_inx = 19;
656 cr_201 = 0x18;
657 } else if (priv->bb_pre_ed_rssi <= 47) {
658 ed_inx = 18;
659 cr_201 = 0x11;
660 } else if (priv->bb_pre_ed_rssi <= 49) {
661 ed_inx = 17;
662 cr_201 = 0xa;
663 } else if (priv->bb_pre_ed_rssi <= 51) {
664 ed_inx = 16;
665 cr_201 = 0x7;
666 } else if (priv->bb_pre_ed_rssi <= 53) {
667 ed_inx = 15;
668 cr_201 = 0x4;
669 } else if (priv->bb_pre_ed_rssi <= 55) {
670 ed_inx = 14;
671 cr_201 = 0x2;
672 cr_206 = 0xc0;
673 } else if (priv->bb_pre_ed_rssi <= 56) {
674 ed_inx = 13;
675 cr_201 = 0x2;
676 cr_206 = 0x30;
677 } else if (priv->bb_pre_ed_rssi <= 57) {
678 ed_inx = 12;
679 cr_201 = 0x1;
680 cr_206 = 0xb0;
681 } else if (priv->bb_pre_ed_rssi <= 58) {
682 ed_inx = 11;
683 cr_201 = 0x1;
684 cr_206 = 0x70;
685 } else if (priv->bb_pre_ed_rssi <= 59) {
686 ed_inx = 10;
687 cr_201 = 0x1;
688 cr_206 = 0x30;
689 } else if (priv->bb_pre_ed_rssi <= 60) {
690 ed_inx = 9;
691 cr_206 = 0xea;
692 } else if (priv->bb_pre_ed_rssi <= 61) {
693 ed_inx = 8;
694 cr_206 = 0xc0;
695 } else if (priv->bb_pre_ed_rssi <= 62) {
696 ed_inx = 7;
697 cr_206 = 0x9c;
698 } else if (priv->bb_pre_ed_rssi <= 63) {
699 ed_inx = 6;
700 cr_206 = 0x80;
701 } else if (priv->bb_pre_ed_rssi <= 64) {
702 ed_inx = 5;
703 cr_206 = 0x68;
704 } else if (priv->bb_pre_ed_rssi <= 65) {
705 ed_inx = 4;
706 cr_206 = 0x52;
707 } else if (priv->bb_pre_ed_rssi <= 66) {
708 ed_inx = 3;
709 cr_206 = 0x43;
710 } else if (priv->bb_pre_ed_rssi <= 67) {
711 ed_inx = 2;
712 cr_206 = 0x36;
713 } else if (priv->bb_pre_ed_rssi <= 68) {
714 ed_inx = 1;
715 cr_206 = 0x2d;
716 } else {
717 ed_inx = 0;
718 cr_206 = 0x24;
719 }
720 break;
721
722 case RF_VT3342A0:
723 if (scanning) {
724 ed_inx = 0;
725 cr_206 = 0x38;
726 break;
727 }
728
729 if (priv->bb_pre_ed_rssi <= 41) {
730 ed_inx = 20;
731 cr_201 = 0xff;
732 } else if (priv->bb_pre_ed_rssi <= 42) {
733 ed_inx = 19;
734 cr_201 = 0x36;
735 } else if (priv->bb_pre_ed_rssi <= 43) {
736 ed_inx = 18;
737 cr_201 = 0x26;
738 } else if (priv->bb_pre_ed_rssi <= 45) {
739 ed_inx = 17;
740 cr_201 = 0x18;
741 } else if (priv->bb_pre_ed_rssi <= 47) {
742 ed_inx = 16;
743 cr_201 = 0x11;
744 } else if (priv->bb_pre_ed_rssi <= 49) {
745 ed_inx = 15;
746 cr_201 = 0xa;
747 } else if (priv->bb_pre_ed_rssi <= 51) {
748 ed_inx = 14;
749 cr_201 = 0x7;
750 } else if (priv->bb_pre_ed_rssi <= 53) {
751 ed_inx = 13;
752 cr_201 = 0x4;
753 } else if (priv->bb_pre_ed_rssi <= 55) {
754 ed_inx = 12;
755 cr_201 = 0x2;
756 cr_206 = 0xc0;
757 } else if (priv->bb_pre_ed_rssi <= 56) {
758 ed_inx = 11;
759 cr_201 = 0x2;
760 cr_206 = 0x30;
761 } else if (priv->bb_pre_ed_rssi <= 57) {
762 ed_inx = 10;
763 cr_201 = 0x1;
764 cr_206 = 0xb0;
765 } else if (priv->bb_pre_ed_rssi <= 58) {
766 ed_inx = 9;
767 cr_201 = 0x1;
768 cr_206 = 0x70;
769 } else if (priv->bb_pre_ed_rssi <= 59) {
770 ed_inx = 8;
771 cr_201 = 0x1;
772 cr_206 = 0x30;
773 } else if (priv->bb_pre_ed_rssi <= 60) {
774 ed_inx = 7;
775 cr_206 = 0xea;
776 } else if (priv->bb_pre_ed_rssi <= 61) {
777 ed_inx = 6;
778 cr_206 = 0xc0;
779 } else if (priv->bb_pre_ed_rssi <= 62) {
780 ed_inx = 5;
781 cr_206 = 0x9c;
782 } else if (priv->bb_pre_ed_rssi <= 63) {
783 ed_inx = 4;
784 cr_206 = 0x80;
785 } else if (priv->bb_pre_ed_rssi <= 64) {
786 ed_inx = 3;
787 cr_206 = 0x68;
788 } else if (priv->bb_pre_ed_rssi <= 65) {
789 ed_inx = 2;
790 cr_206 = 0x52;
791 } else if (priv->bb_pre_ed_rssi <= 66) {
792 ed_inx = 1;
793 cr_206 = 0x43;
794 } else {
795 ed_inx = 0;
796 cr_206 = 0x38;
797 }
798 break;
799 }
800
801 if (ed_inx == priv->bb_pre_ed_index && !scanning)
802 return;
803
804 priv->bb_pre_ed_index = ed_inx;
805
806 dev_dbg(&priv->usb->dev, "%s bb_pre_ed_rssi %d\n",
807 __func__, priv->bb_pre_ed_rssi);
808
809 if (!cr_201 && !cr_206)
810 return;
811
812 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201);
813 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206);
814}
815
816