Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * This file is only included exactly once!
0004  *
0005  * The tables here are derived from the tas3004 datasheet,
0006  * modulo typo corrections and some smoothing...
0007  */
0008 
0009 #define TAS3004_TREBLE_MIN  0
0010 #define TAS3004_TREBLE_MAX  72
0011 #define TAS3004_BASS_MIN    0
0012 #define TAS3004_BASS_MAX    72
0013 #define TAS3004_TREBLE_ZERO 36
0014 #define TAS3004_BASS_ZERO   36
0015 
0016 static const u8 tas3004_treble_table[] = {
0017     150, /* -18 dB */
0018     149,
0019     148,
0020     147,
0021     146,
0022     145,
0023     144,
0024     143,
0025     142,
0026     141,
0027     140,
0028     139,
0029     138,
0030     137,
0031     136,
0032     135,
0033     134,
0034     133,
0035     132,
0036     131,
0037     130,
0038     129,
0039     128,
0040     127,
0041     126,
0042     125,
0043     124,
0044     123,
0045     122,
0046     121,
0047     120,
0048     119,
0049     118,
0050     117,
0051     116,
0052     115,
0053     114, /* 0 dB */
0054     113,
0055     112,
0056     111,
0057     109,
0058     108,
0059     107,
0060     105,
0061     104,
0062     103,
0063     101,
0064     99,
0065     98,
0066     96,
0067     93,
0068     91,
0069     89,
0070     86,
0071     83,
0072     81,
0073     77,
0074     74,
0075     71,
0076     67,
0077     63,
0078     59,
0079     54,
0080     49,
0081     44,
0082     38,
0083     32,
0084     26,
0085     19,
0086     10,
0087     4,
0088     2,
0089     1, /* +18 dB */
0090 };
0091 
0092 static inline u8 tas3004_treble(int idx)
0093 {
0094     return tas3004_treble_table[idx];
0095 }
0096 
0097 /* I only save the difference here to the treble table
0098  * so that the binary is smaller...
0099  * I have also ignored completely differences of
0100  * +/- 1
0101  */
0102 static const s8 tas3004_bass_diff_to_treble[] = {
0103     2, /* 7 dB, offset 50 */
0104     2,
0105     2,
0106     2,
0107     2,
0108     1,
0109     2,
0110     2,
0111     2,
0112     3,
0113     4,
0114     4,
0115     5,
0116     6,
0117     7,
0118     8,
0119     9,
0120     10,
0121     11,
0122     14,
0123     13,
0124     8,
0125     1, /* 18 dB */
0126 };
0127 
0128 static inline u8 tas3004_bass(int idx)
0129 {
0130     u8 result = tas3004_treble_table[idx];
0131 
0132     if (idx >= 50)
0133         result += tas3004_bass_diff_to_treble[idx-50];
0134     return result;
0135 }