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