diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/audio/tlv320.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/firmware/drivers/audio/tlv320.c b/firmware/drivers/audio/tlv320.c index 6a22ab1c74..d4c21bd5c2 100644 --- a/firmware/drivers/audio/tlv320.c +++ b/firmware/drivers/audio/tlv320.c | |||
@@ -16,13 +16,16 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | ||
19 | #include "logf.h" | 20 | #include "logf.h" |
20 | #include "system.h" | 21 | #include "system.h" |
21 | #include "string.h" | 22 | #include "string.h" |
22 | #include "audio.h" | 23 | #include "audio.h" |
23 | 24 | ||
24 | #ifdef CPU_COLDFIRE | 25 | #if CONFIG_I2C == I2C_COLDFIRE |
25 | #include "i2c-coldfire.h" | 26 | #include "i2c-coldfire.h" |
27 | #elif CONFIG_I2C == I2C_DM320 | ||
28 | #include "i2c-dm320.h" | ||
26 | #endif | 29 | #endif |
27 | #include "audiohw.h" | 30 | #include "audiohw.h" |
28 | 31 | ||
@@ -45,7 +48,7 @@ int tenthdb2master(int db) | |||
45 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | 48 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ |
46 | /* 1111111 == +6dB (0x7f) */ | 49 | /* 1111111 == +6dB (0x7f) */ |
47 | /* 1111001 == 0dB (0x79) */ | 50 | /* 1111001 == 0dB (0x79) */ |
48 | /* 0110000 == -73dB (0x30 */ | 51 | /* 0110000 == -73dB (0x30) */ |
49 | /* 0101111 == mute (0x2f) */ | 52 | /* 0101111 == mute (0x2f) */ |
50 | 53 | ||
51 | if (db < VOLUME_MIN) { | 54 | if (db < VOLUME_MIN) { |
@@ -56,7 +59,11 @@ int tenthdb2master(int db) | |||
56 | } | 59 | } |
57 | 60 | ||
58 | /* local functions and definations */ | 61 | /* local functions and definations */ |
62 | #ifndef CREATIVE_ZVM | ||
59 | #define TLV320_ADDR 0x34 | 63 | #define TLV320_ADDR 0x34 |
64 | #else | ||
65 | #define TLV320_ADDR 0x1A | ||
66 | #endif | ||
60 | 67 | ||
61 | struct tlv320_info | 68 | struct tlv320_info |
62 | { | 69 | { |
@@ -75,8 +82,10 @@ static void tlv320_write_reg(unsigned reg, unsigned value) | |||
75 | data[0] = (reg << 1) | ((value >> 8) & 1); | 82 | data[0] = (reg << 1) | ((value >> 8) & 1); |
76 | data[1] = value; | 83 | data[1] = value; |
77 | 84 | ||
78 | #ifdef CPU_COLDFIRE | 85 | #if CONFIG_I2C == I2C_COLDFIRE |
79 | if (i2c_write(I2C_IFACE_0, TLV320_ADDR, data, 2) != 2) | 86 | if (i2c_write(I2C_IFACE_0, TLV320_ADDR, data, 2) != 2) |
87 | #elif CONFIG_I2C == I2C_DM320 | ||
88 | if (i2c_write(TLV320_ADDR, data, 2) != 0) | ||
80 | #else | 89 | #else |
81 | #warning Implement tlv320_write_reg() | 90 | #warning Implement tlv320_write_reg() |
82 | #endif | 91 | #endif |
@@ -95,6 +104,7 @@ static void tlv320_write_reg(unsigned reg, unsigned value) | |||
95 | */ | 104 | */ |
96 | void audiohw_init(void) | 105 | void audiohw_init(void) |
97 | { | 106 | { |
107 | logf("TLV320 init"); | ||
98 | memset(tlv320_regs, 0, sizeof(tlv320_regs)); | 108 | memset(tlv320_regs, 0, sizeof(tlv320_regs)); |
99 | 109 | ||
100 | /* Initialize all registers */ | 110 | /* Initialize all registers */ |
@@ -106,7 +116,11 @@ void audiohw_init(void) | |||
106 | audiohw_mute(true); | 116 | audiohw_mute(true); |
107 | tlv320_write_reg(REG_AAP, AAP_DAC | AAP_MICM); | 117 | tlv320_write_reg(REG_AAP, AAP_DAC | AAP_MICM); |
108 | tlv320_write_reg(REG_DAP, 0x00); /* No deemphasis */ | 118 | tlv320_write_reg(REG_DAP, 0x00); /* No deemphasis */ |
119 | #ifndef CREATIVE_ZVM | ||
109 | tlv320_write_reg(REG_DAIF, DAIF_IWL_16 | DAIF_FOR_I2S); | 120 | tlv320_write_reg(REG_DAIF, DAIF_IWL_16 | DAIF_FOR_I2S); |
121 | #else | ||
122 | tlv320_write_reg(REG_DAIF, DAIF_IWL_16 | DAIF_FOR_DSP); | ||
123 | #endif | ||
110 | tlv320_write_reg(REG_DIA, DIA_ACT); | 124 | tlv320_write_reg(REG_DIA, DIA_ACT); |
111 | audiohw_set_frequency(-1); /* default */ | 125 | audiohw_set_frequency(-1); /* default */ |
112 | } | 126 | } |