kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Make frontend register list generic
rodzic
24853e657a
commit
8aa5318f90
|
@ -1313,11 +1313,10 @@ sanei_genesys_calculate_zmode (uint32_t exposure_time,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
genesys_adjust_gain (double *applied_multi,
|
||||
uint8_t * new_gain, double multi, uint8_t gain)
|
||||
static uint8_t genesys_adjust_gain(double* applied_multi, double multi, uint8_t gain)
|
||||
{
|
||||
double voltage, original_voltage;
|
||||
uint8_t new_gain = 0;
|
||||
|
||||
DBG(DBG_proc, "%s: multi=%f, gain=%d\n", __func__, multi, gain);
|
||||
|
||||
|
@ -1326,17 +1325,18 @@ genesys_adjust_gain (double *applied_multi,
|
|||
|
||||
voltage *= multi;
|
||||
|
||||
*new_gain = (uint8_t) ((voltage - 0.5) * 4);
|
||||
if (*new_gain > 0x0e)
|
||||
*new_gain = 0x0e;
|
||||
new_gain = (uint8_t) ((voltage - 0.5) * 4);
|
||||
if (new_gain > 0x0e)
|
||||
new_gain = 0x0e;
|
||||
|
||||
voltage = 0.5 + (*new_gain) * 0.25;
|
||||
voltage = 0.5 + (new_gain) * 0.25;
|
||||
|
||||
*applied_multi = voltage / original_voltage;
|
||||
|
||||
DBG(DBG_proc, "%s: orig voltage=%.2f, new voltage=%.2f, *applied_multi=%f, *new_gain=%d\n",
|
||||
__func__, original_voltage, voltage, *applied_multi, *new_gain);
|
||||
return;
|
||||
DBG(DBG_proc, "%s: orig voltage=%.2f, new voltage=%.2f, *applied_multi=%f, new_gain=%d\n",
|
||||
__func__, original_voltage, voltage, *applied_multi, new_gain);
|
||||
|
||||
return new_gain;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1468,23 +1468,20 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
return status;
|
||||
}
|
||||
|
||||
dev->frontend.sign[0] = 0;
|
||||
dev->frontend.sign[1] = 0;
|
||||
dev->frontend.sign[2] = 0;
|
||||
dev->frontend.gain[0] = 2;
|
||||
dev->frontend.gain[1] = 2;
|
||||
dev->frontend.gain[2] = 2; /* todo: ? was 2 */
|
||||
dev->frontend.offset[0] = offset[0];
|
||||
dev->frontend.offset[1] = offset[0];
|
||||
dev->frontend.offset[2] = offset[0];
|
||||
dev->frontend.set_gain(0, 2);
|
||||
dev->frontend.set_gain(1, 2);
|
||||
dev->frontend.set_gain(2, 2); // TODO: ? was 2
|
||||
dev->frontend.set_offset(0, offset[0]);
|
||||
dev->frontend.set_offset(1, offset[0]);
|
||||
dev->frontend.set_offset(2, offset[0]);
|
||||
|
||||
for (i = 0; i < 4; i++) /* read 4 lines */
|
||||
{
|
||||
if (i < 3) /* first 3 lines */
|
||||
{
|
||||
dev->frontend.offset[0] = offset[i];
|
||||
dev->frontend.offset[1] = offset[i];
|
||||
dev->frontend.offset[2] = offset[i];
|
||||
dev->frontend.set_offset(0, offset[i]);
|
||||
dev->frontend.set_offset(1, offset[i]);
|
||||
dev->frontend.set_offset(2, offset[i]);
|
||||
}
|
||||
|
||||
if (i == 1) /* second line */
|
||||
|
@ -1498,24 +1495,26 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
gain_white_ref = sensor.gain_white_ref * 256;
|
||||
/* white and black are defined downwards */
|
||||
|
||||
genesys_adjust_gain (&applied_multi,
|
||||
&dev->frontend.gain[0],
|
||||
gain_white_ref / (white[0] - dark[0]),
|
||||
dev->frontend.gain[0]);
|
||||
genesys_adjust_gain (&applied_multi,
|
||||
&dev->frontend.gain[1],
|
||||
gain_white_ref / (white[1] - dark[1]),
|
||||
dev->frontend.gain[1]);
|
||||
genesys_adjust_gain (&applied_multi,
|
||||
&dev->frontend.gain[2],
|
||||
gain_white_ref / (white[2] - dark[2]),
|
||||
dev->frontend.gain[2]);
|
||||
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1] =
|
||||
dev->frontend.gain[2] = 2;
|
||||
uint8_t gain0 = genesys_adjust_gain(&applied_multi,
|
||||
gain_white_ref / (white[0] - dark[0]),
|
||||
dev->frontend.get_gain(0));
|
||||
uint8_t gain1 = genesys_adjust_gain(&applied_multi,
|
||||
gain_white_ref / (white[1] - dark[1]),
|
||||
dev->frontend.get_gain(1));
|
||||
uint8_t gain2 = genesys_adjust_gain(&applied_multi,
|
||||
gain_white_ref / (white[2] - dark[2]),
|
||||
dev->frontend.get_gain(2));
|
||||
// FIXME: looks like overwritten data. Are the above calculations doing
|
||||
// anything at all?
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain1);
|
||||
dev->frontend.set_gain(2, gain2);
|
||||
dev->frontend.set_gain(0, 2);
|
||||
dev->frontend.set_gain(1, 2);
|
||||
dev->frontend.set_gain(2, 2);
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x28, dev->frontend.gain[0]);
|
||||
sanei_genesys_fe_write_data(dev, 0x28, dev->frontend.get_gain(0));
|
||||
if (status != SANE_STATUS_GOOD) /* todo: this was 0x28 + 3 ? */
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to write gain[0]: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1523,7 +1522,7 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x29, dev->frontend.gain[1]);
|
||||
sanei_genesys_fe_write_data(dev, 0x29, dev->frontend.get_gain(1));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to write gain[1]: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1531,7 +1530,7 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x2a, dev->frontend.gain[2]);
|
||||
sanei_genesys_fe_write_data(dev, 0x2a, dev->frontend.get_gain(2));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to write gain[2]: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1553,15 +1552,17 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
y = x - x * (offset[i - 1] / 2) / 254 - dark[(i - 1) * 3 + j];
|
||||
rate = (x - DARK_VALUE - y) * 254 / x + 0.5;
|
||||
|
||||
dev->frontend.offset[j] = (uint8_t) (rate);
|
||||
uint8_t curr_offset = static_cast<uint8_t>(rate);
|
||||
|
||||
if (dev->frontend.offset[j] > 0x7f)
|
||||
dev->frontend.offset[j] = 0x7f;
|
||||
dev->frontend.offset[j] <<= 1;
|
||||
if (curr_offset > 0x7f) {
|
||||
curr_offset = 0x7f;
|
||||
}
|
||||
curr_offset <<= 1;
|
||||
dev->frontend.set_offset(j, curr_offset);
|
||||
}
|
||||
}
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x20, dev->frontend.offset[0]);
|
||||
sanei_genesys_fe_write_data(dev, 0x20, dev->frontend.get_offset(0));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to write offset[0]: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1569,7 +1570,7 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x21, dev->frontend.offset[1]);
|
||||
sanei_genesys_fe_write_data(dev, 0x21, dev->frontend.get_offset(1));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to write offset[1]: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1577,7 +1578,7 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x22, dev->frontend.offset[2]);
|
||||
sanei_genesys_fe_write_data(dev, 0x22, dev->frontend.get_offset(2));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to write offset[2]: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1585,12 +1586,13 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
}
|
||||
|
||||
DBG(DBG_info,
|
||||
"%s: doing scan: sign: %d/%d/%d, gain: %d/%d/%d, offset: %d/%d/%d\n", __func__,
|
||||
dev->frontend.sign[0], dev->frontend.sign[1],
|
||||
dev->frontend.sign[2], dev->frontend.gain[0],
|
||||
dev->frontend.gain[1], dev->frontend.gain[2],
|
||||
dev->frontend.offset[0], dev->frontend.offset[1],
|
||||
dev->frontend.offset[2]);
|
||||
"%s: doing scan: gain: %d/%d/%d, offset: %d/%d/%d\n", __func__,
|
||||
dev->frontend.get_gain(0),
|
||||
dev->frontend.get_gain(1),
|
||||
dev->frontend.get_gain(2),
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
|
||||
status =
|
||||
dev->model->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, SANE_FALSE);
|
||||
|
@ -1697,11 +1699,13 @@ static SANE_Status genesys_coarse_calibration(Genesys_Device * dev, Genesys_Sens
|
|||
}
|
||||
} /* for (i = 0; i < 4; i++) */
|
||||
|
||||
DBG(DBG_info, "%s: final: sign: %d/%d/%d, gain: %d/%d/%d, offset: %d/%d/%d\n", __func__,
|
||||
dev->frontend.sign[0], dev->frontend.sign[1], dev->frontend.sign[2],
|
||||
dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2],
|
||||
dev->frontend.offset[0], dev->frontend.offset[1],
|
||||
dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: final: gain: %d/%d/%d, offset: %d/%d/%d\n", __func__,
|
||||
dev->frontend.get_gain(0),
|
||||
dev->frontend.get_gain(1),
|
||||
dev->frontend.get_gain(2),
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
DBGCOMPLETED;
|
||||
|
||||
return status;
|
||||
|
|
|
@ -63,164 +63,360 @@ void genesys_init_frontend_tables()
|
|||
{
|
||||
s_frontends.init();
|
||||
|
||||
GenesysFrontendLayout wolfson_layout;
|
||||
wolfson_layout.offset_addr = { 0x20, 0x21, 0x22 };
|
||||
wolfson_layout.gain_addr = { 0x28, 0x29, 0x2a };
|
||||
|
||||
Genesys_Frontend fe;
|
||||
fe.fe_id = DAC_WOLFSON_UMAX;
|
||||
fe.reg = {0x00, 0x03, 0x05, 0x11};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x80, 0x80, 0x80};
|
||||
fe.gain = {0x02, 0x02, 0x02};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_UMAX;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x05 },
|
||||
{ 0x03, 0x11 },
|
||||
{ 0x20, 0x80 },
|
||||
{ 0x21, 0x80 },
|
||||
{ 0x22, 0x80 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x02 },
|
||||
{ 0x29, 0x02 },
|
||||
{ 0x2a, 0x02 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_ST12;
|
||||
fe.reg = {0x00, 0x03, 0x05, 0x03};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xc8, 0xc8, 0xc8};
|
||||
fe.gain = {0x04, 0x04, 0x04};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_ST12;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x05 },
|
||||
{ 0x03, 0x03 },
|
||||
{ 0x20, 0xc8 },
|
||||
{ 0x21, 0xc8 },
|
||||
{ 0x22, 0xc8 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x04 },
|
||||
{ 0x29, 0x04 },
|
||||
{ 0x2a, 0x04 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_ST24;
|
||||
fe.reg = {0x00, 0x03, 0x05, 0x21};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xc8, 0xc8, 0xc8};
|
||||
fe.gain = {0x06, 0x06, 0x06};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_ST24;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x05 },
|
||||
{ 0x03, 0x21 },
|
||||
{ 0x20, 0xc8 },
|
||||
{ 0x21, 0xc8 },
|
||||
{ 0x22, 0xc8 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x06 },
|
||||
{ 0x29, 0x06 },
|
||||
{ 0x2a, 0x06 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_5345;
|
||||
fe.reg = {0x00, 0x03, 0x05, 0x12};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xb8, 0xb8, 0xb8};
|
||||
fe.gain = {0x04, 0x04, 0x04};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_5345;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x05 },
|
||||
{ 0x03, 0x12 },
|
||||
{ 0x20, 0xb8 },
|
||||
{ 0x21, 0xb8 },
|
||||
{ 0x22, 0xb8 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x04 },
|
||||
{ 0x29, 0x04 },
|
||||
{ 0x2a, 0x04 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
// reg3=0x02 for 50-600 dpi, 0x32 (0x12 also works well) at 1200
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_HP2400;
|
||||
fe.reg = {0x00, 0x03, 0x05, 0x02};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xb4, 0xb6, 0xbc};
|
||||
fe.gain = {0x06, 0x09, 0x08};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_HP2400;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x05 },
|
||||
{ 0x03, 0x02 },
|
||||
{ 0x20, 0xb4 },
|
||||
{ 0x21, 0xb6 },
|
||||
{ 0x22, 0xbc },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x06 },
|
||||
{ 0x29, 0x09 },
|
||||
{ 0x2a, 0x08 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_HP2300;
|
||||
fe.reg = {0x00, 0x03, 0x04, 0x02};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xbe, 0xbe, 0xbe};
|
||||
fe.gain = {0x04, 0x04, 0x04};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_HP2300;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x04 },
|
||||
{ 0x03, 0x02 },
|
||||
{ 0x20, 0xbe },
|
||||
{ 0x21, 0xbe },
|
||||
{ 0x22, 0xbe },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x04 },
|
||||
{ 0x29, 0x04 },
|
||||
{ 0x2a, 0x04 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CANONLIDE35;
|
||||
fe.reg = {0x00, 0x3d, 0x08, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xe1, 0xe1, 0xe1};
|
||||
fe.gain = {0x93, 0x93, 0x93};
|
||||
fe.reg2 = {0x00, 0x19, 0x06};
|
||||
fe.fe_id = DAC_CANONLIDE35;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x3d },
|
||||
{ 0x02, 0x08 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0xe1 },
|
||||
{ 0x21, 0xe1 },
|
||||
{ 0x22, 0xe1 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x93 },
|
||||
{ 0x29, 0x93 },
|
||||
{ 0x2a, 0x93 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x19, 0x06};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_AD_XP200;
|
||||
fe.reg = {0x58, 0x80, 0x00, 0x00}; /* reg1=0x80 ? */
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x09, 0x09, 0x09};
|
||||
fe.gain = {0x09, 0x09, 0x09};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_AD_XP200;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x58 },
|
||||
{ 0x01, 0x80 },
|
||||
{ 0x02, 0x00 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x09 },
|
||||
{ 0x21, 0x09 },
|
||||
{ 0x22, 0x09 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x09 },
|
||||
{ 0x29, 0x09 },
|
||||
{ 0x2a, 0x09 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_XP300;
|
||||
fe.reg = {0x00, 0x35, 0x20, 0x14}; /* 7: XP300 */
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xe1, 0xe1, 0xe1};
|
||||
fe.gain = {0x93, 0x93, 0x93};
|
||||
fe.reg2 = {0x07, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_XP300;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x35 },
|
||||
{ 0x02, 0x20 },
|
||||
{ 0x03, 0x14 },
|
||||
{ 0x20, 0xe1 },
|
||||
{ 0x21, 0xe1 },
|
||||
{ 0x22, 0xe1 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x93 },
|
||||
{ 0x29, 0x93 },
|
||||
{ 0x2a, 0x93 },
|
||||
};
|
||||
fe.reg2 = {0x07, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_HP3670;
|
||||
fe.reg = {0x00, 0x03, 0x05, 0x32}; /* reg3=0x32 for 100-300 dpi, 0x12 at 1200 */
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0xba, 0xb8, 0xb8};
|
||||
fe.gain = {0x06, 0x05, 0x04}; /* gain 4,3,2 at 1200 ?*/
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_HP3670;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x03 },
|
||||
{ 0x02, 0x05 },
|
||||
{ 0x03, 0x32 },
|
||||
{ 0x20, 0xba },
|
||||
{ 0x21, 0xb8 },
|
||||
{ 0x22, 0xb8 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x06 },
|
||||
{ 0x29, 0x05 },
|
||||
{ 0x2a, 0x04 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_WOLFSON_DSM600;
|
||||
fe.reg = {0x00, 0x35, 0x20, 0x14};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x85, 0x85, 0x85};
|
||||
fe.gain = {0xa0, 0xa0, 0xa0};
|
||||
fe.reg2 = {0x07, 0x00, 0x00};
|
||||
fe.fe_id = DAC_WOLFSON_DSM600;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x35 },
|
||||
{ 0x02, 0x20 },
|
||||
{ 0x03, 0x14 },
|
||||
{ 0x20, 0x85 },
|
||||
{ 0x21, 0x85 },
|
||||
{ 0x22, 0x85 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0xa0 },
|
||||
{ 0x29, 0xa0 },
|
||||
{ 0x2a, 0xa0 },
|
||||
};
|
||||
fe.reg2 = {0x07, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CANONLIDE200;
|
||||
fe.reg = {0x9d, 0x91, 0x00, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x00, 0x3f, 0x00}; /* 0x00 0x3f 0x00 : offset/brigthness ? */
|
||||
fe.gain = {0x32, 0x04, 0x00};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_CANONLIDE200;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x9d },
|
||||
{ 0x01, 0x91 },
|
||||
{ 0x02, 0x00 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x3f },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x32 },
|
||||
{ 0x29, 0x04 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CANONLIDE700;
|
||||
fe.reg = {0x9d, 0x9e, 0x00, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x00, 0x3f, 0x00}; /* 0x00 0x3f 0x00 : offset/brigthness ? */
|
||||
fe.gain = {0x2f, 0x04, 0x00};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_CANONLIDE700;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x9d },
|
||||
{ 0x01, 0x9e },
|
||||
{ 0x02, 0x00 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x3f },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x2f },
|
||||
{ 0x29, 0x04 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_KVSS080;
|
||||
fe.reg = {0x00, 0x23, 0x24, 0x0f};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x80, 0x80, 0x80};
|
||||
fe.gain = {0x4b, 0x4b, 0x4b};
|
||||
fe.reg2 = {0x00,0x00,0x00};
|
||||
fe.fe_id = DAC_KVSS080;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x23 },
|
||||
{ 0x02, 0x24 },
|
||||
{ 0x03, 0x0f },
|
||||
{ 0x20, 0x80 },
|
||||
{ 0x21, 0x80 },
|
||||
{ 0x22, 0x80 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x4b },
|
||||
{ 0x29, 0x4b },
|
||||
{ 0x2a, 0x4b },
|
||||
};
|
||||
fe.reg2 = {0x00,0x00,0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_G4050;
|
||||
fe.reg = {0x00, 0x23, 0x24, 0x1f};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x45, 0x45, 0x45}; /* 0x20, 0x21, 0x22 */
|
||||
fe.gain = {0x4b, 0x4b, 0x4b}; /* 0x28, 0x29, 0x2a */
|
||||
fe.reg2 = {0x00,0x00,0x00};
|
||||
fe.fe_id = DAC_G4050;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x23 },
|
||||
{ 0x02, 0x24 },
|
||||
{ 0x03, 0x1f },
|
||||
{ 0x20, 0x45 },
|
||||
{ 0x21, 0x45 },
|
||||
{ 0x22, 0x45 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x4b },
|
||||
{ 0x29, 0x4b },
|
||||
{ 0x2a, 0x4b },
|
||||
};
|
||||
fe.reg2 = {0x00,0x00,0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CANONLIDE110;
|
||||
fe.reg = {0x80, 0x8a, 0x23, 0x4c};
|
||||
fe.sign = {0x00, 0xca, 0x94};
|
||||
fe.offset = {0x00, 0x00, 0x00};
|
||||
fe.gain = {0x00, 0x00, 0x00};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_CANONLIDE110;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x80 },
|
||||
{ 0x01, 0x8a },
|
||||
{ 0x02, 0x23 },
|
||||
{ 0x03, 0x4c },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x00 },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0xca },
|
||||
{ 0x26, 0x94 },
|
||||
{ 0x28, 0x00 },
|
||||
{ 0x29, 0x00 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
/** @brief GL124 special case
|
||||
|
@ -230,64 +426,133 @@ void genesys_init_frontend_tables()
|
|||
*/
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CANONLIDE120;
|
||||
fe.reg = {0x80,
|
||||
/* 0001 0002 0003 */
|
||||
0xa3, 0x2b, 0x4c};
|
||||
/* 0005 0006 0007 */
|
||||
fe.sign = {0x00, 0xca, 0x95};
|
||||
fe.offset = {0x00, 0x00, 0x00};
|
||||
fe.gain = {0x00, 0x00, 0x00};
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x80 },
|
||||
{ 0x01, 0xa3 },
|
||||
{ 0x02, 0x2b },
|
||||
{ 0x03, 0x4c },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x00 },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 }, // actual address 0x05
|
||||
{ 0x25, 0xca }, // actual address 0x06
|
||||
{ 0x26, 0x95 }, // actual address 0x07
|
||||
{ 0x28, 0x00 },
|
||||
{ 0x29, 0x00 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_PLUSTEK_3600;
|
||||
fe.reg = {0x70, 0x80, 0x00, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x00, 0x00, 0x00};
|
||||
fe.gain = {0x3f, 0x3d, 0x3d};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_PLUSTEK_3600;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x70 },
|
||||
{ 0x01, 0x80 },
|
||||
{ 0x02, 0x00 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x00 },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x3f },
|
||||
{ 0x29, 0x3d },
|
||||
{ 0x2a, 0x3d },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CS8400F;
|
||||
fe.reg = {0x00, 0x23, 0x24, 0x0f};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x60, 0x5c, 0x6c};
|
||||
fe.gain = {0x8a, 0x9f, 0xc2};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_CS8400F;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x23 },
|
||||
{ 0x02, 0x24 },
|
||||
{ 0x03, 0x0f },
|
||||
{ 0x20, 0x60 },
|
||||
{ 0x21, 0x5c },
|
||||
{ 0x22, 0x6c },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x8a },
|
||||
{ 0x29, 0x9f },
|
||||
{ 0x2a, 0xc2 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CS8600F;
|
||||
fe.reg = { 0x00, 0x23, 0x24, 0x2f };
|
||||
fe.sign = { 0x00, 0x00, 0x00 };
|
||||
fe.offset = { 0x67, 0x69, 0x68 };
|
||||
fe.gain = { 0xdb, 0xda, 0xd7 };
|
||||
fe.reg2 = { 0x00, 0x00, 0x00 };
|
||||
fe.fe_id = DAC_CS8600F;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x00 },
|
||||
{ 0x01, 0x23 },
|
||||
{ 0x02, 0x24 },
|
||||
{ 0x03, 0x2f },
|
||||
{ 0x20, 0x67 },
|
||||
{ 0x21, 0x69 },
|
||||
{ 0x22, 0x68 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0xdb },
|
||||
{ 0x29, 0xda },
|
||||
{ 0x2a, 0xd7 },
|
||||
};
|
||||
fe.reg2 = { 0x00, 0x00, 0x00 };
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_IMG101;
|
||||
fe.reg = {0x78, 0xf0, 0x00, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x00, 0x00, 0x00};
|
||||
fe.gain = {0x00, 0x00, 0x00};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_IMG101;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x78 },
|
||||
{ 0x01, 0xf0 },
|
||||
{ 0x02, 0x00 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x00 },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x00 },
|
||||
{ 0x29, 0x00 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_PLUSTEK3800;
|
||||
fe.reg = {0x78, 0xf0, 0x00, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x00, 0x00, 0x00};
|
||||
fe.gain = {0x00, 0x00, 0x00};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_PLUSTEK3800;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x78 },
|
||||
{ 0x01, 0xf0 },
|
||||
{ 0x02, 0x00 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x00 },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x00 },
|
||||
{ 0x29, 0x00 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
|
||||
|
||||
|
@ -296,12 +561,24 @@ void genesys_init_frontend_tables()
|
|||
* reg6: gain
|
||||
* reg0 , reg3, reg6 */
|
||||
fe = Genesys_Frontend();
|
||||
fe.fe_id = DAC_CANONLIDE80;
|
||||
fe.reg = {0x70, 0x16, 0x60, 0x00};
|
||||
fe.sign = {0x00, 0x00, 0x00};
|
||||
fe.offset = {0x00, 0x00, 0x00};
|
||||
fe.gain = {0x00, 0x00, 0x00};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
fe.fe_id = DAC_CANONLIDE80;
|
||||
fe.layout = wolfson_layout;
|
||||
fe.regs = {
|
||||
{ 0x00, 0x70 },
|
||||
{ 0x01, 0x16 },
|
||||
{ 0x02, 0x60 },
|
||||
{ 0x03, 0x00 },
|
||||
{ 0x20, 0x00 },
|
||||
{ 0x21, 0x00 },
|
||||
{ 0x22, 0x00 },
|
||||
{ 0x24, 0x00 },
|
||||
{ 0x25, 0x00 },
|
||||
{ 0x26, 0x00 },
|
||||
{ 0x28, 0x00 },
|
||||
{ 0x29, 0x00 },
|
||||
{ 0x2a, 0x00 },
|
||||
};
|
||||
fe.reg2 = {0x00, 0x00, 0x00};
|
||||
s_frontends->push_back(fe);
|
||||
}
|
||||
|
||||
|
|
|
@ -552,7 +552,6 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set)
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
int i;
|
||||
uint16_t val;
|
||||
|
||||
DBGSTART;
|
||||
if (set == AFE_INIT)
|
||||
|
@ -572,13 +571,13 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
|
||||
/* write values to analog frontend */
|
||||
for (i = 1; i < 4; i++)
|
||||
for (uint16_t addr = 0x01; addr < 0x04; addr++)
|
||||
{
|
||||
val = dev->frontend.reg[i];
|
||||
status = sanei_genesys_fe_write_data (dev, i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, addr, dev->frontend.regs.get_value(addr));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write reg %d: %s\n", __func__, i, sane_strstatus(status));
|
||||
DBG(DBG_error, "%s: failed to write reg %d: %s\n", __func__, addr,
|
||||
sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
@ -594,8 +593,7 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set)
|
|||
/* these are not really sign for this AFE */
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.sign[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x05 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x05 + i, dev->frontend.regs.get_value(0x24 + i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3063,15 +3061,15 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
std::vector<uint8_t> second_line(total_size);
|
||||
|
||||
/* init gain */
|
||||
dev->frontend.gain[0] = 0;
|
||||
dev->frontend.gain[1] = 0;
|
||||
dev->frontend.gain[2] = 0;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
|
||||
/* scan with no move */
|
||||
bottom = 10;
|
||||
dev->frontend.offset[0] = bottom;
|
||||
dev->frontend.offset[1] = bottom;
|
||||
dev->frontend.offset[2] = bottom;
|
||||
dev->frontend.set_offset(0, bottom);
|
||||
dev->frontend.set_offset(1, bottom);
|
||||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
|
@ -3090,9 +3088,9 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* now top value */
|
||||
top = 255;
|
||||
dev->frontend.offset[0] = top;
|
||||
dev->frontend.offset[1] = top;
|
||||
dev->frontend.offset[2] = top;
|
||||
dev->frontend.set_offset(0, top);
|
||||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
|
@ -3108,9 +3106,9 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
pass++;
|
||||
|
||||
/* settings for new scan */
|
||||
dev->frontend.offset[0] = (top + bottom) / 2;
|
||||
dev->frontend.offset[1] = (top + bottom) / 2;
|
||||
dev->frontend.offset[2] = (top + bottom) / 2;
|
||||
dev->frontend.set_offset(0, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(1, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||
|
||||
/* scan with no move */
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
|
@ -3122,27 +3120,29 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
char title[30];
|
||||
snprintf(title, 30, "gl124_offset%03d.pnm", dev->frontend.offset[1]);
|
||||
snprintf(title, 30, "gl124_offset%03d.pnm", dev->frontend.get_offset(1));
|
||||
sanei_genesys_write_pnm_file(title, second_line.data(), bpp, channels, pixels, lines);
|
||||
}
|
||||
|
||||
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1));
|
||||
|
||||
/* compute new boundaries */
|
||||
if (topavg == avg)
|
||||
{
|
||||
topavg = avg;
|
||||
top = dev->frontend.offset[1];
|
||||
top = dev->frontend.get_offset(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bottomavg = avg;
|
||||
bottom = dev->frontend.offset[1];
|
||||
bottom = dev->frontend.get_offset(1);
|
||||
}
|
||||
}
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -3276,25 +3276,28 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
code = 255;
|
||||
else if (code < 0)
|
||||
code = 0;
|
||||
dev->frontend.gain[j] = code;
|
||||
dev->frontend.set_gain(j, code);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j],
|
||||
gain[j], dev->frontend.gain[j]);
|
||||
gain[j], dev->frontend.get_gain(j));
|
||||
}
|
||||
|
||||
if (dev->model->is_cis)
|
||||
{
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[1])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[2])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[2];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
if (dev->model->is_cis) {
|
||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||
if (gain0 > dev->frontend.get_gain(1)) {
|
||||
gain0 = dev->frontend.get_gain(1);
|
||||
}
|
||||
if (gain0 > dev->frontend.get_gain(2)) {
|
||||
gain0 = dev->frontend.get_gain(2);
|
||||
}
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain0);
|
||||
dev->frontend.set_gain(2, gain0);
|
||||
}
|
||||
|
||||
if (channels == 1)
|
||||
{
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1];
|
||||
if (channels == 1) {
|
||||
dev->frontend.set_gain(0, dev->frontend.get_gain(1));
|
||||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
RIE (gl124_stop_action (dev));
|
||||
|
|
|
@ -1369,7 +1369,6 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
int i;
|
||||
uint16_t val;
|
||||
|
||||
DBG(DBG_proc, "%s(): start\n", __func__);
|
||||
if (set == AFE_INIT)
|
||||
|
@ -1379,15 +1378,13 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
dev->frontend = dev->frontend_initial;
|
||||
|
||||
/* write them to analog frontend */
|
||||
val = dev->frontend.reg[0];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
val = dev->frontend.reg[1];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write reg1: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1398,8 +1395,7 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.gain[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02 + i, dev->frontend.get_gain(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write gain %d: %s\n", __func__, i,
|
||||
|
@ -1409,8 +1405,7 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.offset[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x05 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x05 + i, dev->frontend.get_offset(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write offset %d: %s\n", __func__, i,
|
||||
|
@ -1461,13 +1456,13 @@ gl646_wm_hp3670(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set,
|
|||
sanei_genesys_sleep_ms(200);
|
||||
RIE (sanei_genesys_write_register (dev, 0x50, 0x00));
|
||||
dev->frontend = dev->frontend_initial;
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.reg[2]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02, dev->frontend.regs.get_value(0x02));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg2 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1497,7 +1492,7 @@ gl646_wm_hp3670(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set,
|
|||
break;
|
||||
default: /* AFE_SET */
|
||||
/* mode setup */
|
||||
i = dev->frontend.reg[3];
|
||||
i = dev->frontend.regs.get_value(0x03);
|
||||
if (dpi > sensor.optical_res / 2)
|
||||
{
|
||||
/* fe_reg_0x03 must be 0x12 for 1200 dpi in DAC_WOLFSON_HP3670.
|
||||
|
@ -1515,15 +1510,15 @@ gl646_wm_hp3670(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set,
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x20 + i,
|
||||
dev->frontend.offset[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x20 + i, dev->frontend.get_offset(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing offset%d failed: %s\n", __func__, i,
|
||||
sane_strstatus (status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x24 + i, dev->frontend.sign[i]); /* MSB/LSB ? */
|
||||
status = sanei_genesys_fe_write_data(dev, 0x24 + i,
|
||||
dev->frontend.regs.get_value(0x24 + i)); /* MSB/LSB ? */
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing sign%d failed: %s\n", __func__, i,
|
||||
|
@ -1536,8 +1531,7 @@ gl646_wm_hp3670(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set,
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x28 + i,
|
||||
dev->frontend.gain[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x28 + i, dev->frontend.get_gain(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing gain%d failed: %s\n", __func__, i,
|
||||
|
@ -1635,13 +1629,13 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
&& dev->model->ccd_type != CCD_HP3670
|
||||
&& dev->model->ccd_type != CCD_HP2400) */
|
||||
{
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg0 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.reg[2]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02, dev->frontend.regs.get_value(0x02));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg2 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1650,7 +1644,7 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
}
|
||||
|
||||
/* start with reg3 */
|
||||
status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[3]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x03, dev->frontend.regs.get_value(0x03));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg3 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1663,8 +1657,8 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x24 + i,
|
||||
dev->frontend.sign[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x24 + i,
|
||||
dev->frontend.regs.get_value(0x24 + i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, i,
|
||||
|
@ -1673,8 +1667,7 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x28 + i,
|
||||
dev->frontend.gain[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x28 + i, dev->frontend.get_gain(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing gain[%d] failed: %s\n", __func__, i,
|
||||
|
@ -1683,8 +1676,7 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x20 + i,
|
||||
dev->frontend.offset[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x20 + i, dev->frontend.get_offset(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing offset[%d] failed: %s\n", __func__, i,
|
||||
|
@ -1699,13 +1691,13 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
case CCD_HP3670:
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x23, dev->frontend.offset[1]);
|
||||
sanei_genesys_fe_write_data(dev, 0x23, dev->frontend.get_offset(1));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing offset[1] failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x28, dev->frontend.gain[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x28, dev->frontend.get_gain(1));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing gain[1] failed: %s\n", __func__, sane_strstatus (status));
|
||||
|
@ -1715,7 +1707,7 @@ gl646_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set, in
|
|||
}
|
||||
|
||||
/* end with reg1 */
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3366,9 +3358,9 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
settings.dynamic_lineart = SANE_FALSE;
|
||||
|
||||
/* scan first line of data with no gain */
|
||||
dev->frontend.gain[0] = 0;
|
||||
dev->frontend.gain[1] = 0;
|
||||
dev->frontend.gain[2] = 0;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
|
||||
std::vector<uint8_t> line;
|
||||
|
||||
|
@ -3377,9 +3369,9 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
do
|
||||
{
|
||||
pass++;
|
||||
dev->frontend.offset[0] = bottom;
|
||||
dev->frontend.offset[1] = bottom;
|
||||
dev->frontend.offset[2] = bottom;
|
||||
dev->frontend.set_offset(0, bottom);
|
||||
dev->frontend.set_offset(1, bottom);
|
||||
dev->frontend.set_offset(2, bottom);
|
||||
status =
|
||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -3420,8 +3412,10 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
return SANE_STATUS_INVAL;
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
DBG(DBG_proc, "%s: end\n", __func__);
|
||||
return status;
|
||||
}
|
||||
|
@ -3492,15 +3486,15 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* scan first line of data with no gain, but with offset from
|
||||
* last calibration */
|
||||
dev->frontend.gain[0] = 0;
|
||||
dev->frontend.gain[1] = 0;
|
||||
dev->frontend.gain[2] = 0;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
|
||||
/* scan with no move */
|
||||
bottom = 90;
|
||||
dev->frontend.offset[0] = bottom;
|
||||
dev->frontend.offset[1] = bottom;
|
||||
dev->frontend.offset[2] = bottom;
|
||||
dev->frontend.set_offset(0, bottom);
|
||||
dev->frontend.set_offset(1, bottom);
|
||||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
std::vector<uint8_t> first_line, second_line;
|
||||
|
||||
|
@ -3523,9 +3517,9 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* now top value */
|
||||
top = 231;
|
||||
dev->frontend.offset[0] = top;
|
||||
dev->frontend.offset[1] = top;
|
||||
dev->frontend.offset[2] = top;
|
||||
dev->frontend.set_offset(0, top);
|
||||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
status = simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, second_line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3550,9 +3544,9 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
pass++;
|
||||
|
||||
/* settings for new scan */
|
||||
dev->frontend.offset[0] = (top + bottom) / 2;
|
||||
dev->frontend.offset[1] = (top + bottom) / 2;
|
||||
dev->frontend.offset[2] = (top + bottom) / 2;
|
||||
dev->frontend.set_offset(0, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(1, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||
|
||||
/* scan with no move */
|
||||
status = simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, second_line);
|
||||
|
@ -3565,7 +3559,7 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
char title[30];
|
||||
snprintf(title, 30, "gl646_offset%03d.pnm", dev->frontend.offset[1]);
|
||||
snprintf(title, 30, "gl646_offset%03d.pnm", dev->frontend.get_offset(1));
|
||||
sanei_genesys_write_pnm_file (title, second_line.data(), 8, channels,
|
||||
settings.pixels, settings.lines);
|
||||
}
|
||||
|
@ -3573,18 +3567,18 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
avg =
|
||||
dark_average (second_line.data(), settings.pixels, settings.lines, channels,
|
||||
black_pixels);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1));
|
||||
|
||||
/* compute new boundaries */
|
||||
if (topavg == avg)
|
||||
{
|
||||
topavg = avg;
|
||||
top = dev->frontend.offset[1];
|
||||
top = dev->frontend.get_offset(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bottomavg = avg;
|
||||
bottom = dev->frontend.offset[1];
|
||||
bottom = dev->frontend.get_offset(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3601,8 +3595,10 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
settings.pixels, settings.lines);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
DBG(DBG_proc, "%s: end\n", __func__);
|
||||
return status;
|
||||
}
|
||||
|
@ -3647,9 +3643,9 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
size = channels * settings.pixels * settings.lines;
|
||||
|
||||
/* start gain value */
|
||||
dev->frontend.gain[0] = 1;
|
||||
dev->frontend.gain[1] = 1;
|
||||
dev->frontend.gain[2] = 1;
|
||||
dev->frontend.set_gain(0, 1);
|
||||
dev->frontend.set_gain(1, 1);
|
||||
dev->frontend.set_gain(2, 1);
|
||||
|
||||
average = 0;
|
||||
pass = 0;
|
||||
|
@ -3688,17 +3684,23 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
}
|
||||
average = average / count;
|
||||
|
||||
/* adjusts gain for the channel */
|
||||
if (average < sensor.gain_white_ref)
|
||||
dev->frontend.gain[0]++;
|
||||
dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[0];
|
||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||
// adjusts gain for the channel
|
||||
if (average < sensor.gain_white_ref) {
|
||||
gain0 += 1;
|
||||
}
|
||||
|
||||
DBG(DBG_proc, "%s: average = %.2f, gain = %d\n", __func__, average, dev->frontend.gain[0]);
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain0);
|
||||
dev->frontend.set_gain(2, gain0);
|
||||
|
||||
DBG(DBG_proc, "%s: average = %.2f, gain = %d\n", __func__, average, gain0);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1],
|
||||
dev->frontend.gain[2]);
|
||||
DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_gain(0),
|
||||
dev->frontend.get_gain(1),
|
||||
dev->frontend.get_gain(2));
|
||||
DBGCOMPLETED;
|
||||
return status;
|
||||
}
|
||||
|
@ -3767,9 +3769,9 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
settings.dynamic_lineart = SANE_FALSE;
|
||||
|
||||
/* start gain value */
|
||||
dev->frontend.gain[0] = 1;
|
||||
dev->frontend.gain[1] = 1;
|
||||
dev->frontend.gain[2] = 1;
|
||||
dev->frontend.set_gain(0, 1);
|
||||
dev->frontend.set_gain(1, 1);
|
||||
dev->frontend.set_gain(2, 1);
|
||||
|
||||
if (channels > 1)
|
||||
{
|
||||
|
@ -3854,21 +3856,22 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
/* adjusts gain for the channel */
|
||||
if (average[k] < sensor.gain_white_ref)
|
||||
dev->frontend.gain[k]++;
|
||||
dev->frontend.set_gain(k, dev->frontend.get_gain(k) + 1);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, average = %.2f, gain = %d\n", __func__, k, average[k],
|
||||
dev->frontend.gain[k]);
|
||||
dev->frontend.get_gain(k));
|
||||
}
|
||||
}
|
||||
|
||||
if (channels < 3)
|
||||
{
|
||||
dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[0];
|
||||
if (channels < 3) {
|
||||
dev->frontend.set_gain(1, dev->frontend.get_gain(0));
|
||||
dev->frontend.set_gain(2, dev->frontend.get_gain(0));
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1],
|
||||
dev->frontend.gain[2]);
|
||||
DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_gain(0),
|
||||
dev->frontend.get_gain(1),
|
||||
dev->frontend.get_gain(2));
|
||||
DBGCOMPLETED;
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -829,19 +829,19 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set)
|
|||
dev->frontend = dev->frontend_initial;
|
||||
|
||||
/* write them to analog frontend */
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x03, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x03 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.reg[2]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x06, dev->frontend.regs.get_value(0x02));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x06 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -851,19 +851,19 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set)
|
|||
|
||||
if (set == AFE_SET)
|
||||
{
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.offset[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x06, dev->frontend.regs.get_value(0x20));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing offset failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.gain[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x03, dev->frontend.regs.get_value(0x28));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing gain failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -896,14 +896,14 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
dev->frontend = dev->frontend_initial;
|
||||
|
||||
/* write them to analog frontend */
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x01 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -925,14 +925,14 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
if (set == AFE_SET)
|
||||
{
|
||||
/* write them to analog frontend */
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg 0x01 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -940,7 +940,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
|
||||
/* Write fe 0x02 (red gain)*/
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.gain[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02, dev->frontend.get_gain(0));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing fe 0x02 (gain r) fail: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -948,7 +948,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
|
||||
/* Write fe 0x03 (green gain)*/
|
||||
status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.gain[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x03, dev->frontend.get_gain(1));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing fe 0x03 (gain g) fail: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -956,7 +956,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
|
||||
/* Write fe 0x04 (blue gain)*/
|
||||
status = sanei_genesys_fe_write_data (dev, 0x04, dev->frontend.gain[2]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x04, dev->frontend.get_gain(2));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing fe 0x04 (gain b) fail: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -965,7 +965,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
|
||||
/* Write fe 0x05 (red offset)*/
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x05, dev->frontend.offset[0]);
|
||||
sanei_genesys_fe_write_data(dev, 0x05, dev->frontend.get_offset(0));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: write fe 0x05 (offset r) fail: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -974,7 +974,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
|
||||
/* Write fe 0x06 (green offset)*/
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.offset[1]);
|
||||
sanei_genesys_fe_write_data(dev, 0x06, dev->frontend.get_offset(1));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: write fe 0x06 (offset g) fail: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -983,7 +983,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
|
||||
/* Write fe 0x07 (blue offset)*/
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x07, dev->frontend.offset[2]);
|
||||
sanei_genesys_fe_write_data(dev, 0x07, dev->frontend.get_offset(2));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: write fe 0x07 (offset b) fail: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1064,13 +1064,13 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
/*if (dev->model->ccd_type!=CCD_HP2300 && dev->model->ccd_type!=CCD_HP2400) */
|
||||
{
|
||||
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg0 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.reg[2]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02, dev->frontend.regs.get_value(0x02));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg2 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1078,14 +1078,14 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
}
|
||||
}
|
||||
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[3]);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x03, dev->frontend.regs.get_value(0x03));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg3 failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -1116,7 +1116,7 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x24 + i, dev->frontend.sign[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x24 + i, dev->frontend.regs.get_value(0x24 + i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, i,
|
||||
|
@ -1125,7 +1125,7 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x28 + i, dev->frontend.gain[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x28 + i, dev->frontend.get_gain(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing gain[%d] failed: %s\n", __func__, i,
|
||||
|
@ -1134,8 +1134,8 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
}
|
||||
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x20 + i,
|
||||
dev->frontend.offset[i]);
|
||||
sanei_genesys_fe_write_data(dev, 0x20 + i,
|
||||
dev->frontend.get_offset(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing offset[%d] failed: %s\n", __func__, i,
|
||||
|
@ -4299,9 +4299,9 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
dev->frontend.gain[0] = 0x00;
|
||||
dev->frontend.gain[1] = 0x00;
|
||||
dev->frontend.gain[2] = 0x00;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
|
||||
/* loop on scan until target offset is reached */
|
||||
turn=0;
|
||||
|
@ -4310,9 +4310,9 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
top=255;
|
||||
do {
|
||||
/* set up offset mid range */
|
||||
dev->frontend.offset[0] = (top+bottom)/2;
|
||||
dev->frontend.offset[1] = (top+bottom)/2;
|
||||
dev->frontend.offset[2] = (top+bottom)/2;
|
||||
dev->frontend.set_offset(0, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(1, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||
|
||||
/* scan line */
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
|
@ -4349,11 +4349,14 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
turn++;
|
||||
} while ((top-bottom)>1 && turn < 100);
|
||||
|
||||
dev->frontend.offset[0]=0;
|
||||
dev->frontend.offset[1]=0;
|
||||
dev->frontend.offset[2]=0;
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
// FIXME: don't overwrite the calibrated values
|
||||
dev->frontend.set_offset(0, 0);
|
||||
dev->frontend.set_offset(1, 0);
|
||||
dev->frontend.set_offset(2, 0);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
DBGCOMPLETED;
|
||||
return status;
|
||||
}
|
||||
|
@ -4443,9 +4446,9 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
* signal").
|
||||
*
|
||||
*/
|
||||
dev->frontend.gain[0] = 0x00;
|
||||
dev->frontend.gain[1] = 0x00;
|
||||
dev->frontend.gain[2] = 0x00;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
offh[0] = 0xff;
|
||||
offh[1] = 0xff;
|
||||
offh[2] = 0xff;
|
||||
|
@ -4460,7 +4463,7 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
for (j=0; j < channels; j++) {
|
||||
off[j] = (offh[j]+offl[j])/2;
|
||||
dev->frontend.offset[j] = off[j];
|
||||
dev->frontend.set_offset(j, off[j]);
|
||||
}
|
||||
|
||||
status = gl841_set_fe(dev, sensor, AFE_SET);
|
||||
|
@ -4573,7 +4576,7 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
for (j=0; j < channels; j++) {
|
||||
off[j] = (offh[j]+offl[j])/2;
|
||||
dev->frontend.offset[j] = off[j];
|
||||
dev->frontend.set_offset(j, off[j]);
|
||||
}
|
||||
|
||||
status = gl841_set_fe(dev, sensor, AFE_SET);
|
||||
|
@ -4711,7 +4714,7 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
off[j] = 255;
|
||||
if (off[j] < 0)
|
||||
off[j] = 0;
|
||||
dev->frontend.offset[j] = off[j];
|
||||
dev->frontend.set_offset(j, off[j]);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: final offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]);
|
||||
|
@ -4721,15 +4724,15 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
off[0] = off[1];
|
||||
if (off[0] < off[2])
|
||||
off[0] = off[2];
|
||||
dev->frontend.offset[0] = off[0];
|
||||
dev->frontend.offset[1] = off[0];
|
||||
dev->frontend.offset[2] = off[0];
|
||||
dev->frontend.set_offset(0, off[0]);
|
||||
dev->frontend.set_offset(1, off[0]);
|
||||
dev->frontend.set_offset(2, off[0]);
|
||||
}
|
||||
|
||||
if (channels == 1)
|
||||
{
|
||||
dev->frontend.offset[1] = dev->frontend.offset[0];
|
||||
dev->frontend.offset[2] = dev->frontend.offset[0];
|
||||
dev->frontend.set_offset(1, dev->frontend.get_offset(0));
|
||||
dev->frontend.set_offset(2, dev->frontend.get_offset(0));
|
||||
}
|
||||
|
||||
DBG(DBG_proc, "%s: completed\n", __func__);
|
||||
|
@ -4839,25 +4842,28 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
gain[j] = 65535.0/max[j];
|
||||
|
||||
uint8_t out_gain = 0;
|
||||
|
||||
if (dev->model->dac_type == DAC_CANONLIDE35 ||
|
||||
dev->model->dac_type == DAC_WOLFSON_XP300 ||
|
||||
dev->model->dac_type == DAC_WOLFSON_DSM600)
|
||||
{
|
||||
gain[j] *= 0.69;/*seems we don't get the real maximum. empirically derived*/
|
||||
if (283 - 208/gain[j] > 255)
|
||||
dev->frontend.gain[j] = 255;
|
||||
out_gain = 255;
|
||||
else if (283 - 208/gain[j] < 0)
|
||||
dev->frontend.gain[j] = 0;
|
||||
out_gain = 0;
|
||||
else
|
||||
dev->frontend.gain[j] = 283 - 208/gain[j];
|
||||
out_gain = 283 - 208/gain[j];
|
||||
}
|
||||
else if (dev->model->dac_type == DAC_CANONLIDE80)
|
||||
{
|
||||
dev->frontend.gain[j] = gain[j]*12;
|
||||
out_gain = gain[j]*12;
|
||||
}
|
||||
dev->frontend.set_gain(j, out_gain);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j],
|
||||
dev->frontend.gain[j]);
|
||||
out_gain);
|
||||
}
|
||||
|
||||
for (j = 0; j < channels; j++)
|
||||
|
@ -4882,22 +4888,28 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
}
|
||||
|
||||
if (dev->model->is_cis) {
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[1])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[2])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[2];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
}
|
||||
if (dev->model->is_cis) {
|
||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||
if (gain0 > dev->frontend.get_gain(1)) {
|
||||
gain0 = dev->frontend.get_gain(1);
|
||||
}
|
||||
if (gain0 > dev->frontend.get_gain(2)) {
|
||||
gain0 = dev->frontend.get_gain(2);
|
||||
}
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain0);
|
||||
dev->frontend.set_gain(2, gain0);
|
||||
}
|
||||
|
||||
if (channels == 1)
|
||||
{
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1];
|
||||
}
|
||||
if (channels == 1) {
|
||||
dev->frontend.set_gain(0, dev->frontend.get_gain(1));
|
||||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: gain=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1],
|
||||
dev->frontend.gain[2]);
|
||||
DBG(DBG_info, "%s: gain=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_gain(0),
|
||||
dev->frontend.get_gain(1),
|
||||
dev->frontend.get_gain(2));
|
||||
|
||||
RIE (gl841_stop_action (dev));
|
||||
|
||||
|
@ -4925,12 +4937,12 @@ gl841_init_regs_for_warmup (Genesys_Device * dev,
|
|||
*local_reg = dev->reg;
|
||||
|
||||
/* okay.. these should be defaults stored somewhere */
|
||||
dev->frontend.gain[0] = 0x00;
|
||||
dev->frontend.gain[1] = 0x00;
|
||||
dev->frontend.gain[2] = 0x00;
|
||||
dev->frontend.offset[0] = 0x80;
|
||||
dev->frontend.offset[1] = 0x80;
|
||||
dev->frontend.offset[2] = 0x80;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
dev->frontend.set_offset(0, 0x80);
|
||||
dev->frontend.set_offset(1, 0x80);
|
||||
dev->frontend.set_offset(2, 0x80);
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
local_reg,
|
||||
|
@ -5246,9 +5258,9 @@ gl841_search_strip(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
* since we don't have calibrated the sensor yet */
|
||||
if(!black && forward)
|
||||
{
|
||||
dev->frontend.gain[0] = 0xff;
|
||||
dev->frontend.gain[1] = 0xff;
|
||||
dev->frontend.gain[2] = 0xff;
|
||||
dev->frontend.set_gain(0, 0xff);
|
||||
dev->frontend.set_gain(1, 0xff);
|
||||
dev->frontend.set_gain(2, 0xff);
|
||||
}
|
||||
|
||||
gl841_set_fe(dev, sensor, AFE_SET);
|
||||
|
|
|
@ -786,7 +786,13 @@ gl843_set_fe (Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
|
||||
for (i = 1; i <= 3; i++)
|
||||
{
|
||||
status = sanei_genesys_fe_write_data (dev, i, dev->frontend.reg[i]);
|
||||
// FIXME: BUG: we should initialize dev->frontend before first use. Right now it's
|
||||
// initialized during genesys_coarse_calibration()
|
||||
if (dev->frontend.regs.empty()) {
|
||||
status = sanei_genesys_fe_write_data(dev, i, 0x00);
|
||||
} else {
|
||||
status = sanei_genesys_fe_write_data(dev, i, dev->frontend.regs.get_value(0x00 + i));
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing reg[%d] failed: %s\n", __func__, i, sane_strstatus(status));
|
||||
|
@ -803,8 +809,12 @@ gl843_set_fe (Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x20 + i, dev->frontend.offset[i]);
|
||||
// FIXME: BUG: see above
|
||||
if (dev->frontend.regs.empty()) {
|
||||
status = sanei_genesys_fe_write_data(dev, 0x20 + i, 0x00);
|
||||
} else {
|
||||
status = sanei_genesys_fe_write_data(dev, 0x20 + i, dev->frontend.get_offset(i));
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing offset[%d] failed: %s\n", __func__, i,
|
||||
|
@ -817,9 +827,13 @@ gl843_set_fe (Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x24 + i,
|
||||
dev->frontend.sign[i]);
|
||||
// FIXME: BUG: see above
|
||||
if (dev->frontend.regs.empty()) {
|
||||
status = sanei_genesys_fe_write_data(dev, 0x24 + i, 0x00);
|
||||
} else {
|
||||
status = sanei_genesys_fe_write_data(dev, 0x24 + i,
|
||||
dev->frontend.regs.get_value(0x24 + i));
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, i,
|
||||
|
@ -831,8 +845,12 @@ gl843_set_fe (Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
status =
|
||||
sanei_genesys_fe_write_data (dev, 0x28 + i, dev->frontend.gain[i]);
|
||||
// FIXME: BUG: see above
|
||||
if (dev->frontend.regs.empty()) {
|
||||
status = sanei_genesys_fe_write_data(dev, 0x28 + i, 0x00);
|
||||
} else {
|
||||
status = sanei_genesys_fe_write_data(dev, 0x28 + i, dev->frontend.get_gain(i));
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: writing gain[%d] failed: %s\n", __func__, i, sane_strstatus(status));
|
||||
|
@ -3432,8 +3450,8 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
bottom[i] = 10;
|
||||
dev->frontend.offset[i] = bottom[i];
|
||||
dev->frontend.gain[i] = 0;
|
||||
dev->frontend.set_offset(i, bottom[i]);
|
||||
dev->frontend.set_gain(i, 0);
|
||||
}
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
|
@ -3462,7 +3480,7 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
top[i] = 255;
|
||||
dev->frontend.offset[i] = top[i];
|
||||
dev->frontend.set_offset(i, top[i]);
|
||||
}
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
|
@ -3497,7 +3515,7 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
{
|
||||
if (top[i] - bottom[i] > 1)
|
||||
{
|
||||
dev->frontend.offset[i] = (top[i] + bottom[i]) / 2;
|
||||
dev->frontend.set_offset(i, (top[i] + bottom[i]) / 2);
|
||||
}
|
||||
}
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
@ -3514,7 +3532,9 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
char title[100];
|
||||
snprintf(title, 100, "lines: %d pixels_per_line: %d offsets[0..2]: %d %d %d\n",
|
||||
lines, pixels,
|
||||
dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
debug_image_info += title;
|
||||
std::copy(second_line.begin(), second_line.end(), std::back_inserter(debug_image));
|
||||
debug_image_lines += lines;
|
||||
|
@ -3523,7 +3543,8 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
avg[i] = dark_average_channel(second_line.data(), pixels, lines, channels, black_pixels, i);
|
||||
DBG(DBG_info, "%s: avg[%d]=%d offset=%d\n", __func__, i, avg[i], dev->frontend.offset[i]);
|
||||
DBG(DBG_info, "%s: avg[%d]=%d offset=%d\n", __func__, i, avg[i],
|
||||
dev->frontend.get_offset(i));
|
||||
}
|
||||
|
||||
/* compute new boundaries */
|
||||
|
@ -3532,12 +3553,12 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
if (topavg[i] >= avg[i])
|
||||
{
|
||||
topavg[i] = avg[i];
|
||||
top[i] = dev->frontend.offset[i];
|
||||
top[i] = dev->frontend.get_offset(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
bottomavg[i] = avg[i];
|
||||
bottom[i] = dev->frontend.offset[i];
|
||||
bottom[i] = dev->frontend.get_offset(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3550,8 +3571,10 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
debug_image.data(), bpp, channels, pixels, debug_image_lines);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -3715,25 +3738,28 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
code = 255;
|
||||
else if (code < 0)
|
||||
code = 0;
|
||||
dev->frontend.gain[j] = code;
|
||||
dev->frontend.set_gain(j, code);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain,
|
||||
code);
|
||||
}
|
||||
|
||||
if (dev->model->is_cis)
|
||||
{
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[1])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[2])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[2];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
if (dev->model->is_cis) {
|
||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||
if (gain0 > dev->frontend.get_gain(1)) {
|
||||
gain0 = dev->frontend.get_gain(1);
|
||||
}
|
||||
if (gain0 > dev->frontend.get_gain(2)) {
|
||||
gain0 = dev->frontend.get_gain(2);
|
||||
}
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain0);
|
||||
dev->frontend.set_gain(2, gain0);
|
||||
}
|
||||
|
||||
if (channels == 1)
|
||||
{
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1];
|
||||
if (channels == 1) {
|
||||
dev->frontend.set_gain(0, dev->frontend.get_gain(1));
|
||||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
RIE (gl843_stop_action (dev));
|
||||
|
|
|
@ -481,7 +481,6 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set)
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
int i;
|
||||
uint16_t val;
|
||||
uint8_t val8;
|
||||
|
||||
DBGSTART;
|
||||
|
@ -501,16 +500,14 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
|
||||
/* write them to analog frontend */
|
||||
val = dev->frontend.reg[0];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error, "%s: failed to write reg0: %s\n", __func__,
|
||||
sane_strstatus (status));
|
||||
return status;
|
||||
}
|
||||
val = dev->frontend.reg[1];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error, "%s: failed to write reg1: %s\n", __func__,
|
||||
|
@ -520,8 +517,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set)
|
|||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.gain[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02 + i, dev->frontend.get_gain(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -532,8 +528,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.offset[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x05 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x05 + i, dev->frontend.get_offset(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3107,15 +3102,15 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
std::vector<uint8_t> second_line(total_size);
|
||||
|
||||
/* init gain */
|
||||
dev->frontend.gain[0] = 0;
|
||||
dev->frontend.gain[1] = 0;
|
||||
dev->frontend.gain[2] = 0;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
|
||||
/* scan with no move */
|
||||
bottom = 10;
|
||||
dev->frontend.offset[0] = bottom;
|
||||
dev->frontend.offset[1] = bottom;
|
||||
dev->frontend.offset[2] = bottom;
|
||||
dev->frontend.set_offset(0, bottom);
|
||||
dev->frontend.set_offset(1, bottom);
|
||||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
|
@ -3134,9 +3129,9 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* now top value */
|
||||
top = 255;
|
||||
dev->frontend.offset[0] = top;
|
||||
dev->frontend.offset[1] = top;
|
||||
dev->frontend.offset[2] = top;
|
||||
dev->frontend.set_offset(0, top);
|
||||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
|
@ -3152,9 +3147,9 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
pass++;
|
||||
|
||||
/* settings for new scan */
|
||||
dev->frontend.offset[0] = (top + bottom) / 2;
|
||||
dev->frontend.offset[1] = (top + bottom) / 2;
|
||||
dev->frontend.offset[2] = (top + bottom) / 2;
|
||||
dev->frontend.set_offset(0, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(1, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||
|
||||
/* scan with no move */
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
|
@ -3166,27 +3161,29 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
char fn[30];
|
||||
snprintf(fn, 30, "gl846_offset%03d.pnm", dev->frontend.offset[1]);
|
||||
snprintf(fn, 30, "gl846_offset%03d.pnm", dev->frontend.get_offset(1));
|
||||
sanei_genesys_write_pnm_file(fn, second_line.data(), bpp, channels, pixels, lines);
|
||||
}
|
||||
|
||||
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1));
|
||||
|
||||
/* compute new boundaries */
|
||||
if (topavg == avg)
|
||||
{
|
||||
topavg = avg;
|
||||
top = dev->frontend.offset[1];
|
||||
top = dev->frontend.get_offset(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bottomavg = avg;
|
||||
bottom = dev->frontend.offset[1];
|
||||
bottom = dev->frontend.get_offset(1);
|
||||
}
|
||||
}
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -3294,19 +3291,23 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
code = 255;
|
||||
else if (code < 0)
|
||||
code = 0;
|
||||
dev->frontend.gain[j] = code;
|
||||
dev->frontend.set_gain(j, code);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j],
|
||||
dev->frontend.gain[j]);
|
||||
dev->frontend.get_gain(j));
|
||||
}
|
||||
|
||||
if (dev->model->is_cis)
|
||||
{
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[1])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[2])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[2];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
if (dev->model->is_cis) {
|
||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||
if (gain0 > dev->frontend.get_gain(1)) {
|
||||
gain0 = dev->frontend.get_gain(1);
|
||||
}
|
||||
if (gain0 > dev->frontend.get_gain(2)) {
|
||||
gain0 = dev->frontend.get_gain(2);
|
||||
}
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain0);
|
||||
dev->frontend.set_gain(2, gain0);
|
||||
}
|
||||
|
||||
RIE (gl846_stop_action (dev));
|
||||
|
|
|
@ -501,7 +501,6 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
int i;
|
||||
uint16_t val;
|
||||
uint8_t val8;
|
||||
|
||||
DBGSTART;
|
||||
|
@ -530,15 +529,13 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
|
||||
/* write them to analog frontend */
|
||||
val = dev->frontend.reg[0];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x00, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x00, dev->frontend.regs.get_value(0x00));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
val = dev->frontend.reg[1];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x01, dev->frontend.regs.get_value(0x01));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write reg1: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -547,8 +544,7 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.gain[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x02 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x02 + i, dev->frontend.get_gain(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write gain %d: %s\n", __func__, i, sane_strstatus(status));
|
||||
|
@ -557,8 +553,7 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set)
|
|||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
val = dev->frontend.offset[i];
|
||||
status = sanei_genesys_fe_write_data (dev, 0x05 + i, val);
|
||||
status = sanei_genesys_fe_write_data(dev, 0x05 + i, dev->frontend.get_offset(i));
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to write offset %d: %s\n", __func__, i,
|
||||
|
@ -3207,15 +3202,15 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
std::vector<uint8_t> second_line(total_size);
|
||||
|
||||
/* init gain */
|
||||
dev->frontend.gain[0] = 0;
|
||||
dev->frontend.gain[1] = 0;
|
||||
dev->frontend.gain[2] = 0;
|
||||
dev->frontend.set_gain(0, 0);
|
||||
dev->frontend.set_gain(1, 0);
|
||||
dev->frontend.set_gain(2, 0);
|
||||
|
||||
/* scan with no move */
|
||||
bottom = 10;
|
||||
dev->frontend.offset[0] = bottom;
|
||||
dev->frontend.offset[1] = bottom;
|
||||
dev->frontend.offset[2] = bottom;
|
||||
dev->frontend.set_offset(0, bottom);
|
||||
dev->frontend.set_offset(1, bottom);
|
||||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
|
@ -3234,9 +3229,9 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* now top value */
|
||||
top = 255;
|
||||
dev->frontend.offset[0] = top;
|
||||
dev->frontend.offset[1] = top;
|
||||
dev->frontend.offset[2] = top;
|
||||
dev->frontend.set_offset(0, top);
|
||||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
|
@ -3252,9 +3247,9 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
pass++;
|
||||
|
||||
/* settings for new scan */
|
||||
dev->frontend.offset[0] = (top + bottom) / 2;
|
||||
dev->frontend.offset[1] = (top + bottom) / 2;
|
||||
dev->frontend.offset[2] = (top + bottom) / 2;
|
||||
dev->frontend.set_offset(0, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(1, (top + bottom) / 2);
|
||||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||
|
||||
/* scan with no move */
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
|
@ -3266,27 +3261,29 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
char fn[30];
|
||||
snprintf(fn, 30, "gl847_offset%03d.pnm", dev->frontend.offset[1]);
|
||||
snprintf(fn, 30, "gl847_offset%03d.pnm", dev->frontend.get_offset(1));
|
||||
sanei_genesys_write_pnm_file(fn, second_line.data(), bpp, channels, pixels, lines);
|
||||
}
|
||||
|
||||
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]);
|
||||
DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1));
|
||||
|
||||
/* compute new boundaries */
|
||||
if (topavg == avg)
|
||||
{
|
||||
topavg = avg;
|
||||
top = dev->frontend.offset[1];
|
||||
top = dev->frontend.get_offset(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bottomavg = avg;
|
||||
bottom = dev->frontend.offset[1];
|
||||
bottom = dev->frontend.get_offset(1);
|
||||
}
|
||||
}
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
|
||||
dev->frontend.offset[1], dev->frontend.offset[2]);
|
||||
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
|
||||
dev->frontend.get_offset(0),
|
||||
dev->frontend.get_offset(1),
|
||||
dev->frontend.get_offset(2));
|
||||
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -3408,25 +3405,28 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
code = 255;
|
||||
else if (code < 0)
|
||||
code = 0;
|
||||
dev->frontend.gain[j] = code;
|
||||
dev->frontend.set_gain(j, code);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j],
|
||||
dev->frontend.gain[j]);
|
||||
dev->frontend.get_gain(j));
|
||||
}
|
||||
|
||||
if (dev->model->is_cis)
|
||||
{
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[1])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
if (dev->frontend.gain[0] > dev->frontend.gain[2])
|
||||
dev->frontend.gain[0] = dev->frontend.gain[2];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1] = dev->frontend.gain[0];
|
||||
if (dev->model->is_cis) {
|
||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||
if (gain0 > dev->frontend.get_gain(1)) {
|
||||
gain0 = dev->frontend.get_gain(1);
|
||||
}
|
||||
if (gain0 > dev->frontend.get_gain(2)) {
|
||||
gain0 = dev->frontend.get_gain(2);
|
||||
}
|
||||
dev->frontend.set_gain(0, gain0);
|
||||
dev->frontend.set_gain(1, gain0);
|
||||
dev->frontend.set_gain(2, gain0);
|
||||
}
|
||||
|
||||
if (channels == 1)
|
||||
{
|
||||
dev->frontend.gain[0] = dev->frontend.gain[1];
|
||||
dev->frontend.gain[2] = dev->frontend.gain[1];
|
||||
if (channels == 1) {
|
||||
dev->frontend.set_gain(0, dev->frontend.get_gain(1));
|
||||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
RIE (gl847_stop_action (dev));
|
||||
|
|
|
@ -380,36 +380,6 @@ private:
|
|||
std::vector<GenesysRegister> registers_;
|
||||
};
|
||||
|
||||
/** @brief Data structure to set up analog frontend.
|
||||
* The analog frontend converts analog value from image sensor to
|
||||
* digital value. It has its own control registers which are set up
|
||||
* with this structure. The values are written using sanei_genesys_fe_write_data.
|
||||
* The actual register addresses they map to depends on the frontend used.
|
||||
* @see sanei_genesys_fe_write_data
|
||||
*/
|
||||
struct Genesys_Frontend
|
||||
{
|
||||
Genesys_Frontend() = default;
|
||||
|
||||
// id of the frontend description
|
||||
uint8_t fe_id = 0;
|
||||
|
||||
// values to set up frontend control register, they usually map to analog register 0x00 to 0x03
|
||||
std::array<uint8_t, 4> reg = {};
|
||||
|
||||
// sets the sign of the digital value
|
||||
std::array<uint8_t, 3> sign = {};
|
||||
|
||||
// amplification to apply to signal, most often maps to frontend register 0x28-0x2a
|
||||
std::array<uint8_t, 3> offset = {};
|
||||
|
||||
// amplification to apply to signal, most often maps to frontend register 0x28-0x2a
|
||||
std::array<uint8_t, 3> gain = {};
|
||||
|
||||
// extra control registers
|
||||
std::array<uint8_t, 3> reg2 = {};
|
||||
};
|
||||
|
||||
template<class T, size_t Size>
|
||||
struct AssignableArray : public std::array<T, Size> {
|
||||
AssignableArray() = default;
|
||||
|
@ -523,6 +493,54 @@ private:
|
|||
std::vector<GenesysRegisterSetting> regs_;
|
||||
};
|
||||
|
||||
struct GenesysFrontendLayout
|
||||
{
|
||||
std::array<uint16_t, 3> offset_addr = {};
|
||||
std::array<uint16_t, 3> gain_addr = {};
|
||||
};
|
||||
|
||||
/** @brief Data structure to set up analog frontend.
|
||||
The analog frontend converts analog value from image sensor to digital value. It has its own
|
||||
control registers which are set up with this structure. The values are written using
|
||||
sanei_genesys_fe_write_data.
|
||||
*/
|
||||
struct Genesys_Frontend
|
||||
{
|
||||
Genesys_Frontend() = default;
|
||||
|
||||
// id of the frontend description
|
||||
uint8_t fe_id = 0;
|
||||
|
||||
// all registers of the frontend
|
||||
GenesysRegisterSettingSet regs;
|
||||
|
||||
// extra control registers
|
||||
std::array<uint8_t, 3> reg2 = {};
|
||||
|
||||
GenesysFrontendLayout layout;
|
||||
|
||||
void set_offset(unsigned which, uint8_t value)
|
||||
{
|
||||
regs.set_value(layout.offset_addr[which], value);
|
||||
}
|
||||
|
||||
void set_gain(unsigned which, uint8_t value)
|
||||
{
|
||||
regs.set_value(layout.gain_addr[which], value);
|
||||
}
|
||||
|
||||
uint8_t get_offset(unsigned which) const
|
||||
{
|
||||
return regs.get_value(layout.offset_addr[which]);
|
||||
}
|
||||
|
||||
uint8_t get_gain(unsigned which) const
|
||||
{
|
||||
return regs.get_value(layout.gain_addr[which]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct SensorExposure {
|
||||
uint16_t red, green, blue;
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue