diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-04-13 21:38:14 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-04-14 01:39:57 +0000 |
commit | 42dba708e3bcd2fa448f9d2865157b910a62a11a (patch) | |
tree | 11e37ec97f1ef7f8772c346c0c2f8e7ac57fa88b /firmware/drivers/audio/erosqlinux_codec.c | |
parent | ec4b5c794ee81de2f604cc67db2087fca2a90ac1 (diff) | |
download | rockbox-42dba708e3bcd2fa448f9d2865157b910a62a11a.tar.gz rockbox-42dba708e3bcd2fa448f9d2865157b910a62a11a.zip |
hosted: Don't open alsa control device directly
It was just being used as a proxy "yeah, we called hw_init()" so
just use a flag for that directly.
affects rocker, erosq, xduoo x3ii/x20, and fiiom3klinux
Change-Id: I14bd9f8d91f1d6cc8de0982a7426e2a103c6bfce
Diffstat (limited to 'firmware/drivers/audio/erosqlinux_codec.c')
-rw-r--r-- | firmware/drivers/audio/erosqlinux_codec.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/firmware/drivers/audio/erosqlinux_codec.c b/firmware/drivers/audio/erosqlinux_codec.c index abb4fea01f..2b7d819e82 100644 --- a/firmware/drivers/audio/erosqlinux_codec.c +++ b/firmware/drivers/audio/erosqlinux_codec.c | |||
@@ -25,15 +25,11 @@ | |||
25 | #include "config.h" | 25 | #include "config.h" |
26 | #include "audio.h" | 26 | #include "audio.h" |
27 | #include "audiohw.h" | 27 | #include "audiohw.h" |
28 | #include "button.h" | ||
29 | #include "system.h" | 28 | #include "system.h" |
30 | #include "kernel.h" | ||
31 | #include "panic.h" | 29 | #include "panic.h" |
32 | #include "sysfs.h" | 30 | #include "sysfs.h" |
33 | #include "alsa-controls.h" | 31 | #include "alsa-controls.h" |
34 | #include "pcm-alsa.h" | 32 | #include "pcm-alsa.h" |
35 | #include "pcm_sw_volume.h" | ||
36 | |||
37 | #include "settings.h" | 33 | #include "settings.h" |
38 | 34 | ||
39 | #include "logf.h" | 35 | #include "logf.h" |
@@ -64,32 +60,19 @@ | |||
64 | : values=4 | 60 | : values=4 |
65 | */ | 61 | */ |
66 | 62 | ||
67 | static int fd_hw = -1; | 63 | static int hw_init = 0; |
68 | 64 | ||
69 | static long int vol_l_hw = 255; | 65 | static long int vol_l_hw = 255; |
70 | static long int vol_r_hw = 255; | 66 | static long int vol_r_hw = 255; |
71 | static long int last_ps = -1; | 67 | static long int last_ps = -1; |
72 | 68 | ||
73 | static void hw_open(void) | ||
74 | { | ||
75 | fd_hw = open("/dev/snd/controlC0", O_RDWR); | ||
76 | if(fd_hw < 0) | ||
77 | panicf("Cannot open '/dev/snd/controlC0'"); | ||
78 | } | ||
79 | |||
80 | static void hw_close(void) | ||
81 | { | ||
82 | close(fd_hw); | ||
83 | fd_hw = -1; | ||
84 | } | ||
85 | |||
86 | static int muted = -1; | 69 | static int muted = -1; |
87 | 70 | ||
88 | void audiohw_mute(int mute) | 71 | void audiohw_mute(int mute) |
89 | { | 72 | { |
90 | logf("mute %d", mute); | 73 | logf("mute %d", mute); |
91 | 74 | ||
92 | if (fd_hw < 0 || muted == mute) | 75 | if (hw_init < 0 || muted == mute) |
93 | return; | 76 | return; |
94 | 77 | ||
95 | muted = mute; | 78 | muted = mute; |
@@ -111,7 +94,7 @@ int erosq_get_outputs(void) { | |||
111 | 94 | ||
112 | int status = 0; | 95 | int status = 0; |
113 | 96 | ||
114 | if (fd_hw < 0) return ps; | 97 | if (!hw_init) return ps; |
115 | 98 | ||
116 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; | 99 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; |
117 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; | 100 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; |
@@ -129,7 +112,7 @@ int erosq_get_outputs(void) { | |||
129 | 112 | ||
130 | void erosq_set_output(int ps) | 113 | void erosq_set_output(int ps) |
131 | { | 114 | { |
132 | if (fd_hw < 0 || muted) return; | 115 | if (!hw_init || muted) return; |
133 | 116 | ||
134 | if (last_ps != ps) | 117 | if (last_ps != ps) |
135 | { | 118 | { |
@@ -145,7 +128,7 @@ void audiohw_preinit(void) | |||
145 | { | 128 | { |
146 | logf("hw preinit"); | 129 | logf("hw preinit"); |
147 | alsa_controls_init("default"); | 130 | alsa_controls_init("default"); |
148 | hw_open(); | 131 | hw_init = 1; |
149 | audiohw_mute(false); /* No need to stay muted */ | 132 | audiohw_mute(false); /* No need to stay muted */ |
150 | } | 133 | } |
151 | 134 | ||
@@ -157,7 +140,8 @@ void audiohw_postinit(void) | |||
157 | void audiohw_close(void) | 140 | void audiohw_close(void) |
158 | { | 141 | { |
159 | logf("hw close"); | 142 | logf("hw close"); |
160 | hw_close(); | 143 | hw_init = 0; |
144 | muted = -1; | ||
161 | alsa_controls_close(); | 145 | alsa_controls_close(); |
162 | } | 146 | } |
163 | 147 | ||