Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/halrf/halrf_powertracking_win.c
1308 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/1415/*============================================================ */16/* include files */17/*============================================================ */18#include "mp_precomp.h"19#include "phydm_precomp.h"2021/* ************************************************************22* Global var23* ************************************************************ */2425u32 ofdm_swing_table[OFDM_TABLE_SIZE] = {260x7f8001fe, /* 0, +6.0dB */270x788001e2, /* 1, +5.5dB */280x71c001c7, /* 2, +5.0dB */290x6b8001ae, /* 3, +4.5dB */300x65400195, /* 4, +4.0dB */310x5fc0017f, /* 5, +3.5dB */320x5a400169, /* 6, +3.0dB */330x55400155, /* 7, +2.5dB */340x50800142, /* 8, +2.0dB */350x4c000130, /* 9, +1.5dB */360x47c0011f, /* 10, +1.0dB */370x43c0010f, /* 11, +0.5dB */380x40000100, /* 12, +0dB */390x3c8000f2, /* 13, -0.5dB */400x390000e4, /* 14, -1.0dB */410x35c000d7, /* 15, -1.5dB */420x32c000cb, /* 16, -2.0dB */430x300000c0, /* 17, -2.5dB */440x2d4000b5, /* 18, -3.0dB */450x2ac000ab, /* 19, -3.5dB */460x288000a2, /* 20, -4.0dB */470x26000098, /* 21, -4.5dB */480x24000090, /* 22, -5.0dB */490x22000088, /* 23, -5.5dB */500x20000080, /* 24, -6.0dB */510x1e400079, /* 25, -6.5dB */520x1c800072, /* 26, -7.0dB */530x1b00006c, /* 27. -7.5dB */540x19800066, /* 28, -8.0dB */550x18000060, /* 29, -8.5dB */560x16c0005b, /* 30, -9.0dB */570x15800056, /* 31, -9.5dB */580x14400051, /* 32, -10.0dB */590x1300004c, /* 33, -10.5dB */600x12000048, /* 34, -11.0dB */610x11000044, /* 35, -11.5dB */620x10000040, /* 36, -12.0dB */63};6465u8 cck_swing_table_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};100101102u8 cck_swing_table_ch14[CCK_TABLE_SIZE][8] = {103{0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */104{0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */105{0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */106{0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */107{0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */108{0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */109{0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */110{0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */111{0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */112{0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */113{0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */114{0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */115{0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB <== default */116{0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */117{0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */118{0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */119{0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */120{0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */121{0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */122{0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */123{0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */124{0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */125{0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */126{0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */127{0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */128{0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */129{0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */130{0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */131{0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */132{0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */133{0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */134{0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */135{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */136};137138139u32 ofdm_swing_table_new[OFDM_TABLE_SIZE] = {1400x0b40002d, /* 0, -15.0dB */1410x0c000030, /* 1, -14.5dB */1420x0cc00033, /* 2, -14.0dB */1430x0d800036, /* 3, -13.5dB */1440x0e400039, /* 4, -13.0dB */1450x0f00003c, /* 5, -12.5dB */1460x10000040, /* 6, -12.0dB */1470x11000044, /* 7, -11.5dB */1480x12000048, /* 8, -11.0dB */1490x1300004c, /* 9, -10.5dB */1500x14400051, /* 10, -10.0dB */1510x15800056, /* 11, -9.5dB */1520x16c0005b, /* 12, -9.0dB */1530x18000060, /* 13, -8.5dB */1540x19800066, /* 14, -8.0dB */1550x1b00006c, /* 15, -7.5dB */1560x1c800072, /* 16, -7.0dB */1570x1e400079, /* 17, -6.5dB */1580x20000080, /* 18, -6.0dB */1590x22000088, /* 19, -5.5dB */1600x24000090, /* 20, -5.0dB */1610x26000098, /* 21, -4.5dB */1620x288000a2, /* 22, -4.0dB */1630x2ac000ab, /* 23, -3.5dB */1640x2d4000b5, /* 24, -3.0dB */1650x300000c0, /* 25, -2.5dB */1660x32c000cb, /* 26, -2.0dB */1670x35c000d7, /* 27, -1.5dB */1680x390000e4, /* 28, -1.0dB */1690x3c8000f2, /* 29, -0.5dB */1700x40000100, /* 30, +0dB */1710x43c0010f, /* 31, +0.5dB */1720x47c0011f, /* 32, +1.0dB */1730x4c000130, /* 33, +1.5dB */1740x50800142, /* 34, +2.0dB */1750x55400155, /* 35, +2.5dB */1760x5a400169, /* 36, +3.0dB */1770x5fc0017f, /* 37, +3.5dB */1780x65400195, /* 38, +4.0dB */1790x6b8001ae, /* 39, +4.5dB */1800x71c001c7, /* 40, +5.0dB */1810x788001e2, /* 41, +5.5dB */1820x7f8001fe /* 42, +6.0dB */183};184185186u8 cck_swing_table_ch1_ch14_88f[CCK_TABLE_SIZE_88F][16] = {187{0x44, 0x42, 0x3C, 0x33, 0x28, 0x1C, 0x13, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-16dB*/188{0x48, 0x46, 0x3F, 0x36, 0x2A, 0x1E, 0x14, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15.5dB*/189{0x4D, 0x4A, 0x43, 0x39, 0x2C, 0x20, 0x15, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15dB*/190{0x51, 0x4F, 0x47, 0x3C, 0x2F, 0x22, 0x16, 0x0D, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14.5dB*/191{0x56, 0x53, 0x4B, 0x40, 0x32, 0x24, 0x17, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14dB*/192{0x5B, 0x58, 0x50, 0x43, 0x35, 0x26, 0x19, 0x0E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13.5dB*/193{0x60, 0x5D, 0x54, 0x47, 0x38, 0x28, 0x1A, 0x0F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13dB*/194{0x66, 0x63, 0x59, 0x4C, 0x3B, 0x2B, 0x1C, 0x10, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12.5dB*/195{0x6C, 0x69, 0x5F, 0x50, 0x3F, 0x2D, 0x1E, 0x11, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12dB*/196{0x73, 0x6F, 0x64, 0x55, 0x42, 0x30, 0x1F, 0x12, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11.5dB*/197{0x79, 0x76, 0x6A, 0x5A, 0x46, 0x33, 0x21, 0x13, 0x09, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11dB*/198{0x81, 0x7C, 0x71, 0x5F, 0x4A, 0x36, 0x23, 0x14, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10.5dB*/199{0x88, 0x84, 0x77, 0x65, 0x4F, 0x39, 0x25, 0x15, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10dB*/200{0x90, 0x8C, 0x7E, 0x6B, 0x54, 0x3C, 0x27, 0x17, 0x0B, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9.5dB*/201{0x99, 0x94, 0x86, 0x71, 0x58, 0x40, 0x2A, 0x18, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9dB*/202{0xA2, 0x9D, 0x8E, 0x78, 0x5E, 0x43, 0x2C, 0x19, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8.5dB*/203{0xAC, 0xA6, 0x96, 0x7F, 0x63, 0x47, 0x2F, 0x1B, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8dB*/204{0xB6, 0xB0, 0x9F, 0x87, 0x69, 0x4C, 0x32, 0x1D, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7.5dB*/205{0xC1, 0xBA, 0xA8, 0x8F, 0x6F, 0x50, 0x35, 0x1E, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7dB*/206{0xCC, 0xC5, 0xB2, 0x97, 0x76, 0x55, 0x38, 0x20, 0x0F, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-6.5dB*/207{0xD8, 0xD1, 0xBD, 0xA0, 0x7D, 0x5A, 0x3B, 0x22, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /*-6dB*/208};209210211u8 cck_swing_table_ch1_ch13_88f[CCK_TABLE_SIZE_88F][16] = {212{0x44, 0x42, 0x3C, 0x33, 0x28, 0x1C, 0x13, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-16dB*/213{0x48, 0x46, 0x3F, 0x36, 0x2A, 0x1E, 0x14, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15.5dB*/214{0x4D, 0x4A, 0x43, 0x39, 0x2C, 0x20, 0x15, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15dB*/215{0x51, 0x4F, 0x47, 0x3C, 0x2F, 0x22, 0x16, 0x0D, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14.5dB*/216{0x56, 0x53, 0x4B, 0x40, 0x32, 0x24, 0x17, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14dB*/217{0x5B, 0x58, 0x50, 0x43, 0x35, 0x26, 0x19, 0x0E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13.5dB*/218{0x60, 0x5D, 0x54, 0x47, 0x38, 0x28, 0x1A, 0x0F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13dB*/219{0x66, 0x63, 0x59, 0x4C, 0x3B, 0x2B, 0x1C, 0x10, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12.5dB*/220{0x6C, 0x69, 0x5F, 0x50, 0x3F, 0x2D, 0x1E, 0x11, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12dB*/221{0x73, 0x6F, 0x64, 0x55, 0x42, 0x30, 0x1F, 0x12, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11.5dB*/222{0x79, 0x76, 0x6A, 0x5A, 0x46, 0x33, 0x21, 0x13, 0x09, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11dB*/223{0x81, 0x7C, 0x71, 0x5F, 0x4A, 0x36, 0x23, 0x14, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10.5dB*/224{0x88, 0x84, 0x77, 0x65, 0x4F, 0x39, 0x25, 0x15, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10dB*/225{0x90, 0x8C, 0x7E, 0x6B, 0x54, 0x3C, 0x27, 0x17, 0x0B, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9.5dB*/226{0x99, 0x94, 0x86, 0x71, 0x58, 0x40, 0x2A, 0x18, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9dB*/227{0xA2, 0x9D, 0x8E, 0x78, 0x5E, 0x43, 0x2C, 0x19, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8.5dB*/228{0xAC, 0xA6, 0x96, 0x7F, 0x63, 0x47, 0x2F, 0x1B, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8dB*/229{0xB6, 0xB0, 0x9F, 0x87, 0x69, 0x4C, 0x32, 0x1D, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7.5dB*/230{0xC1, 0xBA, 0xA8, 0x8F, 0x6F, 0x50, 0x35, 0x1E, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7dB*/231{0xCC, 0xC5, 0xB2, 0x97, 0x76, 0x55, 0x38, 0x20, 0x0F, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-6.5dB*/232{0xD8, 0xD1, 0xBD, 0xA0, 0x7D, 0x5A, 0x3B, 0x22, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /*-6dB*/233};234235236u8 cck_swing_table_ch14_88f[CCK_TABLE_SIZE_88F][16] = {237{0x44, 0x42, 0x3C, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-16dB*/238{0x48, 0x46, 0x3F, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15.5dB*/239{0x4D, 0x4A, 0x43, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15dB*/240{0x51, 0x4F, 0x47, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14.5dB*/241{0x56, 0x53, 0x4B, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14dB*/242{0x5B, 0x58, 0x50, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13.5dB*/243{0x60, 0x5D, 0x54, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13dB*/244{0x66, 0x63, 0x59, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12.5dB*/245{0x6C, 0x69, 0x5F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12dB*/246{0x73, 0x6F, 0x64, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11.5dB*/247{0x79, 0x76, 0x6A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11dB*/248{0x81, 0x7C, 0x71, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10.5dB*/249{0x88, 0x84, 0x77, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10dB*/250{0x90, 0x8C, 0x7E, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9.5dB*/251{0x99, 0x94, 0x86, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9dB*/252{0xA2, 0x9D, 0x8E, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8.5dB*/253{0xAC, 0xA6, 0x96, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8dB*/254{0xB6, 0xB0, 0x9F, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7.5dB*/255{0xC1, 0xBA, 0xA8, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7dB*/256{0xCC, 0xC5, 0xB2, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-6.5dB*/257{0xD8, 0xD1, 0xBD, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /*-6dB*/258};259260261u8 cck_swing_table_ch1_ch13_new[CCK_TABLE_SIZE][8] = {262{0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}, /* 0, -16.0dB */263{0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 1, -15.5dB */264{0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 2, -15.0dB */265{0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 3, -14.5dB */266{0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 4, -14.0dB */267{0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 5, -13.5dB */268{0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 6, -13.0dB */269{0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 7, -12.5dB */270{0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 8, -12.0dB */271{0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 9, -11.5dB */272{0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 10, -11.0dB */273{0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 11, -10.5dB */274{0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 12, -10.0dB */275{0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 13, -9.5dB */276{0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 14, -9.0dB */277{0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 15, -8.5dB */278{0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */279{0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 17, -7.5dB */280{0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 18, -7.0dB */281{0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 19, -6.5dB */282{0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 20, -6.0dB */283{0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 21, -5.5dB */284{0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 22, -5.0dB */285{0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 23, -4.5dB */286{0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 24, -4.0dB */287{0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 25, -3.5dB */288{0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 26, -3.0dB */289{0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 27, -2.5dB */290{0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 28, -2.0dB */291{0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 29, -1.5dB */292{0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 30, -1.0dB */293{0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 31, -0.5dB */294{0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04} /* 32, +0dB */295};296297298u8 cck_swing_table_ch14_new[CCK_TABLE_SIZE][8] = {299{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}, /* 0, -16.0dB */300{0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 1, -15.5dB */301{0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 2, -15.0dB */302{0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 3, -14.5dB */303{0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 4, -14.0dB */304{0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 5, -13.5dB */305{0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 6, -13.0dB */306{0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 7, -12.5dB */307{0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 8, -12.0dB */308{0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 9, -11.5dB */309{0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 10, -11.0dB */310{0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 11, -10.5dB */311{0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 12, -10.0dB */312{0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 13, -9.5dB */313{0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 14, -9.0dB */314{0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 15, -8.5dB */315{0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */316{0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 17, -7.5dB */317{0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 18, -7.0dB */318{0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 19, -6.5dB */319{0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 20, -6.0dB */320{0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 21, -5.5dB */321{0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 22, -5.0dB */322{0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 23, -4.5dB */323{0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 24, -4.0dB */324{0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 25, -3.5dB */325{0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 26, -3.0dB */326{0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 27, -2.5dB */327{0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 28, -2.0dB */328{0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 29, -1.5dB */329{0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 30, -1.0dB */330{0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 31, -0.5dB */331{0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00} /* 32, +0dB */332};333u32 cck_swing_table_ch1_ch14_8723d[CCK_TABLE_SIZE_8723D] = {3340x0CD,3350x0D9,3360x0E6,3370x0F3,3380x102,3390x111,3400x121,3410x132,3420x144,3430x158,3440x16C,3450x182,3460x198,3470x1B1,3480x1CA,3490x1E5,3500x202,3510x221,3520x241,3530x263,3540x287,3550x2AE,3560x2D6,3570x301,3580x32F,3590x35F,3600x392,3610x3C9,3620x402,3630x43F,3640x47F,3650x4C3,3660x50C,3670x558,3680x5A9,3690x5FF,3700x65A,3710x6BA,3720x720,3730x78C,3740x7FF,375};376/* JJ ADD 20161014 */377u32 cck_swing_table_ch1_ch14_8710b[CCK_TABLE_SIZE_8710B] = {3780x0CD, /*0 , -20dB*/3790x0D9,3800x0E6,3810x0F3,3820x102,3830x111,3840x121,3850x132,3860x144,3870x158,3880x16C,3890x182,3900x198,3910x1B1,3920x1CA,3930x1E5,3940x202,3950x221,3960x241,3970x263, /*19*/3980x287, /*20*/3990x2AE, /*21*/4000x2D6, /*22*/4010x301, /*23*/4020x32F, /*24*/4030x35F, /*25*/4040x392, /*26*/4050x3C9, /*27*/4060x402, /*28*/4070x43F, /*29*/4080x47F, /*30*/4090x4C3, /*31*/4100x50C, /*32*/4110x558, /*33*/4120x5A9, /*34*/4130x5FF, /*35*/4140x65A, /*36*/4150x6BA,4160x720,4170x78C,4180x7FF,419};420421/* Winnita ADD 20170828 PathA 0xAB4[10:0],PathB 0xAB4[21:11]*/422u32 cck_swing_table_ch1_ch14_8192f[CCK_TABLE_SIZE_8192F] = {4230x0CD, /*0 , -20dB*/4240x0D9,4250x0E6,4260x0F3,4270x102,4280x111,4290x121,4300x132,4310x144,4320x158,4330x16C,4340x182,4350x198,4360x1B1,4370x1CA,4380x1E5,4390x202,4400x221,4410x241,4420x263, /*19*/4430x287, /*20*/4440x2AE, /*21*/4450x2D6, /*22*/4460x301, /*23*/4470x32F, /*24*/4480x35F, /*25*/4490x392, /*26*/4500x3C9, /*27*/4510x402, /*28*/4520x43F, /*29*/4530x47F, /*30*/4540x4C3, /*31*/4550x50C, /*32*/4560x558, /*33*/4570x5A9, /*34*/4580x5FF, /*35*/4590x65A, /*36*/4600x6BA,4610x720,4620x78C,4630x7FF,464};465466u32 tx_scaling_table_jaguar[TXSCALE_TABLE_SIZE] = {4670x081, /* 0, -12.0dB */4680x088, /* 1, -11.5dB */4690x090, /* 2, -11.0dB */4700x099, /* 3, -10.5dB */4710x0A2, /* 4, -10.0dB */4720x0AC, /* 5, -9.5dB */4730x0B6, /* 6, -9.0dB */4740x0C0, /* 7, -8.5dB */4750x0CC, /* 8, -8.0dB */4760x0D8, /* 9, -7.5dB */4770x0E5, /* 10, -7.0dB */4780x0F2, /* 11, -6.5dB */4790x101, /* 12, -6.0dB */4800x110, /* 13, -5.5dB */4810x120, /* 14, -5.0dB */4820x131, /* 15, -4.5dB */4830x143, /* 16, -4.0dB */4840x156, /* 17, -3.5dB */4850x16A, /* 18, -3.0dB */4860x180, /* 19, -2.5dB */4870x197, /* 20, -2.0dB */4880x1AF, /* 21, -1.5dB */4890x1C8, /* 22, -1.0dB */4900x1E3, /* 23, -0.5dB */4910x200, /* 24, +0 dB */4920x21E, /* 25, +0.5dB */4930x23E, /* 26, +1.0dB */4940x261, /* 27, +1.5dB */4950x285, /* 28, +2.0dB */4960x2AB, /* 29, +2.5dB */4970x2D3, /* 30, +3.0dB */4980x2FE, /* 31, +3.5dB */4990x32B, /* 32, +4.0dB */5000x35C, /* 33, +4.5dB */5010x38E, /* 34, +5.0dB */5020x3C4, /* 35, +5.5dB */5030x3FE /* 36, +6.0dB */504};505506void507odm_txpowertracking_init(508void *dm_void509)510{511struct dm_struct *dm = (struct dm_struct *)dm_void;512#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))513if (!(dm->support_ic_type & (ODM_RTL8814A | ODM_IC_11N_SERIES | ODM_RTL8822B)))514return;515#endif516517odm_txpowertracking_thermal_meter_init(dm);518}519520u8521get_swing_index(522void *dm_void523)524{525struct dm_struct *dm = (struct dm_struct *)dm_void;526void *adapter = dm->adapter;527HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));528u8 i = 0;529u32 bb_swing, table_value;530531if (dm->support_ic_type == ODM_RTL8188E || dm->support_ic_type == ODM_RTL8723B ||532dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type == ODM_RTL8188F ||533dm->support_ic_type == ODM_RTL8703B || dm->support_ic_type == ODM_RTL8723D ||534dm->support_ic_type == ODM_RTL8192F || dm->support_ic_type == ODM_RTL8710B ||535dm->support_ic_type == ODM_RTL8821) {536bb_swing = odm_get_bb_reg(dm, REG_OFDM_0_XA_TX_IQ_IMBALANCE, 0xFFC00000);537538for (i = 0; i < OFDM_TABLE_SIZE; i++) {539table_value = ofdm_swing_table_new[i];540541if (table_value >= 0x100000)542table_value >>= 22;543if (bb_swing == table_value)544break;545}546} else {547bb_swing = PHY_GetTxBBSwing_8812A(adapter, hal_data->CurrentBandType, RF_PATH_A);548549for (i = 0; i < TXSCALE_TABLE_SIZE; i++) {550table_value = tx_scaling_table_jaguar[i];551552if (bb_swing == table_value)553break;554}555}556557return i;558}559560u8561get_cck_swing_index(562void *dm_void563)564{565struct dm_struct *dm = (struct dm_struct *)dm_void;566567u8 i = 0;568u32 bb_cck_swing;569570if (dm->support_ic_type == ODM_RTL8188E || dm->support_ic_type == ODM_RTL8723B ||571dm->support_ic_type == ODM_RTL8192E) {572bb_cck_swing = odm_read_1byte(dm, 0xa22);573574for (i = 0; i < CCK_TABLE_SIZE; i++) {575if (bb_cck_swing == cck_swing_table_ch1_ch13_new[i][0])576break;577}578} else if (dm->support_ic_type == ODM_RTL8703B) {579bb_cck_swing = odm_read_1byte(dm, 0xa22);580581for (i = 0; i < CCK_TABLE_SIZE_88F; i++) {582if (bb_cck_swing == cck_swing_table_ch1_ch14_88f[i][0])583break;584}585}586587return i;588}589590591void592odm_txpowertracking_thermal_meter_init(593void *dm_void594)595{596struct dm_struct *dm = (struct dm_struct *)dm_void;597u8 default_swing_index = get_swing_index(dm);598u8 default_cck_swing_index = get_cck_swing_index(dm);599struct dm_rf_calibration_struct *cali_info = &(dm->rf_calibrate_info);600struct _hal_rf_ *rf = &dm->rf_table;601struct _halrf_tssi_data *tssi = &rf->halrf_tssi_data;602603#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)604void *adapter = dm->adapter;605HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));606u8 p = 0;607608if (*(dm->mp_mode) == false)609cali_info->txpowertrack_control = true;610#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)611#ifdef CONFIG_RTL8188E612{613cali_info->is_txpowertracking = true;614cali_info->tx_powercount = 0;615cali_info->is_txpowertracking_init = false;616617if (*(dm->mp_mode) == false)618cali_info->txpowertrack_control = true;619620MSG_8192C("dm txpowertrack_control = %d\n", cali_info->txpowertrack_control);621}622#else623{624void *adapter = dm->adapter;625HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));626struct dm_priv *pdmpriv = &hal_data->dmpriv;627628pdmpriv->is_txpowertracking = true;629pdmpriv->tx_powercount = 0;630pdmpriv->is_txpowertracking_init = false;631632if (*(dm->mp_mode) == false)633pdmpriv->txpowertrack_control = true;634635MSG_8192C("pdmpriv->txpowertrack_control = %d\n", pdmpriv->txpowertrack_control);636637}638#endif639#elif (DM_ODM_SUPPORT_TYPE & (ODM_AP))640#ifdef RTL8188E_SUPPORT641{642cali_info->is_txpowertracking = true;643cali_info->tx_powercount = 0;644cali_info->is_txpowertracking_init = false;645cali_info->txpowertrack_control = true;646}647#endif648#endif649650#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)651#if (MP_DRIVER == 1)652cali_info->txpowertrack_control = false;653#else654cali_info->txpowertrack_control = true;655#endif656#else657cali_info->txpowertrack_control = true;658#endif659660cali_info->thermal_value = hal_data->eeprom_thermal_meter;661cali_info->thermal_value_iqk = hal_data->eeprom_thermal_meter;662cali_info->thermal_value_lck = hal_data->eeprom_thermal_meter;663664#if (RTL8822C_SUPPORT == 1 || RTL8814B_SUPPORT == 1)665if (dm->support_ic_type == ODM_RTL8822C) {666cali_info->thermal_value_path[RF_PATH_A] = tssi->thermal[RF_PATH_A];667cali_info->thermal_value_path[RF_PATH_B] = tssi->thermal[RF_PATH_B];668cali_info->thermal_value_iqk = tssi->thermal[RF_PATH_A];669cali_info->thermal_value_lck = tssi->thermal[RF_PATH_A];670}671672if (dm->support_ic_type == ODM_RTL8814B) {673cali_info->thermal_value_path[RF_PATH_A] = tssi->thermal[RF_PATH_A];674cali_info->thermal_value_path[RF_PATH_B] = tssi->thermal[RF_PATH_B];675cali_info->thermal_value_path[RF_PATH_C] = tssi->thermal[RF_PATH_C];676cali_info->thermal_value_path[RF_PATH_D] = tssi->thermal[RF_PATH_D];677cali_info->thermal_value_iqk = tssi->thermal[RF_PATH_A];678cali_info->thermal_value_lck = tssi->thermal[RF_PATH_A];679}680#endif681682if (cali_info->default_bb_swing_index_flag != true) {683/*The index of "0 dB" in SwingTable.*/684if (dm->support_ic_type == ODM_RTL8188E || dm->support_ic_type == ODM_RTL8723B ||685dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type == ODM_RTL8703B ||686dm->support_ic_type == ODM_RTL8821) {687cali_info->default_ofdm_index = (default_swing_index >= OFDM_TABLE_SIZE) ? 30 : default_swing_index;688cali_info->default_cck_index = (default_cck_swing_index >= CCK_TABLE_SIZE) ? 20 : default_cck_swing_index;689} else if (dm->support_ic_type == ODM_RTL8188F) { /*add by Mingzhi.Guo 2015-03-23*/690cali_info->default_ofdm_index = 28; /*OFDM: -1dB*/691cali_info->default_cck_index = 20; /*CCK:-6dB*/692} else if (dm->support_ic_type == ODM_RTL8723D) { /*add by zhaohe 2015-10-27*/693cali_info->default_ofdm_index = 28; /*OFDM: -1dB*/694cali_info->default_cck_index = 28; /*CCK: -6dB*/695/* JJ ADD 20161014 */696} else if (dm->support_ic_type == ODM_RTL8710B) {697cali_info->default_ofdm_index = 28; /*OFDM: -1dB*/698cali_info->default_cck_index = 28; /*CCK: -6dB*/699/*Winnita add 20170828*/700} else if (dm->support_ic_type == ODM_RTL8192F) {701cali_info->default_ofdm_index = 30; /*OFDM: 0dB*/702cali_info->default_cck_index = 28; /*CCK: -6dB*/703} else {704cali_info->default_ofdm_index = (default_swing_index >= TXSCALE_TABLE_SIZE) ? 24 : default_swing_index;705cali_info->default_cck_index = 24;706}707cali_info->default_bb_swing_index_flag = true;708}709710cali_info->bb_swing_idx_cck_base = cali_info->default_cck_index;711cali_info->CCK_index = cali_info->default_cck_index;712713for (p = RF_PATH_A; p < MAX_RF_PATH; ++p) {714cali_info->bb_swing_idx_ofdm_base[p] = cali_info->default_ofdm_index;715cali_info->OFDM_index[p] = cali_info->default_ofdm_index;716cali_info->delta_power_index[p] = 0;717cali_info->delta_power_index_last[p] = 0;718cali_info->power_index_offset[p] = 0;719cali_info->kfree_offset[p] = 0;720}721cali_info->modify_tx_agc_value_ofdm = 0;722cali_info->modify_tx_agc_value_cck = 0;723cali_info->tm_trigger = 0;724}725726727void728odm_txpowertracking_check(729void *dm_void730)731{732733#if 0734/* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */735/* at the same time. In the stage2/3, we need to prive universal interface and merge all */736/* HW dynamic mechanism. */737#endif738739struct dm_struct *dm = (struct dm_struct *)dm_void;740switch (dm->support_platform) {741case ODM_WIN:742odm_txpowertracking_check_mp(dm);743break;744745case ODM_CE:746odm_txpowertracking_check_ce(dm);747break;748749case ODM_AP:750odm_txpowertracking_check_ap(dm);751break;752753default:754break;755}756757}758759void760odm_txpowertracking_check_ce(761void *dm_void762)763{764struct dm_struct *dm = (struct dm_struct *)dm_void;765struct _hal_rf_ *rf = &(dm->rf_table);766#if (DM_ODM_SUPPORT_TYPE == ODM_CE)767void *adapter = dm->adapter;768#if ((RTL8188F_SUPPORT == 1))769rtl8192c_odm_check_txpowertracking(adapter);770#endif771772#if (RTL8188E_SUPPORT == 1)773774if (!(rf->rf_supportability & HAL_RF_TX_PWR_TRACK))775return;776777if (!cali_info->tm_trigger) {778odm_set_rf_reg(dm, RF_PATH_A, RF_T_METER, RFREGOFFSETMASK, 0x60);779/*DBG_8192C("Trigger 92C Thermal Meter!!\n");*/780781cali_info->tm_trigger = 1;782return;783784} else {785/*DBG_8192C("Schedule TxPowerTracking direct call!!\n");*/786odm_txpowertracking_callback_thermal_meter_8188e(adapter);787cali_info->tm_trigger = 0;788}789#endif790#endif791}792793void794odm_txpowertracking_check_mp(795void *dm_void796)797{798struct dm_struct *dm = (struct dm_struct *)dm_void;799#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)800void *adapter = dm->adapter;801802if (*dm->is_fcs_mode_enable)803return;804805if (odm_check_power_status(dm) == false) {806RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("check_pow_status return false\n"));807return;808}809810if (IS_HARDWARE_TYPE_8821B(adapter)) /* TODO: Don't Do PowerTracking*/811return;812813odm_txpowertracking_thermal_meter_check(adapter);814815816#endif817818}819820821void822odm_txpowertracking_check_ap(823void *dm_void824)825{826return;827828}829830#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)831832void833odm_txpowertracking_direct_call(834void *adapter835)836{837HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));838struct dm_struct *dm = &hal_data->DM_OutSrc;839840if (dm->support_ic_type & (ODM_RTL8822C | ODM_RTL8814B)) {841#if (RTL8822C_SUPPORT == 1 || RTL8814B_SUPPORT == 1)842odm_txpowertracking_new_callback_thermal_meter(dm);843#endif844} else845odm_txpowertracking_callback_thermal_meter(adapter);846}847848void849odm_txpowertracking_thermal_meter_check(850void *adapter851)852{853static u8 tm_trigger = 0;854HAL_DATA_TYPE *pHalData = GET_HAL_DATA(((PADAPTER)adapter));855struct dm_struct *dm = &(pHalData->DM_OutSrc);856struct _hal_rf_ *rf = &(dm->rf_table);857struct _halrf_tssi_data *tssi = &rf->halrf_tssi_data;858859if (!(rf->rf_supportability & HAL_RF_TX_PWR_TRACK)) {860RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,861("===>odm_txpowertracking_thermal_meter_check(),mgnt_info->is_txpowertracking is false, return!!\n"));862return;863}864865if (!tm_trigger) {866if (IS_HARDWARE_TYPE_8188E(adapter) || IS_HARDWARE_TYPE_JAGUAR(adapter) || IS_HARDWARE_TYPE_8192E(adapter) || IS_HARDWARE_TYPE_8192F(adapter)867||IS_HARDWARE_TYPE_8723B(adapter) || IS_HARDWARE_TYPE_8814A(adapter) || IS_HARDWARE_TYPE_8188F(adapter) || IS_HARDWARE_TYPE_8703B(adapter)868|| IS_HARDWARE_TYPE_8822B(adapter) || IS_HARDWARE_TYPE_8723D(adapter) || IS_HARDWARE_TYPE_8821C(adapter) || IS_HARDWARE_TYPE_8710B(adapter)869)/* JJ ADD 20161014 */870PHY_SetRFReg(adapter, RF_PATH_A, RF_T_METER_88E, BIT(17) | BIT(16), 0x03);871else if (IS_HARDWARE_TYPE_8822C(adapter)) {872odm_set_rf_reg(dm, RF_PATH_A, R_0x42, BIT(19), 0x01);873odm_set_rf_reg(dm, RF_PATH_A, R_0x42, BIT(19), 0x00);874odm_set_rf_reg(dm, RF_PATH_A, R_0x42, BIT(19), 0x01);875876odm_set_rf_reg(dm, RF_PATH_B, R_0x42, BIT(19), 0x01);877odm_set_rf_reg(dm, RF_PATH_B, R_0x42, BIT(19), 0x00);878odm_set_rf_reg(dm, RF_PATH_B, R_0x42, BIT(19), 0x01);879} else if (IS_HARDWARE_TYPE_8814B(adapter)) {880odm_set_rf_reg(dm, RF_PATH_A, 0x42, BIT(17), 0x1);881odm_set_rf_reg(dm, RF_PATH_B, 0x42, BIT(17), 0x1);882odm_set_rf_reg(dm, RF_PATH_C, 0x42, BIT(17), 0x1);883odm_set_rf_reg(dm, RF_PATH_D, 0x42, BIT(17), 0x1);884} else885PHY_SetRFReg(adapter, RF_PATH_A, RF_T_METER, RFREGOFFSETMASK, 0x60);886887if (dm->support_ic_type & ODM_RTL8814B) {888ODM_delay_us(300);889odm_txpowertracking_direct_call(adapter);890tssi->thermal_trigger = 1;891}892893RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("Trigger Thermal Meter!!\n"));894895tm_trigger = 1;896return;897} else {898RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("Schedule TxPowerTracking direct call!!\n"));899odm_txpowertracking_direct_call(adapter);900901if (dm->support_ic_type & ODM_RTL8814B)902tssi->thermal_trigger = 0;903904tm_trigger = 0;905}906}907908#endif909910911