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/xduoolinux_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/xduoolinux_codec.c')
-rw-r--r-- | firmware/drivers/audio/xduoolinux_codec.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c index c78864db2c..749d551739 100644 --- a/firmware/drivers/audio/xduoolinux_codec.c +++ b/firmware/drivers/audio/xduoolinux_codec.c | |||
@@ -78,32 +78,19 @@ X3ii: | |||
78 | 78 | ||
79 | */ | 79 | */ |
80 | 80 | ||
81 | static int fd_hw = -1; | 81 | static int hw_init = 0; |
82 | 82 | ||
83 | static long int vol_l_hw = 255; | 83 | static long int vol_l_hw = 255; |
84 | static long int vol_r_hw = 255; | 84 | static long int vol_r_hw = 255; |
85 | static long int last_ps = -1; | 85 | static long int last_ps = -1; |
86 | 86 | ||
87 | static void hw_open(void) | ||
88 | { | ||
89 | fd_hw = open("/dev/snd/controlC0", O_RDWR); | ||
90 | if(fd_hw < 0) | ||
91 | panicf("Cannot open '/dev/snd/controlC0'"); | ||
92 | } | ||
93 | |||
94 | static void hw_close(void) | ||
95 | { | ||
96 | close(fd_hw); | ||
97 | fd_hw = -1; | ||
98 | } | ||
99 | |||
100 | static int muted = -1; | 87 | static int muted = -1; |
101 | 88 | ||
102 | void audiohw_mute(int mute) | 89 | void audiohw_mute(int mute) |
103 | { | 90 | { |
104 | logf("mute %d", mute); | 91 | logf("mute %d", mute); |
105 | 92 | ||
106 | if (fd_hw < 0 || muted == mute) | 93 | if (!hw_init || muted == mute) |
107 | return; | 94 | return; |
108 | 95 | ||
109 | muted = mute; | 96 | muted = mute; |
@@ -125,7 +112,7 @@ int xduoo_get_outputs(void){ | |||
125 | 112 | ||
126 | int status = 0; | 113 | int status = 0; |
127 | 114 | ||
128 | if (fd_hw < 0) return ps; | 115 | if (!hw_init) return ps; |
129 | 116 | ||
130 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; | 117 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; |
131 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; | 118 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; |
@@ -151,7 +138,7 @@ int xduoo_get_outputs(void){ | |||
151 | 138 | ||
152 | void xduoo_set_output(int ps) | 139 | void xduoo_set_output(int ps) |
153 | { | 140 | { |
154 | if (fd_hw < 0 || muted) return; | 141 | if (!hw_init || muted) return; |
155 | 142 | ||
156 | if (last_ps != ps) | 143 | if (last_ps != ps) |
157 | { | 144 | { |
@@ -172,7 +159,7 @@ void audiohw_preinit(void) | |||
172 | { | 159 | { |
173 | logf("hw preinit"); | 160 | logf("hw preinit"); |
174 | alsa_controls_init("default"); | 161 | alsa_controls_init("default"); |
175 | hw_open(); | 162 | hw_init = 1; |
176 | 163 | ||
177 | #if defined(XDUOO_X3II) | 164 | #if defined(XDUOO_X3II) |
178 | audiohw_mute(true); /* Start muted to avoid the POP */ | 165 | audiohw_mute(true); /* Start muted to avoid the POP */ |
@@ -191,7 +178,7 @@ void audiohw_postinit(void) | |||
191 | void audiohw_close(void) | 178 | void audiohw_close(void) |
192 | { | 179 | { |
193 | logf("hw close"); | 180 | logf("hw close"); |
194 | hw_close(); | 181 | hw_init = 0; |
195 | alsa_controls_close(); | 182 | alsa_controls_close(); |
196 | } | 183 | } |
197 | 184 | ||
@@ -217,7 +204,7 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
217 | r = -vol_r/5; | 204 | r = -vol_r/5; |
218 | } | 205 | } |
219 | 206 | ||
220 | if (fd_hw < 0) | 207 | if (!hw_init) |
221 | return; | 208 | return; |
222 | 209 | ||
223 | alsa_controls_set_ints("Left Playback Volume", 1, &l); | 210 | alsa_controls_set_ints("Left Playback Volume", 1, &l); |