root/drivers/staging/rtl8723bs/hal/odm.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ODM_DMInit
  2. ODM_DMWatchdog
  3. ODM_CmnInfoInit
  4. ODM_CmnInfoHook
  5. ODM_CmnInfoPtrArrayHook
  6. ODM_CmnInfoUpdate
  7. odm_CommonInfoSelfInit
  8. odm_CommonInfoSelfUpdate
  9. odm_CmnInfoInit_Debug
  10. odm_BasicDbgMessage
  11. odm_RateAdaptiveMaskInit
  12. ODM_Get_Rate_Bitmap
  13. odm_RefreshRateAdaptiveMask
  14. odm_RefreshRateAdaptiveMaskCE
  15. ODM_RAStateCheck
  16. odm_RSSIMonitorInit
  17. odm_RSSIMonitorCheck
  18. FindMinimumRSSI
  19. odm_RSSIMonitorCheckCE
  20. getSwingIndex
  21. odm_TXPowerTrackingInit
  22. ODM_TXPowerTrackingCheck
  23. odm_SwAntDetectInit

   1 // SPDX-License-Identifier: GPL-2.0
   2 /******************************************************************************
   3  *
   4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5  *
   6  ******************************************************************************/
   7 
   8 #include "odm_precomp.h"
   9 
  10 static const u16 dB_Invert_Table[8][12] = {
  11         {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4},
  12         {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16},
  13         {18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63},
  14         {71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251},
  15         {282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000},
  16         {1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981},
  17         {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125,
  18          15849},
  19         {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119,
  20          56234, 65535}
  21  };
  22 
  23 /*  Global var */
  24 
  25 u32 OFDMSwingTable[OFDM_TABLE_SIZE] = {
  26         0x7f8001fe, /*  0, +6.0dB */
  27         0x788001e2, /*  1, +5.5dB */
  28         0x71c001c7, /*  2, +5.0dB */
  29         0x6b8001ae, /*  3, +4.5dB */
  30         0x65400195, /*  4, +4.0dB */
  31         0x5fc0017f, /*  5, +3.5dB */
  32         0x5a400169, /*  6, +3.0dB */
  33         0x55400155, /*  7, +2.5dB */
  34         0x50800142, /*  8, +2.0dB */
  35         0x4c000130, /*  9, +1.5dB */
  36         0x47c0011f, /*  10, +1.0dB */
  37         0x43c0010f, /*  11, +0.5dB */
  38         0x40000100, /*  12, +0dB */
  39         0x3c8000f2, /*  13, -0.5dB */
  40         0x390000e4, /*  14, -1.0dB */
  41         0x35c000d7, /*  15, -1.5dB */
  42         0x32c000cb, /*  16, -2.0dB */
  43         0x300000c0, /*  17, -2.5dB */
  44         0x2d4000b5, /*  18, -3.0dB */
  45         0x2ac000ab, /*  19, -3.5dB */
  46         0x288000a2, /*  20, -4.0dB */
  47         0x26000098, /*  21, -4.5dB */
  48         0x24000090, /*  22, -5.0dB */
  49         0x22000088, /*  23, -5.5dB */
  50         0x20000080, /*  24, -6.0dB */
  51         0x1e400079, /*  25, -6.5dB */
  52         0x1c800072, /*  26, -7.0dB */
  53         0x1b00006c, /*  27. -7.5dB */
  54         0x19800066, /*  28, -8.0dB */
  55         0x18000060, /*  29, -8.5dB */
  56         0x16c0005b, /*  30, -9.0dB */
  57         0x15800056, /*  31, -9.5dB */
  58         0x14400051, /*  32, -10.0dB */
  59         0x1300004c, /*  33, -10.5dB */
  60         0x12000048, /*  34, -11.0dB */
  61         0x11000044, /*  35, -11.5dB */
  62         0x10000040, /*  36, -12.0dB */
  63 };
  64 
  65 u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = {
  66         {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /*  0, +0dB */
  67         {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /*  1, -0.5dB */
  68         {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /*  2, -1.0dB */
  69         {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /*  3, -1.5dB */
  70         {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /*  4, -2.0dB */
  71         {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /*  5, -2.5dB */
  72         {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /*  6, -3.0dB */
  73         {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /*  7, -3.5dB */
  74         {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /*  8, -4.0dB */
  75         {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /*  9, -4.5dB */
  76         {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /*  10, -5.0dB */
  77         {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /*  11, -5.5dB */
  78         {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /*  12, -6.0dB <== default */
  79         {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /*  13, -6.5dB */
  80         {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /*  14, -7.0dB */
  81         {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /*  15, -7.5dB */
  82         {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /*  16, -8.0dB */
  83         {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /*  17, -8.5dB */
  84         {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /*  18, -9.0dB */
  85         {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /*  19, -9.5dB */
  86         {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /*  20, -10.0dB */
  87         {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /*  21, -10.5dB */
  88         {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /*  22, -11.0dB */
  89         {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /*  23, -11.5dB */
  90         {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /*  24, -12.0dB */
  91         {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /*  25, -12.5dB */
  92         {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /*  26, -13.0dB */
  93         {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /*  27, -13.5dB */
  94         {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /*  28, -14.0dB */
  95         {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /*  29, -14.5dB */
  96         {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /*  30, -15.0dB */
  97         {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /*  31, -15.5dB */
  98         {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}        /*  32, -16.0dB */
  99 };
 100 
 101 u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = {
 102         {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /*  0, +0dB */
 103         {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /*  1, -0.5dB */
 104         {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /*  2, -1.0dB */
 105         {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /*  3, -1.5dB */
 106         {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /*  4, -2.0dB */
 107         {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /*  5, -2.5dB */
 108         {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /*  6, -3.0dB */
 109         {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /*  7, -3.5dB */
 110         {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /*  8, -4.0dB */
 111         {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /*  9, -4.5dB */
 112         {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /*  10, -5.0dB */
 113         {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /*  11, -5.5dB */
 114         {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /*  12, -6.0dB  <== default */
 115         {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /*  13, -6.5dB */
 116         {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /*  14, -7.0dB */
 117         {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /*  15, -7.5dB */
 118         {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /*  16, -8.0dB */
 119         {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /*  17, -8.5dB */
 120         {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /*  18, -9.0dB */
 121         {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /*  19, -9.5dB */
 122         {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /*  20, -10.0dB */
 123         {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /*  21, -10.5dB */
 124         {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /*  22, -11.0dB */
 125         {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /*  23, -11.5dB */
 126         {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /*  24, -12.0dB */
 127         {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /*  25, -12.5dB */
 128         {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /*  26, -13.0dB */
 129         {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /*  27, -13.5dB */
 130         {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /*  28, -14.0dB */
 131         {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /*  29, -14.5dB */
 132         {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /*  30, -15.0dB */
 133         {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /*  31, -15.5dB */
 134         {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}        /*  32, -16.0dB */
 135 };
 136 
 137 u32 OFDMSwingTable_New[OFDM_TABLE_SIZE] = {
 138         0x0b40002d, /*  0,  -15.0dB */
 139         0x0c000030, /*  1,  -14.5dB */
 140         0x0cc00033, /*  2,  -14.0dB */
 141         0x0d800036, /*  3,  -13.5dB */
 142         0x0e400039, /*  4,  -13.0dB */
 143         0x0f00003c, /*  5,  -12.5dB */
 144         0x10000040, /*  6,  -12.0dB */
 145         0x11000044, /*  7,  -11.5dB */
 146         0x12000048, /*  8,  -11.0dB */
 147         0x1300004c, /*  9,  -10.5dB */
 148         0x14400051, /*  10, -10.0dB */
 149         0x15800056, /*  11, -9.5dB */
 150         0x16c0005b, /*  12, -9.0dB */
 151         0x18000060, /*  13, -8.5dB */
 152         0x19800066, /*  14, -8.0dB */
 153         0x1b00006c, /*  15, -7.5dB */
 154         0x1c800072, /*  16, -7.0dB */
 155         0x1e400079, /*  17, -6.5dB */
 156         0x20000080, /*  18, -6.0dB */
 157         0x22000088, /*  19, -5.5dB */
 158         0x24000090, /*  20, -5.0dB */
 159         0x26000098, /*  21, -4.5dB */
 160         0x288000a2, /*  22, -4.0dB */
 161         0x2ac000ab, /*  23, -3.5dB */
 162         0x2d4000b5, /*  24, -3.0dB */
 163         0x300000c0, /*  25, -2.5dB */
 164         0x32c000cb, /*  26, -2.0dB */
 165         0x35c000d7, /*  27, -1.5dB */
 166         0x390000e4, /*  28, -1.0dB */
 167         0x3c8000f2, /*  29, -0.5dB */
 168         0x40000100, /*  30, +0dB */
 169         0x43c0010f, /*  31, +0.5dB */
 170         0x47c0011f, /*  32, +1.0dB */
 171         0x4c000130, /*  33, +1.5dB */
 172         0x50800142, /*  34, +2.0dB */
 173         0x55400155, /*  35, +2.5dB */
 174         0x5a400169, /*  36, +3.0dB */
 175         0x5fc0017f, /*  37, +3.5dB */
 176         0x65400195, /*  38, +4.0dB */
 177         0x6b8001ae, /*  39, +4.5dB */
 178         0x71c001c7, /*  40, +5.0dB */
 179         0x788001e2, /*  41, +5.5dB */
 180         0x7f8001fe  /*  42, +6.0dB */
 181 };
 182 
 183 u8 CCKSwingTable_Ch1_Ch13_New[CCK_TABLE_SIZE][8] = {
 184         {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}, /*   0, -16.0dB */
 185         {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /*   1, -15.5dB */
 186         {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /*   2, -15.0dB */
 187         {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /*   3, -14.5dB */
 188         {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /*   4, -14.0dB */
 189         {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /*   5, -13.5dB */
 190         {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /*   6, -13.0dB */
 191         {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /*   7, -12.5dB */
 192         {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /*   8, -12.0dB */
 193         {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /*   9, -11.5dB */
 194         {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /*  10, -11.0dB */
 195         {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /*  11, -10.5dB */
 196         {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /*  12, -10.0dB */
 197         {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /*  13, -9.5dB */
 198         {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /*  14, -9.0dB */
 199         {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /*  15, -8.5dB */
 200         {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /*  16, -8.0dB */
 201         {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /*  17, -7.5dB */
 202         {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /*  18, -7.0dB */
 203         {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /*  19, -6.5dB */
 204         {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /*  20, -6.0dB */
 205         {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /*  21, -5.5dB */
 206         {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /*  22, -5.0dB */
 207         {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /*  23, -4.5dB */
 208         {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /*  24, -4.0dB */
 209         {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /*  25, -3.5dB */
 210         {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /*  26, -3.0dB */
 211         {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /*  27, -2.5dB */
 212         {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /*  28, -2.0dB */
 213         {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /*  29, -1.5dB */
 214         {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /*  30, -1.0dB */
 215         {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /*  31, -0.5dB */
 216         {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}        /*  32, +0dB */
 217 };
 218 
 219 u8 CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8] = {
 220         {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}, /*   0, -16.0dB */
 221         {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /*   1, -15.5dB */
 222         {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /*   2, -15.0dB */
 223         {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /*   3, -14.5dB */
 224         {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /*   4, -14.0dB */
 225         {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /*   5, -13.5dB */
 226         {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /*   6, -13.0dB */
 227         {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /*   7, -12.5dB */
 228         {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /*   8, -12.0dB */
 229         {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /*   9, -11.5dB */
 230         {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /*  10, -11.0dB */
 231         {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /*  11, -10.5dB */
 232         {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /*  12, -10.0dB */
 233         {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /*  13, -9.5dB */
 234         {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /*  14, -9.0dB */
 235         {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /*  15, -8.5dB */
 236         {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /*  16, -8.0dB */
 237         {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /*  17, -7.5dB */
 238         {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /*  18, -7.0dB */
 239         {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /*  19, -6.5dB */
 240         {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /*  20, -6.0dB */
 241         {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /*  21, -5.5dB */
 242         {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /*  22, -5.0dB */
 243         {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /*  23, -4.5dB */
 244         {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /*  24, -4.0dB */
 245         {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /*  25, -3.5dB */
 246         {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /*  26, -3.0dB */
 247         {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /*  27, -2.5dB */
 248         {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /*  28, -2.0dB */
 249         {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /*  29, -1.5dB */
 250         {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /*  30, -1.0dB */
 251         {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /*  31, -0.5dB */
 252         {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}        /*  32, +0dB */
 253 };
 254 
 255 u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = {
 256         0x081, /*  0,  -12.0dB */
 257         0x088, /*  1,  -11.5dB */
 258         0x090, /*  2,  -11.0dB */
 259         0x099, /*  3,  -10.5dB */
 260         0x0A2, /*  4,  -10.0dB */
 261         0x0AC, /*  5,  -9.5dB */
 262         0x0B6, /*  6,  -9.0dB */
 263         0x0C0, /*  7,  -8.5dB */
 264         0x0CC, /*  8,  -8.0dB */
 265         0x0D8, /*  9,  -7.5dB */
 266         0x0E5, /*  10, -7.0dB */
 267         0x0F2, /*  11, -6.5dB */
 268         0x101, /*  12, -6.0dB */
 269         0x110, /*  13, -5.5dB */
 270         0x120, /*  14, -5.0dB */
 271         0x131, /*  15, -4.5dB */
 272         0x143, /*  16, -4.0dB */
 273         0x156, /*  17, -3.5dB */
 274         0x16A, /*  18, -3.0dB */
 275         0x180, /*  19, -2.5dB */
 276         0x197, /*  20, -2.0dB */
 277         0x1AF, /*  21, -1.5dB */
 278         0x1C8, /*  22, -1.0dB */
 279         0x1E3, /*  23, -0.5dB */
 280         0x200, /*  24, +0  dB */
 281         0x21E, /*  25, +0.5dB */
 282         0x23E, /*  26, +1.0dB */
 283         0x261, /*  27, +1.5dB */
 284         0x285, /*  28, +2.0dB */
 285         0x2AB, /*  29, +2.5dB */
 286         0x2D3, /*  30, +3.0dB */
 287         0x2FE, /*  31, +3.5dB */
 288         0x32B, /*  32, +4.0dB */
 289         0x35C, /*  33, +4.5dB */
 290         0x38E, /*  34, +5.0dB */
 291         0x3C4, /*  35, +5.5dB */
 292         0x3FE  /*  36, +6.0dB */
 293 };
 294 
 295 /*  Local Function predefine. */
 296 
 297 /* START------------COMMON INFO RELATED--------------- */
 298 void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm);
 299 
 300 void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm);
 301 
 302 void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm);
 303 
 304 void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm);
 305 
 306 /* END------------COMMON INFO RELATED--------------- */
 307 
 308 /* START---------------DIG--------------------------- */
 309 
 310 /* Remove by Yuchen */
 311 
 312 /* END---------------DIG--------------------------- */
 313 
 314 /* START-------BB POWER SAVE----------------------- */
 315 /* Remove BB power Saving by YuChen */
 316 /* END---------BB POWER SAVE----------------------- */
 317 
 318 void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm);
 319 
 320 /* Remove by YuChen */
 321 
 322 void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm);
 323 
 324 void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm);
 325 
 326 void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm);
 327 
 328 void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm);
 329 
 330 void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
 331 
 332 
 333 
 334 void odm_GlobalAdapterCheck(void);
 335 
 336 void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm);
 337 
 338 void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
 339 
 340 void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm);
 341 
 342 
 343 void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
 344 
 345 /* Remove Edca by Yu Chen */
 346 
 347 
 348 #define RxDefaultAnt1           0x65a9
 349 #define RxDefaultAnt2           0x569a
 350 
 351 void odm_InitHybridAntDiv(PDM_ODM_T pDM_Odm);
 352 
 353 bool odm_StaDefAntSel(
 354         PDM_ODM_T pDM_Odm,
 355         u32 OFDM_Ant1_Cnt,
 356         u32 OFDM_Ant2_Cnt,
 357         u32 CCK_Ant1_Cnt,
 358         u32 CCK_Ant2_Cnt,
 359         u8 *pDefAnt
 360 );
 361 
 362 void odm_SetRxIdleAnt(PDM_ODM_T pDM_Odm, u8 Ant, bool bDualPath);
 363 
 364 
 365 
 366 void odm_HwAntDiv(PDM_ODM_T pDM_Odm);
 367 
 368 
 369 /*  */
 370 /* 3 Export Interface */
 371 /*  */
 372 
 373 /*  */
 374 /*  2011/09/21 MH Add to describe different team necessary resource allocate?? */
 375 /*  */
 376 void ODM_DMInit(PDM_ODM_T pDM_Odm)
 377 {
 378 
 379         odm_CommonInfoSelfInit(pDM_Odm);
 380         odm_CmnInfoInit_Debug(pDM_Odm);
 381         odm_DIGInit(pDM_Odm);
 382         odm_NHMCounterStatisticsInit(pDM_Odm);
 383         odm_AdaptivityInit(pDM_Odm);
 384         odm_RateAdaptiveMaskInit(pDM_Odm);
 385         ODM_CfoTrackingInit(pDM_Odm);
 386         ODM_EdcaTurboInit(pDM_Odm);
 387         odm_RSSIMonitorInit(pDM_Odm);
 388         odm_TXPowerTrackingInit(pDM_Odm);
 389 
 390         ODM_ClearTxPowerTrackingState(pDM_Odm);
 391 
 392         if (*(pDM_Odm->mp_mode) != 1)
 393                 odm_PathDiversityInit(pDM_Odm);
 394 
 395         odm_DynamicBBPowerSavingInit(pDM_Odm);
 396         odm_DynamicTxPowerInit(pDM_Odm);
 397 
 398         odm_SwAntDetectInit(pDM_Odm);
 399 }
 400 
 401 /*  */
 402 /*  2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */
 403 /*  You can not add any dummy function here, be care, you can only use DM structure */
 404 /*  to perform any new ODM_DM. */
 405 /*  */
 406 void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
 407 {
 408         odm_CommonInfoSelfUpdate(pDM_Odm);
 409         odm_BasicDbgMessage(pDM_Odm);
 410         odm_FalseAlarmCounterStatistics(pDM_Odm);
 411         odm_NHMCounterStatistics(pDM_Odm);
 412         ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): RSSI = 0x%x\n", pDM_Odm->RSSI_Min));
 413 
 414         odm_RSSIMonitorCheck(pDM_Odm);
 415 
 416         /* For CE Platform(SPRD or Tablet) */
 417         /* 8723A or 8189ES platform */
 418         /* NeilChen--2012--08--24-- */
 419         /* Fix Leave LPS issue */
 420         if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE) /*  in LPS mode */
 421                 /*  */
 422                 /* (pDM_Odm->SupportICType & (ODM_RTL8723A))|| */
 423                 /* (pDM_Odm->SupportICType & (ODM_RTL8188E) &&(&&(((pDM_Odm->SupportInterface  == ODM_ITRF_SDIO))) */
 424                 /*  */
 425         ) {
 426                         ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n"));
 427                         ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
 428                         odm_DIGbyRSSI_LPS(pDM_Odm);
 429         } else
 430                 odm_DIG(pDM_Odm);
 431 
 432         {
 433                 pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
 434 
 435                 odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
 436         }
 437         odm_CCKPacketDetectionThresh(pDM_Odm);
 438 
 439         if (*(pDM_Odm->pbPowerSaving) == true)
 440                 return;
 441 
 442 
 443         odm_RefreshRateAdaptiveMask(pDM_Odm);
 444         odm_EdcaTurboCheck(pDM_Odm);
 445         odm_PathDiversity(pDM_Odm);
 446         ODM_CfoTracking(pDM_Odm);
 447 
 448         ODM_TXPowerTrackingCheck(pDM_Odm);
 449 
 450         /* odm_EdcaTurboCheck(pDM_Odm); */
 451 
 452         /* 2010.05.30 LukeLee: For CE platform, files in IC subfolders may not be included to be compiled, */
 453         /*  so compile flags must be left here to prevent from compile errors */
 454         pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
 455 }
 456 
 457 
 458 /*  */
 459 /*  Init /.. Fixed HW value. Only init time. */
 460 /*  */
 461 void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
 462 {
 463         /*  */
 464         /*  This section is used for init value */
 465         /*  */
 466         switch (CmnInfo) {
 467         /*  */
 468         /*  Fixed ODM value. */
 469         /*  */
 470         case ODM_CMNINFO_ABILITY:
 471                 pDM_Odm->SupportAbility = (u32)Value;
 472                 break;
 473 
 474         case ODM_CMNINFO_RF_TYPE:
 475                 pDM_Odm->RFType = (u8)Value;
 476                 break;
 477 
 478         case ODM_CMNINFO_PLATFORM:
 479                 pDM_Odm->SupportPlatform = (u8)Value;
 480                 break;
 481 
 482         case ODM_CMNINFO_INTERFACE:
 483                 pDM_Odm->SupportInterface = (u8)Value;
 484                 break;
 485 
 486         case ODM_CMNINFO_MP_TEST_CHIP:
 487                 pDM_Odm->bIsMPChip = (u8)Value;
 488                 break;
 489 
 490         case ODM_CMNINFO_IC_TYPE:
 491                 pDM_Odm->SupportICType = Value;
 492                 break;
 493 
 494         case ODM_CMNINFO_CUT_VER:
 495                 pDM_Odm->CutVersion = (u8)Value;
 496                 break;
 497 
 498         case ODM_CMNINFO_FAB_VER:
 499                 pDM_Odm->FabVersion = (u8)Value;
 500                 break;
 501 
 502         case ODM_CMNINFO_RFE_TYPE:
 503                 pDM_Odm->RFEType = (u8)Value;
 504                 break;
 505 
 506         case    ODM_CMNINFO_RF_ANTENNA_TYPE:
 507                 pDM_Odm->AntDivType = (u8)Value;
 508                 break;
 509 
 510         case ODM_CMNINFO_BOARD_TYPE:
 511                 pDM_Odm->BoardType = (u8)Value;
 512                 break;
 513 
 514         case ODM_CMNINFO_PACKAGE_TYPE:
 515                 pDM_Odm->PackageType = (u8)Value;
 516                 break;
 517 
 518         case ODM_CMNINFO_EXT_LNA:
 519                 pDM_Odm->ExtLNA = (u8)Value;
 520                 break;
 521 
 522         case ODM_CMNINFO_5G_EXT_LNA:
 523                 pDM_Odm->ExtLNA5G = (u8)Value;
 524                 break;
 525 
 526         case ODM_CMNINFO_EXT_PA:
 527                 pDM_Odm->ExtPA = (u8)Value;
 528                 break;
 529 
 530         case ODM_CMNINFO_5G_EXT_PA:
 531                 pDM_Odm->ExtPA5G = (u8)Value;
 532                 break;
 533 
 534         case ODM_CMNINFO_GPA:
 535                 pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value;
 536                 break;
 537         case ODM_CMNINFO_APA:
 538                 pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value;
 539                 break;
 540         case ODM_CMNINFO_GLNA:
 541                 pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value;
 542                 break;
 543         case ODM_CMNINFO_ALNA:
 544                 pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value;
 545                 break;
 546 
 547         case ODM_CMNINFO_EXT_TRSW:
 548                 pDM_Odm->ExtTRSW = (u8)Value;
 549                 break;
 550         case ODM_CMNINFO_PATCH_ID:
 551                 pDM_Odm->PatchID = (u8)Value;
 552                 break;
 553         case ODM_CMNINFO_BINHCT_TEST:
 554                 pDM_Odm->bInHctTest = (bool)Value;
 555                 break;
 556         case ODM_CMNINFO_BWIFI_TEST:
 557                 pDM_Odm->bWIFITest = (bool)Value;
 558                 break;
 559 
 560         case ODM_CMNINFO_SMART_CONCURRENT:
 561                 pDM_Odm->bDualMacSmartConcurrent = (bool)Value;
 562                 break;
 563 
 564         /* To remove the compiler warning, must add an empty default statement to handle the other values. */
 565         default:
 566                 /* do nothing */
 567                 break;
 568         }
 569 
 570 }
 571 
 572 
 573 void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue)
 574 {
 575         /*  */
 576         /*  Hook call by reference pointer. */
 577         /*  */
 578         switch (CmnInfo) {
 579         /*  */
 580         /*  Dynamic call by reference pointer. */
 581         /*  */
 582         case ODM_CMNINFO_MAC_PHY_MODE:
 583                 pDM_Odm->pMacPhyMode = pValue;
 584                 break;
 585 
 586         case ODM_CMNINFO_TX_UNI:
 587                 pDM_Odm->pNumTxBytesUnicast = pValue;
 588                 break;
 589 
 590         case ODM_CMNINFO_RX_UNI:
 591                 pDM_Odm->pNumRxBytesUnicast = pValue;
 592                 break;
 593 
 594         case ODM_CMNINFO_WM_MODE:
 595                 pDM_Odm->pwirelessmode = pValue;
 596                 break;
 597 
 598         case ODM_CMNINFO_BAND:
 599                 pDM_Odm->pBandType = pValue;
 600                 break;
 601 
 602         case ODM_CMNINFO_SEC_CHNL_OFFSET:
 603                 pDM_Odm->pSecChOffset = pValue;
 604                 break;
 605 
 606         case ODM_CMNINFO_SEC_MODE:
 607                 pDM_Odm->pSecurity = pValue;
 608                 break;
 609 
 610         case ODM_CMNINFO_BW:
 611                 pDM_Odm->pBandWidth = pValue;
 612                 break;
 613 
 614         case ODM_CMNINFO_CHNL:
 615                 pDM_Odm->pChannel = pValue;
 616                 break;
 617 
 618         case ODM_CMNINFO_DMSP_GET_VALUE:
 619                 pDM_Odm->pbGetValueFromOtherMac = pValue;
 620                 break;
 621 
 622         case ODM_CMNINFO_BUDDY_ADAPTOR:
 623                 pDM_Odm->pBuddyAdapter = pValue;
 624                 break;
 625 
 626         case ODM_CMNINFO_DMSP_IS_MASTER:
 627                 pDM_Odm->pbMasterOfDMSP = pValue;
 628                 break;
 629 
 630         case ODM_CMNINFO_SCAN:
 631                 pDM_Odm->pbScanInProcess = pValue;
 632                 break;
 633 
 634         case ODM_CMNINFO_POWER_SAVING:
 635                 pDM_Odm->pbPowerSaving = pValue;
 636                 break;
 637 
 638         case ODM_CMNINFO_ONE_PATH_CCA:
 639                 pDM_Odm->pOnePathCCA = pValue;
 640                 break;
 641 
 642         case ODM_CMNINFO_DRV_STOP:
 643                 pDM_Odm->pbDriverStopped =  pValue;
 644                 break;
 645 
 646         case ODM_CMNINFO_PNP_IN:
 647                 pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep =  pValue;
 648                 break;
 649 
 650         case ODM_CMNINFO_INIT_ON:
 651                 pDM_Odm->pinit_adpt_in_progress =  pValue;
 652                 break;
 653 
 654         case ODM_CMNINFO_ANT_TEST:
 655                 pDM_Odm->pAntennaTest =  pValue;
 656                 break;
 657 
 658         case ODM_CMNINFO_NET_CLOSED:
 659                 pDM_Odm->pbNet_closed = pValue;
 660                 break;
 661 
 662         case ODM_CMNINFO_FORCED_RATE:
 663                 pDM_Odm->pForcedDataRate = pValue;
 664                 break;
 665 
 666         case ODM_CMNINFO_FORCED_IGI_LB:
 667                 pDM_Odm->pu1ForcedIgiLb = pValue;
 668                 break;
 669 
 670         case ODM_CMNINFO_MP_MODE:
 671                 pDM_Odm->mp_mode = pValue;
 672                 break;
 673 
 674         /* case ODM_CMNINFO_RTSTA_AID: */
 675         /* pDM_Odm->pAidMap =  (u8 *)pValue; */
 676         /* break; */
 677 
 678         /* case ODM_CMNINFO_BT_COEXIST: */
 679         /* pDM_Odm->BTCoexist = (bool *)pValue; */
 680 
 681         /* case ODM_CMNINFO_STA_STATUS: */
 682         /* pDM_Odm->pODM_StaInfo[] = (PSTA_INFO_T)pValue; */
 683         /* break; */
 684 
 685         /* case ODM_CMNINFO_PHY_STATUS: */
 686         /* pDM_Odm->pPhyInfo = (ODM_PHY_INFO *)pValue; */
 687         /* break; */
 688 
 689         /* case ODM_CMNINFO_MAC_STATUS: */
 690         /* pDM_Odm->pMacInfo = (struct odm_mac_status_info *)pValue; */
 691         /* break; */
 692         /* To remove the compiler warning, must add an empty default statement to handle the other values. */
 693         default:
 694                 /* do nothing */
 695                 break;
 696         }
 697 
 698 }
 699 
 700 
 701 void ODM_CmnInfoPtrArrayHook(
 702         PDM_ODM_T pDM_Odm,
 703         ODM_CMNINFO_E CmnInfo,
 704         u16 Index,
 705         void *pValue
 706 )
 707 {
 708         /*  */
 709         /*  Hook call by reference pointer. */
 710         /*  */
 711         switch (CmnInfo) {
 712         /*  */
 713         /*  Dynamic call by reference pointer. */
 714         /*  */
 715         case ODM_CMNINFO_STA_STATUS:
 716                 pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
 717                 break;
 718         /* To remove the compiler warning, must add an empty default statement to handle the other values. */
 719         default:
 720                 /* do nothing */
 721                 break;
 722         }
 723 
 724 }
 725 
 726 
 727 /*  */
 728 /*  Update Band/CHannel/.. The values are dynamic but non-per-packet. */
 729 /*  */
 730 void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value)
 731 {
 732         /*  */
 733         /*  This init variable may be changed in run time. */
 734         /*  */
 735         switch (CmnInfo) {
 736         case ODM_CMNINFO_LINK_IN_PROGRESS:
 737                 pDM_Odm->bLinkInProcess = (bool)Value;
 738                 break;
 739 
 740         case ODM_CMNINFO_ABILITY:
 741                 pDM_Odm->SupportAbility = (u32)Value;
 742                 break;
 743 
 744         case ODM_CMNINFO_RF_TYPE:
 745                 pDM_Odm->RFType = (u8)Value;
 746                 break;
 747 
 748         case ODM_CMNINFO_WIFI_DIRECT:
 749                 pDM_Odm->bWIFI_Direct = (bool)Value;
 750                 break;
 751 
 752         case ODM_CMNINFO_WIFI_DISPLAY:
 753                 pDM_Odm->bWIFI_Display = (bool)Value;
 754                 break;
 755 
 756         case ODM_CMNINFO_LINK:
 757                 pDM_Odm->bLinked = (bool)Value;
 758                 break;
 759 
 760         case ODM_CMNINFO_STATION_STATE:
 761                 pDM_Odm->bsta_state = (bool)Value;
 762                 break;
 763 
 764         case ODM_CMNINFO_RSSI_MIN:
 765                 pDM_Odm->RSSI_Min = (u8)Value;
 766                 break;
 767 
 768         case ODM_CMNINFO_DBG_COMP:
 769                 pDM_Odm->DebugComponents = Value;
 770                 break;
 771 
 772         case ODM_CMNINFO_DBG_LEVEL:
 773                 pDM_Odm->DebugLevel = (u32)Value;
 774                 break;
 775         case ODM_CMNINFO_RA_THRESHOLD_HIGH:
 776                 pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value;
 777                 break;
 778 
 779         case ODM_CMNINFO_RA_THRESHOLD_LOW:
 780                 pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value;
 781                 break;
 782         /*  The following is for BT HS mode and BT coexist mechanism. */
 783         case ODM_CMNINFO_BT_ENABLED:
 784                 pDM_Odm->bBtEnabled = (bool)Value;
 785                 break;
 786 
 787         case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
 788                 pDM_Odm->bBtConnectProcess = (bool)Value;
 789                 break;
 790 
 791         case ODM_CMNINFO_BT_HS_RSSI:
 792                 pDM_Odm->btHsRssi = (u8)Value;
 793                 break;
 794 
 795         case ODM_CMNINFO_BT_OPERATION:
 796                 pDM_Odm->bBtHsOperation = (bool)Value;
 797                 break;
 798 
 799         case ODM_CMNINFO_BT_LIMITED_DIG:
 800                 pDM_Odm->bBtLimitedDig = (bool)Value;
 801                 break;
 802 
 803         case ODM_CMNINFO_BT_DISABLE_EDCA:
 804                 pDM_Odm->bBtDisableEdcaTurbo = (bool)Value;
 805                 break;
 806 
 807 /*
 808         case    ODM_CMNINFO_OP_MODE:
 809                 pDM_Odm->OPMode = (u8)Value;
 810                 break;
 811 
 812         case    ODM_CMNINFO_WM_MODE:
 813                 pDM_Odm->WirelessMode = (u8)Value;
 814                 break;
 815 
 816         case    ODM_CMNINFO_BAND:
 817                 pDM_Odm->BandType = (u8)Value;
 818                 break;
 819 
 820         case    ODM_CMNINFO_SEC_CHNL_OFFSET:
 821                 pDM_Odm->SecChOffset = (u8)Value;
 822                 break;
 823 
 824         case    ODM_CMNINFO_SEC_MODE:
 825                 pDM_Odm->Security = (u8)Value;
 826                 break;
 827 
 828         case    ODM_CMNINFO_BW:
 829                 pDM_Odm->BandWidth = (u8)Value;
 830                 break;
 831 
 832         case    ODM_CMNINFO_CHNL:
 833                 pDM_Odm->Channel = (u8)Value;
 834                 break;
 835 */
 836         default:
 837                 /* do nothing */
 838                 break;
 839         }
 840 
 841 
 842 }
 843 
 844 void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm)
 845 {
 846         pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
 847         pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
 848 
 849         ODM_InitDebugSetting(pDM_Odm);
 850 
 851         pDM_Odm->TxRate = 0xFF;
 852 }
 853 
 854 void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm)
 855 {
 856         u8 EntryCnt = 0;
 857         u8 i;
 858         PSTA_INFO_T     pEntry;
 859 
 860         if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
 861                 if (*(pDM_Odm->pSecChOffset) == 1)
 862                         pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
 863                 else if (*(pDM_Odm->pSecChOffset) == 2)
 864                         pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
 865         } else
 866                 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
 867 
 868         for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
 869                 pEntry = pDM_Odm->pODM_StaInfo[i];
 870                 if (IS_STA_VALID(pEntry))
 871                         EntryCnt++;
 872         }
 873 
 874         if (EntryCnt == 1)
 875                 pDM_Odm->bOneEntryOnly = true;
 876         else
 877                 pDM_Odm->bOneEntryOnly = false;
 878 }
 879 
 880 void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm)
 881 {
 882         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
 883         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
 884         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility));
 885         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface =%d\n", pDM_Odm->SupportInterface));
 886         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType));
 887         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion));
 888         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion));
 889         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType =%d\n", pDM_Odm->RFType));
 890         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType));
 891         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA));
 892         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA));
 893         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW));
 894         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID =%d\n", pDM_Odm->PatchID));
 895         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest));
 896         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest));
 897         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent));
 898 
 899 }
 900 
 901 void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
 902 {
 903         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
 904         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
 905                 pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
 906         ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
 907                 pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
 908 }
 909 
 910 /* 3 ============================================================ */
 911 /* 3 DIG */
 912 /* 3 ============================================================ */
 913 /*-----------------------------------------------------------------------------
 914  * Function:    odm_DIGInit()
 915  *
 916  * Overview:    Set DIG scheme init value.
 917  *
 918  * Input:               NONE
 919  *
 920  * Output:              NONE
 921  *
 922  * Return:              NONE
 923  *
 924  * Revised History:
 925  *When          Who             Remark
 926  *
 927  *---------------------------------------------------------------------------
 928  */
 929 
 930 /* Remove DIG by yuchen */
 931 
 932 /* Remove DIG and FA check by Yu Chen */
 933 
 934 
 935 /* 3 ============================================================ */
 936 /* 3 BB Power Save */
 937 /* 3 ============================================================ */
 938 
 939 /* Remove BB power saving by Yuchen */
 940 
 941 /* 3 ============================================================ */
 942 /* 3 RATR MASK */
 943 /* 3 ============================================================ */
 944 /* 3 ============================================================ */
 945 /* 3 Rate Adaptive */
 946 /* 3 ============================================================ */
 947 
 948 void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm)
 949 {
 950         PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive;
 951 
 952         pOdmRA->Type = DM_Type_ByDriver;
 953         if (pOdmRA->Type == DM_Type_ByDriver)
 954                 pDM_Odm->bUseRAMask = true;
 955         else
 956                 pDM_Odm->bUseRAMask = false;
 957 
 958         pOdmRA->RATRState = DM_RATR_STA_INIT;
 959         pOdmRA->LdpcThres = 35;
 960         pOdmRA->bUseLdpc = false;
 961         pOdmRA->HighRSSIThresh = 50;
 962         pOdmRA->LowRSSIThresh = 20;
 963 }
 964 
 965 u32 ODM_Get_Rate_Bitmap(
 966         PDM_ODM_T pDM_Odm,
 967         u32 macid,
 968         u32 ra_mask,
 969         u8 rssi_level
 970 )
 971 {
 972         PSTA_INFO_T     pEntry;
 973         u32 rate_bitmap = 0;
 974         u8 WirelessMode;
 975 
 976         pEntry = pDM_Odm->pODM_StaInfo[macid];
 977         if (!IS_STA_VALID(pEntry))
 978                 return ra_mask;
 979 
 980         WirelessMode = pEntry->wireless_mode;
 981 
 982         switch (WirelessMode) {
 983         case ODM_WM_B:
 984                 if (ra_mask & 0x0000000c)               /* 11M or 5.5M enable */
 985                         rate_bitmap = 0x0000000d;
 986                 else
 987                         rate_bitmap = 0x0000000f;
 988                 break;
 989 
 990         case (ODM_WM_G):
 991         case (ODM_WM_A):
 992                 if (rssi_level == DM_RATR_STA_HIGH)
 993                         rate_bitmap = 0x00000f00;
 994                 else
 995                         rate_bitmap = 0x00000ff0;
 996                 break;
 997 
 998         case (ODM_WM_B|ODM_WM_G):
 999                 if (rssi_level == DM_RATR_STA_HIGH)
1000                         rate_bitmap = 0x00000f00;
1001                 else if (rssi_level == DM_RATR_STA_MIDDLE)
1002                         rate_bitmap = 0x00000ff0;
1003                 else
1004                         rate_bitmap = 0x00000ff5;
1005                 break;
1006 
1007         case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
1008         case (ODM_WM_B|ODM_WM_N24G):
1009         case (ODM_WM_G|ODM_WM_N24G):
1010         case (ODM_WM_A|ODM_WM_N5G):
1011                 if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
1012                         if (rssi_level == DM_RATR_STA_HIGH)
1013                                 rate_bitmap = 0x000f0000;
1014                         else if (rssi_level == DM_RATR_STA_MIDDLE)
1015                                 rate_bitmap = 0x000ff000;
1016                         else {
1017                                 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
1018                                         rate_bitmap = 0x000ff015;
1019                                 else
1020                                         rate_bitmap = 0x000ff005;
1021                         }
1022                 } else {
1023                         if (rssi_level == DM_RATR_STA_HIGH)
1024                                 rate_bitmap = 0x0f8f0000;
1025                         else if (rssi_level == DM_RATR_STA_MIDDLE)
1026                                 rate_bitmap = 0x0f8ff000;
1027                         else {
1028                                 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
1029                                         rate_bitmap = 0x0f8ff015;
1030                                 else
1031                                         rate_bitmap = 0x0f8ff005;
1032                         }
1033                 }
1034                 break;
1035 
1036         case (ODM_WM_AC|ODM_WM_G):
1037                 if (rssi_level == 1)
1038                         rate_bitmap = 0xfc3f0000;
1039                 else if (rssi_level == 2)
1040                         rate_bitmap = 0xfffff000;
1041                 else
1042                         rate_bitmap = 0xffffffff;
1043                 break;
1044 
1045         case (ODM_WM_AC|ODM_WM_A):
1046 
1047                 if (pDM_Odm->RFType == RF_1T1R) {
1048                         if (rssi_level == 1)                            /*  add by Gary for ac-series */
1049                                 rate_bitmap = 0x003f8000;
1050                         else if (rssi_level == 2)
1051                                 rate_bitmap = 0x003ff000;
1052                         else
1053                                 rate_bitmap = 0x003ff010;
1054                 } else {
1055                         if (rssi_level == 1)                            /*  add by Gary for ac-series */
1056                                 rate_bitmap = 0xfe3f8000;       /*  VHT 2SS MCS3~9 */
1057                         else if (rssi_level == 2)
1058                                 rate_bitmap = 0xfffff000;       /*  VHT 2SS MCS0~9 */
1059                         else
1060                                 rate_bitmap = 0xfffff010;       /*  All */
1061                 }
1062                 break;
1063 
1064         default:
1065                 if (pDM_Odm->RFType == RF_1T2R)
1066                         rate_bitmap = 0x000fffff;
1067                 else
1068                         rate_bitmap = 0x0fffffff;
1069                 break;
1070         }
1071 
1072         /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", __func__, rssi_level, WirelessMode, rate_bitmap); */
1073         ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", rssi_level, WirelessMode, rate_bitmap));
1074 
1075         return ra_mask & rate_bitmap;
1076 
1077 }
1078 
1079 /*-----------------------------------------------------------------------------
1080 * Function:     odm_RefreshRateAdaptiveMask()
1081 *
1082 * Overview:     Update rate table mask according to rssi
1083 *
1084 * Input:                NONE
1085 *
1086 * Output:               NONE
1087 *
1088 * Return:               NONE
1089 *
1090 * Revised History:
1091 *When           Who             Remark
1092 *05/27/2009     hpfan   Create Version 0.
1093 *
1094 * --------------------------------------------------------------------------
1095 */
1096 void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm)
1097 {
1098 
1099         ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
1100         if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
1101                 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
1102                 return;
1103         }
1104         odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
1105 }
1106 
1107 void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm)
1108 {
1109         u8 i;
1110         struct adapter *padapter =  pDM_Odm->Adapter;
1111 
1112         if (padapter->bDriverStopped) {
1113                 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
1114                 return;
1115         }
1116 
1117         if (!pDM_Odm->bUseRAMask) {
1118                 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
1119                 return;
1120         }
1121 
1122         /* printk("==> %s\n", __func__); */
1123 
1124         for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
1125                 PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
1126 
1127                 if (IS_STA_VALID(pstat)) {
1128                         if (IS_MCAST(pstat->hwaddr))  /* if (psta->mac_id == 1) */
1129                                 continue;
1130                         if (IS_MCAST(pstat->hwaddr))
1131                                 continue;
1132 
1133                         if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
1134                                 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level));
1135                                 /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */
1136                                 rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
1137                         }
1138 
1139                 }
1140         }
1141 }
1142 
1143 /*  Return Value: bool */
1144 /*  - true: RATRState is changed. */
1145 bool ODM_RAStateCheck(
1146         PDM_ODM_T pDM_Odm,
1147         s32 RSSI,
1148         bool bForceUpdate,
1149         u8 *pRATRState
1150 )
1151 {
1152         PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
1153         const u8 GoUpGap = 5;
1154         u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
1155         u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
1156         u8 RATRState;
1157 
1158         /*  Threshold Adjustment: */
1159         /*  when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */
1160         /*  Here GoUpGap is added to solve the boundary's level alternation issue. */
1161         switch (*pRATRState) {
1162         case DM_RATR_STA_INIT:
1163         case DM_RATR_STA_HIGH:
1164                 break;
1165 
1166         case DM_RATR_STA_MIDDLE:
1167                 HighRSSIThreshForRA += GoUpGap;
1168                 break;
1169 
1170         case DM_RATR_STA_LOW:
1171                 HighRSSIThreshForRA += GoUpGap;
1172                 LowRSSIThreshForRA += GoUpGap;
1173                 break;
1174 
1175         default:
1176                 ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
1177                 break;
1178         }
1179 
1180         /*  Decide RATRState by RSSI. */
1181         if (RSSI > HighRSSIThreshForRA)
1182                 RATRState = DM_RATR_STA_HIGH;
1183         else if (RSSI > LowRSSIThreshForRA)
1184                 RATRState = DM_RATR_STA_MIDDLE;
1185         else
1186                 RATRState = DM_RATR_STA_LOW;
1187         /* printk("==>%s, RATRState:0x%02x , RSSI:%d\n", __func__, RATRState, RSSI); */
1188 
1189         if (*pRATRState != RATRState || bForceUpdate) {
1190                 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
1191                 *pRATRState = RATRState;
1192                 return true;
1193         }
1194 
1195         return false;
1196 }
1197 
1198 
1199 /*  */
1200 
1201 /* 3 ============================================================ */
1202 /* 3 Dynamic Tx Power */
1203 /* 3 ============================================================ */
1204 
1205 /* Remove BY YuChen */
1206 
1207 /* 3 ============================================================ */
1208 /* 3 RSSI Monitor */
1209 /* 3 ============================================================ */
1210 
1211 void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm)
1212 {
1213         pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
1214 
1215         pRA_Table->firstconnect = false;
1216 
1217 }
1218 
1219 void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm)
1220 {
1221         if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
1222                 return;
1223 
1224         odm_RSSIMonitorCheckCE(pDM_Odm);
1225 
1226 }       /*  odm_RSSIMonitorCheck */
1227 
1228 static void FindMinimumRSSI(struct adapter *padapter)
1229 {
1230         struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
1231         struct dm_priv *pdmpriv = &pHalData->dmpriv;
1232         PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
1233 
1234         /* 1 1.Determine the minimum RSSI */
1235 
1236         if (
1237                 (pDM_Odm->bLinked != true) &&
1238                 (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
1239         ) {
1240                 pdmpriv->MinUndecoratedPWDBForDM = 0;
1241                 /* ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any\n")); */
1242         } else
1243                 pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
1244 
1245         /* DBG_8192C("%s =>MinUndecoratedPWDBForDM(%d)\n", __func__, pdmpriv->MinUndecoratedPWDBForDM); */
1246         /* ODM_RT_TRACE(pDM_Odm, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", pHalData->MinUndecoratedPWDBForDM)); */
1247 }
1248 
1249 void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm)
1250 {
1251         struct adapter *Adapter = pDM_Odm->Adapter;
1252         struct hal_com_data     *pHalData = GET_HAL_DATA(Adapter);
1253         struct dm_priv *pdmpriv = &pHalData->dmpriv;
1254         int i;
1255         int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
1256         u8 sta_cnt = 0;
1257         u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
1258         pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
1259 
1260         if (pDM_Odm->bLinked != true)
1261                 return;
1262 
1263         pRA_Table->firstconnect = pDM_Odm->bLinked;
1264 
1265         /* if (check_fwstate(&Adapter->mlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) */
1266         {
1267                 struct sta_info *psta;
1268 
1269                 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
1270                         psta = pDM_Odm->pODM_StaInfo[i];
1271                         if (IS_STA_VALID(psta)) {
1272                                 if (IS_MCAST(psta->hwaddr))  /* if (psta->mac_id == 1) */
1273                                         continue;
1274 
1275                                 if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
1276                                         continue;
1277 
1278                                 if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
1279                                         tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
1280 
1281                                 if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
1282                                         tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
1283 
1284                                 if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
1285                                         PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
1286                         }
1287                 }
1288 
1289                 /* printk("%s ==> sta_cnt(%d)\n", __func__, sta_cnt); */
1290 
1291                 for (i = 0; i < sta_cnt; i++) {
1292                         if (PWDB_rssi[i] != (0)) {
1293                                 if (pHalData->fw_ractrl == true)/*  Report every sta's RSSI to FW */
1294                                         rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
1295                         }
1296                 }
1297         }
1298 
1299 
1300 
1301         if (tmpEntryMaxPWDB != 0)       /*  If associated entry is found */
1302                 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
1303         else
1304                 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
1305 
1306         if (tmpEntryMinPWDB != 0xff) /*  If associated entry is found */
1307                 pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
1308         else
1309                 pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
1310 
1311         FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */
1312 
1313         pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
1314         /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */
1315 }
1316 
1317 /* 3 ============================================================ */
1318 /* 3 Tx Power Tracking */
1319 /* 3 ============================================================ */
1320 
1321 static u8 getSwingIndex(PDM_ODM_T pDM_Odm)
1322 {
1323         struct adapter *Adapter = pDM_Odm->Adapter;
1324         u8 i = 0;
1325         u32 bbSwing;
1326         u32 swingTableSize;
1327         u32 *pSwingTable;
1328 
1329         bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
1330 
1331         pSwingTable = OFDMSwingTable_New;
1332         swingTableSize = OFDM_TABLE_SIZE;
1333 
1334         for (i = 0; i < swingTableSize; ++i) {
1335                 u32 tableValue = pSwingTable[i];
1336 
1337                 if (tableValue >= 0x100000)
1338                         tableValue >>= 22;
1339                 if (bbSwing == tableValue)
1340                         break;
1341         }
1342         return i;
1343 }
1344 
1345 void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm)
1346 {
1347         u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
1348         u8 p = 0;
1349         struct adapter *Adapter = pDM_Odm->Adapter;
1350         struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1351 
1352 
1353         struct dm_priv *pdmpriv = &pHalData->dmpriv;
1354 
1355         pdmpriv->bTXPowerTracking = true;
1356         pdmpriv->TXPowercount = 0;
1357         pdmpriv->bTXPowerTrackingInit = false;
1358 
1359         if (*(pDM_Odm->mp_mode) != 1)
1360                 pdmpriv->TxPowerTrackControl = true;
1361         else
1362                 pdmpriv->TxPowerTrackControl = false;
1363 
1364 
1365         /* MSG_8192C("pdmpriv->TxPowerTrackControl = %d\n", pdmpriv->TxPowerTrackControl); */
1366 
1367         /* pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; */
1368         pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
1369         pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
1370         pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
1371 
1372         /*  The index of "0 dB" in SwingTable. */
1373         pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
1374         pDM_Odm->DefaultCckIndex = 20;
1375 
1376         pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
1377         pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
1378 
1379         for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
1380                 pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
1381                 pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
1382                 pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
1383                 pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
1384                 pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
1385         }
1386 
1387 }
1388 
1389 void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm)
1390 {
1391         struct adapter *Adapter = pDM_Odm->Adapter;
1392 
1393         if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
1394                 return;
1395 
1396         if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */
1397                 PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
1398 
1399                 /* DBG_871X("Trigger Thermal Meter!!\n"); */
1400 
1401                 pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
1402                 return;
1403         } else {
1404                 /* DBG_871X("Schedule TxPowerTracking direct call!!\n"); */
1405                 ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
1406                 pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
1407         }
1408 }
1409 
1410 /* 3 ============================================================ */
1411 /* 3 SW Antenna Diversity */
1412 /* 3 ============================================================ */
1413 void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm)
1414 {
1415         pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
1416 
1417         pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
1418         pDM_SWAT_Table->PreAntenna = MAIN_ANT;
1419         pDM_SWAT_Table->CurAntenna = MAIN_ANT;
1420         pDM_SWAT_Table->SWAS_NoLink_State = 0;
1421 }

/* [<][>][^][v][top][bottom][index][help] */