diff options
Diffstat (limited to 'firmware/drivers/wm8758.c')
-rw-r--r-- | firmware/drivers/wm8758.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 */ | ||
44 | int 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 */ | ||
62 | int 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 | |||
43 | void audiohw_reset(void); | 74 | void audiohw_reset(void); |
44 | 75 | ||
45 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ | 76 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ |