diff options
Diffstat (limited to 'firmware/drivers/dac.c')
-rw-r--r-- | firmware/drivers/dac.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/firmware/drivers/dac.c b/firmware/drivers/dac.c index 0c12a8d912..9a40244292 100644 --- a/firmware/drivers/dac.c +++ b/firmware/drivers/dac.c | |||
@@ -16,23 +16,26 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "stdbool.h" | ||
19 | #include "i2c.h" | 20 | #include "i2c.h" |
20 | #include "debug.h" | 21 | #include "debug.h" |
21 | #include "dac.h" | 22 | #include "dac.h" |
22 | 23 | ||
23 | int dac_volume(unsigned int volume) | 24 | int dac_volume(unsigned int left, unsigned int right, bool deemph) |
24 | { | 25 | { |
25 | int ret = 0; | 26 | int ret = 0; |
26 | unsigned char buf[3]; | 27 | unsigned char buf[3]; |
27 | 28 | ||
28 | i2c_begin(); | 29 | i2c_begin(); |
29 | 30 | ||
30 | if(volume > 0x38) | 31 | if (left > 0x38) |
31 | volume = 0x38; | 32 | left = 0x38; |
33 | if (right > 0x38) | ||
34 | right = 0x38; | ||
32 | 35 | ||
33 | buf[0] = DAC_REG_WRITE | DAC_AVOL; | 36 | buf[0] = DAC_REG_WRITE | DAC_AVOL; |
34 | buf[1] = (volume & 0x3f) | 0x40; /* Deemphasis ON */ | 37 | buf[1] = (left & 0x3f) | (deemph ? 0x40 : 0); |
35 | buf[2] = volume & 0x3f; | 38 | buf[2] = right & 0x3f; |
36 | 39 | ||
37 | /* send read command */ | 40 | /* send read command */ |
38 | if (i2c_write(DAC_DEV_WRITE,buf,3)) | 41 | if (i2c_write(DAC_DEV_WRITE,buf,3)) |