summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/cs42l55.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/cs42l55.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/cs42l55.c')
-rw-r--r--firmware/drivers/audio/cs42l55.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/firmware/drivers/audio/cs42l55.c b/firmware/drivers/audio/cs42l55.c
index 38380d5a54..75fcd80b77 100644
--- a/firmware/drivers/audio/cs42l55.c
+++ b/firmware/drivers/audio/cs42l55.c
@@ -29,27 +29,15 @@
29#include "cscodec.h" 29#include "cscodec.h"
30#include "cs42l55.h" 30#include "cs42l55.h"
31 31
32const struct sound_settings_info audiohw_settings[] = {
33 [SOUND_VOLUME] = {"dB", 0, 1, -60, 12, -25},
34 [SOUND_BASS] = {"dB", 1, 15,-105, 120, 0},
35 [SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0},
36 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
37 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
38 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
39 [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 2},
40 [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
41};
42
43static int bass, treble; 32static int bass, treble;
44 33
45/* convert tenth of dB volume (-600..120) to master volume register value */ 34/* convert tenth of dB volume (-600..120) to volume register value */
46int tenthdb2master(int db) 35static int vol_tenthdb2hw(int db)
47{ 36{
48 /* -60dB to +12dB in 1dB steps */ 37 /* -60dB to +12dB in 1dB steps */
49 /* 0001100 == +12dB (0xc) */ 38 /* 0001100 == +12dB (0xc) */
50 /* 0000000 == 0dB (0x0) */ 39 /* 0000000 == 0dB (0x0) */
51 /* 1000100 == -60dB (0x44, this is actually -58dB) */ 40 /* 1000100 == -60dB (0x44, this is actually -58dB) */
52
53 if (db < VOLUME_MIN) return HPACTL_HPAMUTE; 41 if (db < VOLUME_MIN) return HPACTL_HPAMUTE;
54 return (db / 10) & HPACTL_HPAVOL_MASK; 42 return (db / 10) & HPACTL_HPAVOL_MASK;
55} 43}
@@ -125,11 +113,8 @@ void audiohw_postinit(void)
125 113
126void audiohw_set_master_vol(int vol_l, int vol_r) 114void audiohw_set_master_vol(int vol_l, int vol_r)
127{ 115{
128 /* -60dB to +12dB in 1dB steps */ 116 vol_l = vol_tenthdb2hw(vol_l);
129 /* 0001100 == +12dB (0xc) */ 117 vol_r = vol_tenthdb2hw(vol_r);
130 /* 0000000 == 0dB (0x0) */
131 /* 1000100 == -60dB (0x44, this is actually -58dB) */
132
133 cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE, 118 cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE,
134 vol_l << HPACTL_HPAVOL_SHIFT); 119 vol_l << HPACTL_HPAVOL_SHIFT);
135 cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE, 120 cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE,
@@ -138,11 +123,8 @@ void audiohw_set_master_vol(int vol_l, int vol_r)
138 123
139void audiohw_set_lineout_vol(int vol_l, int vol_r) 124void audiohw_set_lineout_vol(int vol_l, int vol_r)
140{ 125{
141 /* -60dB to +12dB in 1dB steps */ 126 vol_l = vol_tenthdb2hw(vol_l);
142 /* 0001100 == +12dB (0xc) */ 127 vol_r = vol_tenthdb2hw(vol_r);
143 /* 0000000 == 0dB (0x0) */
144 /* 1000100 == -60dB (0x44, this is actually -58dB) */
145
146 cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE, 128 cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE,
147 vol_l << LINEACTL_LINEAVOL_SHIFT); 129 vol_l << LINEACTL_LINEAVOL_SHIFT);
148 cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE, 130 cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE,