diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-04-25 22:54:58 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-04-25 22:54:58 +0000 |
commit | 668bd3445ecb39483160bbb310afa4337c83d0d9 (patch) | |
tree | 9df94188c72cd0af723012e022187b14c0d8f710 /firmware/sound.c | |
parent | 5185d9e30a7597425aa7f77c2d323e3002c60d8e (diff) | |
download | rockbox-668bd3445ecb39483160bbb310afa4337c83d0d9.tar.gz rockbox-668bd3445ecb39483160bbb310afa4337c83d0d9.zip |
Remove lots of simulator-speficic #ifdef'ing in sound.c to allow for DSP effects in the sims, e.g. for bass and treble (targets that do those effects in HW don't simulate using dsp).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25719 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/sound.c')
-rw-r--r-- | firmware/sound.c | 145 |
1 files changed, 17 insertions, 128 deletions
diff --git a/firmware/sound.c b/firmware/sound.c index ca8b79e4d9..84c022e0c0 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -25,9 +25,9 @@ | |||
25 | #include "sound.h" | 25 | #include "sound.h" |
26 | #include "logf.h" | 26 | #include "logf.h" |
27 | #include "system.h" | 27 | #include "system.h" |
28 | #ifndef SIMULATOR | ||
29 | #include "i2c.h" | 28 | #include "i2c.h" |
30 | #include "mas.h" | 29 | #include "mas.h" |
30 | #ifndef SIMULATOR | ||
31 | #if CONFIG_CPU == PNX0101 | 31 | #if CONFIG_CPU == PNX0101 |
32 | #include "pnx0101.h" | 32 | #include "pnx0101.h" |
33 | #endif | 33 | #endif |
@@ -41,27 +41,10 @@ | |||
41 | * find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble | 41 | * find a nice way to handle 1.5db steps -> see wm8751 ifdef in sound_set_bass/treble |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #define ONE_DB 10 | ||
45 | |||
46 | #if !defined(VOLUME_MIN) && !defined(VOLUME_MAX) | ||
47 | #warning define for VOLUME_MIN and VOLUME_MAX is missing | ||
48 | #define VOLUME_MIN -700 | ||
49 | #define VOLUME_MAX 0 | ||
50 | #endif | ||
51 | |||
52 | /* volume/balance/treble/bass interdependency main part */ | ||
53 | #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN) | ||
54 | |||
55 | #ifndef SIMULATOR | ||
56 | extern bool audio_is_initialized; | 44 | extern bool audio_is_initialized; |
57 | 45 | ||
58 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
59 | extern unsigned long shadow_io_control_main; | ||
60 | extern unsigned shadow_codec_reg0; | ||
61 | #endif | ||
62 | #endif /* SIMULATOR */ | ||
63 | |||
64 | #ifdef SIMULATOR | 46 | #ifdef SIMULATOR |
47 | extern void audiohw_set_volume(int value); | ||
65 | /* dummy for sim */ | 48 | /* dummy for sim */ |
66 | const struct sound_settings_info audiohw_settings[] = { | 49 | const struct sound_settings_info audiohw_settings[] = { |
67 | [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25}, | 50 | [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25}, |
@@ -90,7 +73,7 @@ const struct sound_settings_info audiohw_settings[] = { | |||
90 | [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, | 73 | [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, |
91 | [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, | 74 | [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, |
92 | [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, | 75 | [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, |
93 | #endif | 76 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ |
94 | }; | 77 | }; |
95 | #endif | 78 | #endif |
96 | 79 | ||
@@ -142,7 +125,7 @@ static sound_set_type * const sound_set_fns[] = | |||
142 | [SOUND_MDB_SHAPE] = sound_set_mdb_shape, | 125 | [SOUND_MDB_SHAPE] = sound_set_mdb_shape, |
143 | [SOUND_MDB_ENABLE] = sound_set_mdb_enable, | 126 | [SOUND_MDB_ENABLE] = sound_set_mdb_enable, |
144 | [SOUND_SUPERBASS] = sound_set_superbass, | 127 | [SOUND_SUPERBASS] = sound_set_superbass, |
145 | #endif | 128 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ |
146 | #if defined(AUDIOHW_HAVE_BASS_CUTOFF) | 129 | #if defined(AUDIOHW_HAVE_BASS_CUTOFF) |
147 | [SOUND_BASS_CUTOFF] = sound_set_bass_cutoff, | 130 | [SOUND_BASS_CUTOFF] = sound_set_bass_cutoff, |
148 | #endif | 131 | #endif |
@@ -166,7 +149,6 @@ void sound_set_dsp_callback(int (*func)(int, intptr_t)) | |||
166 | } | 149 | } |
167 | #endif | 150 | #endif |
168 | 151 | ||
169 | #ifndef SIMULATOR | ||
170 | #if CONFIG_CODEC == MAS3507D | 152 | #if CONFIG_CODEC == MAS3507D |
171 | /* convert tenth of dB volume (-780..+180) to dac3550 register value */ | 153 | /* convert tenth of dB volume (-780..+180) to dac3550 register value */ |
172 | static int tenthdb2reg(int db) | 154 | static int tenthdb2reg(int db) |
@@ -248,6 +230,7 @@ static void set_prescaled_volume(void) | |||
248 | dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0); | 230 | dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0); |
249 | #endif | 231 | #endif |
250 | 232 | ||
233 | #ifndef SIMULATOR | ||
251 | #if CONFIG_CODEC == MAS3507D | 234 | #if CONFIG_CODEC == MAS3507D |
252 | dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); | 235 | dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); |
253 | #elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \ | 236 | #elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \ |
@@ -265,13 +248,13 @@ static void set_prescaled_volume(void) | |||
265 | #elif defined(HAVE_JZ4740_CODEC) | 248 | #elif defined(HAVE_JZ4740_CODEC) |
266 | audiohw_set_volume(current_volume); | 249 | audiohw_set_volume(current_volume); |
267 | #endif | 250 | #endif |
251 | #else /* SIMULATOR */ | ||
252 | audiohw_set_volume(current_volume); | ||
253 | #endif /* !SIMULATOR */ | ||
268 | } | 254 | } |
269 | #endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */ | 255 | #endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */ |
270 | #endif /* !SIMULATOR */ | ||
271 | 256 | ||
272 | 257 | ||
273 | #ifndef SIMULATOR | ||
274 | |||
275 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 258 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
276 | unsigned long mdb_shape_shadow = 0; | 259 | unsigned long mdb_shape_shadow = 0; |
277 | unsigned long loudness_shadow = 0; | 260 | unsigned long loudness_shadow = 0; |
@@ -398,7 +381,7 @@ void sound_set_treble_cutoff(int value) | |||
398 | } | 381 | } |
399 | #endif | 382 | #endif |
400 | 383 | ||
401 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 384 | #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)) |
402 | void sound_set_loudness(int value) | 385 | void sound_set_loudness(int value) |
403 | { | 386 | { |
404 | if(!audio_is_initialized) | 387 | if(!audio_is_initialized) |
@@ -486,95 +469,6 @@ void sound_set_superbass(int value) | |||
486 | } | 469 | } |
487 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ | 470 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ |
488 | 471 | ||
489 | #else /* SIMULATOR */ | ||
490 | int sim_volume; | ||
491 | void sound_set_volume(int value) | ||
492 | { | ||
493 | /* 128 is SDL_MIX_MAXVOLUME */ | ||
494 | sim_volume = 128 * (value - VOLUME_MIN / 10) / (VOLUME_RANGE / 10); | ||
495 | } | ||
496 | |||
497 | void sound_set_balance(int value) | ||
498 | { | ||
499 | (void)value; | ||
500 | } | ||
501 | |||
502 | void sound_set_bass(int value) | ||
503 | { | ||
504 | (void)value; | ||
505 | } | ||
506 | |||
507 | void sound_set_treble(int value) | ||
508 | { | ||
509 | (void)value; | ||
510 | } | ||
511 | |||
512 | void sound_set_channels(int value) | ||
513 | { | ||
514 | (void)value; | ||
515 | } | ||
516 | |||
517 | void sound_set_stereo_width(int value) | ||
518 | { | ||
519 | (void)value; | ||
520 | } | ||
521 | |||
522 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
523 | void sound_set_loudness(int value) | ||
524 | { | ||
525 | (void)value; | ||
526 | } | ||
527 | |||
528 | void sound_set_avc(int value) | ||
529 | { | ||
530 | (void)value; | ||
531 | } | ||
532 | |||
533 | void sound_set_mdb_strength(int value) | ||
534 | { | ||
535 | (void)value; | ||
536 | } | ||
537 | |||
538 | void sound_set_mdb_harmonics(int value) | ||
539 | { | ||
540 | (void)value; | ||
541 | } | ||
542 | |||
543 | void sound_set_mdb_center(int value) | ||
544 | { | ||
545 | (void)value; | ||
546 | } | ||
547 | |||
548 | void sound_set_mdb_shape(int value) | ||
549 | { | ||
550 | (void)value; | ||
551 | } | ||
552 | |||
553 | void sound_set_mdb_enable(int value) | ||
554 | { | ||
555 | (void)value; | ||
556 | } | ||
557 | |||
558 | void sound_set_superbass(int value) | ||
559 | { | ||
560 | (void)value; | ||
561 | } | ||
562 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ | ||
563 | |||
564 | #if defined(HAVE_WM8758) || defined(HAVE_WM8985) | ||
565 | void sound_set_bass_cutoff(int value) | ||
566 | { | ||
567 | (void) value; | ||
568 | } | ||
569 | |||
570 | void sound_set_treble_cutoff(int value) | ||
571 | { | ||
572 | (void) value; | ||
573 | } | ||
574 | #endif /* HAVE_WM8758 */ | ||
575 | |||
576 | #endif /* SIMULATOR */ | ||
577 | |||
578 | void sound_set(int setting, int value) | 472 | void sound_set(int setting, int value) |
579 | { | 473 | { |
580 | sound_set_type* sound_set_val = sound_get_fn(setting); | 474 | sound_set_type* sound_set_val = sound_get_fn(setting); |
@@ -691,13 +585,19 @@ int sound_val2phys(int setting, int value) | |||
691 | #endif /* !defined(HAVE_AS3514) || defined(SIMULATOR) */ | 585 | #endif /* !defined(HAVE_AS3514) || defined(SIMULATOR) */ |
692 | 586 | ||
693 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 587 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
694 | #ifndef SIMULATOR | ||
695 | /* This function works by telling the decoder that we have another | 588 | /* This function works by telling the decoder that we have another |
696 | crystal frequency than we actually have. It will adjust its internal | 589 | crystal frequency than we actually have. It will adjust its internal |
697 | parameters and the result is that the audio is played at another pitch. | 590 | parameters and the result is that the audio is played at another pitch. |
698 | 591 | ||
699 | The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h) | 592 | The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h) |
700 | */ | 593 | */ |
594 | |||
595 | #ifdef SIMULATOR | ||
596 | static | ||
597 | #else | ||
598 | extern | ||
599 | #endif | ||
600 | unsigned long shadow_io_control_main; | ||
701 | static int last_pitch = PITCH_SPEED_100; | 601 | static int last_pitch = PITCH_SPEED_100; |
702 | 602 | ||
703 | void sound_set_pitch(int32_t pitch) | 603 | void sound_set_pitch(int32_t pitch) |
@@ -723,15 +623,4 @@ int32_t sound_get_pitch(void) | |||
723 | { | 623 | { |
724 | return last_pitch; | 624 | return last_pitch; |
725 | } | 625 | } |
726 | #else /* SIMULATOR */ | ||
727 | void sound_set_pitch(int32_t pitch) | ||
728 | { | ||
729 | (void)pitch; | ||
730 | } | ||
731 | |||
732 | int32_t sound_get_pitch(void) | ||
733 | { | ||
734 | return PITCH_SPEED_100; | ||
735 | } | ||
736 | #endif /* SIMULATOR */ | ||
737 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ | 626 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ |