summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/xduoolinux_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/xduoolinux_codec.c')
-rw-r--r--firmware/drivers/audio/xduoolinux_codec.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c
index 0425989dc5..31224abd96 100644
--- a/firmware/drivers/audio/xduoolinux_codec.c
+++ b/firmware/drivers/audio/xduoolinux_codec.c
@@ -36,8 +36,7 @@
36 36
37#include "logf.h" 37#include "logf.h"
38 38
39static int fd_hw; 39static int fd_hw = -1;
40static int inited = 0;
41 40
42static long int vol_l_hw = 255; 41static long int vol_l_hw = 255;
43static long int vol_r_hw = 255; 42static long int vol_r_hw = 255;
@@ -53,6 +52,7 @@ static void hw_open(void)
53static void hw_close(void) 52static void hw_close(void)
54{ 53{
55 close(fd_hw); 54 close(fd_hw);
55 fd_hw = -1;
56} 56}
57 57
58static int muted = -1; 58static int muted = -1;
@@ -61,7 +61,7 @@ void audiohw_mute(int mute)
61{ 61{
62 logf("mute %d", mute); 62 logf("mute %d", mute);
63 63
64 if (muted == mute) 64 if (fd_hw < 0 || muted == mute)
65 return; 65 return;
66 66
67 muted = mute; 67 muted = mute;
@@ -83,7 +83,7 @@ int xduoo_get_outputs(void){
83 83
84 int status = 0; 84 int status = 0;
85 85
86 if (!inited) return ps; 86 if (fd_hw < 0) return ps;
87 87
88 const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; 88 const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
89 const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; 89 const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
@@ -109,7 +109,7 @@ int xduoo_get_outputs(void){
109 109
110void xduoo_set_output(int ps) 110void xduoo_set_output(int ps)
111{ 111{
112 if (!inited || muted) return; 112 if (fd_hw < 0 || muted) return;
113 113
114 if (last_ps != ps) 114 if (last_ps != ps)
115 { 115 {
@@ -127,7 +127,6 @@ void audiohw_preinit(void)
127 alsa_controls_init(); 127 alsa_controls_init();
128 hw_open(); 128 hw_open();
129 audiohw_mute(true); /* Start muted to avoid the POP */ 129 audiohw_mute(true); /* Start muted to avoid the POP */
130 inited = 1;
131// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000 130// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000
132} 131}
133 132
@@ -139,7 +138,6 @@ void audiohw_postinit(void)
139void audiohw_close(void) 138void audiohw_close(void)
140{ 139{
141 logf("hw close"); 140 logf("hw close");
142 inited = 0;
143 hw_close(); 141 hw_close();
144 alsa_controls_close(); 142 alsa_controls_close();
145} 143}
@@ -166,6 +164,9 @@ void audiohw_set_volume(int vol_l, int vol_r)
166 r = -vol_r/5; 164 r = -vol_r/5;
167 } 165 }
168 166
167 if (fd_hw < 0)
168 return;
169
169 alsa_controls_set_ints("Left Playback Volume", 1, &l); 170 alsa_controls_set_ints("Left Playback Volume", 1, &l);
170 alsa_controls_set_ints("Right Playback Volume", 1, &r); 171 alsa_controls_set_ints("Right Playback Volume", 1, &r);
171} 172}