diff options
Diffstat (limited to 'firmware/drivers/audio/rocker_codec.c')
-rw-r--r-- | firmware/drivers/audio/rocker_codec.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/firmware/drivers/audio/rocker_codec.c b/firmware/drivers/audio/rocker_codec.c index f4135fdaa5..abe13be285 100644 --- a/firmware/drivers/audio/rocker_codec.c +++ b/firmware/drivers/audio/rocker_codec.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "panic.h" | 27 | #include "panic.h" |
28 | #include "alsa-controls.h" | 28 | #include "alsa-controls.h" |
29 | 29 | ||
30 | static int fd_hw; | 30 | static int fd_hw = -1; |
31 | 31 | ||
32 | static long int vol_l_hw = 255; | 32 | static long int vol_l_hw = 255; |
33 | static long int vol_r_hw = 255; | 33 | static long int vol_r_hw = 255; |
@@ -44,11 +44,13 @@ static void hw_open(void) | |||
44 | static void hw_close(void) | 44 | static void hw_close(void) |
45 | { | 45 | { |
46 | close(fd_hw); | 46 | close(fd_hw); |
47 | fd_hw = -1; | ||
48 | muted = -1; | ||
47 | } | 49 | } |
48 | 50 | ||
49 | void audiohw_mute(int mute) | 51 | void audiohw_mute(int mute) |
50 | { | 52 | { |
51 | if (muted == mute) | 53 | if (fd_hw < 0 || muted == mute) |
52 | return; | 54 | return; |
53 | 55 | ||
54 | muted = mute; | 56 | muted = mute; |
@@ -92,6 +94,9 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
92 | vol_l_hw = -vol_l/5; | 94 | vol_l_hw = -vol_l/5; |
93 | vol_r_hw = -vol_r/5; | 95 | vol_r_hw = -vol_r/5; |
94 | 96 | ||
97 | if (fd_hw < 0) | ||
98 | return; | ||
99 | |||
95 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); | 100 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); |
96 | alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw); | 101 | alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw); |
97 | } | 102 | } |