Re: [PATCH] staging: vt6656: formulate rspinf values into tables

2020-04-12 Thread Malcolm Priestley
Drop this patch v2 sent

Regards

Malcolm
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: formulate rspinf values into tables

2020-04-11 Thread Malcolm Priestley
Four tables can be extracted from RSPINF_A_* based on BB_TYPE_11A or
else being GB rates.

Preamble short or long tables from fixed size len of 14 for RSPINF_B rates.

Remove function vnt_calculate_ofdm_rate and replace with the tables
calling RSPINF_A and RSPINF_B separately.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 196 +++---
 1 file changed, 40 insertions(+), 156 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 82c775bd20d2..dedb343f3ef3 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -74,99 +74,25 @@ void vnt_set_channel(struct vnt_private *priv, u32 
connection_channel)
   (u8)(connection_channel | 0x80));
 }
 
-/*
- * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
- *
- * Parameters:
- * In:
- * rate- Tx Rate
- * bb_type - Tx Packet type
- * Out:
- * tx_rate - pointer to RSPINF TxRate field
- * rsv_time- pointer to RSPINF RsvTime field
- *
- * Return Value: none
- *
- */
-static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
-   u8 *tx_rate, u8 *rsv_time)
-{
-   switch (rate) {
-   case RATE_6M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9b;
-   *rsv_time = 24;
-   } else {
-   *tx_rate = 0x8b;
-   *rsv_time = 30;
-   }
-   break;
-   case RATE_9M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9f;
-   *rsv_time = 16;
-   } else {
-   *tx_rate = 0x8f;
-   *rsv_time = 22;
-   }
-   break;
-   case RATE_12M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9a;
-   *rsv_time = 12;
-   } else {
-   *tx_rate = 0x8a;
-   *rsv_time = 18;
-   }
-   break;
-   case RATE_18M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9e;
-   *rsv_time = 8;
-   } else {
-   *tx_rate = 0x8e;
-   *rsv_time = 14;
-   }
-   break;
-   case RATE_36M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9d;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x8d;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_48M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x98;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x88;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_54M:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x9c;
-   *rsv_time = 4;
-   } else {
-   *tx_rate = 0x8c;
-   *rsv_time = 10;
-   }
-   break;
-   case RATE_24M:
-   default:
-   if (bb_type == BB_TYPE_11A) {
-   *tx_rate = 0x99;
-   *rsv_time = 8;
-   } else {
-   *tx_rate = 0x89;
-   *rsv_time = 14;
-   }
-   break;
-   }
-}
+static const u8 vnt_rspinf_b_short_table[] = {
+   0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x09, 0x00,
+   0x15, 0x00, 0x0a, 0x00, 0x0b, 0x00, 0x0b, 0x80
+};
+
+static const u8 vnt_rspinf_b_long_table[] = {
+   0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00,
+   0x15, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x03, 0x80
+};
+
+static const u8 vnt_rspinf_a_table[] = {
+   0x9b, 0x1e, 0x9f, 0x16, 0x9a, 0x12, 0x9e, 0x0e, 0x99,
+   0x0e, 0x9d, 0x0a, 0x98, 0x0a, 0x9c, 0x0a, 0x9c, 0x0a
+};
+
+static const u8 vnt_rspinf_gb_table[] = {
+   0x8b, 0x1e, 0x8f, 0x16, 0x8a, 0x12, 0x8e, 0x0e, 0x89,
+   0x0e, 0x8d, 0x0a, 0x88, 0x0a, 0x8c, 0x0a, 0x8c, 0x0a
+};
 
 /*
  * Description: Set RSPINF
@@ -183,74 +109,32 @@ static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
 
 void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
 {
-   struct vnt_phy_field phy[4];
-   u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
-   u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
-   u8 data[34];
-   int i;
-
-   /*RSPINF_b_1*/
-   vnt_get_phy_field(priv, 14, RATE_1M, PK_TYPE_11B, [0]);
-
-   /*RSPINF_b_2*/
-   vnt_get_phy_field(priv, 14, RATE_2M, PK_TYPE_11B, [1]);
-
-   /*RSPINF_b_5*/
-   vnt_get_phy_field(priv, 14, RATE_5M, PK_TYPE_11B, [2]);
-
-   /*RSPINF_b_11*/
-