1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-01-31 20:15:20 +01:00

sdvxio-kfca: add volume overrides

This commit is contained in:
Will Xyen 2022-03-15 00:39:10 -07:00
parent 3cf3d44945
commit ae35b859d9
3 changed files with 81 additions and 3 deletions

View File

@ -6,9 +6,15 @@
#define SDVXIO_KFCA_CONFIG_KFCA_PORT_KEY "kfca.port"
#define SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY "kfca.baud"
#define SDVXIO_KFCA_CONFIG_MAIN_AMP_VOLUME_KEY "kfca.main_override"
#define SDVXIO_KFCA_CONFIG_HEADPHONE_AMP_VOLUME_KEY "kfca.headphone_override"
#define SDVXIO_KFCA_CONFIG_SUBWOOFER_AMP_VOLUME_KEY "kfca.subwoofer_override"
#define SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_PORT_VALUE "COM3"
#define SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE 57600
#define SDVXIO_KFCA_CONFIG_DEFAULT_MAIN_AMP_VOLUME_VALUE -1
#define SDVXIO_KFCA_CONFIG_DEFAULT_HEADPHONE_AMP_VOLUME_VALUE -1
#define SDVXIO_KFCA_CONFIG_DEFAULT_SUBWOOFER_AMP_VOLUME_VALUE -1
void sdvxio_kfca_config_kfca_init(struct cconfig *config)
{
@ -23,6 +29,24 @@ void sdvxio_kfca_config_kfca_init(struct cconfig *config)
SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY,
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE,
"KFCA ACIO bus baudrate (real devices expect 57600)");
cconfig_util_set_int(
config,
SDVXIO_KFCA_CONFIG_MAIN_AMP_VOLUME_KEY,
SDVXIO_KFCA_CONFIG_DEFAULT_MAIN_AMP_VOLUME_VALUE,
"SDVXIO digital amp main volume (0-96) 0 is high, 96 is low. -1 is no override.");
cconfig_util_set_int(
config,
SDVXIO_KFCA_CONFIG_HEADPHONE_AMP_VOLUME_KEY,
SDVXIO_KFCA_CONFIG_DEFAULT_HEADPHONE_AMP_VOLUME_VALUE,
"SDVXIO digital amp headphone volume (0-96) 0 is high, 96 is low. -1 is no override.");
cconfig_util_set_int(
config,
SDVXIO_KFCA_CONFIG_SUBWOOFER_AMP_VOLUME_KEY,
SDVXIO_KFCA_CONFIG_DEFAULT_SUBWOOFER_AMP_VOLUME_VALUE,
"SDVXIO digital amp subwoofer volume (0-96) 0 is high, 96 is low. -1 is no override.");
}
void sdvxio_kfca_config_kfca_get(
@ -52,4 +76,40 @@ void sdvxio_kfca_config_kfca_get(
SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY,
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE);
}
if (!cconfig_util_get_int(
config,
SDVXIO_KFCA_CONFIG_MAIN_AMP_VOLUME_KEY,
&config_kfca->override_main_volume,
SDVXIO_KFCA_CONFIG_DEFAULT_MAIN_AMP_VOLUME_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
SDVXIO_KFCA_CONFIG_MAIN_AMP_VOLUME_KEY,
SDVXIO_KFCA_CONFIG_DEFAULT_MAIN_AMP_VOLUME_VALUE);
}
if (!cconfig_util_get_int(
config,
SDVXIO_KFCA_CONFIG_HEADPHONE_AMP_VOLUME_KEY,
&config_kfca->override_headphone_volume,
SDVXIO_KFCA_CONFIG_DEFAULT_HEADPHONE_AMP_VOLUME_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
SDVXIO_KFCA_CONFIG_HEADPHONE_AMP_VOLUME_KEY,
SDVXIO_KFCA_CONFIG_DEFAULT_HEADPHONE_AMP_VOLUME_VALUE);
}
if (!cconfig_util_get_int(
config,
SDVXIO_KFCA_CONFIG_SUBWOOFER_AMP_VOLUME_KEY,
&config_kfca->override_sub_volume,
SDVXIO_KFCA_CONFIG_DEFAULT_SUBWOOFER_AMP_VOLUME_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
SDVXIO_KFCA_CONFIG_SUBWOOFER_AMP_VOLUME_KEY,
SDVXIO_KFCA_CONFIG_DEFAULT_SUBWOOFER_AMP_VOLUME_VALUE);
}
}

View File

@ -8,6 +8,9 @@
struct sdvxio_kfca_config_kfca {
char port[64];
int32_t baud;
int32_t override_main_volume;
int32_t override_headphone_volume;
int32_t override_sub_volume;
};
void sdvxio_kfca_config_kfca_init(struct cconfig *config);

View File

@ -120,9 +120,24 @@ bool sdvx_io_init(
if (kfca_node_id != -1) {
log_warning("Using KFCA on node: %d", kfca_node_id);
bool init_result = aciodrv_kfca_init(
uint8_t primary = 0;
uint8_t headphone = 0;
uint8_t subwoofer = 0;
if (config_kfca.override_main_volume >= 0) {
primary = config_kfca.override_main_volume;
}
if (config_kfca.override_headphone_volume >= 0) {
headphone = config_kfca.override_headphone_volume;
}
if (config_kfca.override_sub_volume >= 0) {
subwoofer = config_kfca.override_sub_volume;
}
bool init_result = aciodrv_kfca_amp(
aciomgr_port_checkout(acio_manager_ctx),
kfca_node_id);
kfca_node_id,
primary, headphone, 0, subwoofer);
aciomgr_port_checkin(acio_manager_ctx);
if (!init_result) {
@ -240,7 +255,7 @@ bool sdvx_io_set_amp_volume(
bool amp_result = aciodrv_kfca_amp(
aciomgr_port_checkout(acio_manager_ctx),
kfca_node_id,
primary, 96, headphone, subwoofer);
primary, headphone, 96, subwoofer);
aciomgr_port_checkin(acio_manager_ctx);
if (!amp_result) {