summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/tsc2100.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-04-12 23:35:47 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-04-15 12:02:05 -0400
commit0c7b7873984e04941c9f21fa272638018fdb9a16 (patch)
treefb6afca45d2bef0a2c91732a39ffc0b965f5c557 /firmware/drivers/audio/tsc2100.c
parentfd9e2568908f91b5bcf7378dc28f6ec070d6027a (diff)
downloadrockbox-0c7b7873984e04941c9f21fa272638018fdb9a16.tar.gz
rockbox-0c7b7873984e04941c9f21fa272638018fdb9a16.zip
Straighten out the mad twisted state of sound.c and related areas.
This is going right in since it's long overdue. If anything is goofed, drop me a line or just tweak it yourself if you know what's wrong. :-) Make HW/SW codec interface more uniform when emulating HW functionality on SWCODEC for functions such as "audiohw_set_pitch". The firmware-to- DSP plumbing is in firmware/drivers/audiohw-swcodec.c. "sound_XXX" APIs are all in sound.c with none in DSP code any longer. Reduce number of settings definitions needed by each codec by providing defaults for common ones like balance, channels and SW tone controls. Remove need for separate SIM code and tables and add virtual codec header for hosted targets. Change-Id: I3f23702bca054fc9bda40f49824ce681bb7f777b
Diffstat (limited to 'firmware/drivers/audio/tsc2100.c')
-rw-r--r--firmware/drivers/audio/tsc2100.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/firmware/drivers/audio/tsc2100.c b/firmware/drivers/audio/tsc2100.c
index 6479f84b34..41327ae3d7 100644
--- a/firmware/drivers/audio/tsc2100.c
+++ b/firmware/drivers/audio/tsc2100.c
@@ -29,18 +29,9 @@
29#include "sound.h" 29#include "sound.h"
30#include "tsc2100.h" 30#include "tsc2100.h"
31 31
32const struct sound_settings_info audiohw_settings[] = {
33 [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN/10, VOLUME_MAX/10, -25},
34 /* HAVE_SW_TONE_CONTROLS */
35 [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
36 [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
37 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
38 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
39 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
40};
41static bool is_muted = false; 32static bool is_muted = false;
42/* convert tenth of dB volume to master volume register value */ 33/* convert tenth of dB volume to volume register value */
43int tenthdb2master(int db) 34static int vol_tenthdb2hw(int db)
44{ 35{
45 /* 0 to -63.0dB in 1dB steps, tsc2100 can goto -63.5 in 0.5dB steps */ 36 /* 0 to -63.0dB in 1dB steps, tsc2100 can goto -63.5 in 0.5dB steps */
46 if (db < VOLUME_MIN) { 37 if (db < VOLUME_MIN) {
@@ -52,27 +43,6 @@ int tenthdb2master(int db)
52 } 43 }
53} 44}
54 45
55int sound_val2phys(int setting, int value)
56{
57 int result;
58
59 switch(setting)
60 {
61#if 0
62 case SOUND_LEFT_GAIN:
63 case SOUND_RIGHT_GAIN:
64 case SOUND_MIC_GAIN:
65 result = (value - 23) * 15;
66 break;
67#endif
68 default:
69 result = value;
70 break;
71 }
72
73 return result;
74}
75
76void audiohw_init(void) 46void audiohw_init(void)
77{ 47{
78 short val = tsc2100_readreg(TSAC4_PAGE, TSAC4_ADDRESS); 48 short val = tsc2100_readreg(TSAC4_PAGE, TSAC4_ADDRESS);
@@ -104,9 +74,12 @@ void audiohw_postinit(void)
104 audiohw_mute(false); 74 audiohw_mute(false);
105} 75}
106 76
107void audiohw_set_master_vol(int vol_l, int vol_r) 77void audiohw_set_master_volume(int vol_l, int vol_r)
108{ 78{
109 tsc2100_writereg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS, (short)((vol_l<<8) | vol_r) ); 79 vol_l = vol_tenthdb2hw(vol_l);
80 vol_r = vol_tenthdb2hw(vol_r);
81 tsc2100_writereg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS,
82 (short)((vol_l<<8) | vol_r) );
110} 83}
111 84
112void audiohw_close(void) 85void audiohw_close(void)