staging: vt6655: baseband add new function vnt_get_phy_field
authorMalcolm Priestley <tvboxspy@gmail.com>
Wed, 20 Aug 2014 21:30:28 +0000 (22:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:48:19 +0000 (13:48 -0700)
This is a replacement for BBvCalculateParameter for getting
the phy fields via struct vnt_phy_field

This is a direct copy from the vt6656 driver.

BBvCalculateParameter will removed later.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6655/baseband.c
drivers/staging/vt6655/baseband.h

index 7dd866e1280c3bd583cd584c182fa617364e6e96..584220613fdfd96ae10d8c6908246d3406d7b59d 100644 (file)
@@ -1810,17 +1810,150 @@ BBuGetFrameTime(
  *
  * Parameters:
  *  In:
- *      pDevice         - Device Structure
- *      cbFrameLength   - Tx Frame Length
- *      wRate           - Tx Rate
+ *      priv         - Device Structure
+ *      frame_length   - Tx Frame Length
+ *      tx_rate           - Tx Rate
  *  Out:
- *      pwPhyLen        - pointer to Phy Length field
- *      pbyPhySrv       - pointer to Phy Service field
- *      pbyPhySgn       - pointer to Phy Signal field
+ *     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->byPreambleType;
+
+       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 = (bit_count * 10) / 55;
+               tmp = (count * 55) / 10;
+
+               if (tmp != bit_count)
+                       count++;
+
+               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;
+
+               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;
+       }
+
+       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);
+       }
+}
+
 void
 BBvCalculateParameter(
        struct vnt_private *pDevice,
index 6b4388504f5c470e22684e35577f6ef3bdeeda83..049e6b48460e4e445697fbc90cf905eb2690d051 100644 (file)
@@ -87,6 +87,9 @@ BBvCalculateParameter(
        unsigned char *pbyPhySgn
 );
 
+void vnt_get_phy_field(struct vnt_private *, u32 frame_length,
+                      u16 tx_rate, u8 pkt_type, struct vnt_phy_field *);
+
 bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData);
 bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData);