summaryrefslogtreecommitdiff
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 @@
32#include "pcm-alsa.h" 32#include "pcm-alsa.h"
33#include <sys/ioctl.h> 33#include <sys/ioctl.h>
34 34
35static int fd_hw; 35static int fd_hw = -1;
36static int ak_hw; 36static int ak_hw = -1;
37 37
38static int vol_sw[2] = {0}; 38static int vol_sw[2] = {0};
39static long int vol_hw[2] = {0}; 39static long int vol_hw[2] = {0};
@@ -61,8 +61,8 @@ static void hw_close(void)
61 panicf("Call cmd AK4376_POWER_OFF fail"); 61 panicf("Call cmd AK4376_POWER_OFF fail");
62 } 62 }
63 close(ak_hw); 63 close(ak_hw);
64
65 close(fd_hw); 64 close(fd_hw);
65 ak_hw = fd_hw = -1;
66} 66}
67 67
68void audiohw_preinit(void) 68void audiohw_preinit(void)
@@ -91,10 +91,15 @@ void audiohw_set_frequency(int fsel)
91 (void)fsel; 91 (void)fsel;
92} 92}
93 93
94static int muted = -1;
95
94void audiohw_set_volume(int vol_l, int vol_r) 96void audiohw_set_volume(int vol_l, int vol_r)
95{ 97{
96 int vol[2]; 98 int vol[2];
97 99
100 if (fd_hw < 0)
101 return;
102
98 vol[0] = vol_l / 20; 103 vol[0] = vol_l / 20;
99 vol[1] = vol_r / 20; 104 vol[1] = vol_r / 20;
100 105
@@ -121,15 +126,20 @@ void audiohw_set_volume(int vol_l, int vol_r)
121 } 126 }
122 } 127 }
123 128
124 alsa_controls_set_ints("DACL Playback Volume", 1, &vol_hw[0]); 129 if (!muted) {
125 alsa_controls_set_ints("DACR Playback Volume", 1, &vol_hw[1]); 130 alsa_controls_set_ints("DACL Playback Volume", 1, &vol_hw[0]);
126 pcm_alsa_set_digital_volume(vol_sw[0], vol_sw[1]); 131 alsa_controls_set_ints("DACR Playback Volume", 1, &vol_hw[1]);
132 pcm_alsa_set_digital_volume(vol_sw[0], vol_sw[1]);
133 }
127} 134}
128 135
129void audiohw_mute(int mute) 136void audiohw_mute(int mute)
130{ 137{
131 long int vol0 = 0; 138 long int vol0 = 0;
132 139
140 if (fd_hw < 0 || muted == mute)
141 return;
142
133 if(mute) 143 if(mute)
134 { 144 {
135 alsa_controls_set_ints("DACL Playback Volume", 1, &vol0); 145 alsa_controls_set_ints("DACL Playback Volume", 1, &vol0);
@@ -146,6 +156,9 @@ void audiohw_mute(int mute)
146 156
147void audiohw_set_filter_roll_off(int value) 157void audiohw_set_filter_roll_off(int value)
148{ 158{
159 if (fd_hw < 0)
160 return;
161
149 /* 0 = Sharp; 162 /* 0 = Sharp;
150 1 = Slow; 163 1 = Slow;
151 2 = Short Sharp 164 2 = Short Sharp