kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-cleanup' into 'master'
genesys: Various cleanups See merge request sane-project/backends!94merge-requests/93/head
commit
0fc4eb80e3
|
@ -2895,14 +2895,16 @@ genesys_send_shading_coefficient(Genesys_Device * dev, const Genesys_Sensor& sen
|
|||
case CCD_HP3670:
|
||||
case CCD_HP2400:
|
||||
target_code = 0xe000;
|
||||
/* offset is cksel dependent, but we can't use this in common code */
|
||||
// offset is dependent on ccd_pixels_per_system_pixel(), but we couldn't use this in
|
||||
// common code previously.
|
||||
// FIXME: use sensor.ccd_pixels_per_system_pixel()
|
||||
if(dev->settings.xres<=300)
|
||||
{
|
||||
o = -10; /* OK for <=300 */
|
||||
o = -10;
|
||||
}
|
||||
else if(dev->settings.xres<=600)
|
||||
{
|
||||
o = -6; /* ok at 600 */
|
||||
o = -6;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -51,9 +51,6 @@ usb 0x04a9 0x1909
|
|||
# Canon LiDE 200
|
||||
usb 0x04a9 0x1905
|
||||
|
||||
# Canon 5600F
|
||||
usb 0x04a9 0x1906
|
||||
|
||||
# Canon LiDE 700F
|
||||
usb 0x04a9 0x1907
|
||||
|
||||
|
@ -66,7 +63,7 @@ usb 0x04a9 0x190e
|
|||
# Canon LiDE 220
|
||||
usb 0x04a9 0x190f
|
||||
|
||||
# Canon 5600f
|
||||
# Canon 5600F
|
||||
usb 0x04a9 0x1906
|
||||
|
||||
# Canon 8600F
|
||||
|
|
|
@ -995,8 +995,8 @@ gl124_init_optical_regs_scan (Genesys_Device * dev,
|
|||
int flags)
|
||||
{
|
||||
unsigned int words_per_line, segcnt;
|
||||
unsigned int startx, endx, used_pixels, segnb;
|
||||
unsigned int dpiset, cksel, dpihw, factor;
|
||||
unsigned int startx, endx, segnb;
|
||||
unsigned int dpiset, dpihw, factor;
|
||||
unsigned int bytes;
|
||||
GenesysRegister *r;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
@ -1006,31 +1006,29 @@ gl124_init_optical_regs_scan (Genesys_Device * dev,
|
|||
"half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth,
|
||||
half_ccd, flags);
|
||||
|
||||
/* resolution is divided according to CKSEL */
|
||||
r = sanei_genesys_get_address (reg, REG18);
|
||||
cksel= (r->value & REG18_CKSEL)+1;
|
||||
DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel);
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel
|
||||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||
DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel);
|
||||
|
||||
/* to manage high resolution device while keeping good
|
||||
* low resolution scanning speed, we make hardware dpi vary */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, used_res * cksel);
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, used_res * ccd_pixels_per_system_pixel);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
/* sensor parameters */
|
||||
gl124_setup_sensor(dev, sensor, reg, dpihw, half_ccd);
|
||||
dpiset = used_res * cksel;
|
||||
dpiset = used_res * ccd_pixels_per_system_pixel;
|
||||
|
||||
/* start and end coordinate in optical dpi coordinates */
|
||||
/* startx = start/cksel + sensor.dummy_pixel; XXX STEF XXX */
|
||||
startx = start/cksel;
|
||||
used_pixels=pixels/cksel;
|
||||
endx = startx + used_pixels;
|
||||
/* startx = start / ccd_pixels_per_system_pixel + sensor.dummy_pixel; XXX STEF XXX */
|
||||
startx = start / ccd_pixels_per_system_pixel;
|
||||
endx = startx + pixels / ccd_pixels_per_system_pixel;
|
||||
|
||||
/* pixel coordinate factor correction when used dpihw is not maximal one */
|
||||
startx/=factor;
|
||||
endx/=factor;
|
||||
used_pixels=endx-startx;
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
status = gl124_set_fe(dev, sensor, AFE_SET);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -2279,10 +2277,8 @@ gl124_init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBGSTART;
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) {
|
||||
|
@ -2296,7 +2292,7 @@ gl124_init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor
|
|||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / cksel;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
|
@ -2319,7 +2315,7 @@ gl124_init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor
|
|||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -3109,7 +3105,6 @@ gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
/* coarse gain calibration is always done in color mode */
|
||||
channels = 3;
|
||||
|
||||
/* follow CKSEL */
|
||||
if(dev->settings.xres<sensor.optical_res)
|
||||
{
|
||||
coeff=0.9;
|
||||
|
|
|
@ -3654,12 +3654,9 @@ gl841_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBGSTART;
|
||||
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||
channels = 3;
|
||||
|
@ -3672,7 +3669,7 @@ gl841_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / cksel; /* XXX STEF XXX !!! */
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
|
@ -3693,7 +3690,7 @@ gl841_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
}
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
||||
status = sanei_genesys_bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
|
|
@ -279,6 +279,16 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG (0x01, 0x00);
|
||||
SETREG (0x02, 0x78);
|
||||
SETREG (0x03, 0x1f);
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x03, 0x1d);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x03, 0x1c);
|
||||
}
|
||||
|
||||
SETREG (0x04, 0x10);
|
||||
|
||||
// fine tune upon device description
|
||||
|
@ -309,17 +319,48 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
|
||||
// TODO: on 8600F the windows driver turns off GAIN4 which is recommended
|
||||
SETREG (0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0x06, 0xf0); /* SCANMOD=111, PWRBIT and no GAIN4 */
|
||||
}
|
||||
|
||||
SETREG (0x08, 0x00);
|
||||
SETREG (0x09, 0x00);
|
||||
SETREG (0x0a, 0x00);
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x0a, 0x18);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x0a, 0x10);
|
||||
}
|
||||
|
||||
// This register controls clock and RAM settings and is further modified in
|
||||
// gl843_boot
|
||||
SETREG (0x0b, 0x6a);
|
||||
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0x0b, 0x69); // 16M only
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F) {
|
||||
SETREG(0x0b, 0x89);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x0b, 0x89);
|
||||
SETREG(0x0b, 0x69);
|
||||
}
|
||||
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG (0x0c, 0x00);
|
||||
}
|
||||
|
||||
// EXPR[0:15], EXPG[0:15], EXPB[0:15]: Exposure time settings.
|
||||
|
@ -329,12 +370,22 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG(0x13, 0x00); // SENSOR_DEF
|
||||
SETREG(0x14, 0x00); // SENSOR_DEF
|
||||
SETREG(0x15, 0x00); // SENSOR_DEF
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
dev->reg.set16(REG_EXPR, 0x9c40);
|
||||
dev->reg.set16(REG_EXPG, 0x9c40);
|
||||
dev->reg.set16(REG_EXPB, 0x9c40);
|
||||
dev->reg.set16(REG_EXPR, 0x9c40);
|
||||
dev->reg.set16(REG_EXPG, 0x9c40);
|
||||
dev->reg.set16(REG_EXPB, 0x9c40);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
dev->reg.set16(REG_EXPR, 0x2c09);
|
||||
dev->reg.set16(REG_EXPG, 0x22b8);
|
||||
dev->reg.set16(REG_EXPB, 0x10f0);
|
||||
}
|
||||
|
||||
// CCD signal settings.
|
||||
SETREG(0x16, 0x33); // SENSOR_DEF
|
||||
SETREG(0x17, 0x1c); // SENSOR_DEF
|
||||
|
@ -349,10 +400,14 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG(0x1c, 0x20); // SENSOR_DEF
|
||||
SETREG(0x1d, 0x04); // SENSOR_DEF
|
||||
|
||||
SETREG (0x1e, 0x10);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
SETREG(0x1e, 0x10);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x1e, 0x20);
|
||||
SETREG(0x1e, 0x20);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x1e, 0xa0);
|
||||
}
|
||||
|
||||
SETREG (0x1f, 0x01);
|
||||
|
@ -363,16 +418,18 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
|
||||
SETREG (0x20, 0x10);
|
||||
SETREG (0x21, 0x04);
|
||||
SETREG (0x22, 0x01);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x22, 0xc8);
|
||||
}
|
||||
|
||||
SETREG (0x23, 0x01);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
SETREG(0x22, 0x01);
|
||||
SETREG(0x23, 0x01);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x23, 0xc8);
|
||||
SETREG(0x22, 0xc8);
|
||||
SETREG(0x23, 0xc8);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x22, 0x50);
|
||||
SETREG(0x23, 0x50);
|
||||
}
|
||||
|
||||
SETREG (0x24, 0x04);
|
||||
|
@ -438,20 +495,27 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
// 0x5b-0x5c: GMMADDR[0:15] address for gamma or motor tables download
|
||||
// SENSOR_DEF
|
||||
|
||||
// DECSEL[0:2]: The number of deceleratino steps after touching home sensor
|
||||
// STOPTIM[0:4]: The stop duration between change of directions in
|
||||
// backtracking
|
||||
SETREG (0x5e, 0x23);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x5e, 0x1f);
|
||||
// DECSEL[0:2]: The number of deceleratino steps after touching home sensor
|
||||
// STOPTIM[0:4]: The stop duration between change of directions in
|
||||
// backtracking
|
||||
SETREG(0x5e, 0x23);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0x5e, 0x3f);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x5e, 0x85);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F) {
|
||||
SETREG(0x5e, 0x1f);
|
||||
}
|
||||
|
||||
// FMOVDEC: The number of deceleration steps in table 5 for auto-go-home
|
||||
SETREG (0x5f, 0x01);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x5f, 0xf0);
|
||||
//FMOVDEC: The number of deceleration steps in table 5 for auto-go-home
|
||||
SETREG(0x5f, 0x01);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0x5f, 0xf0);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F) {
|
||||
SETREG(0x5f, 0xf0);
|
||||
}
|
||||
|
||||
// Z1MOD[0:20]
|
||||
|
@ -489,31 +553,61 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG(0x69, 64);
|
||||
}
|
||||
|
||||
// GPIO-related register bits
|
||||
SETREG (0x6b, 0x30);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
// GPIO-related register bits
|
||||
SETREG(0x6b, 0x30);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x6b, 0x72);
|
||||
SETREG(0x6b, 0x72);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x6b, 0xb1);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x6b, 0xf4);
|
||||
}
|
||||
|
||||
// 0x6c, 0x6d, 0x6e, 0x6f are set according to gpio tables. See
|
||||
// gl843_init_gpio.
|
||||
|
||||
// RSH[0:4]: The position of rising edge of CCD RS signal in cycles
|
||||
// RSL[0:4]: The position of falling edge of CCD RS signal in cycles
|
||||
// CPH[0:4]: The position of rising edge of CCD CP signal in cycles.
|
||||
// CPL[0:4]: The position of falling edge of CCD CP signal in cycles
|
||||
SETREG(0x70, 0x01); // SENSOR_DEF
|
||||
SETREG(0x71, 0x03); // SENSOR_DEF
|
||||
SETREG (0x72, 0x04);
|
||||
SETREG (0x73, 0x05);
|
||||
// RSH[0:4]: The position of rising edge of CCD RS signal in cycles
|
||||
// RSL[0:4]: The position of falling edge of CCD RS signal in cycles
|
||||
// CPH[0:4]: The position of rising edge of CCD CP signal in cycles.
|
||||
// CPL[0:4]: The position of falling edge of CCD CP signal in cycles
|
||||
SETREG(0x70, 0x01); // SENSOR_DEF
|
||||
SETREG(0x71, 0x03); // SENSOR_DEF
|
||||
SETREG(0x72, 0x04);
|
||||
SETREG(0x73, 0x05);
|
||||
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0x70, 0x01);
|
||||
SETREG(0x71, 0x03);
|
||||
SETREG(0x72, 0x01);
|
||||
SETREG(0x73, 0x03);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x70, 0x01);
|
||||
SETREG(0x71, 0x03);
|
||||
SETREG(0x72, 0x03);
|
||||
SETREG(0x73, 0x04);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F) {
|
||||
SETREG(0x70, 0x00);
|
||||
SETREG(0x71, 0x02);
|
||||
SETREG(0x72, 0x02);
|
||||
SETREG(0x73, 0x04);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x70, 0x00);
|
||||
SETREG(0x71, 0x02);
|
||||
SETREG(0x72, 0x02);
|
||||
SETREG(0x73, 0x04);
|
||||
SETREG(0x70, 0x00);
|
||||
SETREG(0x71, 0x02);
|
||||
SETREG(0x72, 0x00);
|
||||
SETREG(0x73, 0x00);
|
||||
}
|
||||
|
||||
// CK1MAP[0:17], CK3MAP[0:17], CK4MAP[0:17]: CCD clock bit mapping setting.
|
||||
|
@ -527,8 +621,11 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG(0x7b, 0x00); // SENSOR_DEF
|
||||
SETREG(0x7c, 0x55); // SENSOR_DEF
|
||||
|
||||
// various AFE settings
|
||||
SETREG(0x7d, 0x00);
|
||||
// various AFE settings
|
||||
SETREG(0x7d, 0x00);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x7d, 0x20);
|
||||
}
|
||||
|
||||
// GPOLED[x]: LED vs GPIO settings
|
||||
SETREG(0x7e, 0x00);
|
||||
|
@ -537,9 +634,21 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
// LEDCNT[0:1]: Controls led blinking and its period
|
||||
SETREG (0x7f, 0x00);
|
||||
|
||||
// VRHOME, VRMOVE, VRBACK, VRSCAN: Vref settings of the motor driver IC for
|
||||
// moving in various situations.
|
||||
SETREG (0x80, 0x00);
|
||||
// VRHOME, VRMOVE, VRBACK, VRSCAN: Vref settings of the motor driver IC for
|
||||
// moving in various situations.
|
||||
SETREG(0x80, 0x00);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0x80, 0x0c);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x80, 0x28);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x80, 0x50);
|
||||
}
|
||||
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_4400F)
|
||||
{
|
||||
|
@ -554,16 +663,17 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG (0x86, 0x00);
|
||||
}
|
||||
|
||||
SETREG (0x87, 0x00);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
SETREG(0x87, 0x00);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x87, 0x02);
|
||||
SETREG(0x87, 0x02);
|
||||
}
|
||||
|
||||
// MTRPLS[0:7]: The width of the ADF motor trigger signal pulse.
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0x94, 0xff);
|
||||
// MTRPLS[0:7]: The width of the ADF motor trigger signal pulse.
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0x94, 0xff);
|
||||
}
|
||||
|
||||
// 0x95-0x97: SCANLEN[0:19]: Controls when paper jam bit is set in sheetfed
|
||||
|
@ -579,128 +689,76 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
SETREG(0x9a, 0x00);
|
||||
SETREG(0x9b, 0x00);
|
||||
}
|
||||
|
||||
// RMADLY[0:1], MOTLAG, CMODE, STEPTIM, MULDMYLN, IFRS
|
||||
SETREG(0x9d, 0x04);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x9d, 0x08); // additionally sets the multiplier for slope tables
|
||||
// TODO: move to set for scan
|
||||
SETREG(0x98, 0x03);
|
||||
SETREG(0x99, 0x30);
|
||||
SETREG(0x9a, 0x01);
|
||||
SETREG(0x9b, 0x80);
|
||||
}
|
||||
|
||||
// RMADLY[0:1], MOTLAG, CMODE, STEPTIM, MULDMYLN, IFRS
|
||||
SETREG(0x9d, 0x04);
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0x9d, 0x08); // sets the multiplier for slope tables
|
||||
}
|
||||
|
||||
|
||||
// SEL3INV, TGSTIME[0:2], TGWTIME[0:2]
|
||||
SETREG (0x9e, 0x00); // SENSOR_DEF
|
||||
|
||||
// RFHSET[0:4]: Refresh time of SDRAM in units of 2us
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_8400F)
|
||||
{
|
||||
SETREG(0xa2, 0x1f);
|
||||
SETREG(0x9e, 0x00); // SENSOR_DEF
|
||||
}
|
||||
|
||||
// 0xa6-0xa9: controls gpio, see gl843_gpio_init
|
||||
|
||||
// GPOM9, MULSTOP[0-2], NODECEL, TB3TB1, TB5TB2, FIX16CLK.
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
// RFHSET[0:4]: Refresh time of SDRAM in units of 2us
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
SETREG(0xab, 0x00);
|
||||
SETREG(0xa2, 0x1f);
|
||||
}
|
||||
|
||||
// 0xa6-0xa9: controls gpio, see gl843_gpio_init
|
||||
|
||||
// not documented
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_4400F
|
||||
&& dev->model->model_id != MODEL_CANON_CANOSCAN_8400F)
|
||||
{
|
||||
SETREG(0xaa, 0x00);
|
||||
}
|
||||
|
||||
// GPOM9, MULSTOP[0-2], NODECEL, TB3TB1, TB5TB2, FIX16CLK.
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_8400F) {
|
||||
SETREG(0xab, 0x50);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F) {
|
||||
SETREG(0xab, 0x00);
|
||||
}
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
// BUG: this should apply to MODEL_CANON_CANOSCAN_8600F too, but due to previous bug
|
||||
// the 8400F case overwrote it
|
||||
SETREG(0xab, 0x40);
|
||||
}
|
||||
|
||||
// VRHOME[3:2], VRMOVE[3:2], VRBACK[3:2]: Vref setting of the motor driver IC
|
||||
// for various situations.
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG(0xac, 0x00);
|
||||
}
|
||||
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_8400F)
|
||||
{
|
||||
SETREG (0x0c, 0x00);
|
||||
SETREG (0x94, 0xff);
|
||||
SETREG (0xab, 0x50);
|
||||
}
|
||||
|
||||
if (dev->model->model_id != MODEL_CANON_CANOSCAN_4400F
|
||||
&& dev->model->model_id != MODEL_CANON_CANOSCAN_8400F)
|
||||
{
|
||||
SETREG (0xaa, 0x00);
|
||||
}
|
||||
|
||||
/* G4050 values */
|
||||
if (dev->model->model_id == MODEL_HP_SCANJET_G4010 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_G4050 ||
|
||||
dev->model->model_id == MODEL_HP_SCANJET_4850C)
|
||||
{
|
||||
SETREG (0x03, 0x1d);
|
||||
SETREG (0x06, 0xd0); /* SCANMOD=110, PWRBIT and no GAIN4 */
|
||||
SETREG (0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */
|
||||
SETREG (0x0a, 0x18);
|
||||
SETREG (0x0b, 0x69);
|
||||
|
||||
/* CIS exposure is used for XPA lamp movement */
|
||||
SETREG (0x10, 0x2c);
|
||||
SETREG (0x11, 0x09);
|
||||
SETREG (0x12, 0x22);
|
||||
SETREG (0x13, 0xb8);
|
||||
SETREG (0x14, 0x10);
|
||||
SETREG (0x15, 0xf0);
|
||||
|
||||
SETREG (0x6b, 0xf4);
|
||||
|
||||
SETREG (0x70, 0x00);
|
||||
SETREG (0x71, 0x02);
|
||||
SETREG (0x72, 0x00);
|
||||
SETREG (0x73, 0x00);
|
||||
|
||||
SETREG (0x80, 0x50);
|
||||
SETREG (0x9d, 0x08);
|
||||
SETREG (0xab, 0x40);
|
||||
|
||||
/* XXX STEF XXX TODO move to set for scan */
|
||||
SETREG (0x98, 0x03);
|
||||
SETREG (0x99, 0x30);
|
||||
SETREG (0x9a, 0x01);
|
||||
SETREG (0x9b, 0x80);
|
||||
SETREG (0xac, 0x00);
|
||||
}
|
||||
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_4400F)
|
||||
{
|
||||
SETREG (0x06, 0xf0); /* SCANMOD=111, PWRBIT and no GAIN4 */
|
||||
SETREG (0x0b, 0x69); /* 16M only */
|
||||
SETREG (0x1e, 0x20);
|
||||
SETREG (0x22, 0xc8);
|
||||
SETREG (0x23, 0xc8);
|
||||
SETREG (0x5e, 0x3f);
|
||||
SETREG (0x5f, 0xf0);
|
||||
SETREG (0x6b, 0x72);
|
||||
SETREG (0x72, 0x01);
|
||||
SETREG (0x73, 0x03);
|
||||
SETREG (0x80, 0x0c);
|
||||
SETREG (0x87, 0x02); /* MCLOCK -> CK4MAP */
|
||||
SETREG (0x9d, 0x08); /* STEPTIM=2 */
|
||||
SETREG (0xa2, 0x1f);
|
||||
SETREG (0xab, 0x00);
|
||||
sanei_genesys_set_double(&dev->reg,REG_EXPR,0x9c40);
|
||||
sanei_genesys_set_double(&dev->reg,REG_EXPG,0x9c40);
|
||||
sanei_genesys_set_double(&dev->reg,REG_EXPB,0x9c40);
|
||||
}
|
||||
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F)
|
||||
{
|
||||
SETREG (0x03, 0x1c);
|
||||
SETREG (0x06, 0xd0); /* SCANMOD=110, PWRBIT and no GAIN4 */
|
||||
SETREG (0x0a, 0x10);
|
||||
SETREG (0x22, 0x50);
|
||||
SETREG (0x23, 0x50);
|
||||
SETREG (0x5e, 0x85);
|
||||
SETREG (0x6b, 0xb1);
|
||||
SETREG (0x1e, 0xa0);
|
||||
SETREG (0x72, 0x03);
|
||||
SETREG (0x73, 0x04);
|
||||
SETREG (0x7d, 0x20);
|
||||
SETREG (0x80, 0x28);
|
||||
SETREG (0x87, 0x02); /* MCLOCK -> CK4MAP */
|
||||
SETREG (0x9d, 0x08); /* STEPTIM=2 */
|
||||
SETREG(0xac, 0x00);
|
||||
}
|
||||
|
||||
dev->calib_reg = dev->reg;
|
||||
|
@ -1093,11 +1151,10 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
|
|||
int flags)
|
||||
{
|
||||
unsigned int words_per_line;
|
||||
unsigned int startx, endx, used_pixels;
|
||||
unsigned int startx, endx;
|
||||
unsigned int dpiset, dpihw, factor;
|
||||
unsigned int bytes;
|
||||
unsigned int tgtime; /**> exposure time multiplier */
|
||||
unsigned int cksel; /**> clock per system pixel time in capturing image */
|
||||
GenesysRegister *r;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
||||
|
@ -1118,22 +1175,19 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
|
|||
/* sensor parameters */
|
||||
gl843_setup_sensor (dev, sensor, reg, dpihw, flags);
|
||||
|
||||
/* resolution is divided according to CKSEL which is known once sensor is set up */
|
||||
r = sanei_genesys_get_address (reg, REG18);
|
||||
cksel= (r->value & REG18_CKSEL)+1;
|
||||
DBG(DBG_io2, "%s: cksel=%d\n", __func__, cksel);
|
||||
dpiset = used_res * cksel;
|
||||
// resolution is divided according to CKSEL
|
||||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||
DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel );
|
||||
dpiset = used_res * ccd_pixels_per_system_pixel ;
|
||||
|
||||
/* start and end coordinate in optical dpi coordinates */
|
||||
startx = (start + sensor.dummy_pixel)/cksel;
|
||||
// start and end coordinate in optical dpi coordinates
|
||||
startx = (start + sensor.dummy_pixel) / ccd_pixels_per_system_pixel ;
|
||||
endx = startx + pixels / ccd_pixels_per_system_pixel;
|
||||
|
||||
used_pixels=pixels/cksel;
|
||||
endx = startx + used_pixels;
|
||||
|
||||
/* pixel coordinate factor correction when used dpihw is not maximal one */
|
||||
startx/=factor;
|
||||
endx/=factor;
|
||||
used_pixels=endx-startx;
|
||||
// pixel coordinate factor correction when used dpihw is not maximal one
|
||||
startx /= factor;
|
||||
endx /= factor;
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
/* in case of stagger we have to start at an odd coordinate */
|
||||
if ((flags & OPTICAL_FLAG_STAGGER)
|
||||
|
@ -2654,10 +2708,8 @@ gl843_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBGSTART;
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||
|
@ -2679,7 +2731,7 @@ gl843_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = sensor.optical_res / cksel; // XXX STEF XXX dpi instead of pixels!
|
||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
session.params.lines = 20;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = channels;
|
||||
|
@ -2699,7 +2751,7 @@ gl843_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -4268,7 +4320,6 @@ gl843_send_shading_data (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
uint32_t final_size, length, i;
|
||||
uint8_t *buffer;
|
||||
int count,offset;
|
||||
unsigned int cksel;
|
||||
GenesysRegister *r;
|
||||
uint16_t dpiset, strpixel, endpixel, startx, factor;
|
||||
|
||||
|
@ -4282,13 +4333,11 @@ gl843_send_shading_data (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
/* recompute STRPIXEL used shading calibration so we can
|
||||
* compute offset within data for SHDAREA case */
|
||||
r = sanei_genesys_get_address(&dev->reg, REG18);
|
||||
cksel= (r->value & REG18_CKSEL)+1;
|
||||
sanei_genesys_get_double(&dev->reg,REG_DPISET,&strpixel);
|
||||
sanei_genesys_get_double(&dev->reg,REG_DPISET,&dpiset);
|
||||
factor=sensor.optical_res/sanei_genesys_compute_dpihw(dev, sensor, dpiset);
|
||||
|
||||
/* start coordinate in optical dpi coordinates */
|
||||
startx = (sensor.dummy_pixel / cksel) / factor;
|
||||
startx = (sensor.dummy_pixel / sensor.ccd_pixels_per_system_pixel()) / factor;
|
||||
|
||||
/* current scan coordinates */
|
||||
sanei_genesys_get_double(&dev->reg,REG_STRPIXEL,&strpixel);
|
||||
|
|
|
@ -855,8 +855,7 @@ gl846_init_optical_regs_scan (Genesys_Device * dev,
|
|||
SANE_Bool half_ccd, ColorFilter color_filter, int flags)
|
||||
{
|
||||
unsigned int words_per_line;
|
||||
unsigned int startx, endx, used_pixels;
|
||||
unsigned int dpiset, dpihw,segnb,cksel,factor;
|
||||
unsigned int dpiset, dpihw, segnb, factor;
|
||||
unsigned int bytes;
|
||||
GenesysRegister *r;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
@ -865,28 +864,24 @@ gl846_init_optical_regs_scan (Genesys_Device * dev,
|
|||
"half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth,
|
||||
half_ccd, flags);
|
||||
|
||||
/* resolution is divided according to CKSEL */
|
||||
r = sanei_genesys_get_address (reg, REG18);
|
||||
cksel= (r->value & REG18_CKSEL)+1;
|
||||
DBG(DBG_io2, "%s: cksel=%d\n", __func__, cksel);
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel()
|
||||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||
DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel);
|
||||
|
||||
/* to manage high resolution device while keeping good
|
||||
* low resolution scanning speed, we make hardware dpi vary */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, used_res * cksel);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
// to manage high resolution device while keeping good low resolution scanning speed,
|
||||
// we make hardware dpi vary
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, used_res * ccd_pixels_per_system_pixel);
|
||||
factor = sensor.optical_res/dpihw;
|
||||
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
/* sensor parameters */
|
||||
Sensor_Profile* sensor_profile = get_sensor_profile(dev->model->ccd_type, dpihw);
|
||||
gl846_setup_sensor(dev, sensor, reg, dpihw);
|
||||
dpiset = used_res * cksel;
|
||||
dpiset = used_res * ccd_pixels_per_system_pixel ;
|
||||
|
||||
/* start and end coordinate in optical dpi coordinates */
|
||||
startx = start/cksel+sensor.CCD_start_xoffset;
|
||||
used_pixels=pixels/cksel;
|
||||
|
||||
/* end of sensor window */
|
||||
endx = startx + used_pixels;
|
||||
// start and end coordinate in optical dpi coordinates
|
||||
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
|
||||
unsigned endx = startx + pixels / ccd_pixels_per_system_pixel;
|
||||
|
||||
/* sensors are built from 600 dpi segments for LiDE 100/200
|
||||
* and 1200 dpi for the 700F */
|
||||
|
@ -899,11 +894,10 @@ gl846_init_optical_regs_scan (Genesys_Device * dev,
|
|||
segnb=1;
|
||||
}
|
||||
|
||||
/* compute pixel coordinate in the given dpihw space,
|
||||
* taking segments into account */
|
||||
startx/=factor*segnb;
|
||||
endx/=factor*segnb;
|
||||
dev->len=endx-startx;
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= factor*segnb;
|
||||
endx /= factor*segnb;
|
||||
dev->len = endx - startx;
|
||||
dev->dist=0;
|
||||
dev->skip=0;
|
||||
|
||||
|
@ -916,7 +910,7 @@ gl846_init_optical_regs_scan (Genesys_Device * dev,
|
|||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((dev->dist+1)&0xfffe)*(segnb-1);
|
||||
used_pixels=endx-startx;
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
status = gl846_set_fe(dev, sensor, AFE_SET);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -1911,13 +1905,9 @@ gl846_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBG(DBG_proc, "%s\n", __func__);
|
||||
|
||||
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||
channels = 3;
|
||||
|
@ -1930,7 +1920,7 @@ gl846_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / cksel;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
|
@ -1950,8 +1940,8 @@ gl846_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
return status;
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
|
|
@ -870,8 +870,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
|
|||
SANE_Bool half_ccd, ColorFilter color_filter, int flags)
|
||||
{
|
||||
unsigned int words_per_line;
|
||||
unsigned int startx, endx, used_pixels;
|
||||
unsigned int dpiset, dpihw,segnb,cksel,factor;
|
||||
unsigned dpiset, dpihw, segnb, factor;
|
||||
unsigned int bytes;
|
||||
GenesysRegister *r;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
@ -880,28 +879,24 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
|
|||
"half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth,
|
||||
half_ccd, flags);
|
||||
|
||||
/* resolution is divided according to CKSEL */
|
||||
r = sanei_genesys_get_address (reg, REG18);
|
||||
cksel= (r->value & REG18_CKSEL)+1;
|
||||
DBG(DBG_io2, "%s: cksel=%d\n", __func__, cksel);
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel()
|
||||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||
DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel);
|
||||
|
||||
/* to manage high resolution device while keeping good
|
||||
* low resolution scanning speed, we make hardware dpi vary */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, used_res * cksel);
|
||||
// to manage high resolution device while keeping good low resolution scanning speed, we make
|
||||
// hardware dpi vary
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, used_res * ccd_pixels_per_system_pixel);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
/* sensor parameters */
|
||||
Sensor_Profile* sensor_profile=get_sensor_profile(dev->model->ccd_type, dpihw);
|
||||
gl847_setup_sensor(dev, sensor, reg, dpihw);
|
||||
dpiset = used_res * cksel;
|
||||
dpiset = used_res * ccd_pixels_per_system_pixel;
|
||||
|
||||
/* start and end coordinate in optical dpi coordinates */
|
||||
startx = start/cksel+sensor.CCD_start_xoffset;
|
||||
used_pixels=pixels/cksel;
|
||||
|
||||
/* end of sensor window */
|
||||
endx = startx + used_pixels;
|
||||
// start and end coordinate in optical dpi coordinates
|
||||
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
|
||||
unsigned endx = startx + pixels / ccd_pixels_per_system_pixel;
|
||||
|
||||
/* sensors are built from 600 dpi segments for LiDE 100/200
|
||||
* and 1200 dpi for the 700F */
|
||||
|
@ -914,10 +909,9 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
|
|||
segnb=1;
|
||||
}
|
||||
|
||||
/* compute pixel coordinate in the given dpihw space,
|
||||
* taking segments into account */
|
||||
startx/=factor*segnb;
|
||||
endx/=factor*segnb;
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= factor*segnb;
|
||||
endx /= factor*segnb;
|
||||
dev->len=endx-startx;
|
||||
dev->dist=0;
|
||||
dev->skip=0;
|
||||
|
@ -931,7 +925,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
|
|||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((dev->dist+1)&0xfffe)*(segnb-1);
|
||||
used_pixels=endx-startx;
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
status = gl847_set_fe(dev, sensor, AFE_SET);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -1977,13 +1971,9 @@ gl847_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBG(DBG_proc, "%s\n", __func__);
|
||||
|
||||
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||
channels = 3;
|
||||
|
@ -1996,7 +1986,7 @@ gl847_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / cksel;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
|
@ -2017,7 +2007,7 @@ gl847_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Senso
|
|||
}
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
||||
status =
|
||||
dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
|
|
|
@ -235,8 +235,8 @@ void sanei_genesys_bulk_read_data_send_header(Genesys_Device* dev, size_t len)
|
|||
dev->model->asic_type == GENESYS_GL843) {
|
||||
outdata[0] = BULK_IN;
|
||||
outdata[1] = BULK_RAM;
|
||||
outdata[2] = VALUE_BUFFER & 0xff;
|
||||
outdata[3] = (VALUE_BUFFER >> 8) & 0xff;
|
||||
outdata[2] = 0x82; //
|
||||
outdata[3] = 0x00;
|
||||
} else {
|
||||
outdata[0] = BULK_IN;
|
||||
outdata[1] = BULK_RAM;
|
||||
|
@ -352,11 +352,13 @@ SANE_Status sanei_genesys_bulk_write_data(Genesys_Device * dev, uint8_t addr, ui
|
|||
if (dev->model->asic_type == GENESYS_GL841) {
|
||||
outdata[0] = BULK_OUT;
|
||||
outdata[1] = BULK_RAM;
|
||||
outdata[2] = VALUE_BUFFER & 0xff;
|
||||
outdata[3] = (VALUE_BUFFER >> 8) & 0xff;
|
||||
// both 0x82 and 0x00 works on GL841.
|
||||
outdata[2] = 0x82;
|
||||
outdata[3] = 0x00;
|
||||
} else {
|
||||
outdata[0] = BULK_OUT;
|
||||
outdata[1] = BULK_RAM;
|
||||
// 8600F uses 0x82, but 0x00 works too. 8400F uses 0x02 for certain transactions.
|
||||
outdata[2] = 0x00;
|
||||
outdata[3] = 0x00;
|
||||
}
|
||||
|
@ -2059,3 +2061,11 @@ void debug_dump(unsigned level, const Genesys_Current_Setup& setup)
|
|||
setup.stagger,
|
||||
setup.max_shift);
|
||||
}
|
||||
|
||||
void debug_dump(unsigned level, const Genesys_Register_Set& regs)
|
||||
{
|
||||
DBG(level, "register_set:\n");
|
||||
for (const auto& reg : regs) {
|
||||
DBG(level, " %04x=%02x\n", reg.address, reg.value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -635,6 +635,9 @@ struct Genesys_Sensor {
|
|||
|
||||
// id of the sensor description
|
||||
uint8_t sensor_id = 0;
|
||||
|
||||
// sensor resolution in CCD pixels. Note that we may read more than one CCD pixel per logical
|
||||
// pixel, see ccd_pixels_per_system_pixel()
|
||||
int optical_res = 0;
|
||||
|
||||
// the minimum and maximum resolution this sensor is usable at. -1 means that the resolution
|
||||
|
@ -682,6 +685,14 @@ struct Genesys_Sensor {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// how many CCD pixels are processed per system pixel time. This corresponds to CKSEL + 1
|
||||
unsigned ccd_pixels_per_system_pixel() const
|
||||
{
|
||||
// same on GL646, GL841, GL843, GL846, GL847, GL124
|
||||
constexpr unsigned REG_0x18_CKSEL = 0x03;
|
||||
return (custom_regs.get_value(0x18) & REG_0x18_CKSEL) + 1;
|
||||
}
|
||||
|
||||
bool operator==(const Genesys_Sensor& other) const
|
||||
{
|
||||
return sensor_id == other.sensor_id &&
|
||||
|
@ -1262,7 +1273,8 @@ struct SetupParams {
|
|||
float startx = -1;
|
||||
// start pixel in Y direction, counted according to base_ydpi
|
||||
float starty = -1;
|
||||
// the number of pixels in X direction
|
||||
// the number of pixels in X direction. Note that each logical pixel may correspond to more
|
||||
// than one CCD pixel, see CKSEL and GenesysSensor::ccd_pixels_per_system_pixel()
|
||||
unsigned pixels = NOT_SET;
|
||||
// the number of pixels in Y direction
|
||||
unsigned lines = NOT_SET;
|
||||
|
@ -2038,5 +2050,6 @@ void genesys_init_frontend_tables();
|
|||
void debug_dump(unsigned level, const Genesys_Settings& settings);
|
||||
void debug_dump(unsigned level, const SetupParams& params);
|
||||
void debug_dump(unsigned level, const Genesys_Current_Setup& setup);
|
||||
void debug_dump(unsigned level, const Genesys_Register_Set& regs);
|
||||
|
||||
#endif /* not GENESYS_LOW_H */
|
||||
|
|
Ładowanie…
Reference in New Issue