summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/tlv320.c16
-rw-r--r--firmware/drivers/uda1380.c26
-rw-r--r--firmware/drivers/wm8731l.c28
-rw-r--r--firmware/drivers/wm8758.c31
-rw-r--r--firmware/drivers/wm8975.c30
5 files changed, 131 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
diff --git a/firmware/drivers/uda1380.c b/firmware/drivers/uda1380.c
index 841e7fbd19..00019148c1 100644
--- a/firmware/drivers/uda1380.c
+++ b/firmware/drivers/uda1380.c
@@ -35,6 +35,32 @@
35#include "uda1380.h" 35#include "uda1380.h"
36#include "pcf50606.h" 36#include "pcf50606.h"
37 37
38/* convert tenth of dB volume (-840..0) to master volume register value */
39int tenthdb2master(int db)
40{
41 if (db < -720) /* 1.5 dB steps */
42 return (2940 - db) / 15;
43 else if (db < -660) /* 0.75 dB steps */
44 return (1110 - db) * 2 / 15;
45 else if (db < -520) /* 0.5 dB steps */
46 return (520 - db) / 5;
47 else /* 0.25 dB steps */
48 return -db * 2 / 5;
49}
50
51/* convert tenth of dB volume (-780..0) to mixer volume register value */
52int tenthdb2mixer(int db)
53{
54 if (db < -660) /* 1.5 dB steps */
55 return (2640 - db) / 15;
56 else if (db < -600) /* 0.75 dB steps */
57 return (990 - db) * 2 / 15;
58 else if (db < -460) /* 0.5 dB steps */
59 return (460 - db) / 5;
60 else /* 0.25 dB steps */
61 return -db * 2 / 5;
62}
63
38/* ------------------------------------------------- */ 64/* ------------------------------------------------- */
39/* Local functions and variables */ 65/* Local functions and variables */
40/* ------------------------------------------------- */ 66/* ------------------------------------------------- */
diff --git a/firmware/drivers/wm8731l.c b/firmware/drivers/wm8731l.c
index 4fc33f882d..30521339e9 100644
--- a/firmware/drivers/wm8731l.c
+++ b/firmware/drivers/wm8731l.c
@@ -42,6 +42,34 @@
42 42
43#define IPOD_PCM_LEVEL 0x65 /* -6dB */ 43#define IPOD_PCM_LEVEL 0x65 /* -6dB */
44 44
45/* convert tenth of dB volume (-730..60) to master volume register value */
46int tenthdb2master(int db)
47{
48 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
49 /* 1111111 == +6dB (0x7f) */
50 /* 1111001 == 0dB (0x79) */
51 /* 0110000 == -73dB (0x30 */
52 /* 0101111 == mute (0x2f) */
53
54 if (db < VOLUME_MIN) {
55 return 0x2f;
56 } else {
57 return((db/10)+0x30+73);
58 }
59}
60
61/* convert tenth of dB volume (-780..0) to mixer volume register value */
62int tenthdb2mixer(int db)
63{
64 if (db < -660) /* 1.5 dB steps */
65 return (2640 - db) / 15;
66 else if (db < -600) /* 0.75 dB steps */
67 return (990 - db) * 2 / 15;
68 else if (db < -460) /* 0.5 dB steps */
69 return (460 - db) / 5;
70 else /* 0.25 dB steps */
71 return -db * 2 / 5;
72}
45 73
46int audiohw_mute(int mute) 74int audiohw_mute(int mute)
47{ 75{
diff --git a/firmware/drivers/wm8758.c b/firmware/drivers/wm8758.c
index 3a4256bb69..268df13f07 100644
--- a/firmware/drivers/wm8758.c
+++ b/firmware/drivers/wm8758.c
@@ -40,6 +40,37 @@
40#include "wmcodec.h" 40#include "wmcodec.h"
41#include "wm8758.h" 41#include "wm8758.h"
42 42
43/* convert tenth of dB volume (-57..6) to master volume register value */
44int tenthdb2master(int db)
45{
46 /* +6 to -57dB in 1dB steps == 64 levels = 6 bits */
47 /* 0111111 == +6dB (0x3f) = 63) */
48 /* 0111001 == 0dB (0x39) = 57) */
49 /* 0000001 == -56dB (0x01) = */
50 /* 0000000 == -57dB (0x00) */
51
52 /* 1000000 == Mute (0x40) */
53
54 if (db < VOLUME_MIN) {
55 return 0x40;
56 } else {
57 return((db/10)+57);
58 }
59}
60
61/* convert tenth of dB volume (-780..0) to mixer volume register value */
62int tenthdb2mixer(int db)
63{
64 if (db < -660) /* 1.5 dB steps */
65 return (2640 - db) / 15;
66 else if (db < -600) /* 0.75 dB steps */
67 return (990 - db) * 2 / 15;
68 else if (db < -460) /* 0.5 dB steps */
69 return (460 - db) / 5;
70 else /* 0.25 dB steps */
71 return -db * 2 / 5;
72}
73
43void audiohw_reset(void); 74void audiohw_reset(void);
44 75
45#define IPOD_PCM_LEVEL 0x65 /* -6dB */ 76#define IPOD_PCM_LEVEL 0x65 /* -6dB */
diff --git a/firmware/drivers/wm8975.c b/firmware/drivers/wm8975.c
index 96a563b1c9..7f2f2c4a7d 100644
--- a/firmware/drivers/wm8975.c
+++ b/firmware/drivers/wm8975.c
@@ -40,6 +40,36 @@
40#include "wmcodec.h" 40#include "wmcodec.h"
41#include "wm8975.h" 41#include "wm8975.h"
42 42
43/* convert tenth of dB volume (-730..60) to master volume register value */
44int tenthdb2master(int db)
45{
46 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
47 /* 1111111 == +6dB (0x7f) */
48 /* 1111001 == 0dB (0x79) */
49 /* 0110000 == -73dB (0x30 */
50 /* 0101111 == mute (0x2f) */
51
52 if (db < VOLUME_MIN) {
53 return 0x0;
54 } else {
55 return((db/10)+73+0x30);
56 }
57}
58
59/* convert tenth of dB volume (-780..0) to mixer volume register value */
60int tenthdb2mixer(int db)
61{
62 if (db < -660) /* 1.5 dB steps */
63 return (2640 - db) / 15;
64 else if (db < -600) /* 0.75 dB steps */
65 return (990 - db) * 2 / 15;
66 else if (db < -460) /* 0.5 dB steps */
67 return (460 - db) / 5;
68 else /* 0.25 dB steps */
69 return -db * 2 / 5;
70}
71
72
43void audiohw_reset(void); 73void audiohw_reset(void);
44 74
45#define IPOD_PCM_LEVEL 0x65 /* -6dB */ 75#define IPOD_PCM_LEVEL 0x65 /* -6dB */