summaryrefslogtreecommitdiff
path: root/firmware/drivers/dac.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/dac.c')
-rw-r--r--firmware/drivers/dac.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/firmware/drivers/dac.c b/firmware/drivers/dac.c
index c8a5414611..4212b322f0 100644
--- a/firmware/drivers/dac.c
+++ b/firmware/drivers/dac.c
@@ -24,6 +24,10 @@
24 24
25#ifdef HAVE_DAC3550A 25#ifdef HAVE_DAC3550A
26 26
27static bool line_in_enabled = false;
28static bool dac_enabled = false;
29
30
27int dac_volume(unsigned int left, unsigned int right, bool deemph) 31int dac_volume(unsigned int left, unsigned int right, bool deemph)
28{ 32{
29 int ret = 0; 33 int ret = 0;
@@ -54,12 +58,16 @@ int dac_volume(unsigned int left, unsigned int right, bool deemph)
54** Bit6: 0 = 3V 1 = 5V 58** Bit6: 0 = 3V 1 = 5V
55** Bit5: 0 = normal 1 = low power 59** Bit5: 0 = normal 1 = low power
56** Bit4: 0 = AUX2 off 1 = AUX2 on 60** Bit4: 0 = AUX2 off 1 = AUX2 on
57** Bit3: 0 = AUX1 off 1 = AUX2 on 61** Bit3: 0 = AUX1 off 1 = AUX1 on
58** Bit2: 0 = DAC off 1 = DAC on 62** Bit2: 0 = DAC off 1 = DAC on
59** Bit1: 0 = stereo 1 = mono 63** Bit1: 0 = stereo 1 = mono
60** Bit0: 0 = normal right amp 1 = inverted right amp 64** Bit0: 0 = normal right amp 1 = inverted right amp
61******************************************************************/ 65******************************************************************/
62int dac_config(int value) 66/* dac_config is called once to initialize it. we will apply
67 our static settings because of the init flow.
68 dac_init -> dac_line_in -> mpeg_init -> dac_config
69*/
70static int dac_config(void)
63{ 71{
64 int ret = 0; 72 int ret = 0;
65 unsigned char buf[2]; 73 unsigned char buf[2];
@@ -67,7 +75,8 @@ int dac_config(int value)
67 i2c_begin(); 75 i2c_begin();
68 76
69 buf[0] = DAC_REG_WRITE | DAC_GCFG; 77 buf[0] = DAC_REG_WRITE | DAC_GCFG;
70 buf[1] = value; 78 buf[1] = (dac_enabled ? 0x04 : 0) |
79 (line_in_enabled ? 0x08 : 0);
71 80
72 /* send write command */ 81 /* send write command */
73 if (i2c_write(DAC_DEV_WRITE,buf,2)) 82 if (i2c_write(DAC_DEV_WRITE,buf,2))
@@ -79,6 +88,18 @@ int dac_config(int value)
79 return ret; 88 return ret;
80} 89}
81 90
91void dac_enable(bool enable)
92{
93 dac_enabled = enable;
94 dac_config();
95}
96
97void dac_line_in(bool enable)
98{
99 line_in_enabled = enable;
100 dac_config();
101}
102
82void dac_init(void) 103void dac_init(void)
83{ 104{
84 unsigned char buf[2]; 105 unsigned char buf[2];