diff options
Diffstat (limited to 'firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c')
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c b/firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c new file mode 100644 index 0000000000..14b126c72a --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c | |||
@@ -0,0 +1,67 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2016 by Roman Stolyarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "kernel.h" | ||
24 | #include "audiohw.h" | ||
25 | #include "i2c-rk27xx.h" | ||
26 | |||
27 | #define ES9018_I2C_ADDR 0x90 | ||
28 | |||
29 | static unsigned char buf; | ||
30 | |||
31 | void es9018_write_reg(uint8_t reg, uint8_t val) | ||
32 | { | ||
33 | buf = val; | ||
34 | i2c_write(ES9018_I2C_ADDR, reg, sizeof(buf), (void*)&buf); | ||
35 | } | ||
36 | |||
37 | uint8_t es9018_read_reg(uint8_t reg) | ||
38 | { | ||
39 | i2c_read(ES9018_I2C_ADDR, reg, sizeof(buf), (void*)&buf); | ||
40 | return buf; | ||
41 | } | ||
42 | |||
43 | static void pop_ctrl(const int val) | ||
44 | { | ||
45 | if (val) | ||
46 | GPIO_PADR |= (1<<7); | ||
47 | else | ||
48 | GPIO_PADR &= ~(1<<7); | ||
49 | } | ||
50 | |||
51 | void audiohw_postinit(void) | ||
52 | { | ||
53 | pop_ctrl(0); | ||
54 | sleep(HZ/4); | ||
55 | audiohw_init(); | ||
56 | sleep(HZ/2); | ||
57 | pop_ctrl(1); | ||
58 | sleep(HZ/4); | ||
59 | audiohw_unmute(); | ||
60 | } | ||
61 | |||
62 | void audiohw_close(void) | ||
63 | { | ||
64 | audiohw_mute(); | ||
65 | pop_ctrl(0); | ||
66 | sleep(HZ/4); | ||
67 | } | ||