genesys: Initialize frontend state from the outset

merge-requests/177/head
Povilas Kanapickas 2019-09-13 11:36:52 +03:00
rodzic 0440123bdc
commit 8ed2cd991b
3 zmienionych plików z 15 dodań i 9 usunięć

Wyświetl plik

@ -281,6 +281,7 @@ sanei_genesys_init_structs (Genesys_Device * dev)
for (const auto& frontend : *s_frontends) { for (const auto& frontend : *s_frontends) {
if (dev->model->dac_type == frontend.fe_id) { if (dev->model->dac_type == frontend.fe_id) {
dev->frontend_initial = frontend; dev->frontend_initial = frontend;
dev->frontend = frontend;
fe_ok = true; fe_ok = true;
break; break;
} }

Wyświetl plik

@ -238,6 +238,11 @@ struct Genesys_Device
Genesys_Register_Set calib_reg; Genesys_Register_Set calib_reg;
Genesys_Settings settings; Genesys_Settings settings;
Genesys_Frontend frontend, frontend_initial; Genesys_Frontend frontend, frontend_initial;
// whether the frontend is initialized. This is currently used just to preserve historical
// behavior
bool frontend_is_init = false;
Genesys_Gpo gpo; Genesys_Gpo gpo;
Genesys_Motor motor; Genesys_Motor motor;
uint8_t control[6] = {}; uint8_t control[6] = {};

Wyświetl plik

@ -751,6 +751,7 @@ static void gl843_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
{ {
DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type);
dev->frontend = dev->frontend_initial; dev->frontend = dev->frontend_initial;
dev->frontend_is_init = true;
} }
// check analog frontend type // check analog frontend type
@ -767,9 +768,8 @@ static void gl843_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
for (i = 1; i <= 3; i++) for (i = 1; i <= 3; i++)
{ {
// FIXME: BUG: we should initialize dev->frontend before first use. Right now it's // FIXME: the check below is just historical artifact, we can remove it when convenient
// initialized during genesys_coarse_calibration() if (!dev->frontend_is_init) {
if (dev->frontend.regs.empty()) {
sanei_genesys_fe_write_data(dev, i, 0x00); sanei_genesys_fe_write_data(dev, i, 0x00);
} else { } else {
sanei_genesys_fe_write_data(dev, i, dev->frontend.regs.get_value(0x00 + i)); sanei_genesys_fe_write_data(dev, i, dev->frontend.regs.get_value(0x00 + i));
@ -781,8 +781,8 @@ static void gl843_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
// FIXME: BUG: see above // FIXME: the check below is just historical artifact, we can remove it when convenient
if (dev->frontend.regs.empty()) { if (!dev->frontend_is_init) {
sanei_genesys_fe_write_data(dev, 0x20 + i, 0x00); sanei_genesys_fe_write_data(dev, 0x20 + i, 0x00);
} else { } else {
sanei_genesys_fe_write_data(dev, 0x20 + i, dev->frontend.get_offset(i)); sanei_genesys_fe_write_data(dev, 0x20 + i, dev->frontend.get_offset(i));
@ -793,8 +793,8 @@ static void gl843_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
{ {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
// FIXME: BUG: see above // FIXME: the check below is just historical artifact, we can remove it when convenient
if (dev->frontend.regs.empty()) { if (!dev->frontend_is_init) {
sanei_genesys_fe_write_data(dev, 0x24 + i, 0x00); sanei_genesys_fe_write_data(dev, 0x24 + i, 0x00);
} else { } else {
sanei_genesys_fe_write_data(dev, 0x24 + i, dev->frontend.regs.get_value(0x24 + i)); sanei_genesys_fe_write_data(dev, 0x24 + i, dev->frontend.regs.get_value(0x24 + i));
@ -804,8 +804,8 @@ static void gl843_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
// FIXME: BUG: see above // FIXME: the check below is just historical artifact, we can remove it when convenient
if (dev->frontend.regs.empty()) { if (!dev->frontend_is_init) {
sanei_genesys_fe_write_data(dev, 0x28 + i, 0x00); sanei_genesys_fe_write_data(dev, 0x28 + i, 0x00);
} else { } else {
sanei_genesys_fe_write_data(dev, 0x28 + i, dev->frontend.get_gain(i)); sanei_genesys_fe_write_data(dev, 0x28 + i, dev->frontend.get_gain(i));