tas-basstreble.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * This file is only included exactly once!
  4. *
  5. * The tables here are derived from the tas3004 datasheet,
  6. * modulo typo corrections and some smoothing...
  7. */
  8. #define TAS3004_TREBLE_MIN 0
  9. #define TAS3004_TREBLE_MAX 72
  10. #define TAS3004_BASS_MIN 0
  11. #define TAS3004_BASS_MAX 72
  12. #define TAS3004_TREBLE_ZERO 36
  13. #define TAS3004_BASS_ZERO 36
  14. static const u8 tas3004_treble_table[] = {
  15. 150, /* -18 dB */
  16. 149,
  17. 148,
  18. 147,
  19. 146,
  20. 145,
  21. 144,
  22. 143,
  23. 142,
  24. 141,
  25. 140,
  26. 139,
  27. 138,
  28. 137,
  29. 136,
  30. 135,
  31. 134,
  32. 133,
  33. 132,
  34. 131,
  35. 130,
  36. 129,
  37. 128,
  38. 127,
  39. 126,
  40. 125,
  41. 124,
  42. 123,
  43. 122,
  44. 121,
  45. 120,
  46. 119,
  47. 118,
  48. 117,
  49. 116,
  50. 115,
  51. 114, /* 0 dB */
  52. 113,
  53. 112,
  54. 111,
  55. 109,
  56. 108,
  57. 107,
  58. 105,
  59. 104,
  60. 103,
  61. 101,
  62. 99,
  63. 98,
  64. 96,
  65. 93,
  66. 91,
  67. 89,
  68. 86,
  69. 83,
  70. 81,
  71. 77,
  72. 74,
  73. 71,
  74. 67,
  75. 63,
  76. 59,
  77. 54,
  78. 49,
  79. 44,
  80. 38,
  81. 32,
  82. 26,
  83. 19,
  84. 10,
  85. 4,
  86. 2,
  87. 1, /* +18 dB */
  88. };
  89. static inline u8 tas3004_treble(int idx)
  90. {
  91. return tas3004_treble_table[idx];
  92. }
  93. /* I only save the difference here to the treble table
  94. * so that the binary is smaller...
  95. * I have also ignored completely differences of
  96. * +/- 1
  97. */
  98. static const s8 tas3004_bass_diff_to_treble[] = {
  99. 2, /* 7 dB, offset 50 */
  100. 2,
  101. 2,
  102. 2,
  103. 2,
  104. 1,
  105. 2,
  106. 2,
  107. 2,
  108. 3,
  109. 4,
  110. 4,
  111. 5,
  112. 6,
  113. 7,
  114. 8,
  115. 9,
  116. 10,
  117. 11,
  118. 14,
  119. 13,
  120. 8,
  121. 1, /* 18 dB */
  122. };
  123. static inline u8 tas3004_bass(int idx)
  124. {
  125. u8 result = tas3004_treble_table[idx];
  126. if (idx >= 50)
  127. result += tas3004_bass_diff_to_treble[idx-50];
  128. return result;
  129. }