diff options
Diffstat (limited to 'firmware/target/arm/pp/ascodec-pp.c')
-rw-r--r-- | firmware/target/arm/pp/ascodec-pp.c | 77 |
1 files changed, 62 insertions, 15 deletions
diff --git a/firmware/target/arm/pp/ascodec-pp.c b/firmware/target/arm/pp/ascodec-pp.c index 49a69d1a11..eb8093c841 100644 --- a/firmware/target/arm/pp/ascodec-pp.c +++ b/firmware/target/arm/pp/ascodec-pp.c | |||
@@ -26,7 +26,8 @@ | |||
26 | 26 | ||
27 | #include "audiohw.h" | 27 | #include "audiohw.h" |
28 | #include "i2s.h" | 28 | #include "i2s.h" |
29 | #include "ascodec-target.h" | 29 | #include "i2c-pp.h" |
30 | #include "ascodec.h" | ||
30 | 31 | ||
31 | /* | 32 | /* |
32 | * Initialise the PP I2C and I2S. | 33 | * Initialise the PP I2C and I2S. |
@@ -65,18 +66,64 @@ void audiohw_init(void) | |||
65 | audiohw_preinit(); | 66 | audiohw_preinit(); |
66 | } | 67 | } |
67 | 68 | ||
68 | void ascodec_suppressor_on(bool on) | 69 | int ascodec_write(unsigned int reg, unsigned int value) |
69 | { | 70 | { |
70 | /* CHECK: Good for c200 too? */ | 71 | return pp_i2c_send(AS3514_I2C_ADDR, reg, value); |
71 | #ifdef SANSA_E200 | 72 | } |
72 | if (on) { | 73 | |
73 | /* Set pop prevention */ | 74 | int ascodec_read(unsigned int reg) |
74 | GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x08); | 75 | { |
75 | } else { | 76 | return i2c_readbyte(AS3514_I2C_ADDR, reg); |
76 | /* Release pop prevention */ | 77 | } |
77 | GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x08); | 78 | |
78 | } | 79 | int ascodec_readbytes(unsigned int addr, unsigned int len, unsigned char *data) |
79 | #else | 80 | { |
80 | (void)on; | 81 | return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data); |
81 | #endif | 82 | } |
82 | } | 83 | |
84 | void ascodec_lock(void) | ||
85 | { | ||
86 | i2c_lock(); | ||
87 | } | ||
88 | |||
89 | void ascodec_unlock(void) | ||
90 | { | ||
91 | i2c_unlock(); | ||
92 | } | ||
93 | |||
94 | bool ascodec_chg_status(void) | ||
95 | { | ||
96 | return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; | ||
97 | } | ||
98 | |||
99 | bool ascodec_endofch(void) | ||
100 | { | ||
101 | return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; | ||
102 | } | ||
103 | |||
104 | void ascodec_monitor_endofch(void) | ||
105 | { | ||
106 | ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); | ||
107 | } | ||
108 | |||
109 | void ascodec_write_charger(int value) | ||
110 | { | ||
111 | ascodec_write(AS3514_CHARGER, value); | ||
112 | } | ||
113 | |||
114 | int ascodec_read_charger(void) | ||
115 | { | ||
116 | return ascodec_read(AS3514_CHARGER); | ||
117 | } | ||
118 | |||
119 | void ascodec_wait_adc_finished(void) | ||
120 | { | ||
121 | /* | ||
122 | * FIXME: not implemented | ||
123 | * | ||
124 | * If irqs are not available on the target platform, | ||
125 | * this should be most likely implemented by polling | ||
126 | * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c | ||
127 | * is polling IRQ_ENDOFCH. | ||
128 | */ | ||
129 | } | ||