summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/audio/fiiolinux_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/fiiolinux_codec.c')
-rw-r--r--firmware/drivers/audio/fiiolinux_codec.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/firmware/drivers/audio/fiiolinux_codec.c b/firmware/drivers/audio/fiiolinux_codec.c
index 44ebdd092c..d23e023564 100644
--- a/firmware/drivers/audio/fiiolinux_codec.c
+++ b/firmware/drivers/audio/fiiolinux_codec.c
@@ -32,8 +32,8 @@
#include "pcm-alsa.h"
#include <sys/ioctl.h>
-static int fd_hw;
-static int ak_hw;
+static int fd_hw = -1;
+static int ak_hw = -1;
static int vol_sw[2] = {0};
static long int vol_hw[2] = {0};
@@ -61,8 +61,8 @@ static void hw_close(void)
panicf("Call cmd AK4376_POWER_OFF fail");
}
close(ak_hw);
-
close(fd_hw);
+ ak_hw = fd_hw = -1;
}
void audiohw_preinit(void)
@@ -91,10 +91,15 @@ void audiohw_set_frequency(int fsel)
(void)fsel;
}
+static int muted = -1;
+
void audiohw_set_volume(int vol_l, int vol_r)
{
int vol[2];
+ if (fd_hw < 0)
+ return;
+
vol[0] = vol_l / 20;
vol[1] = vol_r / 20;
@@ -121,15 +126,20 @@ void audiohw_set_volume(int vol_l, int vol_r)
}
}
- alsa_controls_set_ints("DACL Playback Volume", 1, &vol_hw[0]);
- alsa_controls_set_ints("DACR Playback Volume", 1, &vol_hw[1]);
- pcm_alsa_set_digital_volume(vol_sw[0], vol_sw[1]);
+ if (!muted) {
+ alsa_controls_set_ints("DACL Playback Volume", 1, &vol_hw[0]);
+ alsa_controls_set_ints("DACR Playback Volume", 1, &vol_hw[1]);
+ pcm_alsa_set_digital_volume(vol_sw[0], vol_sw[1]);
+ }
}
void audiohw_mute(int mute)
{
long int vol0 = 0;
+ if (fd_hw < 0 || muted == mute)
+ return;
+
if(mute)
{
alsa_controls_set_ints("DACL Playback Volume", 1, &vol0);
@@ -146,6 +156,9 @@ void audiohw_mute(int mute)
void audiohw_set_filter_roll_off(int value)
{
+ if (fd_hw < 0)
+ return;
+
/* 0 = Sharp;
1 = Slow;
2 = Short Sharp