summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/audio/erosqlinux_codec.c13
-rw-r--r--firmware/drivers/audio/rocker_codec.c12
-rw-r--r--firmware/drivers/audio/xduoolinux_codec.c13
-rw-r--r--firmware/export/erosqlinux_codec.h1
-rw-r--r--firmware/target/hosted/pcm-alsa.c14
5 files changed, 31 insertions, 22 deletions
diff --git a/firmware/drivers/audio/erosqlinux_codec.c b/firmware/drivers/audio/erosqlinux_codec.c
index 9336083d58..d56e32c6ff 100644
--- a/firmware/drivers/audio/erosqlinux_codec.c
+++ b/firmware/drivers/audio/erosqlinux_codec.c
@@ -42,7 +42,7 @@ static int inited = 0;
static long int vol_l_hw = 255;
static long int vol_r_hw = 255;
-static long int last_ps = 0;
+static long int last_ps = -1;
static void hw_open(void)
{
@@ -62,6 +62,11 @@ void audiohw_mute(int mute)
{
logf("mute %d", mute);
+ if (muted == mute)
+ return;
+
+ muted = mute;
+
if(mute)
{
long int ps0 = 0;
@@ -69,10 +74,8 @@ void audiohw_mute(int mute)
}
else
{
- last_ps = 0;
erosq_get_outputs();
}
- muted = mute;
}
int erosq_get_outputs(void) {
@@ -115,14 +118,14 @@ void audiohw_preinit(void)
logf("hw preinit");
alsa_controls_init();
hw_open();
- audiohw_mute(true); /* Start muted to avoid the POP */
+// audiohw_mute(true); /* Start muted to avoid the POP */
+ audiohw_mute(false);
inited = 1;
}
void audiohw_postinit(void)
{
logf("hw postinit");
- erosq_get_outputs(); // Unmutes
}
void audiohw_close(void)
diff --git a/firmware/drivers/audio/rocker_codec.c b/firmware/drivers/audio/rocker_codec.c
index e5573df843..e34cb87e9b 100644
--- a/firmware/drivers/audio/rocker_codec.c
+++ b/firmware/drivers/audio/rocker_codec.c
@@ -32,6 +32,8 @@ static int fd_hw;
static long int vol_l_hw = 255;
static long int vol_r_hw = 255;
+static int muted = -1;
+
static void hw_open(void)
{
fd_hw = open("/dev/snd/controlC0", O_RDWR);
@@ -46,6 +48,11 @@ static void hw_close(void)
void audiohw_mute(int mute)
{
+ if (muted == mute)
+ return;
+
+ muted = mute;
+
if(mute)
{
long int ps0 = 0;
@@ -67,10 +74,7 @@ void audiohw_preinit(void)
void audiohw_postinit(void)
{
- long int hp = 2;
-
- /* Output port switch set to Headphones */
- //alsa_controls_set_ints("Output Port Switch", 1, &hp); // Unmute happens on PCM start
+ logf("hw postinit");
}
void audiohw_close(void)
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c
index 59ef562d0a..f9642812d3 100644
--- a/firmware/drivers/audio/xduoolinux_codec.c
+++ b/firmware/drivers/audio/xduoolinux_codec.c
@@ -41,7 +41,7 @@ static int inited = 0;
static long int vol_l_hw = 255;
static long int vol_r_hw = 255;
-static long int last_ps = 0;
+static long int last_ps = -1;
static void hw_open(void)
{
@@ -61,6 +61,11 @@ void audiohw_mute(int mute)
{
logf("mute %d", mute);
+ if (muted == mute)
+ return;
+
+ muted = mute;
+
if(mute)
{
long int ps0 = 0;
@@ -68,10 +73,8 @@ void audiohw_mute(int mute)
}
else
{
- last_ps = 0;
xduoo_get_outputs();
}
- muted = mute;
}
int xduoo_get_outputs(void){
@@ -124,14 +127,12 @@ void audiohw_preinit(void)
hw_open();
audiohw_mute(true); /* Start muted to avoid the POP */
inited = 1;
+// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000
}
void audiohw_postinit(void)
{
-// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000
-
logf("hw postinit");
- // xduoo_get_outputs(); // Unmute happens upon playback.
}
void audiohw_close(void)
diff --git a/firmware/export/erosqlinux_codec.h b/firmware/export/erosqlinux_codec.h
index 8a3afbfe3c..1dd9b7e6c6 100644
--- a/firmware/export/erosqlinux_codec.h
+++ b/firmware/export/erosqlinux_codec.h
@@ -5,6 +5,7 @@
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)
+//#define AUDIOHW_NEEDS_INITIAL_UNMUTE
void audiohw_mute(int mute);
void erosq_set_output(int ps);
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
index 428902b82e..db86a790d2 100644
--- a/firmware/target/hosted/pcm-alsa.c
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -454,7 +454,6 @@ void cleanup(void)
snd_pcm_close(handle);
}
-
void pcm_play_dma_init(void)
{
int err;
@@ -533,9 +532,6 @@ static void pcm_dma_apply_settings_nolock(void)
/* Sony NWZ linux driver uses a nonstandard mecanism to set the sampling rate */
audiohw_set_frequency(pcm_sampr);
#endif
-#ifdef AUDIOHW_MUTE_ON_SRATE_CHANGE
- audiohw_mute(false);
-#endif
/* (Will be unmuted by pcm resuming) */
}
}
@@ -564,7 +560,7 @@ void pcm_play_dma_stop(void)
snd_pcm_nonblock(handle, 0);
snd_pcm_drain(handle);
snd_pcm_nonblock(handle, 1);
- last_sample_rate = 0;
+// last_sample_rate = 0;
#ifdef AUDIOHW_MUTE_ON_PAUSE
audiohw_mute(true);
#endif
@@ -579,7 +575,7 @@ void pcm_play_dma_start(const void *addr, size_t size)
pcm_data = addr;
pcm_size = size;
-#if !defined(AUDIOHW_MUTE_ON_PAUSE) || !defined(AUDIOHW_MUTE_ON_SRATE_CHANGE)
+#if !defined(AUDIOHW_MUTE_ON_PAUSE) && defined(AUDIOHW_MUTE_ON_SRATE_CHANGE)
audiohw_mute(false);
#endif
@@ -615,7 +611,7 @@ void pcm_play_dma_start(const void *addr, size_t size)
logf("Start error: %s\n", snd_strerror(err));
return;
}
-#ifdef AUDIOHW_MUTE_ON_PAUSE
+#if defined(AUDIOHW_MUTE_ON_PAUSE)
audiohw_mute(false);
#endif
if (err == 0)
@@ -652,6 +648,10 @@ const void * pcm_play_dma_get_peak_buffer(int *count)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
+
+#ifdef AUDIOHW_NEEDS_INITIAL_UNMUTE
+ audiohw_mute(false);
+#endif
}
void pcm_set_mixer_volume(int volume)