Fix advanced EQ menu
[maemo-rb.git] / firmware / export / mas35xx.h
blobf75658fce197ea42e41546e26d5233c86b5f06dc
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Implementation of MAS35xx audiohw api driver.
12 * Copyright (C) 2007 by Christian Gmeiner
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
24 #ifndef _MAS35XX_H
25 #define _MAS35XX_H
27 #include "config.h"
28 #include "mascodec.h"
30 #define MAS_BANK_D0 0
31 #define MAS_BANK_D1 1
33 /* registers common to all MAS35xx */
34 #define MAS_REG_DCCF 0x8e
35 #define MAS_REG_MUTE 0xaa
36 #define MAS_REG_PIODATA 0xc8
37 #define MAS_REG_StartUpConfig 0xe6
38 #define MAS_REG_KPRESCALE 0xe7
40 #if CONFIG_CODEC == MAS3507D
42 /* I2C defines */
43 #define MAS_ADR 0x3a
44 #define MAS_DEV_WRITE (MAS_ADR | 0x00)
45 #define MAS_DEV_READ (MAS_ADR | 0x01)
47 /* MAS3507D registers */
48 #define MAS_DATA_WRITE 0x68
49 #define MAS_DATA_READ 0x69
50 #define MAS_CONTROL 0x6a
52 #define MAS_REG_KBASS 0x6b
53 #define MAS_REG_KTREBLE 0x6f
55 /* MAS3507D commands */
56 #define MAS_CMD_READ_ANCILLARY 0x30
57 #define MAS_CMD_WRITE_REG 0x90
58 #define MAS_CMD_WRITE_D0_MEM 0xa0
59 #define MAS_CMD_WRITE_D1_MEM 0xb0
60 #define MAS_CMD_READ_REG 0xd0
61 #define MAS_CMD_READ_D0_MEM 0xe0
62 #define MAS_CMD_READ_D1_MEM 0xf0
64 /* MAS3507D D0 memmory cells */
65 #define MAS_D0_MPEG_FRAME_COUNT 0x300
66 #define MAS_D0_MPEG_STATUS_1 0x301
67 #define MAS_D0_MPEG_STATUS_2 0x302
68 #define MAS_D0_CRC_ERROR_COUNT 0x303
69 #define MAS_D0_OUT_LL 0x7f8
70 #define MAS_D0_OUT_LR 0x7f9
71 #define MAS_D0_OUT_RL 0x7fa
72 #define MAS_D0_OUT_RR 0x7fb
74 #define VOLUME_MIN -780
75 #define VOLUME_MAX 180
76 #define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP)
78 static const unsigned int bass_table[] =
80 0x9e400, /* -15dB */
81 0xa2800, /* -14dB */
82 0xa7400, /* -13dB */
83 0xac400, /* -12dB */
84 0xb1800, /* -11dB */
85 0xb7400, /* -10dB */
86 0xbd400, /* -9dB */
87 0xc3c00, /* -8dB */
88 0xca400, /* -7dB */
89 0xd1800, /* -6dB */
90 0xd8c00, /* -5dB */
91 0xe0400, /* -4dB */
92 0xe8000, /* -3dB */
93 0xefc00, /* -2dB */
94 0xf7c00, /* -1dB */
96 0x800, /* 1dB */
97 0x10000, /* 2dB */
98 0x17c00, /* 3dB */
99 0x1f800, /* 4dB */
100 0x27000, /* 5dB */
101 0x2e400, /* 6dB */
102 0x35800, /* 7dB */
103 0x3c000, /* 8dB */
104 0x42800, /* 9dB */
105 0x48800, /* 10dB */
106 0x4e400, /* 11dB */
107 0x53800, /* 12dB */
108 0x58800, /* 13dB */
109 0x5d400, /* 14dB */
110 0x61800 /* 15dB */
113 static const unsigned int treble_table[] =
115 0xb2c00, /* -15dB */
116 0xbb400, /* -14dB */
117 0xc1800, /* -13dB */
118 0xc6c00, /* -12dB */
119 0xcbc00, /* -11dB */
120 0xd0400, /* -10dB */
121 0xd5000, /* -9dB */
122 0xd9800, /* -8dB */
123 0xde000, /* -7dB */
124 0xe2800, /* -6dB */
125 0xe7e00, /* -5dB */
126 0xec000, /* -4dB */
127 0xf0c00, /* -3dB */
128 0xf5c00, /* -2dB */
129 0xfac00, /* -1dB */
131 0x5400, /* 1dB */
132 0xac00, /* 2dB */
133 0x10400, /* 3dB */
134 0x16000, /* 4dB */
135 0x1c000, /* 5dB */
136 0x22400, /* 6dB */
137 0x28400, /* 7dB */
138 0x2ec00, /* 8dB */
139 0x35400, /* 9dB */
140 0x3c000, /* 10dB */
141 0x42c00, /* 11dB */
142 0x49c00, /* 12dB */
143 0x51800, /* 13dB */
144 0x58400, /* 14dB */
145 0x5f800 /* 15dB */
148 static const unsigned int prescale_table[] =
150 0x80000, /* 0db */
151 0x8e000, /* 1dB */
152 0x9a400, /* 2dB */
153 0xa5800, /* 3dB */
154 0xaf400, /* 4dB */
155 0xb8000, /* 5dB */
156 0xbfc00, /* 6dB */
157 0xc6c00, /* 7dB */
158 0xcd000, /* 8dB */
159 0xd25c0, /* 9dB */
160 0xd7800, /* 10dB */
161 0xdc000, /* 11dB */
162 0xdfc00, /* 12dB */
163 0xe3400, /* 13dB */
164 0xe6800, /* 14dB */
165 0xe9400 /* 15dB */
168 #else /* CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F */
170 /* I2C defines */
171 #define MAS_ADR 0x3c
172 #define MAS_DEV_WRITE (MAS_ADR | 0x00)
173 #define MAS_DEV_READ (MAS_ADR | 0x01)
175 /* MAS3587F/MAS3539F registers */
176 #define MAS_DATA_WRITE 0x68
177 #define MAS_DATA_READ 0x69
178 #define MAS_CODEC_WRITE 0x6c
179 #define MAS_CODEC_READ 0x6d
180 #define MAS_CONTROL 0x6a
181 #define MAS_DCCF 0x76
182 #define MAS_DCFR 0x77
184 #define MAS_REG_KMDB_SWITCH 0x21
185 #define MAS_REG_KMDB_STR 0x22
186 #define MAS_REG_KMDB_HAR 0x23
187 #define MAS_REG_KMDB_FC 0x24
188 #define MAS_REG_KLOUDNESS 0x1e
189 #define MAS_REG_QPEAK_L 0x0a
190 #define MAS_REG_QPEAK_R 0x0b
191 #define MAS_REG_DQPEAK_L 0x0c
192 #define MAS_REG_DQPEAK_R 0x0d
193 #define MAS_REG_VOLUME_CONTROL 0x10
194 #define MAS_REG_BALANCE 0x11
195 #define MAS_REG_KAVC 0x12
196 #define MAS_REG_KBASS 0x14
197 #define MAS_REG_KTREBLE 0x15
199 /* MAS3587F/MAS3539F commands */
200 #define MAS_CMD_READ_ANCILLARY 0x50
201 #define MAS_CMD_FAST_PRG_DL 0x60
202 #define MAS_CMD_READ_IC_VER 0x70
203 #define MAS_CMD_READ_REG 0xa0
204 #define MAS_CMD_WRITE_REG 0xb0
205 #define MAS_CMD_READ_D0_MEM 0xc0
206 #define MAS_CMD_READ_D1_MEM 0xd0
207 #define MAS_CMD_WRITE_D0_MEM 0xe0
208 #define MAS_CMD_WRITE_D1_MEM 0xf0
210 /* MAS3587F D0 memory cells */
211 #if CONFIG_CODEC == MAS3587F
212 #define MAS_D0_APP_SELECT 0x7f6
213 #define MAS_D0_APP_RUNNING 0x7f7
214 #define MAS_D0_ENCODER_CONTROL 0x7f0
215 #define MAS_D0_IO_CONTROL_MAIN 0x7f1
216 #define MAS_D0_INTERFACE_CONTROL 0x7f2
217 #define MAS_D0_OFREQ_CONTROL 0x7f3
218 #define MAS_D0_OUT_CLK_CONFIG 0x7f4
219 #define MAS_D0_SPD_OUT_BITS 0x7f8
220 #define MAS_D0_SOFT_MUTE 0x7f9
221 #define MAS_D0_OUT_LL 0x7fc
222 #define MAS_D0_OUT_LR 0x7fd
223 #define MAS_D0_OUT_RL 0x7fe
224 #define MAS_D0_OUT_RR 0x7ff
225 #define MAS_D0_MPEG_FRAME_COUNT 0xfd0
226 #define MAS_D0_MPEG_STATUS_1 0xfd1
227 #define MAS_D0_MPEG_STATUS_2 0xfd2
228 #define MAS_D0_CRC_ERROR_COUNT 0xfd3
230 /* MAS3539F D0 memory cells */
231 #elif CONFIG_CODEC == MAS3539F
232 #define MAS_D0_APP_SELECT 0x34b
233 #define MAS_D0_APP_RUNNING 0x34c
234 /* no encoder :( */
235 #define MAS_D0_IO_CONTROL_MAIN 0x346
236 #define MAS_D0_INTERFACE_CONTROL 0x347
237 #define MAS_D0_OFREQ_CONTROL 0x348
238 #define MAS_D0_OUT_CLK_CONFIG 0x349
239 #define MAS_D0_SPD_OUT_BITS 0x351
240 #define MAS_D0_SOFT_MUTE 0x350
241 #define MAS_D0_OUT_LL 0x354
242 #define MAS_D0_OUT_LR 0x355
243 #define MAS_D0_OUT_RL 0x356
244 #define MAS_D0_OUT_RR 0x357
245 #define MAS_D0_MPEG_FRAME_COUNT 0xfd0
246 #define MAS_D0_MPEG_STATUS_1 0xfd1
247 #define MAS_D0_MPEG_STATUS_2 0xfd2
248 #define MAS_D0_CRC_ERROR_COUNT 0xfd3
249 #endif
251 /* MAS3587F and MAS3539F handle clipping prevention internally so we do not need
252 * the prescaler -> CLIPPING_CAP
255 #define VOLUME_MIN -400
256 #define VOLUME_MAX 600
257 #define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | BALANCE_CAP | CLIPPING_CAP)
259 #endif /* CONFIG_CODEC */
261 /* Function prototypes */
262 #if CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F
263 extern void audiohw_set_loudness(int value);
264 extern void audiohw_set_avc(int value);
265 extern void audiohw_set_mdb_strength(int value);
266 extern void audiohw_set_mdb_harmonics(int value);
267 extern void audiohw_set_mdb_center(int value);
268 extern void audiohw_set_mdb_shape(int value);
269 extern void audiohw_set_mdb_enable(int value);
270 extern void audiohw_set_superbass(int value);
271 extern void audiohw_set_balance(int val);
272 extern void audiohw_set_pitch(unsigned long val);
273 #endif
275 #endif /* _MAS35XX_H */