forked from len0rd/rockbox
hosted: Make sure we don't call mixer/etc controls when we're not ready
(Might fix the rocker crash-on-shutdown bug) Change-Id: Id375fc5053adef18d7ec812bdba36ee002e706ef
This commit is contained in:
parent
d993448c9f
commit
ce40ef42ff
4 changed files with 40 additions and 24 deletions
|
|
@ -37,8 +37,7 @@
|
||||||
|
|
||||||
#include "logf.h"
|
#include "logf.h"
|
||||||
|
|
||||||
static int fd_hw;
|
static int fd_hw = -1;
|
||||||
static int inited = 0;
|
|
||||||
|
|
||||||
static long int vol_l_hw = 255;
|
static long int vol_l_hw = 255;
|
||||||
static long int vol_r_hw = 255;
|
static long int vol_r_hw = 255;
|
||||||
|
|
@ -54,6 +53,7 @@ static void hw_open(void)
|
||||||
static void hw_close(void)
|
static void hw_close(void)
|
||||||
{
|
{
|
||||||
close(fd_hw);
|
close(fd_hw);
|
||||||
|
fd_hw = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int muted = -1;
|
static int muted = -1;
|
||||||
|
|
@ -62,7 +62,7 @@ void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
logf("mute %d", mute);
|
logf("mute %d", mute);
|
||||||
|
|
||||||
if (muted == mute)
|
if (fd_hw < 0 || muted == mute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
muted = mute;
|
muted = mute;
|
||||||
|
|
@ -84,7 +84,7 @@ int erosq_get_outputs(void) {
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if (!inited) return ps;
|
if (fd_hw < 0) return ps;
|
||||||
|
|
||||||
const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
|
const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
|
||||||
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
|
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
|
||||||
|
|
@ -102,7 +102,7 @@ int erosq_get_outputs(void) {
|
||||||
|
|
||||||
void erosq_set_output(int ps)
|
void erosq_set_output(int ps)
|
||||||
{
|
{
|
||||||
if (!inited || muted) return;
|
if (fd_hw < 0 || muted) return;
|
||||||
|
|
||||||
if (last_ps != ps)
|
if (last_ps != ps)
|
||||||
{
|
{
|
||||||
|
|
@ -119,9 +119,7 @@ void audiohw_preinit(void)
|
||||||
logf("hw preinit");
|
logf("hw preinit");
|
||||||
alsa_controls_init();
|
alsa_controls_init();
|
||||||
hw_open();
|
hw_open();
|
||||||
// audiohw_mute(true); /* Start muted to avoid the POP */
|
audiohw_mute(false); /* No need to stay muted */
|
||||||
audiohw_mute(false);
|
|
||||||
inited = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_postinit(void)
|
void audiohw_postinit(void)
|
||||||
|
|
@ -132,7 +130,6 @@ void audiohw_postinit(void)
|
||||||
void audiohw_close(void)
|
void audiohw_close(void)
|
||||||
{
|
{
|
||||||
logf("hw close");
|
logf("hw close");
|
||||||
inited = 0;
|
|
||||||
hw_close();
|
hw_close();
|
||||||
alsa_controls_close();
|
alsa_controls_close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@
|
||||||
#include "pcm-alsa.h"
|
#include "pcm-alsa.h"
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
static int fd_hw;
|
static int fd_hw = -1;
|
||||||
static int ak_hw;
|
static int ak_hw = -1;
|
||||||
|
|
||||||
static int vol_sw[2] = {0};
|
static int vol_sw[2] = {0};
|
||||||
static long int vol_hw[2] = {0};
|
static long int vol_hw[2] = {0};
|
||||||
|
|
@ -61,8 +61,8 @@ static void hw_close(void)
|
||||||
panicf("Call cmd AK4376_POWER_OFF fail");
|
panicf("Call cmd AK4376_POWER_OFF fail");
|
||||||
}
|
}
|
||||||
close(ak_hw);
|
close(ak_hw);
|
||||||
|
|
||||||
close(fd_hw);
|
close(fd_hw);
|
||||||
|
ak_hw = fd_hw = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_preinit(void)
|
void audiohw_preinit(void)
|
||||||
|
|
@ -91,10 +91,15 @@ void audiohw_set_frequency(int fsel)
|
||||||
(void)fsel;
|
(void)fsel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int muted = -1;
|
||||||
|
|
||||||
void audiohw_set_volume(int vol_l, int vol_r)
|
void audiohw_set_volume(int vol_l, int vol_r)
|
||||||
{
|
{
|
||||||
int vol[2];
|
int vol[2];
|
||||||
|
|
||||||
|
if (fd_hw < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
vol[0] = vol_l / 20;
|
vol[0] = vol_l / 20;
|
||||||
vol[1] = vol_r / 20;
|
vol[1] = vol_r / 20;
|
||||||
|
|
||||||
|
|
@ -121,15 +126,20 @@ void audiohw_set_volume(int vol_l, int vol_r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!muted) {
|
||||||
alsa_controls_set_ints("DACL Playback Volume", 1, &vol_hw[0]);
|
alsa_controls_set_ints("DACL Playback Volume", 1, &vol_hw[0]);
|
||||||
alsa_controls_set_ints("DACR Playback Volume", 1, &vol_hw[1]);
|
alsa_controls_set_ints("DACR Playback Volume", 1, &vol_hw[1]);
|
||||||
pcm_alsa_set_digital_volume(vol_sw[0], vol_sw[1]);
|
pcm_alsa_set_digital_volume(vol_sw[0], vol_sw[1]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void audiohw_mute(int mute)
|
void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
long int vol0 = 0;
|
long int vol0 = 0;
|
||||||
|
|
||||||
|
if (fd_hw < 0 || muted == mute)
|
||||||
|
return;
|
||||||
|
|
||||||
if(mute)
|
if(mute)
|
||||||
{
|
{
|
||||||
alsa_controls_set_ints("DACL Playback Volume", 1, &vol0);
|
alsa_controls_set_ints("DACL Playback Volume", 1, &vol0);
|
||||||
|
|
@ -146,6 +156,9 @@ void audiohw_mute(int mute)
|
||||||
|
|
||||||
void audiohw_set_filter_roll_off(int value)
|
void audiohw_set_filter_roll_off(int value)
|
||||||
{
|
{
|
||||||
|
if (fd_hw < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
/* 0 = Sharp;
|
/* 0 = Sharp;
|
||||||
1 = Slow;
|
1 = Slow;
|
||||||
2 = Short Sharp
|
2 = Short Sharp
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "alsa-controls.h"
|
#include "alsa-controls.h"
|
||||||
|
|
||||||
static int fd_hw;
|
static int fd_hw = -1;
|
||||||
|
|
||||||
static long int vol_l_hw = 255;
|
static long int vol_l_hw = 255;
|
||||||
static long int vol_r_hw = 255;
|
static long int vol_r_hw = 255;
|
||||||
|
|
@ -44,11 +44,13 @@ static void hw_open(void)
|
||||||
static void hw_close(void)
|
static void hw_close(void)
|
||||||
{
|
{
|
||||||
close(fd_hw);
|
close(fd_hw);
|
||||||
|
fd_hw = -1;
|
||||||
|
muted = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_mute(int mute)
|
void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
if (muted == mute)
|
if (fd_hw < 0 || muted == mute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
muted = mute;
|
muted = mute;
|
||||||
|
|
@ -92,6 +94,9 @@ void audiohw_set_volume(int vol_l, int vol_r)
|
||||||
vol_l_hw = -vol_l/5;
|
vol_l_hw = -vol_l/5;
|
||||||
vol_r_hw = -vol_r/5;
|
vol_r_hw = -vol_r/5;
|
||||||
|
|
||||||
|
if (fd_hw < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw);
|
alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw);
|
||||||
alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw);
|
alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,7 @@
|
||||||
|
|
||||||
#include "logf.h"
|
#include "logf.h"
|
||||||
|
|
||||||
static int fd_hw;
|
static int fd_hw = -1;
|
||||||
static int inited = 0;
|
|
||||||
|
|
||||||
static long int vol_l_hw = 255;
|
static long int vol_l_hw = 255;
|
||||||
static long int vol_r_hw = 255;
|
static long int vol_r_hw = 255;
|
||||||
|
|
@ -53,6 +52,7 @@ static void hw_open(void)
|
||||||
static void hw_close(void)
|
static void hw_close(void)
|
||||||
{
|
{
|
||||||
close(fd_hw);
|
close(fd_hw);
|
||||||
|
fd_hw = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int muted = -1;
|
static int muted = -1;
|
||||||
|
|
@ -61,7 +61,7 @@ void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
logf("mute %d", mute);
|
logf("mute %d", mute);
|
||||||
|
|
||||||
if (muted == mute)
|
if (fd_hw < 0 || muted == mute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
muted = mute;
|
muted = mute;
|
||||||
|
|
@ -83,7 +83,7 @@ int xduoo_get_outputs(void){
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if (!inited) return ps;
|
if (fd_hw < 0) return ps;
|
||||||
|
|
||||||
const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
|
const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
|
||||||
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
|
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
|
||||||
|
|
@ -109,7 +109,7 @@ int xduoo_get_outputs(void){
|
||||||
|
|
||||||
void xduoo_set_output(int ps)
|
void xduoo_set_output(int ps)
|
||||||
{
|
{
|
||||||
if (!inited || muted) return;
|
if (fd_hw < 0 || muted) return;
|
||||||
|
|
||||||
if (last_ps != ps)
|
if (last_ps != ps)
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +127,6 @@ void audiohw_preinit(void)
|
||||||
alsa_controls_init();
|
alsa_controls_init();
|
||||||
hw_open();
|
hw_open();
|
||||||
audiohw_mute(true); /* Start muted to avoid the POP */
|
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
|
// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +138,6 @@ void audiohw_postinit(void)
|
||||||
void audiohw_close(void)
|
void audiohw_close(void)
|
||||||
{
|
{
|
||||||
logf("hw close");
|
logf("hw close");
|
||||||
inited = 0;
|
|
||||||
hw_close();
|
hw_close();
|
||||||
alsa_controls_close();
|
alsa_controls_close();
|
||||||
}
|
}
|
||||||
|
|
@ -166,6 +164,9 @@ void audiohw_set_volume(int vol_l, int vol_r)
|
||||||
r = -vol_r/5;
|
r = -vol_r/5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd_hw < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
alsa_controls_set_ints("Left Playback Volume", 1, &l);
|
alsa_controls_set_ints("Left Playback Volume", 1, &l);
|
||||||
alsa_controls_set_ints("Right Playback Volume", 1, &r);
|
alsa_controls_set_ints("Right Playback Volume", 1, &r);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue