summaryrefslogtreecommitdiff
path: root/firmware/drivers/tlv320.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/tlv320.c')
-rw-r--r--firmware/drivers/tlv320.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/firmware/drivers/tlv320.c b/firmware/drivers/tlv320.c
index c9ab094ef3..a88eae5f26 100644
--- a/firmware/drivers/tlv320.c
+++ b/firmware/drivers/tlv320.c
@@ -33,6 +33,22 @@
33#include "i2c-coldfire.h" 33#include "i2c-coldfire.h"
34#include "tlv320.h" 34#include "tlv320.h"
35 35
36/* convert tenth of dB volume (-840..0) to master volume register value */
37int tenthdb2master(int db)
38{
39 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
40 /* 1111111 == +6dB (0x7f) */
41 /* 1111001 == 0dB (0x79) */
42 /* 0110000 == -73dB (0x30 */
43 /* 0101111 == mute (0x2f) */
44
45 if (db < VOLUME_MIN) {
46 return 0x2f;
47 } else {
48 return((db/10)+73+0x30);
49 }
50}
51
36/* local functions and definations */ 52/* local functions and definations */
37#define TLV320_ADDR 0x34 53#define TLV320_ADDR 0x34
38 54