diff options
Diffstat (limited to 'firmware/drivers/uda1380.c')
-rw-r--r-- | firmware/drivers/uda1380.c | 26 |
1 files changed, 26 insertions, 0 deletions
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 */ | ||
39 | int 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 */ | ||
52 | int 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 | /* ------------------------------------------------- */ |