diff options
Diffstat (limited to 'firmware/drivers/audio/rocker_codec.c')
-rw-r--r-- | firmware/drivers/audio/rocker_codec.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/firmware/drivers/audio/rocker_codec.c b/firmware/drivers/audio/rocker_codec.c index 87257c92a4..20e45d5afb 100644 --- a/firmware/drivers/audio/rocker_codec.c +++ b/firmware/drivers/audio/rocker_codec.c | |||
@@ -27,30 +27,16 @@ | |||
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 = -1; | 30 | static int hw_init = 0; |
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; |
34 | 34 | ||
35 | static int muted = -1; | 35 | static int muted = -1; |
36 | 36 | ||
37 | static void hw_open(void) | ||
38 | { | ||
39 | fd_hw = open("/dev/snd/controlC0", O_RDWR); | ||
40 | if(fd_hw < 0) | ||
41 | panicf("Cannot open '/dev/snd/controlC0'"); | ||
42 | } | ||
43 | |||
44 | static void hw_close(void) | ||
45 | { | ||
46 | close(fd_hw); | ||
47 | fd_hw = -1; | ||
48 | muted = -1; | ||
49 | } | ||
50 | |||
51 | void audiohw_mute(int mute) | 37 | void audiohw_mute(int mute) |
52 | { | 38 | { |
53 | if (fd_hw < 0 || muted == mute) | 39 | if (!hw_init || muted == mute) |
54 | return; | 40 | return; |
55 | 41 | ||
56 | muted = mute; | 42 | muted = mute; |
@@ -70,7 +56,7 @@ void audiohw_mute(int mute) | |||
70 | void audiohw_preinit(void) | 56 | void audiohw_preinit(void) |
71 | { | 57 | { |
72 | alsa_controls_init("default"); | 58 | alsa_controls_init("default"); |
73 | hw_open(); | 59 | hw_init = 1; |
74 | #if defined(AUDIOHW_MUTE_ON_STOP) || defined(AUDIOHW_NEEDS_INITIAL_UNMUTE) | 60 | #if defined(AUDIOHW_MUTE_ON_STOP) || defined(AUDIOHW_NEEDS_INITIAL_UNMUTE) |
75 | audiohw_mute(true); /* Start muted to avoid the POP */ | 61 | audiohw_mute(true); /* Start muted to avoid the POP */ |
76 | #else | 62 | #else |
@@ -84,7 +70,8 @@ void audiohw_postinit(void) | |||
84 | 70 | ||
85 | void audiohw_close(void) | 71 | void audiohw_close(void) |
86 | { | 72 | { |
87 | hw_close(); | 73 | hw_init = 0; |
74 | muted = -1; | ||
88 | alsa_controls_close(); | 75 | alsa_controls_close(); |
89 | } | 76 | } |
90 | 77 | ||
@@ -98,7 +85,7 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
98 | vol_l_hw = -vol_l/5; | 85 | vol_l_hw = -vol_l/5; |
99 | vol_r_hw = -vol_r/5; | 86 | vol_r_hw = -vol_r/5; |
100 | 87 | ||
101 | if (fd_hw < 0) | 88 | if (!hw_init) |
102 | return; | 89 | return; |
103 | 90 | ||
104 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); | 91 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); |