diff options
Diffstat (limited to 'firmware/drivers/audio/erosqlinux_codec.c')
-rw-r--r-- | firmware/drivers/audio/erosqlinux_codec.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/firmware/drivers/audio/erosqlinux_codec.c b/firmware/drivers/audio/erosqlinux_codec.c index c8a104efd6..268da54280 100644 --- a/firmware/drivers/audio/erosqlinux_codec.c +++ b/firmware/drivers/audio/erosqlinux_codec.c | |||
@@ -37,8 +37,7 @@ | |||
37 | 37 | ||
38 | #include "logf.h" | 38 | #include "logf.h" |
39 | 39 | ||
40 | static int fd_hw; | 40 | static int fd_hw = -1; |
41 | static int inited = 0; | ||
42 | 41 | ||
43 | static long int vol_l_hw = 255; | 42 | static long int vol_l_hw = 255; |
44 | static long int vol_r_hw = 255; | 43 | static long int vol_r_hw = 255; |
@@ -54,6 +53,7 @@ static void hw_open(void) | |||
54 | static void hw_close(void) | 53 | static void hw_close(void) |
55 | { | 54 | { |
56 | close(fd_hw); | 55 | close(fd_hw); |
56 | fd_hw = -1; | ||
57 | } | 57 | } |
58 | 58 | ||
59 | static int muted = -1; | 59 | static int muted = -1; |
@@ -62,7 +62,7 @@ void audiohw_mute(int mute) | |||
62 | { | 62 | { |
63 | logf("mute %d", mute); | 63 | logf("mute %d", mute); |
64 | 64 | ||
65 | if (muted == mute) | 65 | if (fd_hw < 0 || muted == mute) |
66 | return; | 66 | return; |
67 | 67 | ||
68 | muted = mute; | 68 | muted = mute; |
@@ -84,7 +84,7 @@ int erosq_get_outputs(void) { | |||
84 | 84 | ||
85 | int status = 0; | 85 | int status = 0; |
86 | 86 | ||
87 | if (!inited) return ps; | 87 | if (fd_hw < 0) return ps; |
88 | 88 | ||
89 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; | 89 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; |
90 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; | 90 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; |
@@ -102,7 +102,7 @@ int erosq_get_outputs(void) { | |||
102 | 102 | ||
103 | void erosq_set_output(int ps) | 103 | void erosq_set_output(int ps) |
104 | { | 104 | { |
105 | if (!inited || muted) return; | 105 | if (fd_hw < 0 || muted) return; |
106 | 106 | ||
107 | if (last_ps != ps) | 107 | if (last_ps != ps) |
108 | { | 108 | { |
@@ -119,9 +119,7 @@ void audiohw_preinit(void) | |||
119 | logf("hw preinit"); | 119 | logf("hw preinit"); |
120 | alsa_controls_init(); | 120 | alsa_controls_init(); |
121 | hw_open(); | 121 | hw_open(); |
122 | // audiohw_mute(true); /* Start muted to avoid the POP */ | 122 | audiohw_mute(false); /* No need to stay muted */ |
123 | audiohw_mute(false); | ||
124 | inited = 1; | ||
125 | } | 123 | } |
126 | 124 | ||
127 | void audiohw_postinit(void) | 125 | void audiohw_postinit(void) |
@@ -132,7 +130,6 @@ void audiohw_postinit(void) | |||
132 | void audiohw_close(void) | 130 | void audiohw_close(void) |
133 | { | 131 | { |
134 | logf("hw close"); | 132 | logf("hw close"); |
135 | inited = 0; | ||
136 | hw_close(); | 133 | hw_close(); |
137 | alsa_controls_close(); | 134 | alsa_controls_close(); |
138 | } | 135 | } |