aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/staging/vt6656/baseband.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/vt6656/baseband.c')
-rw-r--r--drivers/staging/vt6656/baseband.c620
1 files changed, 138 insertions, 482 deletions
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index a19a563d8bcc..41ae779ec61f 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -23,13 +23,15 @@
*/
#include <linux/bits.h>
+#include <linux/errno.h>
#include <linux/kernel.h>
+#include "device.h"
#include "mac.h"
#include "baseband.h"
#include "rf.h"
#include "usbpipe.h"
-static u8 vnt_vt3184_agc[] = {
+static const u8 vnt_vt3184_agc[] = {
0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x06, 0x06,
0x08, 0x08, 0x0a, 0x0a, 0x0c, 0x0c, 0x0e, 0x0e, /* 0x0f */
0x10, 0x10, 0x12, 0x12, 0x14, 0x14, 0x16, 0x16,
@@ -76,7 +78,7 @@ static u8 vnt_vt3184_al2230[] = {
};
/* {{RobertYu:20060515, new BB setting for VT3226D0 */
-static u8 vnt_vt3184_vt3226d0[] = {
+static const u8 vnt_vt3184_vt3226d0[] = {
0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x70, 0x45, 0x2a, 0x76, 0x00, 0x00, 0x80, 0x00, /* 0x0f */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -111,198 +113,85 @@ static u8 vnt_vt3184_vt3226d0[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0xff */
};
-static const u16 vnt_frame_time[MAX_RATE] = {
- 10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
+struct vnt_threshold {
+ u8 bb_pre_ed_rssi;
+ u8 cr_201;
+ u8 cr_206;
};
-/*
- * Description: Calculate data frame transmitting time
- *
- * Parameters:
- * In:
- * preamble_type - Preamble Type
- * pkt_type - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
- * frame_length - Baseband Type
- * tx_rate - Tx Rate
- * Out:
- *
- * Return Value: FrameTime
- *
- */
-unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
- unsigned int frame_length, u16 tx_rate)
-{
- unsigned int frame_time;
- unsigned int preamble;
- unsigned int rate = 0;
-
- if (tx_rate > RATE_54M)
- return 0;
-
- rate = (unsigned int)vnt_frame_time[tx_rate];
-
- if (tx_rate <= 3) {
- if (preamble_type == 1)
- preamble = 96;
- else
- preamble = 192;
-
- frame_time = DIV_ROUND_UP(frame_length * 80, rate);
- return preamble + frame_time;
- }
-
- frame_time = DIV_ROUND_UP(frame_length * 8 + 22, rate);
- frame_time = frame_time * 4;
-
- if (pkt_type != PK_TYPE_11A)
- frame_time += 6;
- return 20 + frame_time;
-}
-
-/*
- * Description: Calculate Length, Service, and Signal fields of Phy for Tx
- *
- * Parameters:
- * In:
- * priv - Device Structure
- * frame_length - Tx Frame Length
- * tx_rate - Tx Rate
- * Out:
- * struct vnt_phy_field *phy
- * - pointer to Phy Length field
- * - pointer to Phy Service field
- * - pointer to Phy Signal field
- *
- * Return Value: none
- *
- */
-void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
- u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy)
-{
- u32 bit_count;
- u32 count = 0;
- u32 tmp;
- int ext_bit;
- u8 preamble_type = priv->preamble_type;
-
- bit_count = frame_length * 8;
- ext_bit = false;
-
- switch (tx_rate) {
- case RATE_1M:
- count = bit_count;
-
- phy->signal = 0x00;
-
- break;
- case RATE_2M:
- count = bit_count / 2;
-
- if (preamble_type == 1)
- phy->signal = 0x09;
- else
- phy->signal = 0x01;
-
- break;
- case RATE_5M:
- count = DIV_ROUND_UP(bit_count * 10, 55);
-
- if (preamble_type == 1)
- phy->signal = 0x0a;
- else
- phy->signal = 0x02;
-
- break;
- case RATE_11M:
- count = bit_count / 11;
- tmp = count * 11;
-
- if (tmp != bit_count) {
- count++;
-
- if ((bit_count - tmp) <= 3)
- ext_bit = true;
- }
-
- if (preamble_type == 1)
- phy->signal = 0x0b;
- else
- phy->signal = 0x03;
-
- break;
- case RATE_6M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9b;
- else
- phy->signal = 0x8b;
-
- break;
- case RATE_9M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9f;
- else
- phy->signal = 0x8f;
-
- break;
- case RATE_12M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9a;
- else
- phy->signal = 0x8a;
-
- break;
- case RATE_18M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9e;
- else
- phy->signal = 0x8e;
-
- break;
- case RATE_24M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x99;
- else
- phy->signal = 0x89;
-
- break;
- case RATE_36M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9d;
- else
- phy->signal = 0x8d;
-
- break;
- case RATE_48M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x98;
- else
- phy->signal = 0x88;
+static const struct vnt_threshold al2230_vnt_threshold[] = {
+ {0, 0x00, 0x30}, /* Max sensitivity */
+ {68, 0x00, 0x36},
+ {67, 0x00, 0x43},
+ {66, 0x00, 0x51},
+ {65, 0x00, 0x62},
+ {64, 0x00, 0x79},
+ {63, 0x00, 0x93},
+ {62, 0x00, 0xb9},
+ {61, 0x00, 0xe3},
+ {60, 0x01, 0x18},
+ {59, 0x01, 0x54},
+ {58, 0x01, 0xa0},
+ {57, 0x02, 0x20},
+ {56, 0x02, 0xa0},
+ {55, 0x03, 0x00},
+ {53, 0x06, 0x00},
+ {51, 0x09, 0x00},
+ {49, 0x0e, 0x00},
+ {47, 0x15, 0x00},
+ {46, 0x1a, 0x00},
+ {45, 0xff, 0x00}
+};
- break;
- case RATE_54M:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9c;
- else
- phy->signal = 0x8c;
- break;
- default:
- if (pkt_type == PK_TYPE_11A)
- phy->signal = 0x9c;
- else
- phy->signal = 0x8c;
- break;
- }
+static const struct vnt_threshold vt3226_vnt_threshold[] = {
+ {0, 0x00, 0x24}, /* Max sensitivity */
+ {68, 0x00, 0x2d},
+ {67, 0x00, 0x36},
+ {66, 0x00, 0x43},
+ {65, 0x00, 0x52},
+ {64, 0x00, 0x68},
+ {63, 0x00, 0x80},
+ {62, 0x00, 0x9c},
+ {61, 0x00, 0xc0},
+ {60, 0x00, 0xea},
+ {59, 0x01, 0x30},
+ {58, 0x01, 0x70},
+ {57, 0x01, 0xb0},
+ {56, 0x02, 0x30},
+ {55, 0x02, 0xc0},
+ {53, 0x04, 0x00},
+ {51, 0x07, 0x00},
+ {49, 0x0a, 0x00},
+ {47, 0x11, 0x00},
+ {45, 0x18, 0x00},
+ {43, 0x26, 0x00},
+ {42, 0x36, 0x00},
+ {41, 0xff, 0x00}
+};
- if (pkt_type == PK_TYPE_11B) {
- phy->service = 0x00;
- if (ext_bit)
- phy->service |= 0x80;
- phy->len = cpu_to_le16((u16)count);
- } else {
- phy->service = 0x00;
- phy->len = cpu_to_le16((u16)frame_length);
- }
-}
+static const struct vnt_threshold vt3342_vnt_threshold[] = {
+ {0, 0x00, 0x38}, /* Max sensitivity */
+ {66, 0x00, 0x43},
+ {65, 0x00, 0x52},
+ {64, 0x00, 0x68},
+ {63, 0x00, 0x80},
+ {62, 0x00, 0x9c},
+ {61, 0x00, 0xc0},
+ {60, 0x00, 0xea},
+ {59, 0x01, 0x30},
+ {58, 0x01, 0x70},
+ {57, 0x01, 0xb0},
+ {56, 0x02, 0x30},
+ {55, 0x02, 0xc0},
+ {53, 0x04, 0x00},
+ {51, 0x07, 0x00},
+ {49, 0x0a, 0x00},
+ {47, 0x11, 0x00},
+ {45, 0x18, 0x00},
+ {43, 0x26, 0x00},
+ {42, 0x36, 0x00},
+ {41, 0xff, 0x00}
+};
/*
* Description: Set Antenna mode
@@ -352,9 +241,10 @@ int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
int vnt_vt3184_init(struct vnt_private *priv)
{
- int ret = 0;
+ int ret;
u16 length;
- u8 *addr;
+ u8 *addr = NULL;
+ const u8 *c_addr;
u8 data;
ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM,
@@ -366,23 +256,15 @@ int vnt_vt3184_init(struct vnt_private *priv)
dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->rf_type);
- if (priv->rf_type == RF_AL2230 ||
- priv->rf_type == RF_AL2230S) {
+ if ((priv->rf_type == RF_AL2230) ||
+ (priv->rf_type == RF_AL2230S) ||
+ (priv->rf_type == RF_AIROHA7230)) {
priv->bb_rx_conf = vnt_vt3184_al2230[10];
length = sizeof(vnt_vt3184_al2230);
addr = vnt_vt3184_al2230;
- priv->bb_vga[0] = 0x1C;
- priv->bb_vga[1] = 0x10;
- priv->bb_vga[2] = 0x0;
- priv->bb_vga[3] = 0x0;
-
- } else if (priv->rf_type == RF_AIROHA7230) {
- priv->bb_rx_conf = vnt_vt3184_al2230[10];
- length = sizeof(vnt_vt3184_al2230);
- addr = vnt_vt3184_al2230;
-
- addr[0xd7] = 0x06;
+ if (priv->rf_type == RF_AIROHA7230)
+ addr[0xd7] = 0x06;
priv->bb_vga[0] = 0x1c;
priv->bb_vga[1] = 0x10;
@@ -390,25 +272,11 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_vga[3] = 0x0;
} else if ((priv->rf_type == RF_VT3226) ||
- (priv->rf_type == RF_VT3226D0)) {
+ (priv->rf_type == RF_VT3226D0) ||
+ (priv->rf_type == RF_VT3342A0)) {
priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
length = sizeof(vnt_vt3184_vt3226d0);
- addr = vnt_vt3184_vt3226d0;
-
- priv->bb_vga[0] = 0x20;
- priv->bb_vga[1] = 0x10;
- priv->bb_vga[2] = 0x0;
- priv->bb_vga[3] = 0x0;
-
- /* Fix VT3226 DFC system timing issue */
- ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
- SOFTPWRCTL_RFLEOPT);
- if (ret)
- goto end;
- } else if (priv->rf_type == RF_VT3342A0) {
- priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
- length = sizeof(vnt_vt3184_vt3226d0);
- addr = vnt_vt3184_vt3226d0;
+ c_addr = vnt_vt3184_vt3226d0;
priv->bb_vga[0] = 0x20;
priv->bb_vga[1] = 0x10;
@@ -424,8 +292,11 @@ int vnt_vt3184_init(struct vnt_private *priv)
goto end;
}
+ if (addr)
+ c_addr = addr;
+
ret = vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE,
- MESSAGE_REQUEST_BBREG, length, addr);
+ MESSAGE_REQUEST_BBREG, length, c_addr);
if (ret)
goto end;
@@ -435,19 +306,13 @@ int vnt_vt3184_init(struct vnt_private *priv)
if (ret)
goto end;
- if (priv->rf_type == RF_VT3226 ||
- priv->rf_type == RF_VT3342A0) {
- ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
- MAC_REG_ITRTMSET, 0x23);
- if (ret)
- goto end;
+ if ((priv->rf_type == RF_VT3226) ||
+ (priv->rf_type == RF_VT3342A0) ||
+ (priv->rf_type == RF_VT3226D0)) {
+ data = (priv->rf_type == RF_VT3226D0) ? 0x11 : 0x23;
- ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, BIT(0));
- if (ret)
- goto end;
- } else if (priv->rf_type == RF_VT3226D0) {
ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
- MAC_REG_ITRTMSET, 0x11);
+ MAC_REG_ITRTMSET, data);
if (ret)
goto end;
@@ -507,21 +372,22 @@ int vnt_set_short_slot_time(struct vnt_private *priv)
ret = vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga);
if (ret)
- goto end;
+ return ret;
if (bb_vga == priv->bb_vga[0])
priv->bb_rx_conf |= 0x20;
- ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
- priv->bb_rx_conf);
-
-end:
- return ret;
+ return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
+ priv->bb_rx_conf);
}
-void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
+int vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
{
- vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data);
+ int ret;
+
+ ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data);
+ if (ret)
+ return ret;
/* patch for 3253B0 Baseband with Cardbus module */
if (priv->short_slot_time)
@@ -529,7 +395,8 @@ void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
else
priv->bb_rx_conf |= 0x20; /* 0010 0000 */
- vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
+ return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
+ priv->bb_rx_conf);
}
/*
@@ -570,268 +437,57 @@ int vnt_exit_deep_sleep(struct vnt_private *priv)
return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
}
-void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
+int vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
{
- u8 cr_201 = 0x0, cr_206 = 0x0;
- u8 ed_inx = priv->bb_pre_ed_index;
+ const struct vnt_threshold *threshold = NULL;
+ u8 length;
+ u8 cr_201, cr_206;
+ u8 ed_inx;
+ int ret;
switch (priv->rf_type) {
case RF_AL2230:
case RF_AL2230S:
case RF_AIROHA7230:
- if (scanning) { /* Max sensitivity */
- ed_inx = 0;
- cr_206 = 0x30;
- break;
- }
-
- if (priv->bb_pre_ed_rssi <= 45) {
- ed_inx = 20;
- cr_201 = 0xff;
- } else if (priv->bb_pre_ed_rssi <= 46) {
- ed_inx = 19;
- cr_201 = 0x1a;
- } else if (priv->bb_pre_ed_rssi <= 47) {
- ed_inx = 18;
- cr_201 = 0x15;
- } else if (priv->bb_pre_ed_rssi <= 49) {
- ed_inx = 17;
- cr_201 = 0xe;
- } else if (priv->bb_pre_ed_rssi <= 51) {
- ed_inx = 16;
- cr_201 = 0x9;
- } else if (priv->bb_pre_ed_rssi <= 53) {
- ed_inx = 15;
- cr_201 = 0x6;
- } else if (priv->bb_pre_ed_rssi <= 55) {
- ed_inx = 14;
- cr_201 = 0x3;
- } else if (priv->bb_pre_ed_rssi <= 56) {
- ed_inx = 13;
- cr_201 = 0x2;
- cr_206 = 0xa0;
- } else if (priv->bb_pre_ed_rssi <= 57) {
- ed_inx = 12;
- cr_201 = 0x2;
- cr_206 = 0x20;
- } else if (priv->bb_pre_ed_rssi <= 58) {
- ed_inx = 11;
- cr_201 = 0x1;
- cr_206 = 0xa0;
- } else if (priv->bb_pre_ed_rssi <= 59) {
- ed_inx = 10;
- cr_201 = 0x1;
- cr_206 = 0x54;
- } else if (priv->bb_pre_ed_rssi <= 60) {
- ed_inx = 9;
- cr_201 = 0x1;
- cr_206 = 0x18;
- } else if (priv->bb_pre_ed_rssi <= 61) {
- ed_inx = 8;
- cr_206 = 0xe3;
- } else if (priv->bb_pre_ed_rssi <= 62) {
- ed_inx = 7;
- cr_206 = 0xb9;
- } else if (priv->bb_pre_ed_rssi <= 63) {
- ed_inx = 6;
- cr_206 = 0x93;
- } else if (priv->bb_pre_ed_rssi <= 64) {
- ed_inx = 5;
- cr_206 = 0x79;
- } else if (priv->bb_pre_ed_rssi <= 65) {
- ed_inx = 4;
- cr_206 = 0x62;
- } else if (priv->bb_pre_ed_rssi <= 66) {
- ed_inx = 3;
- cr_206 = 0x51;
- } else if (priv->bb_pre_ed_rssi <= 67) {
- ed_inx = 2;
- cr_206 = 0x43;
- } else if (priv->bb_pre_ed_rssi <= 68) {
- ed_inx = 1;
- cr_206 = 0x36;
- } else {
- ed_inx = 0;
- cr_206 = 0x30;
- }
+ threshold = al2230_vnt_threshold;
+ length = ARRAY_SIZE(al2230_vnt_threshold);
break;
case RF_VT3226:
case RF_VT3226D0:
- if (scanning) { /* Max sensitivity */
- ed_inx = 0;
- cr_206 = 0x24;
- break;
- }
-
- if (priv->bb_pre_ed_rssi <= 41) {
- ed_inx = 22;
- cr_201 = 0xff;
- } else if (priv->bb_pre_ed_rssi <= 42) {
- ed_inx = 21;
- cr_201 = 0x36;
- } else if (priv->bb_pre_ed_rssi <= 43) {
- ed_inx = 20;
- cr_201 = 0x26;
- } else if (priv->bb_pre_ed_rssi <= 45) {
- ed_inx = 19;
- cr_201 = 0x18;
- } else if (priv->bb_pre_ed_rssi <= 47) {
- ed_inx = 18;
- cr_201 = 0x11;
- } else if (priv->bb_pre_ed_rssi <= 49) {
- ed_inx = 17;
- cr_201 = 0xa;
- } else if (priv->bb_pre_ed_rssi <= 51) {
- ed_inx = 16;
- cr_201 = 0x7;
- } else if (priv->bb_pre_ed_rssi <= 53) {
- ed_inx = 15;
- cr_201 = 0x4;
- } else if (priv->bb_pre_ed_rssi <= 55) {
- ed_inx = 14;
- cr_201 = 0x2;
- cr_206 = 0xc0;
- } else if (priv->bb_pre_ed_rssi <= 56) {
- ed_inx = 13;
- cr_201 = 0x2;
- cr_206 = 0x30;
- } else if (priv->bb_pre_ed_rssi <= 57) {
- ed_inx = 12;
- cr_201 = 0x1;
- cr_206 = 0xb0;
- } else if (priv->bb_pre_ed_rssi <= 58) {
- ed_inx = 11;
- cr_201 = 0x1;
- cr_206 = 0x70;
- } else if (priv->bb_pre_ed_rssi <= 59) {
- ed_inx = 10;
- cr_201 = 0x1;
- cr_206 = 0x30;
- } else if (priv->bb_pre_ed_rssi <= 60) {
- ed_inx = 9;
- cr_206 = 0xea;
- } else if (priv->bb_pre_ed_rssi <= 61) {
- ed_inx = 8;
- cr_206 = 0xc0;
- } else if (priv->bb_pre_ed_rssi <= 62) {
- ed_inx = 7;
- cr_206 = 0x9c;
- } else if (priv->bb_pre_ed_rssi <= 63) {
- ed_inx = 6;
- cr_206 = 0x80;
- } else if (priv->bb_pre_ed_rssi <= 64) {
- ed_inx = 5;
- cr_206 = 0x68;
- } else if (priv->bb_pre_ed_rssi <= 65) {
- ed_inx = 4;
- cr_206 = 0x52;
- } else if (priv->bb_pre_ed_rssi <= 66) {
- ed_inx = 3;
- cr_206 = 0x43;
- } else if (priv->bb_pre_ed_rssi <= 67) {
- ed_inx = 2;
- cr_206 = 0x36;
- } else if (priv->bb_pre_ed_rssi <= 68) {
- ed_inx = 1;
- cr_206 = 0x2d;
- } else {
- ed_inx = 0;
- cr_206 = 0x24;
- }
+ threshold = vt3226_vnt_threshold;
+ length = ARRAY_SIZE(vt3226_vnt_threshold);
break;
case RF_VT3342A0:
- if (scanning) { /* need Max sensitivity */
- ed_inx = 0;
- cr_206 = 0x38;
- break;
- }
-
- if (priv->bb_pre_ed_rssi <= 41) {
- ed_inx = 20;
- cr_201 = 0xff;
- } else if (priv->bb_pre_ed_rssi <= 42) {
- ed_inx = 19;
- cr_201 = 0x36;
- } else if (priv->bb_pre_ed_rssi <= 43) {
- ed_inx = 18;
- cr_201 = 0x26;
- } else if (priv->bb_pre_ed_rssi <= 45) {
- ed_inx = 17;
- cr_201 = 0x18;
- } else if (priv->bb_pre_ed_rssi <= 47) {
- ed_inx = 16;
- cr_201 = 0x11;
- } else if (priv->bb_pre_ed_rssi <= 49) {
- ed_inx = 15;
- cr_201 = 0xa;
- } else if (priv->bb_pre_ed_rssi <= 51) {
- ed_inx = 14;
- cr_201 = 0x7;
- } else if (priv->bb_pre_ed_rssi <= 53) {
- ed_inx = 13;
- cr_201 = 0x4;
- } else if (priv->bb_pre_ed_rssi <= 55) {
- ed_inx = 12;
- cr_201 = 0x2;
- cr_206 = 0xc0;
- } else if (priv->bb_pre_ed_rssi <= 56) {
- ed_inx = 11;
- cr_201 = 0x2;
- cr_206 = 0x30;
- } else if (priv->bb_pre_ed_rssi <= 57) {
- ed_inx = 10;
- cr_201 = 0x1;
- cr_206 = 0xb0;
- } else if (priv->bb_pre_ed_rssi <= 58) {
- ed_inx = 9;
- cr_201 = 0x1;
- cr_206 = 0x70;
- } else if (priv->bb_pre_ed_rssi <= 59) {
- ed_inx = 8;
- cr_201 = 0x1;
- cr_206 = 0x30;
- } else if (priv->bb_pre_ed_rssi <= 60) {
- ed_inx = 7;
- cr_206 = 0xea;
- } else if (priv->bb_pre_ed_rssi <= 61) {
- ed_inx = 6;
- cr_206 = 0xc0;
- } else if (priv->bb_pre_ed_rssi <= 62) {
- ed_inx = 5;
- cr_206 = 0x9c;
- } else if (priv->bb_pre_ed_rssi <= 63) {
- ed_inx = 4;
- cr_206 = 0x80;
- } else if (priv->bb_pre_ed_rssi <= 64) {
- ed_inx = 3;
- cr_206 = 0x68;
- } else if (priv->bb_pre_ed_rssi <= 65) {
- ed_inx = 2;
- cr_206 = 0x52;
- } else if (priv->bb_pre_ed_rssi <= 66) {
- ed_inx = 1;
- cr_206 = 0x43;
- } else {
- ed_inx = 0;
- cr_206 = 0x38;
- }
+ threshold = vt3342_vnt_threshold;
+ length = ARRAY_SIZE(vt3342_vnt_threshold);
break;
}
+ if (!threshold)
+ return -EINVAL;
+
+ for (ed_inx = scanning ? 0 : length - 1; ed_inx > 0; ed_inx--) {
+ if (priv->bb_pre_ed_rssi <= threshold[ed_inx].bb_pre_ed_rssi)
+ break;
+ }
+
+ cr_201 = threshold[ed_inx].cr_201;
+ cr_206 = threshold[ed_inx].cr_206;
+
if (ed_inx == priv->bb_pre_ed_index && !scanning)
- return;
+ return 0;
priv->bb_pre_ed_index = ed_inx;
dev_dbg(&priv->usb->dev, "%s bb_pre_ed_rssi %d\n",
__func__, priv->bb_pre_ed_rssi);
- if (!cr_201 && !cr_206)
- return;
+ ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201);
+ if (ret)
+ return ret;
- vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201);
- vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206);
+ return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206);
}