genesys: Use output_pixel_offset for CCD offsets on gl841

merge-requests/213/head^2
Povilas Kanapickas 2020-04-13 07:23:38 +03:00
rodzic 648a24830f
commit dc00ab867b
3 zmienionych plików z 79 dodań i 70 usunięć

Wyświetl plik

@ -2838,33 +2838,30 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso
{
DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size);
uint32_t length, x, pixels, i;
std::uint16_t beginpixel;
uint8_t *ptr,*src;
/* old method if no SHDAREA */
if ((dev->reg.find_reg(0x01).value & REG_0x01_SHDAREA) == 0) {
// Note that this requires the sensor pixel offset to be exactly the same as to start
// reading from dummy_pixel + 1 position.
dev->interface->write_buffer(0x3c, 0x0000, data, size);
return;
}
/* data is whole line, we extract only the part for the scanned area */
length = static_cast<std::uint32_t>(size / 3);
unsigned strpixel = dev->session.pixel_startx;
unsigned endpixel = dev->session.pixel_endx;
/* turn pixel value into bytes 2x16 bits words */
strpixel*=2*2; /* 2 words of 2 bytes */
endpixel*=2*2;
pixels=endpixel-strpixel;
// turn pixel value into bytes 2x16 bits words
pixels = dev->session.pixel_endx - dev->session.pixel_startx;
pixels *= 4;
/* shading pixel begin is start pixel minus start pixel during shading
* calibration. Currently only cases handled are full and half ccd resolution.
*/
beginpixel = sensor.ccd_start_xoffset / dev->session.ccd_size_divisor;
beginpixel += sensor.dummy_pixel + 1;
DBG(DBG_io2, "%s: ORIGIN PIXEL=%d\n", __func__, beginpixel);
beginpixel = (strpixel - beginpixel * 2 * 2) / sensor.shading_factor;
DBG(DBG_io2, "%s: BEGIN PIXEL=%d\n", __func__, beginpixel/4);
// shading pixel begin is start pixel minus start pixel during shading
// calibration. Currently only cases handled are full and half ccd resolution.
unsigned beginpixel = dev->session.params.startx * dev->session.optical_resolution /
dev->session.params.xres;
DBG(DBG_io2, "%s: ORIGIN PIXEL=%d\n", __func__, beginpixel);
beginpixel *= 4;
beginpixel /= sensor.shading_factor;
dev->interface->record_key_value("shading_offset", std::to_string(beginpixel));
dev->interface->record_key_value("shading_pixels", std::to_string(pixels));
@ -2888,7 +2885,7 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso
for(x=0;x<pixels;x+=4)
{
/* coefficient source */
src=data+x+beginpixel+i*length;
src = data + x + beginpixel + i * length;
ptr[0]=src[0];
ptr[1]=src[1];
ptr[2]=src[2];

Wyświetl plik

@ -834,13 +834,7 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
s.pixel_endx = s.pixel_startx + s.optical_pixels * s.ccd_size_divisor;
} else if (dev->model->asic_type == AsicType::GL841) {
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
s.pixel_startx = ((sensor.ccd_start_xoffset + startx) * s.optical_resolution)
/ sensor.optical_res;
s.pixel_startx += sensor.dummy_pixel + 1;
s.pixel_startx = (s.output_startx * s.optical_resolution) / s.params.xres;
s.pixel_endx = s.pixel_startx + s.optical_pixels;
} else if (dev->model->asic_type == AsicType::GL843) {

Wyświetl plik

@ -581,16 +581,17 @@ void genesys_init_sensor_tables()
unsigned register_dpihw;
unsigned register_dpiset;
unsigned shading_resolution;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 1200, 150, 600 },
{ { 100 }, 1200, 200, 600 },
{ { 150 }, 1200, 300, 600 },
{ { 200 }, 1200, 400, 600 },
{ { 300 }, 1200, 600, 600 },
{ { 600 }, 1200, 1200, 600 },
{ { 1200 }, 1200, 1200, 1200 },
{ { 75 }, 1200, 150, 600, 11 },
{ { 100 }, 1200, 200, 600, 14 },
{ { 150 }, 1200, 300, 600, 22 },
{ { 200 }, 1200, 400, 600, 29 },
{ { 300 }, 1200, 600, 600, 44 },
{ { 600 }, 1200, 1200, 600, 88 },
{ { 1200 }, 1200, 1200, 1200, 88 },
};
for (const CustomSensorSettings& setting : custom_settings) {
@ -598,6 +599,7 @@ void genesys_init_sensor_tables()
sensor.register_dpihw = setting.register_dpihw;
sensor.register_dpiset = setting.register_dpiset;
sensor.shading_resolution = setting.shading_resolution;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -813,19 +815,21 @@ void genesys_init_sensor_tables()
{
ValueFilterAny<unsigned> resolutions;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 75 },
{ { 150 }, 150 },
{ { 300 }, 300 },
{ { 600 }, 600 },
{ { 1200 }, 1200 },
{ { 75 }, 75, 1 },
{ { 150 }, 150, 3 },
{ { 300 }, 300, 7 },
{ { 600 }, 600, 14 },
{ { 1200 }, 1200, 28 },
};
for (const CustomSensorSettings& setting : custom_settings) {
sensor.resolutions = setting.resolutions;
sensor.register_dpiset = setting.register_dpiset;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -868,19 +872,21 @@ void genesys_init_sensor_tables()
{
ValueFilterAny<unsigned> resolutions;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 75 },
{ { 150 }, 150 },
{ { 300 }, 300 },
{ { 600 }, 600 },
{ { 1200 }, 1200 },
{ { 75 }, 75, 1 },
{ { 150 }, 150, 3 },
{ { 300 }, 300, 7 },
{ { 600 }, 600, 14 },
{ { 1200 }, 1200, 28 },
};
for (const CustomSensorSettings& setting : custom_settings) {
sensor.resolutions = setting.resolutions;
sensor.register_dpiset = setting.register_dpiset;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -924,18 +930,20 @@ void genesys_init_sensor_tables()
{
ValueFilterAny<unsigned> resolutions;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 75 },
{ { 150 }, 150 },
{ { 300 }, 300 },
{ { 600 }, 600 },
{ { 75 }, 75, 3 },
{ { 150 }, 150, 7 },
{ { 300 }, 300, 14 },
{ { 600 }, 600, 29 },
};
for (const CustomSensorSettings& setting : custom_settings) {
sensor.resolutions = setting.resolutions;
sensor.register_dpiset = setting.register_dpiset;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -979,18 +987,20 @@ void genesys_init_sensor_tables()
{
ValueFilterAny<unsigned> resolutions;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 150 },
{ { 150 }, 300 },
{ { 300 }, 600 },
{ { 600 }, 1200 },
{ { 75 }, 150, 3 },
{ { 150 }, 300, 7 },
{ { 300 }, 600, 14 },
{ { 600 }, 1200, 28 },
};
for (const CustomSensorSettings& setting : custom_settings) {
sensor.resolutions = setting.resolutions;
sensor.register_dpiset = setting.register_dpiset;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -1034,18 +1044,20 @@ void genesys_init_sensor_tables()
{
ValueFilterAny<unsigned> resolutions;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 150 },
{ { 150 }, 300 },
{ { 300 }, 600 },
{ { 600 }, 600 },
{ { 75 }, 150, 3 },
{ { 150 }, 300, 7 },
{ { 300 }, 600, 14 },
{ { 600 }, 600, 28 },
};
for (const CustomSensorSettings& setting : custom_settings) {
sensor.resolutions = setting.resolutions;
sensor.register_dpiset = setting.register_dpiset;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -1090,18 +1102,20 @@ void genesys_init_sensor_tables()
{
ValueFilterAny<unsigned> resolutions;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 75 },
{ { 150 }, 150 },
{ { 300 }, 300 },
{ { 600 }, 600 },
{ { 75 }, 75, 3 },
{ { 150 }, 150, 6 },
{ { 300 }, 300, 13 },
{ { 600 }, 600, 27 },
};
for (const CustomSensorSettings& setting : custom_settings) {
sensor.resolutions = setting.resolutions;
sensor.register_dpiset = setting.register_dpiset;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -3127,16 +3141,17 @@ void genesys_init_sensor_tables()
ValueFilterAny<unsigned> resolutions;
unsigned register_dpihw;
unsigned register_dpiset;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 600, 150 },
{ { 100 }, 600, 200 },
{ { 150 }, 600, 300 },
{ { 200 }, 600, 400 },
{ { 300 }, 600, 600 },
{ { 600 }, 600, 1200 },
{ { 1200 }, 1200, 1200 },
{ { 75 }, 600, 150, 11 },
{ { 100 }, 600, 200, 14 },
{ { 150 }, 600, 300, 22 },
{ { 200 }, 600, 400, 29 },
{ { 300 }, 600, 600, 44 },
{ { 600 }, 600, 1200, 88 },
{ { 1200 }, 1200, 1200, 88 },
};
for (const CustomSensorSettings& setting : custom_settings) {
@ -3144,6 +3159,7 @@ void genesys_init_sensor_tables()
sensor.register_dpihw = setting.register_dpihw;
sensor.register_dpiset = setting.register_dpiset;
sensor.shading_resolution = setting.register_dpihw;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}
@ -3647,16 +3663,17 @@ void genesys_init_sensor_tables()
unsigned register_dpiset;
unsigned shading_resolution;
unsigned shading_factor;
unsigned output_pixel_offset;
};
CustomSensorSettings custom_settings[] = {
{ { 75 }, 150, 600, 8 },
{ { 100 }, 200, 600, 6 },
{ { 150 }, 300, 600, 4 },
{ { 200 }, 400, 600, 3 },
{ { 300 }, 600, 600, 2 },
{ { 600 }, 1200, 600, 1 },
{ { 1200 }, 1200, 1200, 1 },
{ { 75 }, 150, 600, 8, 2 },
{ { 100 }, 200, 600, 6, 3 },
{ { 150 }, 300, 600, 4, 4 },
{ { 200 }, 400, 600, 3, 6 },
{ { 300 }, 600, 600, 2, 9 },
{ { 600 }, 1200, 600, 1, 17 },
{ { 1200 }, 1200, 1200, 1, 35 },
};
for (const CustomSensorSettings& setting : custom_settings) {
@ -3664,6 +3681,7 @@ void genesys_init_sensor_tables()
sensor.register_dpiset = setting.register_dpiset;
sensor.shading_resolution = setting.shading_resolution;
sensor.shading_factor = setting.shading_factor;
sensor.output_pixel_offset = setting.output_pixel_offset;
s_sensors->push_back(sensor);
}
}