diff options
-rw-r--r-- | firmware/drivers/audio/erosqlinux_codec.c | 13 | ||||
-rw-r--r-- | firmware/drivers/audio/rocker_codec.c | 12 | ||||
-rw-r--r-- | firmware/drivers/audio/xduoolinux_codec.c | 13 | ||||
-rw-r--r-- | firmware/export/erosqlinux_codec.h | 1 | ||||
-rw-r--r-- | firmware/target/hosted/pcm-alsa.c | 14 |
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; | |||
42 | 42 | ||
43 | static long int vol_l_hw = 255; | 43 | static long int vol_l_hw = 255; |
44 | static long int vol_r_hw = 255; | 44 | static long int vol_r_hw = 255; |
45 | static long int last_ps = 0; | 45 | static long int last_ps = -1; |
46 | 46 | ||
47 | static void hw_open(void) | 47 | static void hw_open(void) |
48 | { | 48 | { |
@@ -62,6 +62,11 @@ void audiohw_mute(int mute) | |||
62 | { | 62 | { |
63 | logf("mute %d", mute); | 63 | logf("mute %d", mute); |
64 | 64 | ||
65 | if (muted == mute) | ||
66 | return; | ||
67 | |||
68 | muted = mute; | ||
69 | |||
65 | if(mute) | 70 | if(mute) |
66 | { | 71 | { |
67 | long int ps0 = 0; | 72 | long int ps0 = 0; |
@@ -69,10 +74,8 @@ void audiohw_mute(int mute) | |||
69 | } | 74 | } |
70 | else | 75 | else |
71 | { | 76 | { |
72 | last_ps = 0; | ||
73 | erosq_get_outputs(); | 77 | erosq_get_outputs(); |
74 | } | 78 | } |
75 | muted = mute; | ||
76 | } | 79 | } |
77 | 80 | ||
78 | int erosq_get_outputs(void) { | 81 | int erosq_get_outputs(void) { |
@@ -115,14 +118,14 @@ void audiohw_preinit(void) | |||
115 | logf("hw preinit"); | 118 | logf("hw preinit"); |
116 | alsa_controls_init(); | 119 | alsa_controls_init(); |
117 | hw_open(); | 120 | hw_open(); |
118 | audiohw_mute(true); /* Start muted to avoid the POP */ | 121 | // audiohw_mute(true); /* Start muted to avoid the POP */ |
122 | audiohw_mute(false); | ||
119 | inited = 1; | 123 | inited = 1; |
120 | } | 124 | } |
121 | 125 | ||
122 | void audiohw_postinit(void) | 126 | void audiohw_postinit(void) |
123 | { | 127 | { |
124 | logf("hw postinit"); | 128 | logf("hw postinit"); |
125 | erosq_get_outputs(); // Unmutes | ||
126 | } | 129 | } |
127 | 130 | ||
128 | void audiohw_close(void) | 131 | 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; | |||
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; | ||
36 | |||
35 | static void hw_open(void) | 37 | static void hw_open(void) |
36 | { | 38 | { |
37 | fd_hw = open("/dev/snd/controlC0", O_RDWR); | 39 | fd_hw = open("/dev/snd/controlC0", O_RDWR); |
@@ -46,6 +48,11 @@ static void hw_close(void) | |||
46 | 48 | ||
47 | void audiohw_mute(int mute) | 49 | void audiohw_mute(int mute) |
48 | { | 50 | { |
51 | if (muted == mute) | ||
52 | return; | ||
53 | |||
54 | muted = mute; | ||
55 | |||
49 | if(mute) | 56 | if(mute) |
50 | { | 57 | { |
51 | long int ps0 = 0; | 58 | long int ps0 = 0; |
@@ -67,10 +74,7 @@ void audiohw_preinit(void) | |||
67 | 74 | ||
68 | void audiohw_postinit(void) | 75 | void audiohw_postinit(void) |
69 | { | 76 | { |
70 | long int hp = 2; | 77 | logf("hw postinit"); |
71 | |||
72 | /* Output port switch set to Headphones */ | ||
73 | //alsa_controls_set_ints("Output Port Switch", 1, &hp); // Unmute happens on PCM start | ||
74 | } | 78 | } |
75 | 79 | ||
76 | void audiohw_close(void) | 80 | 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; | |||
41 | 41 | ||
42 | static long int vol_l_hw = 255; | 42 | static long int vol_l_hw = 255; |
43 | static long int vol_r_hw = 255; | 43 | static long int vol_r_hw = 255; |
44 | static long int last_ps = 0; | 44 | static long int last_ps = -1; |
45 | 45 | ||
46 | static void hw_open(void) | 46 | static void hw_open(void) |
47 | { | 47 | { |
@@ -61,6 +61,11 @@ void audiohw_mute(int mute) | |||
61 | { | 61 | { |
62 | logf("mute %d", mute); | 62 | logf("mute %d", mute); |
63 | 63 | ||
64 | if (muted == mute) | ||
65 | return; | ||
66 | |||
67 | muted = mute; | ||
68 | |||
64 | if(mute) | 69 | if(mute) |
65 | { | 70 | { |
66 | long int ps0 = 0; | 71 | long int ps0 = 0; |
@@ -68,10 +73,8 @@ void audiohw_mute(int mute) | |||
68 | } | 73 | } |
69 | else | 74 | else |
70 | { | 75 | { |
71 | last_ps = 0; | ||
72 | xduoo_get_outputs(); | 76 | xduoo_get_outputs(); |
73 | } | 77 | } |
74 | muted = mute; | ||
75 | } | 78 | } |
76 | 79 | ||
77 | int xduoo_get_outputs(void){ | 80 | int xduoo_get_outputs(void){ |
@@ -124,14 +127,12 @@ void audiohw_preinit(void) | |||
124 | hw_open(); | 127 | hw_open(); |
125 | audiohw_mute(true); /* Start muted to avoid the POP */ | 128 | audiohw_mute(true); /* Start muted to avoid the POP */ |
126 | inited = 1; | 129 | inited = 1; |
130 | // const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000 | ||
127 | } | 131 | } |
128 | 132 | ||
129 | void audiohw_postinit(void) | 133 | void audiohw_postinit(void) |
130 | { | 134 | { |
131 | // const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000 | ||
132 | |||
133 | logf("hw postinit"); | 135 | logf("hw postinit"); |
134 | // xduoo_get_outputs(); // Unmute happens upon playback. | ||
135 | } | 136 | } |
136 | 137 | ||
137 | void audiohw_close(void) | 138 | 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 @@ | |||
5 | 5 | ||
6 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25) | 6 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25) |
7 | 7 | ||
8 | //#define AUDIOHW_NEEDS_INITIAL_UNMUTE | ||
8 | 9 | ||
9 | void audiohw_mute(int mute); | 10 | void audiohw_mute(int mute); |
10 | void erosq_set_output(int ps); | 11 | 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) | |||
454 | snd_pcm_close(handle); | 454 | snd_pcm_close(handle); |
455 | } | 455 | } |
456 | 456 | ||
457 | |||
458 | void pcm_play_dma_init(void) | 457 | void pcm_play_dma_init(void) |
459 | { | 458 | { |
460 | int err; | 459 | int err; |
@@ -533,9 +532,6 @@ static void pcm_dma_apply_settings_nolock(void) | |||
533 | /* Sony NWZ linux driver uses a nonstandard mecanism to set the sampling rate */ | 532 | /* Sony NWZ linux driver uses a nonstandard mecanism to set the sampling rate */ |
534 | audiohw_set_frequency(pcm_sampr); | 533 | audiohw_set_frequency(pcm_sampr); |
535 | #endif | 534 | #endif |
536 | #ifdef AUDIOHW_MUTE_ON_SRATE_CHANGE | ||
537 | audiohw_mute(false); | ||
538 | #endif | ||
539 | /* (Will be unmuted by pcm resuming) */ | 535 | /* (Will be unmuted by pcm resuming) */ |
540 | } | 536 | } |
541 | } | 537 | } |
@@ -564,7 +560,7 @@ void pcm_play_dma_stop(void) | |||
564 | snd_pcm_nonblock(handle, 0); | 560 | snd_pcm_nonblock(handle, 0); |
565 | snd_pcm_drain(handle); | 561 | snd_pcm_drain(handle); |
566 | snd_pcm_nonblock(handle, 1); | 562 | snd_pcm_nonblock(handle, 1); |
567 | last_sample_rate = 0; | 563 | // last_sample_rate = 0; |
568 | #ifdef AUDIOHW_MUTE_ON_PAUSE | 564 | #ifdef AUDIOHW_MUTE_ON_PAUSE |
569 | audiohw_mute(true); | 565 | audiohw_mute(true); |
570 | #endif | 566 | #endif |
@@ -579,7 +575,7 @@ void pcm_play_dma_start(const void *addr, size_t size) | |||
579 | pcm_data = addr; | 575 | pcm_data = addr; |
580 | pcm_size = size; | 576 | pcm_size = size; |
581 | 577 | ||
582 | #if !defined(AUDIOHW_MUTE_ON_PAUSE) || !defined(AUDIOHW_MUTE_ON_SRATE_CHANGE) | 578 | #if !defined(AUDIOHW_MUTE_ON_PAUSE) && defined(AUDIOHW_MUTE_ON_SRATE_CHANGE) |
583 | audiohw_mute(false); | 579 | audiohw_mute(false); |
584 | #endif | 580 | #endif |
585 | 581 | ||
@@ -615,7 +611,7 @@ void pcm_play_dma_start(const void *addr, size_t size) | |||
615 | logf("Start error: %s\n", snd_strerror(err)); | 611 | logf("Start error: %s\n", snd_strerror(err)); |
616 | return; | 612 | return; |
617 | } | 613 | } |
618 | #ifdef AUDIOHW_MUTE_ON_PAUSE | 614 | #if defined(AUDIOHW_MUTE_ON_PAUSE) |
619 | audiohw_mute(false); | 615 | audiohw_mute(false); |
620 | #endif | 616 | #endif |
621 | if (err == 0) | 617 | if (err == 0) |
@@ -652,6 +648,10 @@ const void * pcm_play_dma_get_peak_buffer(int *count) | |||
652 | void pcm_play_dma_postinit(void) | 648 | void pcm_play_dma_postinit(void) |
653 | { | 649 | { |
654 | audiohw_postinit(); | 650 | audiohw_postinit(); |
651 | |||
652 | #ifdef AUDIOHW_NEEDS_INITIAL_UNMUTE | ||
653 | audiohw_mute(false); | ||
654 | #endif | ||
655 | } | 655 | } |
656 | 656 | ||
657 | void pcm_set_mixer_volume(int volume) | 657 | void pcm_set_mixer_volume(int volume) |