diff options
Diffstat (limited to 'firmware/drivers/wm8731l.c')
-rw-r--r-- | firmware/drivers/wm8731l.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 */ | ||
46 | int 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 */ | ||
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 | } | ||
45 | 73 | ||
46 | int audiohw_mute(int mute) | 74 | int audiohw_mute(int mute) |
47 | { | 75 | { |