summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/audio/erosqlinux_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/erosqlinux_codec.c')
-rw-r--r--firmware/drivers/audio/erosqlinux_codec.c15
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 @@
#include "logf.h"
-static int fd_hw;
-static int inited = 0;
+static int fd_hw = -1;
static long int vol_l_hw = 255;
static long int vol_r_hw = 255;
@@ -54,6 +53,7 @@ static void hw_open(void)
static void hw_close(void)
{
close(fd_hw);
+ fd_hw = -1;
}
static int muted = -1;
@@ -62,7 +62,7 @@ void audiohw_mute(int mute)
{
logf("mute %d", mute);
- if (muted == mute)
+ if (fd_hw < 0 || muted == mute)
return;
muted = mute;
@@ -84,7 +84,7 @@ int erosq_get_outputs(void) {
int status = 0;
- if (!inited) return ps;
+ if (fd_hw < 0) return ps;
const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
@@ -102,7 +102,7 @@ int erosq_get_outputs(void) {
void erosq_set_output(int ps)
{
- if (!inited || muted) return;
+ if (fd_hw < 0 || muted) return;
if (last_ps != ps)
{
@@ -119,9 +119,7 @@ void audiohw_preinit(void)
logf("hw preinit");
alsa_controls_init();
hw_open();
-// audiohw_mute(true); /* Start muted to avoid the POP */
- audiohw_mute(false);
- inited = 1;
+ audiohw_mute(false); /* No need to stay muted */
}
void audiohw_postinit(void)
@@ -132,7 +130,6 @@ void audiohw_postinit(void)
void audiohw_close(void)
{
logf("hw close");
- inited = 0;
hw_close();
alsa_controls_close();
}