diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-28 15:10:20 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-28 15:10:20 +0000 |
commit | 07b233515742d4f2a3d0a832e103600093a9d177 (patch) | |
tree | 0ec917cd095ea27cbdd42ee3c0e5b364119b174c /firmware/mpeg.c | |
parent | 811fc3a67ee5ab10b4af6ab354fbdde24c125b89 (diff) | |
download | rockbox-07b233515742d4f2a3d0a832e103600093a9d177.tar.gz rockbox-07b233515742d4f2a3d0a832e103600093a9d177.zip |
Tone controls are now in dB
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1251 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 98 |
1 files changed, 80 insertions, 18 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index e2de26e5f6..5fb674db06 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -48,8 +48,8 @@ extern char* peek_prev_track(int type); | |||
48 | static char *units[] = | 48 | static char *units[] = |
49 | { | 49 | { |
50 | "%", /* Volume */ | 50 | "%", /* Volume */ |
51 | "%", /* Bass */ | 51 | "dB", /* Bass */ |
52 | "%" /* Treble */ | 52 | "dB" /* Treble */ |
53 | }; | 53 | }; |
54 | 54 | ||
55 | static int numdecimals[] = | 55 | static int numdecimals[] = |
@@ -69,15 +69,25 @@ static int minval[] = | |||
69 | static int maxval[] = | 69 | static int maxval[] = |
70 | { | 70 | { |
71 | 50, /* Volume */ | 71 | 50, /* Volume */ |
72 | 50, /* Bass */ | 72 | #ifdef ARCHOS_RECORDER |
73 | 50 /* Treble */ | 73 | 24, /* Bass */ |
74 | 24 /* Treble */ | ||
75 | #else | ||
76 | 30, /* Bass */ | ||
77 | 30 /* Treble */ | ||
78 | #endif | ||
74 | }; | 79 | }; |
75 | 80 | ||
76 | static int defaultval[] = | 81 | static int defaultval[] = |
77 | { | 82 | { |
78 | 70/2, /* Volume */ | 83 | 70/2, /* Volume */ |
79 | 50/2, /* Bass */ | 84 | #ifdef ARCHOS_RECORDER |
80 | 50/2 /* Treble */ | 85 | 12, /* Bass */ |
86 | 12 /* Treble */ | ||
87 | #else | ||
88 | 15, /* Bass */ | ||
89 | 15 /* Treble */ | ||
90 | #endif | ||
81 | }; | 91 | }; |
82 | 92 | ||
83 | char *mpeg_sound_unit(int setting) | 93 | char *mpeg_sound_unit(int setting) |
@@ -108,6 +118,21 @@ int mpeg_sound_default(int setting) | |||
108 | #ifndef ARCHOS_RECORDER | 118 | #ifndef ARCHOS_RECORDER |
109 | static unsigned int bass_table[] = | 119 | static unsigned int bass_table[] = |
110 | { | 120 | { |
121 | 0x9e400, /* -15dB */ | ||
122 | 0xa2800, /* -14dB */ | ||
123 | 0xa7400, /* -13dB */ | ||
124 | 0xac400, /* -12dB */ | ||
125 | 0xb1800, /* -11dB */ | ||
126 | 0xb7400, /* -10dB */ | ||
127 | 0xbd400, /* -9dB */ | ||
128 | 0xc3c00, /* -8dB */ | ||
129 | 0xca400, /* -7dB */ | ||
130 | 0xd1800, /* -6dB */ | ||
131 | 0xd8c00, /* -5dB */ | ||
132 | 0xe0400, /* -4dB */ | ||
133 | 0xe8000, /* -3dB */ | ||
134 | 0xefc00, /* -2dB */ | ||
135 | 0xf7c00, /* -1dB */ | ||
111 | 0, | 136 | 0, |
112 | 0x800, /* 1dB */ | 137 | 0x800, /* 1dB */ |
113 | 0x10000, /* 2dB */ | 138 | 0x10000, /* 2dB */ |
@@ -128,6 +153,21 @@ static unsigned int bass_table[] = | |||
128 | 153 | ||
129 | static unsigned int treble_table[] = | 154 | static unsigned int treble_table[] = |
130 | { | 155 | { |
156 | 0xb2c00, /* -15dB */ | ||
157 | 0xbb400, /* -14dB */ | ||
158 | 0xc1800, /* -13dB */ | ||
159 | 0xc6c00, /* -12dB */ | ||
160 | 0xcbc00, /* -11dB */ | ||
161 | 0xd0400, /* -10dB */ | ||
162 | 0xd5000, /* -9dB */ | ||
163 | 0xd9800, /* -8dB */ | ||
164 | 0xde000, /* -7dB */ | ||
165 | 0xe2800, /* -6dB */ | ||
166 | 0xe7e00, /* -5dB */ | ||
167 | 0xec000, /* -4dB */ | ||
168 | 0xf0c00, /* -3dB */ | ||
169 | 0xf5c00, /* -2dB */ | ||
170 | 0xfac00, /* -1dB */ | ||
131 | 0, | 171 | 0, |
132 | 0x5400, /* 1dB */ | 172 | 0x5400, /* 1dB */ |
133 | 0xac00, /* 2dB */ | 173 | 0xac00, /* 2dB */ |
@@ -145,6 +185,26 @@ static unsigned int treble_table[] = | |||
145 | 0x58400, /* 14dB */ | 185 | 0x58400, /* 14dB */ |
146 | 0x5f800 /* 15dB */ | 186 | 0x5f800 /* 15dB */ |
147 | }; | 187 | }; |
188 | |||
189 | static unsigned int prescale_table[] = | ||
190 | { | ||
191 | 0x80000, /* 0db */ | ||
192 | 0x8e000, /* 1dB */ | ||
193 | 0x9a400, /* 2dB */ | ||
194 | 0xa5800, /* 3dB */ | ||
195 | 0xaf400, /* 4dB */ | ||
196 | 0xb8000, /* 5dB */ | ||
197 | 0xbfc00, /* 6dB */ | ||
198 | 0xc6c00, /* 7dB */ | ||
199 | 0xcd000, /* 8dB */ | ||
200 | 0xd25c0, /* 9dB */ | ||
201 | 0xd7800, /* 10dB */ | ||
202 | 0xdc000, /* 11dB */ | ||
203 | 0xdfc00, /* 12dB */ | ||
204 | 0xe3400, /* 13dB */ | ||
205 | 0xe6800, /* 14dB */ | ||
206 | 0xe9400 /* 15dB */ | ||
207 | }; | ||
148 | #endif | 208 | #endif |
149 | 209 | ||
150 | static unsigned char fliptable[] = | 210 | static unsigned char fliptable[] = |
@@ -718,26 +778,20 @@ void mpeg_sound_set(int setting, int value) | |||
718 | break; | 778 | break; |
719 | 779 | ||
720 | case SOUND_BASS: | 780 | case SOUND_BASS: |
721 | value *= 2; /* Convert to percent */ | ||
722 | |||
723 | #ifdef ARCHOS_RECORDER | 781 | #ifdef ARCHOS_RECORDER |
724 | tmp = 0x6000 * value / 100; | 782 | tmp = (((value-12) * 8) & 0xff) << 8; |
725 | mas_codec_writereg(0x14, tmp & 0xff00); | 783 | mas_codec_writereg(0x14, tmp & 0xff00); |
726 | #else | 784 | #else |
727 | tmp = 15 * value / 100; | 785 | mas_writereg(MAS_REG_KBASS, bass_table[value]); |
728 | mas_writereg(MAS_REG_KBASS, bass_table[tmp]); | ||
729 | #endif | 786 | #endif |
730 | break; | 787 | break; |
731 | 788 | ||
732 | case SOUND_TREBLE: | 789 | case SOUND_TREBLE: |
733 | value *= 2; /* Convert to percent */ | ||
734 | |||
735 | #ifdef ARCHOS_RECORDER | 790 | #ifdef ARCHOS_RECORDER |
736 | tmp = 0x6000 * value / 100; | 791 | tmp = (((value-12) * 8) & 0xff) << 8; |
737 | mas_codec_writereg(0x15, tmp & 0xff00); | 792 | mas_codec_writereg(0x15, tmp & 0xff00); |
738 | #else | 793 | #else |
739 | tmp = 15 * value / 100; | 794 | mas_writereg(MAS_REG_KTREBLE, treble_table[value]); |
740 | mas_writereg(MAS_REG_KTREBLE, treble_table[tmp]); | ||
741 | #endif | 795 | #endif |
742 | break; | 796 | break; |
743 | } | 797 | } |
@@ -754,11 +808,19 @@ int mpeg_val2phys(int setting, int value) | |||
754 | break; | 808 | break; |
755 | 809 | ||
756 | case SOUND_BASS: | 810 | case SOUND_BASS: |
757 | result = value * 2; | 811 | #ifdef ARCHOS_RECORDER |
812 | result = value - 12; | ||
813 | #else | ||
814 | result = value - 15; | ||
815 | #endif | ||
758 | break; | 816 | break; |
759 | 817 | ||
760 | case SOUND_TREBLE: | 818 | case SOUND_TREBLE: |
761 | result = value * 2; | 819 | #ifdef ARCHOS_RECORDER |
820 | result = value - 12; | ||
821 | #else | ||
822 | result = value - 15; | ||
823 | #endif | ||
762 | break; | 824 | break; |
763 | } | 825 | } |
764 | return result; | 826 | return result; |