1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
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
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
[] =
113 static const unsigned int treble_table
[] =
148 static const unsigned int prescale_table
[] =
168 #else /* CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F */
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
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
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
);
275 #endif /* _MAS35XX_H */