653-0034-rtl8xxxu-Implement-rtl8188e_set_tx_power.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From cd4a93d1532b2f0ffe508f7fb5d464ec49634dcd Mon Sep 17 00:00:00 2001
  2. From: Jes Sorensen <Jes.Sorensen@redhat.com>
  3. Date: Fri, 22 Jul 2016 13:55:24 -0400
  4. Subject: [PATCH] rtl8xxxu: Implement rtl8188e_set_tx_power()
  5. This matches the code used to set TX power on 8192eu, except it only
  6. handles path A.
  7. We should be able to consolidate this code.
  8. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
  9. ---
  10. .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 63 ++++++++++++++++++++++
  11. 1 file changed, 63 insertions(+)
  12. --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
  13. +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
  14. @@ -283,6 +283,68 @@ static struct rtl8xxxu_rfregval rtl8188e
  15. {0xff, 0xffffffff}
  16. };
  17. +int rtl8xxxu_8188e_channel_to_group(int channel)
  18. +{
  19. + int group;
  20. +
  21. + if (channel < 3)
  22. + group = 0;
  23. + else if (channel < 6)
  24. + group = 1;
  25. + else if (channel < 9)
  26. + group = 2;
  27. + else if (channel < 12)
  28. + group = 3;
  29. + else if (channel < 14)
  30. + group = 4;
  31. + else
  32. + group = 5;
  33. +
  34. + return group;
  35. +}
  36. +
  37. +static void
  38. +rtl8188e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40)
  39. +{
  40. + u32 val32, ofdm, mcs;
  41. + u8 cck, ofdmbase, mcsbase;
  42. + int group, tx_idx;
  43. +
  44. + tx_idx = 0;
  45. + group = rtl8xxxu_8188e_channel_to_group(channel);
  46. +
  47. + cck = priv->cck_tx_power_index_A[group];
  48. +
  49. + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32);
  50. + val32 &= 0xffff00ff;
  51. + val32 |= (cck << 8);
  52. + rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32);
  53. +
  54. + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11);
  55. + val32 &= 0xff;
  56. + val32 |= ((cck << 8) | (cck << 16) | (cck << 24));
  57. + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32);
  58. +
  59. + ofdmbase = priv->ht40_1s_tx_power_index_A[group];
  60. + ofdmbase += priv->ofdm_tx_power_diff[tx_idx].a;
  61. + ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24;
  62. +
  63. + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm);
  64. + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm);
  65. +
  66. + mcsbase = priv->ht40_1s_tx_power_index_A[group];
  67. + if (ht40)
  68. + mcsbase += priv->ht40_tx_power_diff[tx_idx++].a;
  69. + else
  70. + mcsbase += priv->ht20_tx_power_diff[tx_idx++].a;
  71. + mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24;
  72. +
  73. + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs);
  74. + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs);
  75. + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs);
  76. + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs);
  77. +}
  78. +
  79. void rtl8188eu_config_channel(struct ieee80211_hw *hw)
  80. {
  81. struct rtl8xxxu_priv *priv = hw->priv;
  82. @@ -1152,6 +1214,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops =
  83. .enable_rf = rtl8188e_enable_rf,
  84. .disable_rf = rtl8188e_disable_rf,
  85. .usb_quirks = rtl8188e_usb_quirks,
  86. + .set_tx_power = rtl8188e_set_tx_power,
  87. .update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
  88. .report_connect = rtl8xxxu_gen2_report_connect,
  89. .writeN_block_size = 128,