summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2008-05-13 06:19:16 +0000
committerChristian Gmeiner <christian.gmeiner@gmail.com>2008-05-13 06:19:16 +0000
commit785e7762466eebc23ae678a470239fc65235b4d1 (patch)
treeaec4ceac3517d07fd0ad7acc6441bd88f45d266f
parent3e743ec6c9685ef3b7d9729e2b21236bf66bed93 (diff)
downloadrockbox-785e7762466eebc23ae678a470239fc65235b4d1.tar.gz
rockbox-785e7762466eebc23ae678a470239fc65235b4d1.zip
add BALANCE_CAP and CLIPPING_CAP and move some mas35xx code into audio driver mas35xx.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17489 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/audio/mas35xx.c12
-rw-r--r--firmware/export/audiohw.h30
-rw-r--r--firmware/export/mas35xx.h14
-rw-r--r--firmware/sound.c42
4 files changed, 66 insertions, 32 deletions
diff --git a/firmware/drivers/audio/mas35xx.c b/firmware/drivers/audio/mas35xx.c
index 983818bf61..403ce07068 100644
--- a/firmware/drivers/audio/mas35xx.c
+++ b/firmware/drivers/audio/mas35xx.c
@@ -170,3 +170,15 @@ void audiohw_set_treble(int val)
170 mas_writereg(MAS_REG_KTREBLE, treble_table[val+15]); 170 mas_writereg(MAS_REG_KTREBLE, treble_table[val+15]);
171#endif 171#endif
172} 172}
173
174#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
175void audiohw_set_volume(int val) {
176 unsigned tmp = ((unsigned)(val + 115) & 0xff) << 8;
177 mas_codec_writereg(0x10, tmp);
178}
179
180void audiohw_set_balance(int val) {
181 unsigned tmp = ((unsigned)(val * 127 / 100) & 0xff) << 8;
182 mas_codec_writereg(0x11, tmp);
183}
184#endif
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index d450613aff..d11a3b5181 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -26,6 +26,8 @@
26/* define some audiohw caps */ 26/* define some audiohw caps */
27#define TREBLE_CAP (1 << 0) 27#define TREBLE_CAP (1 << 0)
28#define BASS_CAP (1 << 1) 28#define BASS_CAP (1 << 1)
29#define BALANCE_CAP (1 << 2)
30#define CLIPPING_CAP (1 << 3)
29 31
30#ifdef HAVE_UDA1380 32#ifdef HAVE_UDA1380
31#include "uda1380.h" 33#include "uda1380.h"
@@ -62,6 +64,14 @@
62#if (AUDIOHW_CAPS & BASS_CAP) 64#if (AUDIOHW_CAPS & BASS_CAP)
63#define AUDIOHW_HAVE_BASS 65#define AUDIOHW_HAVE_BASS
64#endif 66#endif
67
68#if (AUDIOHW_CAPS & BALANCE_CAP)
69#define AUDIOHW_HAVE_BALANCE
70#endif
71
72#if (AUDIOHW_CAPS & CLIPPING_CAP)
73#define AUDIOHW_HAVE_CLIPPING
74#endif
65#endif /* AUDIOHW_CAPS */ 75#endif /* AUDIOHW_CAPS */
66 76
67enum { 77enum {
@@ -144,6 +154,26 @@ void audiohw_postinit(void);
144 */ 154 */
145void audiohw_close(void); 155void audiohw_close(void);
146 156
157#ifdef AUDIOHW_HAVE_CLIPPING
158 /**
159 * Set new volume value
160 * @param val to set.
161 * NOTE: AUDIOHW_CAPS need to contain
162 * CLIPPING_CAP
163 */
164void audiohw_set_volume(int val);
165#endif
166
167#ifdef AUDIOHW_HAVE_BALANCE
168/**
169 * Set new balance value
170 * @param val to set.
171 * NOTE: AUDIOHW_CAPS need to contain
172 * BALANCE_CAP
173 */
174void audiohw_set_balance(int val);
175#endif
176
147/** 177/**
148 * Mute or enable sound. 178 * Mute or enable sound.
149 * @param mute true or false. 179 * @param mute true or false.
diff --git a/firmware/export/mas35xx.h b/firmware/export/mas35xx.h
index dbe9d38a37..d28db0fb33 100644
--- a/firmware/export/mas35xx.h
+++ b/firmware/export/mas35xx.h
@@ -24,14 +24,22 @@
24 24
25#include "config.h" 25#include "config.h"
26 26
27#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP)
28
29#if CONFIG_CODEC == MAS3507D 27#if CONFIG_CODEC == MAS3507D
28
30#define VOLUME_MIN -780 29#define VOLUME_MIN -780
31#define VOLUME_MAX 180 30#define VOLUME_MAX 180
32#else 31#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP)
32
33#else /* CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F */
34
35/* MAS3587F and MAS3539F handle clipping prevention internally so we do not need
36 * the prescaler -> CLIPPING_CAP
37 */
38
33#define VOLUME_MIN -400 39#define VOLUME_MIN -400
34#define VOLUME_MAX 600 40#define VOLUME_MAX 600
41#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | BALANCE_CAP | CLIPPING_CAP)
42
35#endif 43#endif
36 44
37 45
diff --git a/firmware/sound.c b/firmware/sound.c
index 45d3e4b1b6..1e8f9e2b24 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -227,11 +227,7 @@ static int tenthdb2reg(int db)
227#endif 227#endif
228 228
229 229
230/* MAS3587F and MAS3539F handle clipping prevention internally so we do not need 230#if !defined(AUDIOHW_HAVE_CLIPPING)
231 * the prescaler.
232 */
233#if (CONFIG_CODEC != MAS3587F) && (CONFIG_CODEC != MAS3539F)
234
235/* 231/*
236 * The prescaler compensates for any kind of boosts, to prevent clipping. 232 * The prescaler compensates for any kind of boosts, to prevent clipping.
237 * 233 *
@@ -327,41 +323,29 @@ void sound_set_volume(int value)
327{ 323{
328 if(!audio_is_initialized) 324 if(!audio_is_initialized)
329 return; 325 return;
330#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 326
331 unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8; 327#if defined(AUDIOHW_HAVE_CLIPPING)
332 mas_codec_writereg(0x10, tmp); 328 audiohw_set_volume(value);
333#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \
334 || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
335 || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) \
336 || defined(HAVE_AS3514) || defined(HAVE_WM8985) || defined(HAVE_TSC2100) \
337 || defined(HAVE_WM8978)
338 current_volume = value * 10; /* tenth of dB */
339 set_prescaled_volume();
340#elif CONFIG_CPU == PNX0101 329#elif CONFIG_CPU == PNX0101
341 int tmp = (60 - value * 4) & 0xff; 330 int tmp = (60 - value * 4) & 0xff;
342 CODECVOL = tmp | (tmp << 8); 331 CODECVOL = tmp | (tmp << 8);
332#else
333 current_volume = value * 10; /* tenth of dB */
334 set_prescaled_volume();
343#endif 335#endif
344 (void)value;
345} 336}
346 337
347void sound_set_balance(int value) 338void sound_set_balance(int value)
348{ 339{
349 if(!audio_is_initialized) 340 if(!audio_is_initialized)
350 return; 341 return;
351#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 342
352 unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8; 343#ifdef AUDIOHW_HAVE_BALANCE
353 mas_codec_writereg(0x11, tmp); 344 audiohw_set_balance(value);
354#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 \ 345#else
355 || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \
356 || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) \
357 || defined(HAVE_AS3514) || defined(HAVE_WM8985) || defined(HAVE_TSC2100) \
358 || defined(HAVE_WM8978)
359 current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */ 346 current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
360 set_prescaled_volume(); 347 set_prescaled_volume();
361#elif CONFIG_CPU == PNX0101
362 /* TODO: implement for iFP */
363#endif 348#endif
364 (void)value;
365} 349}
366 350
367void sound_set_bass(int value) 351void sound_set_bass(int value)
@@ -375,7 +359,7 @@ void sound_set_bass(int value)
375 dsp_callback(DSP_CALLBACK_SET_BASS, current_bass); 359 dsp_callback(DSP_CALLBACK_SET_BASS, current_bass);
376#endif 360#endif
377 361
378#if (CONFIG_CODEC != MAS3587F) && (CONFIG_CODEC != MAS3539F) 362#if !defined(AUDIOHW_HAVE_CLIPPING)
379#if defined(HAVE_WM8751) 363#if defined(HAVE_WM8751)
380 current_bass = value; 364 current_bass = value;
381#else 365#else
@@ -396,7 +380,7 @@ void sound_set_treble(int value)
396 dsp_callback(DSP_CALLBACK_SET_TREBLE, current_treble); 380 dsp_callback(DSP_CALLBACK_SET_TREBLE, current_treble);
397#endif 381#endif
398 382
399#if (CONFIG_CODEC != MAS3587F) && (CONFIG_CODEC != MAS3539F) 383#if !defined(AUDIOHW_HAVE_CLIPPING)
400#if defined(HAVE_WM8751) 384#if defined(HAVE_WM8751)
401 current_treble = value; 385 current_treble = value;
402#else 386#else