kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Move GL843 sensor profiles to global sensor database
Note that gl843_setup_sensor() did not write certain registers and they weren't written to the scanner anywhere else, thus they have been excluded from the new definitions.merge-requests/81/head
rodzic
723aa2b73c
commit
8a9a4e3f71
|
@ -183,16 +183,34 @@ const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev)
|
|||
throw std::runtime_error("Given device does not have sensor defined");
|
||||
}
|
||||
|
||||
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi)
|
||||
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi,
|
||||
int scan_method)
|
||||
{
|
||||
(void) dpi; // TODO: this will be used in the future once we support multiple sensors
|
||||
return sanei_genesys_find_sensor_any(dev);
|
||||
bool is_transparency = scan_method == SCAN_METHOD_TRANSPARENCY;
|
||||
for (const auto& sensor : *s_sensors) {
|
||||
if (dev->model->ccd_type == sensor.sensor_id &&
|
||||
(sensor.min_resolution == -1 || dpi >= sensor.min_resolution) &&
|
||||
(sensor.max_resolution == -1 || dpi <= sensor.max_resolution) &&
|
||||
sensor.is_transparency == is_transparency) {
|
||||
return sensor;
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("Given device does not have sensor defined");
|
||||
}
|
||||
|
||||
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi)
|
||||
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi,
|
||||
int scan_method)
|
||||
{
|
||||
(void) dpi; // TODO: this will be used in the future once we support multiple sensors
|
||||
return sanei_genesys_find_sensor_any_for_write(dev);
|
||||
bool is_transparency = scan_method == SCAN_METHOD_TRANSPARENCY;
|
||||
for (auto& sensor : *s_sensors) {
|
||||
if (dev->model->ccd_type == sensor.sensor_id &&
|
||||
(sensor.min_resolution == -1 || dpi >= sensor.min_resolution) &&
|
||||
(sensor.max_resolution == -1 || dpi <= sensor.max_resolution) &&
|
||||
sensor.is_transparency == is_transparency) {
|
||||
return sensor;
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("Given device does not have sensor defined");
|
||||
}
|
||||
|
||||
|
||||
|
@ -3798,8 +3816,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: we should pick current sensor according to scan settings
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dev->settings.xres);
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dev->settings.xres,
|
||||
dev->settings.scan_method);
|
||||
|
||||
/* send gamma tables. They have been set to device or user value
|
||||
* when setting option value */
|
||||
|
@ -7296,7 +7314,8 @@ SANE_Status sane_start_impl(SANE_Handle handle)
|
|||
/* deskew image if required */
|
||||
if(s->val[OPT_SWDESKEW].b == SANE_TRUE)
|
||||
{
|
||||
const auto& sensor = sanei_genesys_find_sensor(s->dev, s->dev->settings.xres);
|
||||
const auto& sensor = sanei_genesys_find_sensor(s->dev, s->dev->settings.xres,
|
||||
s->dev->settings.scan_method);
|
||||
RIE(genesys_deskew(s, sensor));
|
||||
}
|
||||
|
||||
|
|
|
@ -974,11 +974,16 @@ void genesys_init_sensor_tables()
|
|||
sensor.fau_gain_white_ref = 160;
|
||||
sensor.gain_white_ref = 160;
|
||||
sensor.exposure = { 0x0000, 0x0000, 0x0000 };
|
||||
sensor.exposure_lperiod = 8000;
|
||||
sensor.custom_regs = {
|
||||
{ 0x08, 0x00 },
|
||||
{ 0x09, 0x00 },
|
||||
{ 0x0a, 0x00 },
|
||||
{ 0x0b, 0x6a },
|
||||
{ 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 },
|
||||
{ 0x77, 0x00 }, { 0x78, 0xff }, { 0x79, 0xff },
|
||||
{ 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x01 },
|
||||
{ 0x71, 0x03 },
|
||||
{ 0x9e, 0x00 },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x33 },
|
||||
{ 0x17, 0x1c },
|
||||
{ 0x18, 0x00 },
|
||||
|
@ -996,10 +1001,6 @@ void genesys_init_sensor_tables()
|
|||
{ 0x58, 0x6b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0xc0 },
|
||||
{ 0x5b, 0x00 },
|
||||
{ 0x5c, 0x00 },
|
||||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x23 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
s_sensors->push_back(sensor);
|
||||
|
@ -1016,36 +1017,173 @@ void genesys_init_sensor_tables()
|
|||
sensor.fau_gain_white_ref = 160;
|
||||
sensor.gain_white_ref = 160;
|
||||
sensor.exposure = { 0x2c09, 0x22b8, 0x10f0 };
|
||||
sensor.custom_regs = {
|
||||
{ 0x08, 0x00 },
|
||||
{ 0x09, 0x00 },
|
||||
{ 0x0a, 0x18 },
|
||||
{ 0x0b, 0x69 },
|
||||
{ 0x16, 0x33 },
|
||||
{ 0x17, 0x0c },
|
||||
{ 0x18, 0x00 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x08 },
|
||||
{ 0x52, 0x0b },
|
||||
{ 0x53, 0x0e },
|
||||
{ 0x54, 0x11 },
|
||||
{ 0x55, 0x02 },
|
||||
{ 0x56, 0x05 },
|
||||
{ 0x57, 0x08 },
|
||||
{ 0x58, 0x63 },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
{ 0x5b, 0x00 },
|
||||
{ 0x5c, 0x00 },
|
||||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x6f },
|
||||
};
|
||||
sensor.custom_regs = {};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
{
|
||||
struct CustomSensorSettings {
|
||||
int min_resolution;
|
||||
int max_resolution;
|
||||
int exposure;
|
||||
int is_transparency;
|
||||
GenesysRegisterSettingSet extra_custom_regs;
|
||||
};
|
||||
|
||||
CustomSensorSettings custom_settings[] = {
|
||||
{ -1, 600, 8016, false, {
|
||||
{ 0x74, 0x00 }, { 0x75, 0x01 }, { 0x76, 0xff },
|
||||
{ 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff },
|
||||
{ 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x00 },
|
||||
{ 0x71, 0x02 },
|
||||
{ 0x9e, 0x00 },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x33 },
|
||||
{ 0x17, 0x0c },
|
||||
{ 0x18, 0x00 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x08 },
|
||||
{ 0x52, 0x0b },
|
||||
{ 0x53, 0x0e },
|
||||
{ 0x54, 0x11 },
|
||||
{ 0x55, 0x02 },
|
||||
{ 0x56, 0x05 },
|
||||
{ 0x57, 0x08 },
|
||||
{ 0x58, 0x63 },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
}
|
||||
},
|
||||
{ 1200, 1200, 56064, false, {
|
||||
{ 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff },
|
||||
{ 0x77, 0x00 }, { 0x78, 0x01 }, { 0x79, 0xff },
|
||||
{ 0x7a, 0x00 }, { 0x7b, 0x01 }, { 0x7c, 0xff },
|
||||
{ 0x0c, 0x20 },
|
||||
{ 0x70, 0x08 },
|
||||
{ 0x71, 0x0c },
|
||||
{ 0x9e, 0xc0 },
|
||||
{ 0xaa, 0x05 },
|
||||
{ 0x16, 0x3b },
|
||||
{ 0x17, 0x0c },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x38 },
|
||||
{ 0x1b, 0x10 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x08 },
|
||||
{ 0x52, 0x02 },
|
||||
{ 0x53, 0x05 },
|
||||
{ 0x54, 0x08 },
|
||||
{ 0x55, 0x0b },
|
||||
{ 0x56, 0x0e },
|
||||
{ 0x57, 0x11 },
|
||||
{ 0x58, 0x1b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
}
|
||||
},
|
||||
{ 2400, 2400, 56064, false, {
|
||||
{ 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff },
|
||||
{ 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 },
|
||||
{ 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 },
|
||||
{ 0x0c, 0x20 },
|
||||
{ 0x70, 0x08 },
|
||||
{ 0x71, 0x0a },
|
||||
{ 0x9e, 0xc0 },
|
||||
{ 0xaa, 0x05 },
|
||||
{ 0x16, 0x3b },
|
||||
{ 0x17, 0x0c },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x38 },
|
||||
{ 0x1b, 0x10 },
|
||||
{ 0x1c, 0xc0 },
|
||||
{ 0x1d, 0x08 },
|
||||
{ 0x52, 0x02 },
|
||||
{ 0x53, 0x05 },
|
||||
{ 0x54, 0x08 },
|
||||
{ 0x55, 0x0b },
|
||||
{ 0x56, 0x0e },
|
||||
{ 0x57, 0x11 },
|
||||
{ 0x58, 0x1b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
}
|
||||
},
|
||||
{ 4800, 4800, 42752, false, {
|
||||
{ 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff },
|
||||
{ 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 },
|
||||
{ 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 },
|
||||
{ 0x0c, 0x21 },
|
||||
{ 0x70, 0x08 },
|
||||
{ 0x71, 0x0a },
|
||||
{ 0x9e, 0xc0 },
|
||||
{ 0xaa, 0x07 },
|
||||
{ 0x16, 0x3b },
|
||||
{ 0x17, 0x0c },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x38 },
|
||||
{ 0x1b, 0x10 },
|
||||
{ 0x1c, 0xc1 },
|
||||
{ 0x1d, 0x08 },
|
||||
{ 0x52, 0x02 },
|
||||
{ 0x53, 0x05 },
|
||||
{ 0x54, 0x08 },
|
||||
{ 0x55, 0x0b },
|
||||
{ 0x56, 0x0e },
|
||||
{ 0x57, 0x11 },
|
||||
{ 0x58, 0x1b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
}
|
||||
},
|
||||
{ -1, -1, 15624, true, {
|
||||
{ 0x74, 0x00 }, { 0x75, 0x1c }, { 0x76, 0x7f },
|
||||
{ 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff },
|
||||
{ 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x00 },
|
||||
{ 0x71, 0x02 },
|
||||
{ 0x9e, 0x00 },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x33 },
|
||||
{ 0x17, 0x4c },
|
||||
{ 0x18, 0x01 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x08 },
|
||||
{ 0x52, 0x0e },
|
||||
{ 0x53, 0x11 },
|
||||
{ 0x54, 0x02 },
|
||||
{ 0x55, 0x05 },
|
||||
{ 0x56, 0x08 },
|
||||
{ 0x57, 0x0b },
|
||||
{ 0x58, 0x6b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0xc0 },
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto base_custom_regs = sensor.custom_regs;
|
||||
for (const CustomSensorSettings& setting : custom_settings)
|
||||
{
|
||||
sensor.min_resolution = setting.min_resolution;
|
||||
sensor.max_resolution = setting.max_resolution;
|
||||
sensor.exposure_lperiod = setting.exposure;
|
||||
sensor.is_transparency = setting.is_transparency;
|
||||
sensor.custom_regs = base_custom_regs;
|
||||
sensor.custom_regs.merge(setting.extra_custom_regs);
|
||||
s_sensors->push_back(sensor);
|
||||
}
|
||||
}
|
||||
|
||||
sensor = Genesys_Sensor();
|
||||
sensor.sensor_id = CCD_CS4400F;
|
||||
|
@ -1060,11 +1198,16 @@ void genesys_init_sensor_tables()
|
|||
sensor.fau_gain_white_ref = 160;
|
||||
sensor.gain_white_ref = 160;
|
||||
sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 };
|
||||
sensor.exposure_lperiod = 11640;
|
||||
sensor.custom_regs = {
|
||||
{ 0x08, 0x00 },
|
||||
{ 0x09, 0x00 },
|
||||
{ 0x0a, 0x18 },
|
||||
{ 0x0b, 0x69 },
|
||||
{ 0x74, 0x00 }, { 0x75, 0xf8 }, { 0x76, 0x38 },
|
||||
{ 0x77, 0x00 }, { 0x78, 0xfc }, { 0x79, 0x00 },
|
||||
{ 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0xa4 },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x00 },
|
||||
{ 0x71, 0x02 },
|
||||
{ 0x9e, 0x2d },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x13 },
|
||||
{ 0x17, 0x0a },
|
||||
{ 0x18, 0x10 },
|
||||
|
@ -1082,10 +1225,6 @@ void genesys_init_sensor_tables()
|
|||
{ 0x58, 0x5b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
{ 0x5b, 0x00 },
|
||||
{ 0x5c, 0x00 },
|
||||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x3f },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
s_sensors->push_back(sensor);
|
||||
|
@ -1103,32 +1242,33 @@ void genesys_init_sensor_tables()
|
|||
sensor.fau_gain_white_ref = 160;
|
||||
sensor.gain_white_ref = 160;
|
||||
sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 };
|
||||
sensor.exposure_lperiod = 7200;
|
||||
sensor.custom_regs = {
|
||||
{ 0x08, 0x00 },
|
||||
{ 0x09, 0x00 },
|
||||
{ 0x0a, 0x18 },
|
||||
{ 0x0b, 0x69 },
|
||||
{ 0x16, 0x13 },
|
||||
{ 0x17, 0x0a },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x74, 0x00 }, { 0x75, 0x0e }, { 0x76, 0x3f },
|
||||
{ 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 },
|
||||
{ 0x7a, 0x01 }, { 0x7b, 0xb6 }, { 0x7c, 0xdb },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x01 },
|
||||
{ 0x71, 0x02 },
|
||||
{ 0x9e, 0x00 },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x33 },
|
||||
{ 0x17, 0x0c },
|
||||
{ 0x18, 0x13 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x6b },
|
||||
{ 0x52, 0x0a },
|
||||
{ 0x53, 0x0d },
|
||||
{ 0x54, 0x00 },
|
||||
{ 0x55, 0x03 },
|
||||
{ 0x56, 0x06 },
|
||||
{ 0x57, 0x08 },
|
||||
{ 0x58, 0x5b },
|
||||
{ 0x1d, 0x84 },
|
||||
{ 0x52, 0x0d },
|
||||
{ 0x53, 0x10 },
|
||||
{ 0x54, 0x01 },
|
||||
{ 0x55, 0x04 },
|
||||
{ 0x56, 0x07 },
|
||||
{ 0x57, 0x0a },
|
||||
{ 0x58, 0x6b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
{ 0x5b, 0x00 },
|
||||
{ 0x5c, 0x00 },
|
||||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x3f },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
s_sensors->push_back(sensor);
|
||||
|
@ -1146,34 +1286,89 @@ void genesys_init_sensor_tables()
|
|||
sensor.fau_gain_white_ref = 160;
|
||||
sensor.gain_white_ref = 160;
|
||||
sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 };
|
||||
sensor.custom_regs = {
|
||||
{ 0x08, 0x00 },
|
||||
{ 0x09, 0x00 },
|
||||
{ 0x0a, 0x00 },
|
||||
{ 0x0b, 0x00 },
|
||||
{ 0x16, 0x13 },
|
||||
{ 0x17, 0x15 },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x20 },
|
||||
{ 0x1d, 0x75 },
|
||||
{ 0x52, 0x0c },
|
||||
{ 0x53, 0x0f },
|
||||
{ 0x54, 0x00 },
|
||||
{ 0x55, 0x03 },
|
||||
{ 0x56, 0x06 },
|
||||
{ 0x57, 0x09 },
|
||||
{ 0x58, 0x6b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
{ 0x5b, 0x00 },
|
||||
{ 0x5c, 0x00 },
|
||||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x1f },
|
||||
};
|
||||
sensor.custom_regs = {};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
|
||||
{
|
||||
struct CustomSensorSettings {
|
||||
int min_resolution;
|
||||
int max_resolution;
|
||||
int exposure;
|
||||
int is_transparency;
|
||||
GenesysRegisterSettingSet extra_custom_regs;
|
||||
};
|
||||
|
||||
CustomSensorSettings custom_settings[] = {
|
||||
{ -1, 1200, 0x5dc0, false, {
|
||||
{ 0x74, 0x03 }, { 0x75, 0xf0 }, { 0x76, 0xf0 },
|
||||
{ 0x77, 0x03 }, { 0x78, 0xfe }, { 0x79, 0x00 },
|
||||
{ 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0x49 },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x00 },
|
||||
{ 0x71, 0x02 },
|
||||
{ 0x9e, 0x2d },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x13 },
|
||||
{ 0x17, 0x0a },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x6b },
|
||||
{ 0x52, 0x0c },
|
||||
{ 0x53, 0x0f },
|
||||
{ 0x54, 0x00 },
|
||||
{ 0x55, 0x03 },
|
||||
{ 0x56, 0x06 },
|
||||
{ 0x57, 0x09 },
|
||||
{ 0x58, 0x6b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
}
|
||||
},
|
||||
{ -1, 1200, 0x5dc0, true, {
|
||||
{ 0x74, 0x03 }, { 0x75, 0xf0 }, { 0x76, 0xf0 },
|
||||
{ 0x77, 0x03 }, { 0x78, 0xfe }, { 0x79, 0x00 },
|
||||
{ 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0x49 },
|
||||
{ 0x0c, 0x00 },
|
||||
{ 0x70, 0x00 },
|
||||
{ 0x71, 0x02 },
|
||||
{ 0x9e, 0x2d },
|
||||
{ 0xaa, 0x00 },
|
||||
{ 0x16, 0x13 },
|
||||
{ 0x17, 0x0a },
|
||||
{ 0x18, 0x10 },
|
||||
{ 0x19, 0x2a },
|
||||
{ 0x1a, 0x30 },
|
||||
{ 0x1b, 0x00 },
|
||||
{ 0x1c, 0x00 },
|
||||
{ 0x1d, 0x6b },
|
||||
{ 0x52, 0x0c },
|
||||
{ 0x53, 0x0f },
|
||||
{ 0x54, 0x00 },
|
||||
{ 0x55, 0x03 },
|
||||
{ 0x56, 0x06 },
|
||||
{ 0x57, 0x09 },
|
||||
{ 0x58, 0x6b },
|
||||
{ 0x59, 0x00 },
|
||||
{ 0x5a, 0x40 },
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
auto base_custom_regs = sensor.custom_regs;
|
||||
for (const CustomSensorSettings& setting : custom_settings)
|
||||
{
|
||||
sensor.min_resolution = setting.min_resolution;
|
||||
sensor.max_resolution = setting.max_resolution;
|
||||
sensor.is_transparency = setting.is_transparency;
|
||||
sensor.exposure_lperiod = setting.exposure;
|
||||
sensor.custom_regs = base_custom_regs;
|
||||
sensor.custom_regs.merge(setting.extra_custom_regs);
|
||||
s_sensors->push_back(sensor);
|
||||
}
|
||||
}
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
|
|
@ -231,138 +231,24 @@ gl843_test_motor_flag_bit (SANE_Byte val)
|
|||
return SANE_FALSE;
|
||||
}
|
||||
|
||||
/** @brief sensor profile
|
||||
* search for the database of motor profiles and get the best one. Each
|
||||
* profile is at a specific dpihw. Use first entry of table by default.
|
||||
* @param sensor_type sensor id
|
||||
* @param dpi hardware dpi for the scan
|
||||
* @param flags to select between XPA, XPA+IR or regular scan from OPTICAL_FLAGS_*
|
||||
* @return a pointer to a Sensor_Profile struct
|
||||
*/
|
||||
static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi, int flags)
|
||||
{
|
||||
unsigned int i, count;
|
||||
int idx;
|
||||
Sensor_Profile *sp;
|
||||
|
||||
if(flags & OPTICAL_FLAG_USE_XPA)
|
||||
{
|
||||
sp=xpa_sensors;
|
||||
count=sizeof(xpa_sensors)/sizeof(Sensor_Profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp=sensors;
|
||||
count=sizeof(sensors)/sizeof(Sensor_Profile);
|
||||
}
|
||||
i=0;
|
||||
idx=-1;
|
||||
while(i<count)
|
||||
{
|
||||
/* exact match */
|
||||
if(sp[i].sensor_type==sensor_type && sp[i].dpi==dpi)
|
||||
{
|
||||
return &(sp[i]);
|
||||
}
|
||||
|
||||
/* closest match */
|
||||
if(sp[i].sensor_type==sensor_type)
|
||||
{
|
||||
if(idx<0)
|
||||
{
|
||||
idx=i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sp[i].dpi>=dpi
|
||||
&& sp[i].dpi<sp[idx].dpi)
|
||||
{
|
||||
idx=i;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* default fallback */
|
||||
if(idx<0)
|
||||
{
|
||||
DBG(DBG_warn,"%s: using default sensor profile\n", __func__);
|
||||
idx=0;
|
||||
}
|
||||
|
||||
return &(sp[idx]);
|
||||
}
|
||||
|
||||
|
||||
/** copy sensor specific settings */
|
||||
static void
|
||||
gl843_setup_sensor (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set * regs, int dpi,int flags)
|
||||
{
|
||||
GenesysRegister *r;
|
||||
int i,dpihw;
|
||||
(void) dpi;
|
||||
(void) flags;
|
||||
|
||||
DBGSTART;
|
||||
DBGSTART;
|
||||
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpi);
|
||||
Sensor_Profile* sensor_profile=get_sensor_profile(dev->model->ccd_type, dpihw, flags);
|
||||
|
||||
for (i = 0; i < 0x1e - 0x16; i++)
|
||||
{
|
||||
r = sanei_genesys_get_address(regs, 0x16 + i);
|
||||
if (r)
|
||||
r->value = sensor_profile->regs_0x16_0x1d[i];
|
||||
for (const auto& custom_reg : sensor.custom_regs) {
|
||||
regs->set8(custom_reg.address, custom_reg.value);
|
||||
}
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
r = sanei_genesys_get_address (regs, 0x52 + i);
|
||||
if (r)
|
||||
r->value = sensor_profile->regs_0x52_0x5e[i];
|
||||
if (!(dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE)) {
|
||||
regs->set8(0x7d, 0x90);
|
||||
}
|
||||
|
||||
/* specific registers */
|
||||
r = sanei_genesys_get_address (regs, 0x0c);
|
||||
if (r)
|
||||
{
|
||||
r->value = sensor_profile->reg0c;
|
||||
}
|
||||
r = sanei_genesys_get_address (regs, 0x70);
|
||||
if (r)
|
||||
{
|
||||
r->value = sensor_profile->reg70;
|
||||
}
|
||||
r = sanei_genesys_get_address (regs, 0x71);
|
||||
if (r)
|
||||
{
|
||||
r->value = sensor_profile->reg71;
|
||||
}
|
||||
r = sanei_genesys_get_address (regs, 0x7d);
|
||||
if (r)
|
||||
{
|
||||
if (!(dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE))
|
||||
{
|
||||
r->value = 0x90;
|
||||
}
|
||||
}
|
||||
r = sanei_genesys_get_address (regs, 0x9e);
|
||||
if (r)
|
||||
{
|
||||
r->value = sensor_profile->reg9e;
|
||||
}
|
||||
/* undocumented register */
|
||||
r = sanei_genesys_get_address (regs, 0xaa);
|
||||
if (r)
|
||||
{
|
||||
r->value = sensor_profile->regaa;
|
||||
}
|
||||
|
||||
/* CKxMAP */
|
||||
sanei_genesys_set_triple(regs,REG_CK1MAP,sensor_profile->ck1map);
|
||||
sanei_genesys_set_triple(regs,REG_CK3MAP,sensor_profile->ck3map);
|
||||
sanei_genesys_set_triple(regs,REG_CK4MAP,sensor_profile->ck4map);
|
||||
|
||||
DBGCOMPLETED;
|
||||
DBGCOMPLETED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1150,15 +1036,6 @@ gl843_init_motor_regs_scan (Genesys_Device * dev,
|
|||
}
|
||||
|
||||
|
||||
/**@brief compute exposure to use
|
||||
* compute the sensor exposure based on target resolution
|
||||
*/
|
||||
static int gl843_compute_exposure(Genesys_Device *dev, int xres, int flags)
|
||||
{
|
||||
Sensor_Profile* sensor_profile = get_sensor_profile(dev->model->ccd_type, xres, flags);
|
||||
return sensor_profile->exposure;
|
||||
}
|
||||
|
||||
/** @brief setup optical related registers
|
||||
* start and pixels are expressed in optical sensor resolution coordinate
|
||||
* space.
|
||||
|
@ -1630,16 +1507,11 @@ static SANE_Status gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Senso
|
|||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
/* scan_step_type */
|
||||
if(session.params.flags & SCAN_FLAG_FEEDING)
|
||||
{
|
||||
exposure=gl843_compute_exposure (dev, sanei_genesys_get_lowest_ydpi(dev), oflags);
|
||||
scan_step_type=sanei_genesys_compute_step_type (gl843_motors, dev->model->motor_type, exposure);
|
||||
}
|
||||
else
|
||||
{
|
||||
exposure = gl843_compute_exposure (dev, session.output_resolution, oflags);
|
||||
scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure);
|
||||
}
|
||||
exposure = sensor.exposure_lperiod;
|
||||
if (exposure < 0) {
|
||||
throw std::runtime_error("Exposure not defined in sensor definition");
|
||||
}
|
||||
scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure);
|
||||
|
||||
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
|
||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type);
|
||||
|
@ -1793,7 +1665,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
|
||||
SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */
|
||||
int optical_res;
|
||||
int oflags;
|
||||
|
||||
DBG(DBG_info, "%s settings:\n"
|
||||
"Resolution: %ux%uDPI\n"
|
||||
|
@ -1842,13 +1713,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
start += dev->settings.tl_x;
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
/* optical flags */
|
||||
oflags=0;
|
||||
if(dev->settings.scan_method==SCAN_METHOD_TRANSPARENCY)
|
||||
{
|
||||
oflags=OPTICAL_FLAG_USE_XPA;
|
||||
}
|
||||
|
||||
startx = start;
|
||||
pixels = dev->settings.pixels;
|
||||
lines = dev->settings.lines;
|
||||
|
@ -1887,7 +1751,10 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
|
||||
/* exposure */
|
||||
exposure = gl843_compute_exposure (dev, used_res, oflags);
|
||||
exposure = sensor.exposure_lperiod;
|
||||
if (exposure < 0) {
|
||||
throw std::runtime_error("Exposure not defined in sensor definition");
|
||||
}
|
||||
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
|
||||
|
||||
/* it seems base_dpi of the G4050 motor is changed above 600 dpi*/
|
||||
|
@ -2665,7 +2532,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
local_reg = dev->reg;
|
||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||
|
||||
const auto& sensor = sanei_genesys_find_sensor_any(dev);
|
||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
|
@ -3034,8 +2901,11 @@ gl843_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
factor=sensor.optical_res/dpihw;
|
||||
resolution=dpihw;
|
||||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
||||
dev->settings.scan_method);
|
||||
|
||||
dev->calib_resolution = resolution;
|
||||
dev->calib_pixels = sensor.sensor_pixels/factor;
|
||||
dev->calib_pixels = calib_sensor.sensor_pixels/factor;
|
||||
|
||||
int flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
|
@ -3067,9 +2937,9 @@ gl843_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
session.params.scan_mode = dev->settings.scan_mode;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = flags;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
|
||||
// the pixel number may be updated to conform to scanner constraints
|
||||
dev->calib_pixels = dev->current_setup.pixels;
|
||||
|
@ -3273,8 +3143,11 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
channels = 3;
|
||||
depth = 16;
|
||||
used_res = sensor.optical_res;
|
||||
|
||||
auto& calib_sensor = sanei_genesys_find_sensor_for_write(dev, used_res,
|
||||
dev->settings.scan_method);
|
||||
num_pixels =
|
||||
(sensor.sensor_pixels * used_res) / sensor.optical_res;
|
||||
(calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
|
@ -3294,9 +3167,9 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3318,25 +3191,25 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
adjust exposure times
|
||||
*/
|
||||
|
||||
expr = sensor.exposure.red;
|
||||
expg = sensor.exposure.green;
|
||||
expb = sensor.exposure.blue;
|
||||
expr = calib_sensor.exposure.red;
|
||||
expg = calib_sensor.exposure.green;
|
||||
expb = calib_sensor.exposure.blue;
|
||||
|
||||
turn = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
sensor.exposure.red = expr;
|
||||
sensor.exposure.green = expg;
|
||||
sensor.exposure.blue = expb;
|
||||
calib_sensor.exposure.red = expr;
|
||||
calib_sensor.exposure.green = expg;
|
||||
calib_sensor.exposure.blue = expb;
|
||||
|
||||
sanei_genesys_set_exposure(dev->calib_reg, sensor.exposure);
|
||||
sanei_genesys_set_exposure(dev->calib_reg, calib_sensor.exposure);
|
||||
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE (gl843_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE (gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE (sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
|
||||
|
@ -3417,6 +3290,8 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
|
||||
DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, expr, expg, expb);
|
||||
|
||||
sensor.exposure = calib_sensor.exposure;
|
||||
|
||||
gl843_slow_back_home (dev, SANE_TRUE);
|
||||
|
||||
DBG(DBG_proc, "%s: completed\n", __func__);
|
||||
|
@ -3486,8 +3361,11 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
factor = sensor.optical_res / dpihw;
|
||||
resolution = dpihw;
|
||||
|
||||
int target_pixels = sensor.sensor_pixels / factor;
|
||||
black_pixels = sensor.black_pixels / factor;
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
||||
dev->settings.scan_method);
|
||||
|
||||
int target_pixels = calib_sensor.sensor_pixels / factor;
|
||||
black_pixels = calib_sensor.black_pixels / factor;
|
||||
|
||||
int flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
|
@ -3511,7 +3389,7 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
session.params.scan_mode = SCAN_MODE_COLOR;
|
||||
session.params.color_filter = 0;
|
||||
session.params.flags = flags;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
pixels = session.output_pixels;
|
||||
|
||||
DBG(DBG_io, "%s: dpihw =%d\n", __func__, dpihw);
|
||||
|
@ -3519,7 +3397,7 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_io, "%s: resolution =%d\n", __func__, resolution);
|
||||
DBG(DBG_io, "%s: pixels =%d\n", __func__, pixels);
|
||||
DBG(DBG_io, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
status = gl843_init_scan_regs(dev, sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3540,12 +3418,12 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.offset[i] = bottom[i];
|
||||
dev->frontend.gain[i] = 0;
|
||||
}
|
||||
RIE(gl843_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
/* scan with obttom AFE settings */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE(gl843_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
|
||||
|
@ -3569,12 +3447,12 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
top[i] = 255;
|
||||
dev->frontend.offset[i] = top[i];
|
||||
}
|
||||
RIE(gl843_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
/* scan with top AFE values */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl843_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
|
||||
|
@ -3605,12 +3483,12 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.offset[i] = (top[i] + bottom[i]) / 2;
|
||||
}
|
||||
}
|
||||
RIE(gl843_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
/* scan with no move */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl843_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
|
||||
|
@ -3723,6 +3601,9 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
flags |= SCAN_FLAG_USE_XPA;
|
||||
}
|
||||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
||||
dev->settings.scan_method);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
|
@ -3735,10 +3616,10 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
session.params.scan_mode = SCAN_MODE_COLOR;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = flags;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
pixels = session.output_pixels;
|
||||
|
||||
status = gl843_init_scan_regs(dev, sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
gl843_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -3753,8 +3634,8 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
RIE(gl843_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl843_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
|
||||
|
@ -3811,7 +3692,7 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
{PGA} = 283 * (1 - {output} / {target output})
|
||||
*/
|
||||
float gain = ((float) max[j] / (sensor.gain_white_ref*coeff));
|
||||
float gain = ((float) max[j] / (calib_sensor.gain_white_ref*coeff));
|
||||
int code = 283 * (1 - gain);
|
||||
if (code > 255)
|
||||
code = 255;
|
||||
|
@ -3871,8 +3752,11 @@ gl843_init_regs_for_warmup (Genesys_Device * dev,
|
|||
resolution=600;
|
||||
dpihw=sanei_genesys_compute_dpihw_calibration(dev, sensor, resolution);
|
||||
resolution=dpihw;
|
||||
factor=sensor.optical_res/dpihw;
|
||||
num_pixels=sensor.sensor_pixels/(factor*2);
|
||||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
||||
dev->settings.scan_method);
|
||||
factor = calib_sensor.optical_res/dpihw;
|
||||
num_pixels = calib_sensor.sensor_pixels/(factor*2);
|
||||
*total_size = num_pixels * 3 * 1;
|
||||
|
||||
*reg = dev->reg;
|
||||
|
@ -3892,9 +3776,9 @@ gl843_init_regs_for_warmup (Genesys_Device * dev,
|
|||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, sensor, reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, reg, session);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -4169,12 +4053,14 @@ gl843_search_strip (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
dpi = sanei_genesys_get_lowest_dpi(dev);
|
||||
channels = 1;
|
||||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, dpi, dev->settings.scan_method);
|
||||
|
||||
/* 10 MM */
|
||||
/* lines = (10 * dpi) / MM_PER_INCH; */
|
||||
/* shading calibation is done with dev->motor.base_ydpi */
|
||||
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
|
||||
depth = 8;
|
||||
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
|
||||
pixels = (calib_sensor.sensor_pixels * dpi) / calib_sensor.optical_res;
|
||||
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
|
||||
|
@ -4192,9 +4078,9 @@ gl843_search_strip (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
session.params.scan_mode = SCAN_MODE_GRAY;
|
||||
session.params.color_filter = 0;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_SHADING;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &local_reg, session);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -4219,7 +4105,7 @@ gl843_search_strip (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
return status;
|
||||
}
|
||||
|
||||
status = gl843_begin_scan(dev, sensor, &local_reg, SANE_TRUE);
|
||||
status = gl843_begin_scan(dev, calib_sensor, &local_reg, SANE_TRUE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -4269,7 +4155,7 @@ gl843_search_strip (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
}
|
||||
|
||||
/* now start scan */
|
||||
status = gl843_begin_scan(dev, sensor, &local_reg, SANE_TRUE);
|
||||
status = gl843_begin_scan(dev, calib_sensor, &local_reg, SANE_TRUE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status));
|
||||
|
|
|
@ -419,110 +419,6 @@ static Gpio_layout gpios[]={
|
|||
},
|
||||
};
|
||||
|
||||
/** @brief structure for sensor settings
|
||||
* this structure describes the sensor settings to use for a given
|
||||
* exposure.
|
||||
*/
|
||||
typedef struct {
|
||||
int sensor_type; /**> sensor id */
|
||||
int dpi; /**> maximum dpi for which data are valid, used only to select the sensor */
|
||||
|
||||
// exposure. The value of LPERIOD register depend on it
|
||||
int exposure;
|
||||
int ck1map; /**> CK1MAP */
|
||||
int ck3map; /**> CK2MAP */
|
||||
int ck4map; /**> CK3MAP */
|
||||
uint8_t reg0c; /**> register 0x0c value */
|
||||
uint8_t reg70; /**> register 0x70 value */
|
||||
uint8_t reg71; /**> register 0x71 value */
|
||||
uint8_t reg9e; /**> register 0x9e value */
|
||||
uint8_t regaa; /**> either undocumented or mapping to somewhere else */
|
||||
|
||||
// 0x10-0x15 define the exposure and may be modified during calibration.
|
||||
uint8_t regs_0x16_0x1d[8];
|
||||
// 0x5b-0x5c defines download address and is later overwritten
|
||||
// 0x5d is unused.
|
||||
uint8_t regs_0x52_0x5e[13];
|
||||
} Sensor_Profile;
|
||||
|
||||
/**
|
||||
* database of sensor profiles
|
||||
*/
|
||||
static Sensor_Profile xpa_sensors[]={
|
||||
{CCD_G4050 , 600, 15624, 0x001c7f, 0x03ffff, 0x03ffff, 0x00, 0x00, 0x02, 0x00, 0x00,
|
||||
{0x33, 0x4c, 0x01, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
|
||||
{0x0e, 0x11, 0x02, 0x05, 0x08, 0x0b, 0x6b, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x6f},
|
||||
},
|
||||
{
|
||||
// sensor_type
|
||||
CCD_CS8600F,
|
||||
// dpi
|
||||
4800,
|
||||
// exposure
|
||||
0x5dc0,
|
||||
// ck1map, ck3map, ck4map
|
||||
0x03f0f0, 0x03fe00, 0x009249,
|
||||
// reg0c, reg70, reg71, reg9e, regaa
|
||||
0x00, 0x00, 0x02, 0x2d, 0x00,
|
||||
// regs_0x16_0x1d
|
||||
{ 0x13, 0x0a, 0x10, 0x2a, 0x30, 0x00, 0x00, 0x6b },
|
||||
// regs_0x52_0x5e
|
||||
{ 0x0c, 0x0f, 0x00, 0x03, 0x06, 0x09, 0x6b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1f },
|
||||
}
|
||||
};
|
||||
static Sensor_Profile sensors[]={
|
||||
/* 0c 70 71 9e aa*/
|
||||
{CCD_KVSS080, 600, 8000, 0x000000, 0x00ffff, 0x03ffff, 0x00, 0x01, 0x03, 0x00, 0x00,
|
||||
/* 16 17 18 19 1a 1b 1c 1d */
|
||||
{0x33, 0x1c, 0x00, 0x2a, 0x2c, 0x00, 0x20, 0x04} ,
|
||||
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
|
||||
{0x0c, 0x0f, 0x00, 0x03, 0x06, 0x09, 0x6b, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x23},
|
||||
},
|
||||
|
||||
{CCD_G4050 , 600, 8016, 0x0001ff, 0x03ffff, 0x03ffff, 0x00, 0x00, 0x02, 0x00, 0x00,
|
||||
{0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
|
||||
{0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
|
||||
},
|
||||
|
||||
{CCD_G4050 , 1200, 56064, 0x0fffff, 0x0001ff, 0x0001ff, 0x20, 0x08, 0x0c, 0xc0, 0x05,
|
||||
{0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0x00, 0x08} ,
|
||||
{0x02, 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x1b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
|
||||
},
|
||||
|
||||
{CCD_G4050 , 2400, 56064, 0x0fffff, 0x000000, 0x000000, 0x20, 0x08, 0x0a, 0xc0, 0x05,
|
||||
{0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0xc0, 0x08} ,
|
||||
{0x02, 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x1b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
|
||||
},
|
||||
|
||||
{CCD_G4050 , 4800, 42752, 0x0fffff, 0x000000, 0x000000, 0x21, 0x08, 0x0a, 0xc0, 0x07,
|
||||
{0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0xc1, 0x08} ,
|
||||
{0x02, 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x1b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
|
||||
},
|
||||
{CCD_CS4400F, 600, 11640, 0xf838, 0xfc00, 0x92a4, 0x00, 0x00, 0x02, 0x2d, 0x00,
|
||||
{0x13, 0x0a, 0x10, 0x2a, 0x30, 0x00, 0x00, 0x6b},
|
||||
{0x0a, 0x0d, 0x00, 0x03, 0x06, 0x08, 0x5b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f},
|
||||
},
|
||||
{CCD_CS8400F, 600, 7200, 0x0e3f, 0x0000, 0x1b6db, 0x00, 0x01, 0x02, 0x00, 0x00,
|
||||
{0x33, 0x0c, 0x13, 0x2a, 0x30, 0x00, 0x00, 0x84},
|
||||
{0x0d, 0x10, 0x01, 0x04, 0x07, 0x0a, 0x6b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x85},
|
||||
},
|
||||
{
|
||||
// sensor_type
|
||||
CCD_CS8600F,
|
||||
// dpi
|
||||
4800,
|
||||
// exposure
|
||||
0x5dc0,
|
||||
// ck1map, ck3map, ck4map
|
||||
0x03f0f0, 0x03fe00, 0x009249,
|
||||
// reg0c, reg70, reg71, reg9e, regaa
|
||||
0x00, 0x00, 0x02, 0x2d, 0x00,
|
||||
// regs_0x16_0x1d
|
||||
{ 0x13, 0x0a, 0x10, 0x2a, 0x30, 0x00, 0x00, 0x6b },
|
||||
// regs_0x52_0x5e
|
||||
{ 0x0c, 0x0f, 0x00, 0x03, 0x06, 0x09, 0x6b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1f },
|
||||
}
|
||||
};
|
||||
|
||||
static uint32_t kvss080[]={44444, 34188, 32520, 29630, 26666, 24242, 22222, 19048, 16666, 15686, 14814, 14034, 12402, 11110, 8888, 7618, 6666, 5926, 5228, 4678, 4172, 3682, 3336, 3074, 2866, 2702, 2566, 2450, 2352, 2266, 2188, 2118, 2056, 2002, 1950, 1904, 1860, 1820, 1784, 1748, 1716, 1684, 1656, 1628, 1600, 1576, 1552, 1528, 1506, 1486, 1466, 1446, 1428, 1410, 1394, 1376, 1360, 1346, 1330, 1316, 1302, 1288, 1276, 1264, 1250, 1238, 1228, 1216, 1206, 1194, 1184, 1174, 1164, 1154, 1146, 1136, 1128, 1120, 1110, 1102, 1094, 1088, 1080, 1072, 1064, 1058, 1050, 1044, 1038, 1030, 1024, 1018, 1012, 1006, 1000, 994, 988, 984, 978, 972, 968, 962, 958, 952, 948, 942, 938, 934, 928, 924, 920, 916, 912, 908, 904, 900, 896, 892, 888, 884, 882, 878, 874, 870, 868, 864, 860, 858, 854, 850, 848, 844, 842, 838, 836, 832, 830, 826, 824, 822, 820, 816, 814, 812, 808, 806, 804, 802, 800, 796, 794, 792, 790, 788, 786, 784, 782, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 750, 748, 746, 744, 742, 740, 738, 736, 734, 734, 732, 730, 728, 726, 724, 724, 722, 720, 718, 716, 716, 714, 712, 710, 710, 708, 706, 704, 704, 702, 700, 698, 698, 696, 694, 694, 692, 690, 690, 688, 686, 686, 684, 682, 682, 680, 678, 678, 676, 674, 674, 672, 672, 670, 668, 668, 666, 666, 664, 662, 662, 660, 660, 658, 656, 656, 654, 654, 652, 652, 650, 650, 648, 646, 646, 644, 644, 642, 642, 640, 640, 638, 638, 636, 636, 636, 634, 634, 632, 632, 630, 630, 628, 628, 626, 626, 624, 624, 624, 622, 622, 620, 620, 618, 618, 618, 616, 616, 614, 614, 612, 612, 612, 610, 610, 608, 608, 608, 606, 606, 606, 604, 604, 602, 602, 602, 600, 600, 600, 598, 598, 596, 596, 596, 594, 594, 594, 592, 592, 592, 590, 590, 590, 588, 588, 588, 586, 586, 586, 584, 584, 584, 582, 582, 582, 590, 590, 590, 588, 588, 588, 586, 586, 586, 584, 584, 584, 582, 582, 582, 580, 580, 580, 578, 578, 578, 576, 576, 576, 576, 574, 574, 574, 572, 572, 572, 570, 570, 570, 568, 568, 568, 568, 566, 566, 566, 564, 564, 564, 562, 562, 562, 562, 560, 560, 560, 558, 558, 558, 558, 556, 556, 556, 554, 554, 554, 552, 552, 552, 552, 550, 550, 550, 548, 548, 548, 548, 546, 546, 546, 546, 544, 544, 544, 542, 542, 542, 542, 540, 540, 540, 538, 538, 538, 538, 536, 536, 536, 536, 534, 534, 534, 534, 532, 532, 532, 530, 530, 530, 530, 528, 528, 528, 528, 526, 526, 526, 526, 524, 524, 524, 524, 522, 522, 522, 522, 520, 520, 520, 520, 518, 518, 518, 516, 516, 516, 516, 514, 514, 514, 514, 514, 512, 512, 512, 512, 510, 510, 510, 510, 508, 508, 508, 508, 506, 506, 506, 506, 504, 504, 504, 504, 502, 502, 502, 502, 500, 500, 500, 500, 0};
|
||||
static uint32_t g4050_fast[]={7842,5898,4384,4258,4152,4052,3956,3864,3786,3714,3632,3564,3498,3444,3384,3324,3276,3228,3174,3128,3086,3044,3002,2968,2930,2892,2860,2824,2794,2760,2732,2704,2676,2650,2618,2594,2568,2548,2524,2500,2478,2454,2436,2414,2392,2376,2354,2338,2318,2302,2282,2266,2252,2232,2218,2202,2188,2174,2160,2142,2128,2116,2102,2088,2076,2062,2054,2040,2028,2020,2014,2008,2004,2002,2002,2002,1946,1882,1826,1770,1716,1662,1612,1568,1526,1488,1454,1422,1390,1362,1336,1310,1288,1264,1242,1222,1204,1184,1166,1150,1134,1118,1104,1090,1076,1064,1050,1038,1026,1016,1004,994,984,972,964,954,944,936,928,920,910,902,896,888,880,874,866,860,854,848,840,834,828,822,816,812,806,800,796,790,784,780,776,770,766,760,756,752,748,744,740,736,732,728,724,720,716,712,708,704,702,698,694,690,688,684,682,678,674,672,668,666,662,660,656,654,650,648,646,644,640,638,636,632,630,628,624,622,620,618,616,614,610,608,606,604,602,600,598,596,594,592,590,588,586,584,582,580,578,576,574,572,570,568,566,564,564,562,560,558,556,554,552,552,550,548,546,546,544,542,540,538,538,536,534,532,532,530,528,528,526,524,522,522,520,518,518,516,514,514,512,512,510,508,508,506,504,504,502,502,500,498,498,496,496,494,494,492,490,490,488,488,486,486,484,484,482,480,480,478,478,476,476,474,474,472,472,470,470,468,468,468,466,466,464,464,462,462,460,460,458,458,456,456,456,454,454,452,452,450,450,450,448,448,446,446,444,444,444,442,442,440,440,440,438,438,438,436,436,434,434,434,432,432,432,430,430,428,428,428,426,426,426,424,424,424,422,422,422,420,420,420,418,418,418,416,416,416,414,414,414,412,412,412,410,410,410,408,408,408,406,406,406,404,404,404,404,402,402,402,400,400,400,400,398,398,398,396,396,396,396,394,394,394,392,392,392,392,390,390,390,388,388,388,388,386,386,386,386,384,384,384,384,382,382,382,382,380,380,380,380,378,378,378,378,376,376,376,376,376,374,374,374,374,374,372,372,372,372,372,370,370,370,370,370,368,368,368,368,368,366,366,366,366,366,364,364,364,364,364,364,362,362,362,362,362,360,360,360,360,360,360,358,358,358,358,358,358,356,356,356,356,356,356,354,354,354,354,354,352,352,352,352,352,352,350,350,350,350,350,350,350,348,348,348,348,348,348,346,346,346,346,346,346,344,344,344,344,344,344,344,342,342,342,342,342,342,340,340,340,340,340,340,340,338,338,338,338,338,338,338,336,336,336,336,336,336,336,334,334,334,334,334,334,334,332,332,332,332,332,332,332,332,330,330,330,330,330,330,330,328,328,328,328,328,328,328,328,326,326,326,326,326,326,326,324,324,324,324,324,324,324,324,322,322,322,322,322,322,322,322,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320, 0};
|
||||
|
|
|
@ -477,6 +477,13 @@ public:
|
|||
|
||||
void push_back(GenesysRegisterSetting reg) { regs_.push_back(reg); }
|
||||
|
||||
void merge(const GenesysRegisterSettingSet& other)
|
||||
{
|
||||
for (const auto& reg : other) {
|
||||
set_value(reg.address, reg.value);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t get_value(uint16_t address) const
|
||||
{
|
||||
for (const auto& reg : regs_) {
|
||||
|
@ -494,7 +501,7 @@ public:
|
|||
return;
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("Unknown register");
|
||||
push_back(GenesysRegisterSetting(address, value));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -513,6 +520,15 @@ struct Genesys_Sensor {
|
|||
// id of the sensor description
|
||||
uint8_t sensor_id = 0;
|
||||
int optical_res = 0;
|
||||
|
||||
// the minimum and maximum resolution this sensor is usable at. -1 means that the resolution
|
||||
// can be any.
|
||||
int min_resolution = -1;
|
||||
int max_resolution = -1;
|
||||
|
||||
// whether the sensor is transparency sensor.
|
||||
bool is_transparency = false;
|
||||
|
||||
// half or quarter CCD mode
|
||||
bool half_ccd_mode = false;
|
||||
|
||||
|
@ -531,6 +547,8 @@ struct Genesys_Sensor {
|
|||
// red, green and blue initial exposure values
|
||||
SensorExposure exposure;
|
||||
|
||||
int exposure_lperiod = -1;
|
||||
|
||||
GenesysRegisterSettingSet custom_regs;
|
||||
|
||||
// red, green and blue gamma coefficient for default gamma tables
|
||||
|
@ -1481,8 +1499,10 @@ extern void sanei_genesys_init_structs (Genesys_Device * dev);
|
|||
|
||||
const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev);
|
||||
Genesys_Sensor& sanei_genesys_find_sensor_any_for_write(Genesys_Device* dev);
|
||||
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi);
|
||||
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi);
|
||||
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi,
|
||||
int scan_method = SCAN_METHOD_FLATBED);
|
||||
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi,
|
||||
int scan_method = SCAN_METHOD_FLATBED);
|
||||
|
||||
extern SANE_Status
|
||||
sanei_genesys_init_shading_data (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
|
|
Ładowanie…
Reference in New Issue