diff --git a/backend/rts8891.c b/backend/rts8891.c index e9fa3b40f..7cccc627e 100644 --- a/backend/rts8891.c +++ b/backend/rts8891.c @@ -118,7 +118,7 @@ /* #define FAST_INIT 1 */ -#define BUILD 2301 +#define BUILD 2401 #define MOVE_DPI 100 @@ -5392,14 +5392,751 @@ offset_calibration (struct Rts8891_Device *dev, int mode, int light) return status; } +/* + * do shading calibration + * We scan a 637 pixels by 66 linesxoffset=24 , xend=661, pixels=637 +y offset=1 , yend=67, lines =66 + */ +#ifndef UNIT_TESTING +static +#endif +SANE_Status +setup_shading_calibration (struct Rts8891_Device *dev, int mode, int *light, int *status1, SANE_Byte * regs) +{ + SANE_Status status = SANE_STATUS_GOOD; + int lines = 66; + + DBG (DBG_proc, "setup_shading_calibration: start\n"); + DBG (DBG_info, "setup_shading_calibration: sensor type is %s (%d)\n", sensor_name (dev->sensor), dev->sensor); + + /* set up registers */ + /* 0x20/0x28 0x3b/0x3f seen in logs */ + *status1 = mode; + if (dev->xdpi > 300) + { + *status1 |= 0x08; + } + + /* we default to 75 dpi then override needed registers */ + regs[0x32] = 0x20; + regs[0x33] = 0x83; + regs[0x35] = 0x0e; + regs[0x36] = 0x2c; + regs[0x3a] = 0x0e; + + regs[0xe2] = 0x05; + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; + /* regs[0xe5] = 0xdd; */ + SET_DOUBLE (regs, EXPOSURE_REG, 221); + if (dev->sensor == SENSOR_TYPE_XPA || dev->sensor == SENSOR_TYPE_4400) + { + regs[0xc0] = 0x67; + regs[0xc1] = 0x06; + regs[0xc2] = 0xe6; + regs[0xc3] = 0x98; + regs[0xc4] = 0xf9; + regs[0xc5] = 0x19; + regs[0xc6] = 0x67; + regs[0xc7] = 0x06; + regs[0xc8] = 0xe6; + regs[0xc9] = 0x01; + regs[0xca] = 0xf8; + regs[0xcb] = 0xff; + regs[0xcc] = 0x98; + regs[0xcd] = 0xf9; + regs[0xce] = 0x19; + regs[0xcf] = 0xe0; + regs[0xd0] = 0xe2; + + regs[0xd1] = 0xeb; + regs[0xd2] = 0x0c; + + regs[0xd7] = 0x10; + } + if (dev->sensor == SENSOR_TYPE_4400) + { + *light &= 0xf7; /* clear bit 3 */ + regs[0x36] = 0x29; /* 0x2c */ + regs[0x80] = 0x32; /* 0x2e */ + regs[0x81] = 0x00; /* 0x01 */ + regs[0x82] = 0x33; /* 0x2f */ + regs[0x83] = 0x00; /* 0x01 */ + regs[0x85] = 0x00; /* 0x8c */ + regs[0x86] = 0x06; /* 0x10 */ + regs[0x87] = 0x00; /* 0x18 */ + regs[0x88] = 0x06; /* 0x1b */ + regs[0x89] = 0x34; /* 0x30 */ + regs[0x8a] = 0x00; /* 0x01 */ + regs[0x8d] = 0x00; /* 0x77 */ + /* c5,c6 ?? */ + /* regs[0xd3] = 0x02; 0x0e */ + regs[0xd4] = 0x04; /* 0x10 */ + regs[0xe2] = 0x02; /* 0x05 */ + /* regs[0xe5] = 0xbb; + regs[0xe6] = 0x01; 1bb =443 */ + SET_DOUBLE (regs, EXPOSURE_REG, 443); /* 221*2+1 */ + } + if (dev->sensor == SENSOR_TYPE_4400_BARE) + { + regs[0x13] = 0x39; /* 0x20 */ + regs[0x14] = 0xf0; /* 0xf8 */ + regs[0x15] = 0x29; /* 0x28 */ + regs[0x16] = 0x0f; /* 0x07 */ + regs[0x17] = 0x10; /* 0x00 */ + regs[0x23] = 0x00; /* 0xff */ + regs[0x36] = 0x29; /* 0x2c */ + regs[0x39] = 0x00; /* 0x02 */ + regs[0xe2] = 0x02; /* 0x05 */ + SET_DOUBLE (regs, EXPOSURE_REG, 443); /* 221*2+1 */ + } + + switch (dev->xdpi) + { + case 75: + break; + + case 150: + /* X resolution related registers */ + switch (dev->sensor) + { + case SENSOR_TYPE_XPA: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_XPA for 150 dpi\n"); + regs[0x80] = 0x2b; + regs[0x81] = 0x02; /* 22b=555 */ + regs[0x82] = 0x2c; + regs[0x83] = 0x02; /* 22c=556 */ + regs[0x85] = 0x18; + regs[0x86] = 0x1b; + regs[0x87] = 0x30; + regs[0x88] = 0x30; + regs[0x89] = 0x2d; + regs[0x8a] = 0x02; /* 22d=557=3*150+107 */ + regs[0x8d] = 0xef; + regs[0xc0] = 0x00; + regs[0xc1] = 0x8e; + regs[0xc2] = 0xff; + regs[0xc3] = 0xff; + regs[0xc4] = 0x71; + regs[0xc5] = 0x00; + regs[0xc6] = 0x00; + regs[0xc7] = 0x8e; + regs[0xc8] = 0xff; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0x1f; + regs[0xcc] = 0xff; + regs[0xcd] = 0x71; + regs[0xce] = 0x00; + regs[0xcf] = 0xe6; + regs[0xd0] = 0xe8; + regs[0xd1] = 0xf6; + regs[0xd2] = 0x17; + /* regs[0xd3] = 0x0b; */ + regs[0xd4] = 0x0d; + /* regs[0xe5] = 0xe4; */ + SET_DOUBLE (regs, EXPOSURE_REG, 228); + break; + case SENSOR_TYPE_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_BARE for 150 dpi\n"); + regs[0x80] = 0x2e; + regs[0x81] = 0x01; /* 12e=302 */ + regs[0x82] = 0x2f; + regs[0x83] = 0x01; /* 12f */ + regs[0x85] = 0x8c; + regs[0x86] = 0x10; + regs[0x87] = 0x18; + regs[0x88] = 0x1b; + regs[0x89] = 0x30; + regs[0x8a] = 0x01; /* 130 */ + regs[0x8d] = 0x77; + regs[0xc0] = 0x80; + regs[0xc1] = 0x87; + regs[0xc2] = 0x7f; + regs[0xc9] = 0x00; + regs[0xcb] = 0x78; + regs[0xcc] = 0x7f; + regs[0xcd] = 0x78; + regs[0xce] = 0x80; + regs[0xcf] = 0xe6; + regs[0xd0] = 0xe8; + + regs[0xd1] = 0xf7; + regs[0xd2] = 0x00; + + /* regs[0xd3] = 0x0e; */ + regs[0xd4] = 0x10; + + /* regs[0xe5] = 0xe4; */ + SET_DOUBLE (regs, EXPOSURE_REG, 228); + break; + case SENSOR_TYPE_4400: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400 for 150 dpi\n"); + regs[0x80] = 0x2e; + regs[0x81] = 0x01; + regs[0x82] = 0x2f; + regs[0x83] = 0x01; + regs[0x85] = 0x8c; + regs[0x86] = 0x10; + regs[0x87] = 0x18; + regs[0x88] = 0x1b; + regs[0x89] = 0x30; + regs[0x8a] = 0x01; + regs[0x8d] = 0x77; + regs[0xc0] = 0x00; + regs[0xc1] = 0x8e; + regs[0xc2] = 0xff; + regs[0xc3] = 0xff; + regs[0xc4] = 0x71; + regs[0xc5] = 0x00; + regs[0xc6] = 0x00; + regs[0xc7] = 0x8e; + regs[0xc8] = 0xff; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0x1f; + regs[0xcc] = 0xff; + regs[0xcd] = 0x71; + regs[0xce] = 0x00; + regs[0xcf] = 0xe6; + regs[0xd0] = 0xe8; + regs[0xd1] = 0xf6; + regs[0xd2] = 0x17; + /* regs[0xd3] = 0x0b; */ + regs[0xd4] = 0x0d; + SET_DOUBLE (regs, EXPOSURE_REG, 457); + break; + case SENSOR_TYPE_4400_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400_BARE for 150 dpi\n"); + regs[0x13] = 0x39; /* 0x20 */ + regs[0x14] = 0xf0; /* 0xf8 */ + regs[0x15] = 0x29; /* 0x28 */ + regs[0x16] = 0x0f; /* 0x07 */ + regs[0x17] = 0x10; /* 0x00 */ + regs[0x23] = 0x00; /* 0xff */ + regs[0x36] = 0x29; /* 0x2c */ + regs[0x39] = 0x00; /* 0x02 */ + regs[0x80] = 0xb0; /* 0x32 */ + regs[0x82] = 0xb1; /* 0x33 */ + regs[0x85] = 0x46; /* 0x00 */ + regs[0x86] = 0x0b; /* 0x06 */ + regs[0x87] = 0x8c; /* 0x00 */ + regs[0x88] = 0x10; /* 0x06 */ + regs[0x89] = 0xb2; /* 0x34 */ + regs[0x8d] = 0x3b; /* 0x00 */ + regs[0xc0] = 0xff; /* 0x06 */ + regs[0xc1] = 0x0f; /* 0xe6 */ + regs[0xc2] = 0x00; /* 0x67 */ + regs[0xc9] = 0x00; /* 0x07 */ + regs[0xca] = 0x0e; /* 0x00 */ + regs[0xcb] = 0x00; /* 0xfe */ + regs[0xcc] = 0x00; /* 0xf9 */ + regs[0xcd] = 0xf0; /* 0x19 */ + regs[0xce] = 0xff; /* 0x98 */ + regs[0xcf] = 0xf5; /* 0xe8 */ + regs[0xd0] = 0xf7; /* 0xea */ + regs[0xd1] = 0xea; /* 0xf3 */ + regs[0xd2] = 0x0b; /* 0x14 */ + /* regs[0xd3] = 0x17; 0x02 */ + regs[0xd4] = 0x01; /* 0x04 */ + regs[0xe2] = 0x02; /* 0x05 */ + /* regs[0xe5] = 0x93; regs[0xe6] = 0x03; */ + SET_DOUBLE (regs, EXPOSURE_REG, 915); /* 221*2+1 */ + break; + } + break; + + case 300: + switch (dev->sensor) + { + case SENSOR_TYPE_XPA: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_XPA for 300 dpi\n"); + regs[0x80] = 0xb0; + regs[0x81] = 0x00; + regs[0x82] = 0xb1; + regs[0x83] = 0x00; + regs[0x85] = 0x46; + regs[0x86] = 0x0b; + regs[0x87] = 0x8c; + regs[0x88] = 0x10; + regs[0x89] = 0xb2; + regs[0x8a] = 0x00; + regs[0x8d] = 0x3b; + regs[0xc0] = 0x00; + regs[0xc1] = 0xff; + regs[0xc2] = 0x0f; + regs[0xc3] = 0xff; + regs[0xc4] = 0x00; + regs[0xc5] = 0xf0; + regs[0xc6] = 0x00; + regs[0xc7] = 0xff; + regs[0xc8] = 0x0f; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0xf1; + regs[0xcc] = 0xff; + regs[0xcd] = 0x00; + regs[0xce] = 0xf0; + regs[0xcf] = 0xed; + regs[0xd0] = 0xef; + regs[0xd1] = 0xe2; + regs[0xd2] = 0x03; + /* regs[0xd3] = 0x17; */ + regs[0xd4] = 0x01; + /* regs[0xe5] = 0xc9; + regs[0xe6] = 0x01; 0x01c9=457 */ + SET_DOUBLE (regs, EXPOSURE_REG, 457); + break; + case SENSOR_TYPE_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_BARE for 300 dpi\n"); + regs[0x80] = 0x2e; + regs[0x81] = 0x01; + regs[0x82] = 0x2f; + regs[0x83] = 0x01; + regs[0x85] = 0x8c; + regs[0x86] = 0x10; + regs[0x87] = 0x18; + regs[0x88] = 0x1b; + regs[0x89] = 0x30; + regs[0x8a] = 0x01; + + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; /* low nibble of 8e and 8d are proportional to + the scanned width 1de => 5100 wide scan */ + + regs[0xc0] = 0xff; + regs[0xc1] = 0x0f; + regs[0xc2] = 0x00; + regs[0xc9] = 0x00; + regs[0xca] = 0x0e; + regs[0xcb] = 0x00; + regs[0xcc] = 0x00; + regs[0xcd] = 0xf0; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + + regs[0xd1] = 0xea; + regs[0xd2] = 0x0b; + + /* regs[0xd3] = 0x17; */ + regs[0xd4] = 0x01; + /* regs[0xe5] = 0xc9; + regs[0xe6] = 0x01; 0x1c9=457 */ + SET_DOUBLE (regs, EXPOSURE_REG, 457); + break; + case SENSOR_TYPE_4400: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400 for 300 dpi\n"); + regs[0x80] = 0x2b; + regs[0x81] = 0x02; + regs[0x82] = 0x2c; + regs[0x83] = 0x02; + regs[0x85] = 0x18; + regs[0x86] = 0x1b; + regs[0x87] = 0x30; + regs[0x88] = 0x30; + regs[0x89] = 0x2d; + regs[0x8a] = 0x02; + regs[0x8d] = 0xef; + regs[0xc0] = 0x00; + regs[0xc1] = 0xff; + regs[0xc2] = 0x0f; + regs[0xc3] = 0xff; + regs[0xc4] = 0x00; + regs[0xc5] = 0xf0; + regs[0xc6] = 0x00; + regs[0xc7] = 0xff; + regs[0xc8] = 0x0f; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0xf1; + regs[0xcc] = 0xff; + regs[0xcd] = 0x00; + regs[0xce] = 0xf0; + regs[0xcf] = 0xed; + regs[0xd0] = 0xef; + regs[0xd1] = 0xe2; + regs[0xd2] = 0x03; + /* regs[0xd3] = 0x17; */ + regs[0xd4] = 0x01; + /* 0x0393 = 915 = 2*457+1 */ + SET_DOUBLE (regs, EXPOSURE_REG, 915); + break; + + case SENSOR_TYPE_4400_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400_BARE for 300 dpi\n"); + return SANE_STATUS_INVAL; + break; + } + break; + + case 600: + switch (dev->sensor) + { + case SENSOR_TYPE_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_BARE for 600 dpi\n"); + regs[0x34] = 0x10; + + regs[0x72] = 0x3a; + regs[0x73] = 0x15; + regs[0x74] = 0x62; + + regs[0x80] = 0x2b; + regs[0x81] = 0x02; + + regs[0x82] = 0x2c; + regs[0x83] = 0x02; + + regs[0x85] = 0x18; + regs[0x86] = 0x1b; + + regs[0x87] = 0x30; + regs[0x88] = 0x30; + + regs[0x89] = 0x2d; + regs[0x8a] = 0x02; + + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; /* low nibble of 8e and 8d are proportional to + the scanned width 1de => 5100 wide scan */ + regs[0xc0] = 0xff; + regs[0xc1] = 0xff; + regs[0xc2] = 0xff; + regs[0xc3] = 0x00; + regs[0xc4] = 0xf0; + regs[0xc7] = 0x0f; + regs[0xc8] = 0x00; + regs[0xcb] = 0xe0; + regs[0xcc] = 0xff; + regs[0xcd] = 0xff; + regs[0xce] = 0xff; + regs[0xcf] = 0xe9; + regs[0xd0] = 0xeb; + + regs[0xd7] = 0x14; + + /* regs[0xe5] = 0x93; + regs[0xe6] = 0x03; 0x393=915 = 457*2+1 */ + SET_DOUBLE (regs, EXPOSURE_REG, 915); + break; + + case SENSOR_TYPE_XPA: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_XPA for 600 dpi\n"); + *light &= 0xfb; /* clear bit 2 */ + regs[0x16] = 0x07; + regs[0x33] = 0x83; /* 0x86 */ + regs[0x34] = 0x10; + regs[0x50] = 0x00; /* 0x18 */ + regs[0x64] = 0x01; /* 0x02 */ + regs[0x65] = 0x20; /* 0x10 */ + regs[0x66] = 0xa6; + regs[0x6c] = 0x92; + regs[0x72] = 0x3a; + regs[0x73] = 0x15; + regs[0x74] = 0x62; + regs[0x80] = 0xb0; + regs[0x81] = 0x00; + regs[0x82] = 0xb1; + regs[0x83] = 0x00; + regs[0x85] = 0x46; + regs[0x86] = 0x0b; + regs[0x87] = 0x8c; + regs[0x88] = 0x10; + regs[0x89] = 0xb2; + regs[0x8a] = 0x00; + regs[0x8d] = 0x3b; /* 0x77 */ + regs[0x8e] = 0x60; + regs[0xc0] = 0xf8; + regs[0xc1] = 0x7f; + regs[0xc2] = 0x00; + regs[0xc3] = 0xf8; + regs[0xc4] = 0x7f; + regs[0xc5] = 0x00; + regs[0xc6] = 0xf8; + regs[0xc7] = 0x7f; + regs[0xc8] = 0x00; + regs[0xc9] = 0xff; + regs[0xca] = 0x8f; + regs[0xcb] = 0xff; + regs[0xcc] = 0x07; + regs[0xcd] = 0x80; + regs[0xce] = 0xff; + regs[0xcf] = 0xf2; + regs[0xd0] = 0xf4; + regs[0xd1] = 0xe7; + regs[0xd2] = 0x08; + regs[0xd3] = 0x0e; + regs[0xd4] = 0x10; + regs[0xd7] = 0x31; + SET_DOUBLE (regs, EXPOSURE_REG, 915); /* 0x393 */ + break; + + case SENSOR_TYPE_4400: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400 for 600 dpi\n"); + *light = 0x23; + + regs[0x13] = 0x39; + regs[0x14] = 0xf0; + regs[0x15] = 0x29; + regs[0x16] = 0x0f; + regs[0x17] = 0x10; + regs[0x23] = 0x00; + regs[0x34] = 0xf0; + regs[0x36] = 0x29; + regs[0x39] = 0x00; + regs[0x72] = 0x3a; + regs[0x73] = 0x15; + regs[0x74] = 0x62; + regs[0x80] = 0x26; + regs[0x81] = 0x04; + regs[0x82] = 0x27; + regs[0x83] = 0x04; + regs[0x85] = 0x30; + regs[0x86] = 0x30; + regs[0x87] = 0x60; + regs[0x88] = 0x5a; + regs[0x89] = 0x28; + regs[0x8a] = 0x04; + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; + regs[0xc0] = 0xf8; + regs[0xc1] = 0x7f; + regs[0xc2] = 0x00; + regs[0xc3] = 0xf8; + regs[0xc4] = 0x7f; + regs[0xc5] = 0x00; + regs[0xc6] = 0xf8; + regs[0xc7] = 0x7f; + regs[0xc8] = 0x00; + regs[0xc9] = 0xff; + regs[0xca] = 0x8f; + regs[0xcb] = 0xff; + regs[0xcc] = 0x07; + regs[0xcd] = 0x80; + regs[0xce] = 0xff; + regs[0xcf] = 0xf2; + regs[0xd0] = 0xf4; + regs[0xd1] = 0xe7; + regs[0xd2] = 0x08; + regs[0xd3] = 0x0e; + regs[0xd4] = 0x10; + regs[0xd7] = 0x31; + regs[0xe2] = 0x02; + SET_DOUBLE (regs, EXPOSURE_REG, 1832); + + break; + + case SENSOR_TYPE_4400_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400_BARE for 600 dpi\n"); + return SANE_STATUS_INVAL; + break; + } + break; + + case 1200: + switch (dev->sensor) + { + case SENSOR_TYPE_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_BARE for 1200 dpi\n"); + regs[0x34] = 0xf0; + regs[0x40] = 0xa0; + + regs[0x80] = 0x26; + regs[0x81] = 0x04; + + regs[0x82] = 0x27; + regs[0x83] = 0x04; + + regs[0x85] = 0x30; + regs[0x86] = 0x30; + + regs[0x87] = 0x60; + regs[0x88] = 0x5a; + + regs[0x89] = 0x28; + regs[0x8a] = 0x04; + + regs[0x8d] = 0xbd; + regs[0x8e] = 0x63; + + regs[0xc0] = 0xff; + regs[0xc1] = 0xff; + regs[0xc2] = 0xff; + regs[0xc4] = 0x0f; + regs[0xc5] = 0x00; + regs[0xc6] = 0x00; + regs[0xc7] = 0xf0; + regs[0xc9] = 0x00; + regs[0xca] = 0x0e; + regs[0xcb] = 0x00; + regs[0xcc] = 0xff; + regs[0xcd] = 0xff; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + regs[0xd1] = 0xea; + regs[0xd2] = 0x0b; + /* regs[0xd3] = 0x17; */ + regs[0xd4] = 0xc1; + regs[0xd7] = 0x14; + regs[0xd8] = 0xa4; + /* regs[0xe5] = 0x28; + regs[0xe6] = 0x07; 0x728=1832=915*2+2 */ + SET_DOUBLE (regs, EXPOSURE_REG, 1832); + break; + case SENSOR_TYPE_XPA: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_XPA for 1200 dpi\n"); + regs[0x34] = 0xf0; + regs[0x40] = 0xa0; + + regs[0x80] = 0x26; + regs[0x81] = 0x04; + + regs[0x82] = 0x27; + regs[0x83] = 0x04; + + regs[0x85] = 0x30; + regs[0x86] = 0x30; + + regs[0x87] = 0x60; + regs[0x88] = 0x5a; + + regs[0x89] = 0x28; + regs[0x8a] = 0x04; + + regs[0x8e] = 0x63; + + regs[0xc1] = 0xff; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + SET_DOUBLE (regs, EXPOSURE_REG, 1832); + regs[0x33] = 0x86; + regs[0x50] = 0x18; + regs[0x64] = 0x02; + regs[0x65] = 0x10; + regs[0x8d] = 0xbc; + regs[0xc0] = 0xe0; + regs[0xc2] = 0x01; + regs[0xc3] = 0x1f; + regs[0xc4] = 0x00; + regs[0xc5] = 0xfe; + regs[0xc6] = 0xff; + regs[0xc7] = 0xff; + regs[0xc8] = 0x00; + regs[0xc9] = 0x3f; + regs[0xca] = 0xfe; + regs[0xcb] = 0xff; + regs[0xcc] = 0x00; + regs[0xcd] = 0x00; + regs[0xd1] = 0xec; + regs[0xd2] = 0x0d; + /* regs[0xd3] = 0x05; */ + regs[0xd4] = 0x67; + regs[0xd7] = 0x10; + regs[0xd8] = 0x52; + break; + + case SENSOR_TYPE_4400: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400 for 1200 dpi\n"); + regs[0x13] = 0x39; + regs[0x14] = 0xf0; + regs[0x15] = 0x29; + regs[0x16] = 0x0f; + regs[0x17] = 0x10; + regs[0x23] = 0x00; + regs[0x34] = 0xf0; + regs[0x36] = 0x29; + regs[0x39] = 0x00; + regs[0x40] = 0xa0; + regs[0x80] = 0x26; + regs[0x81] = 0x04; + regs[0x82] = 0x27; + regs[0x83] = 0x04; + regs[0x85] = 0x30; + regs[0x86] = 0x30; + regs[0x87] = 0x60; + regs[0x88] = 0x5a; + regs[0x89] = 0x28; + regs[0x8a] = 0x04; + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; + regs[0xc0] = 0xe0; + regs[0xc1] = 0xff; + regs[0xc2] = 0x01; + regs[0xc3] = 0x1f; + regs[0xc4] = 0x00; + regs[0xc5] = 0xfe; + regs[0xc6] = 0xff; + regs[0xc7] = 0xff; + regs[0xc8] = 0x00; + regs[0xc9] = 0x3f; + regs[0xca] = 0xfe; + regs[0xcb] = 0xff; + regs[0xcc] = 0x00; + regs[0xcd] = 0x00; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + regs[0xd1] = 0xec; + regs[0xd2] = 0x0d; + /* regs[0xd3] = 0x05; */ + regs[0xd4] = 0x67; + regs[0xd7] = 0x10; + regs[0xd8] = 0x52; + regs[0xe2] = 0x02; + *light = 0x23; + SET_DOUBLE (regs, EXPOSURE_REG, 3665); + break; + + case SENSOR_TYPE_4400_BARE: + DBG (DBG_io, + "setup_shading_calibration: setting up SENSOR_TYPE_4400_BARE for 1200 dpi\n"); + return SANE_STATUS_INVAL; + break; + } + break; + } + + /* in logs, the driver use the computed offset minus 2 */ + sanei_rts88xx_set_offset (regs, dev->red_offset, dev->green_offset, dev->blue_offset); + sanei_rts88xx_set_gain (regs, dev->red_gain, dev->green_gain, dev->blue_gain); + sanei_rts88xx_set_scan_area (regs, 1, 1 + lines, dev->xstart, dev->xstart + dev->pixels); + + DBG (DBG_proc, "setup_shading_calibration: exit\n"); + return status; +} + /* * do shading calibration * We scan a 637 pixels by 66 linesxoffset=24 , xend=661, pixels=637 y offset=1 , yend=67, lines =66 */ static SANE_Status -shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode, - int light) +shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode, int light) { SANE_Status status = SANE_STATUS_GOOD; int width; @@ -5435,733 +6172,22 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode, "shading_calibration: failed to allocate memory for data\n"); return SANE_STATUS_NO_MEM; } - - /* set up registers */ - /* 0x20/0x28 0x3b/0x3f seen in logs */ - status1 = mode; - if (dev->xdpi > 300) + + /* set up registers */ + status=setup_shading_calibration(dev, mode, &light, &status1, dev->regs); + if (status != SANE_STATUS_GOOD) { - status1 |= 0x08; + DBG (DBG_error, "shading_calibration: failed to set up registers\n"); + free (dev->shading_data); + dev->shading_data = NULL; + free (image); + return status; } - /* we default to 75 dpi then override needed registers */ - dev->regs[0x32] = 0x20; - dev->regs[0x33] = 0x83; - dev->regs[0x35] = 0x0e; - dev->regs[0x36] = 0x2c; - dev->regs[0x3a] = 0x0e; - - dev->regs[0xe2] = 0x05; - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; - /* dev->regs[0xe5] = 0xdd; */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 221); - if (dev->sensor == SENSOR_TYPE_XPA || dev->sensor == SENSOR_TYPE_4400) - { - dev->regs[0xc0] = 0x67; - dev->regs[0xc1] = 0x06; - dev->regs[0xc2] = 0xe6; - dev->regs[0xc3] = 0x98; - dev->regs[0xc4] = 0xf9; - dev->regs[0xc5] = 0x19; - dev->regs[0xc6] = 0x67; - dev->regs[0xc7] = 0x06; - dev->regs[0xc8] = 0xe6; - dev->regs[0xc9] = 0x01; - dev->regs[0xca] = 0xf8; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x98; - dev->regs[0xcd] = 0xf9; - dev->regs[0xce] = 0x19; - dev->regs[0xcf] = 0xe0; - dev->regs[0xd0] = 0xe2; - - dev->regs[0xd1] = 0xeb; - dev->regs[0xd2] = 0x0c; - - dev->regs[0xd7] = 0x10; - } - if (dev->sensor == SENSOR_TYPE_4400) - { - light &= 0xf7; /* clear bit 3 */ - dev->regs[0x36] = 0x29; /* 0x2c */ - dev->regs[0x80] = 0x32; /* 0x2e */ - dev->regs[0x81] = 0x00; /* 0x01 */ - dev->regs[0x82] = 0x33; /* 0x2f */ - dev->regs[0x83] = 0x00; /* 0x01 */ - dev->regs[0x85] = 0x00; /* 0x8c */ - dev->regs[0x86] = 0x06; /* 0x10 */ - dev->regs[0x87] = 0x00; /* 0x18 */ - dev->regs[0x88] = 0x06; /* 0x1b */ - dev->regs[0x89] = 0x34; /* 0x30 */ - dev->regs[0x8a] = 0x00; /* 0x01 */ - dev->regs[0x8d] = 0x00; /* 0x77 */ - /* c5,c6 ?? */ - /* dev->regs[0xd3] = 0x02; 0x0e */ - dev->regs[0xd4] = 0x04; /* 0x10 */ - dev->regs[0xe2] = 0x02; /* 0x05 */ - /* dev->regs[0xe5] = 0xbb; - dev->regs[0xe6] = 0x01; 1bb =443 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 443); /* 221*2+1 */ - } - if (dev->sensor == SENSOR_TYPE_4400_BARE) - { - dev->regs[0x13] = 0x39; /* 0x20 */ - dev->regs[0x14] = 0xf0; /* 0xf8 */ - dev->regs[0x15] = 0x29; /* 0x28 */ - dev->regs[0x16] = 0x0f; /* 0x07 */ - dev->regs[0x17] = 0x10; /* 0x00 */ - dev->regs[0x23] = 0x00; /* 0xff */ - dev->regs[0x36] = 0x29; /* 0x2c */ - dev->regs[0x39] = 0x00; /* 0x02 */ - dev->regs[0xe2] = 0x02; /* 0x05 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 443); /* 221*2+1 */ - } - - switch (dev->xdpi) - { - case 75: - break; - - case 150: - /* X resolution related registers */ - switch (dev->sensor) - { - case SENSOR_TYPE_XPA: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_XPA for 150 dpi\n"); - dev->regs[0x80] = 0x2b; - dev->regs[0x81] = 0x02; /* 22b=555 */ - dev->regs[0x82] = 0x2c; - dev->regs[0x83] = 0x02; /* 22c=556 */ - dev->regs[0x85] = 0x18; - dev->regs[0x86] = 0x1b; - dev->regs[0x87] = 0x30; - dev->regs[0x88] = 0x30; - dev->regs[0x89] = 0x2d; - dev->regs[0x8a] = 0x02; /* 22d=557=3*150+107 */ - dev->regs[0x8d] = 0xef; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0x8e; - dev->regs[0xc2] = 0xff; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x71; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0x8e; - dev->regs[0xc8] = 0xff; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0x1f; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x71; - dev->regs[0xce] = 0x00; - dev->regs[0xcf] = 0xe6; - dev->regs[0xd0] = 0xe8; - dev->regs[0xd1] = 0xf6; - dev->regs[0xd2] = 0x17; - /* dev->regs[0xd3] = 0x0b; */ - dev->regs[0xd4] = 0x0d; - /* dev->regs[0xe5] = 0xe4; */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 228); - break; - case SENSOR_TYPE_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_BARE for 150 dpi\n"); - dev->regs[0x80] = 0x2e; - dev->regs[0x81] = 0x01; /* 12e=302 */ - dev->regs[0x82] = 0x2f; - dev->regs[0x83] = 0x01; /* 12f */ - dev->regs[0x85] = 0x8c; - dev->regs[0x86] = 0x10; - dev->regs[0x87] = 0x18; - dev->regs[0x88] = 0x1b; - dev->regs[0x89] = 0x30; - dev->regs[0x8a] = 0x01; /* 130 */ - dev->regs[0x8d] = 0x77; - dev->regs[0xc0] = 0x80; - dev->regs[0xc1] = 0x87; - dev->regs[0xc2] = 0x7f; - dev->regs[0xc9] = 0x00; - dev->regs[0xcb] = 0x78; - dev->regs[0xcc] = 0x7f; - dev->regs[0xcd] = 0x78; - dev->regs[0xce] = 0x80; - dev->regs[0xcf] = 0xe6; - dev->regs[0xd0] = 0xe8; - - dev->regs[0xd1] = 0xf7; - dev->regs[0xd2] = 0x00; - - /* dev->regs[0xd3] = 0x0e; */ - dev->regs[0xd4] = 0x10; - - /* dev->regs[0xe5] = 0xe4; */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 228); - break; - case SENSOR_TYPE_4400: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400 for 150 dpi\n"); - dev->regs[0x80] = 0x2e; - dev->regs[0x81] = 0x01; - dev->regs[0x82] = 0x2f; - dev->regs[0x83] = 0x01; - dev->regs[0x85] = 0x8c; - dev->regs[0x86] = 0x10; - dev->regs[0x87] = 0x18; - dev->regs[0x88] = 0x1b; - dev->regs[0x89] = 0x30; - dev->regs[0x8a] = 0x01; - dev->regs[0x8d] = 0x77; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0x8e; - dev->regs[0xc2] = 0xff; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x71; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0x8e; - dev->regs[0xc8] = 0xff; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0x1f; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x71; - dev->regs[0xce] = 0x00; - dev->regs[0xcf] = 0xe6; - dev->regs[0xd0] = 0xe8; - dev->regs[0xd1] = 0xf6; - dev->regs[0xd2] = 0x17; - /* dev->regs[0xd3] = 0x0b; */ - dev->regs[0xd4] = 0x0d; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 457); - break; - case SENSOR_TYPE_4400_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400_BARE for 150 dpi\n"); - dev->regs[0x13] = 0x39; /* 0x20 */ - dev->regs[0x14] = 0xf0; /* 0xf8 */ - dev->regs[0x15] = 0x29; /* 0x28 */ - dev->regs[0x16] = 0x0f; /* 0x07 */ - dev->regs[0x17] = 0x10; /* 0x00 */ - dev->regs[0x23] = 0x00; /* 0xff */ - dev->regs[0x36] = 0x29; /* 0x2c */ - dev->regs[0x39] = 0x00; /* 0x02 */ - dev->regs[0x80] = 0xb0; /* 0x32 */ - dev->regs[0x82] = 0xb1; /* 0x33 */ - dev->regs[0x85] = 0x46; /* 0x00 */ - dev->regs[0x86] = 0x0b; /* 0x06 */ - dev->regs[0x87] = 0x8c; /* 0x00 */ - dev->regs[0x88] = 0x10; /* 0x06 */ - dev->regs[0x89] = 0xb2; /* 0x34 */ - dev->regs[0x8d] = 0x3b; /* 0x00 */ - dev->regs[0xc0] = 0xff; /* 0x06 */ - dev->regs[0xc1] = 0x0f; /* 0xe6 */ - dev->regs[0xc2] = 0x00; /* 0x67 */ - dev->regs[0xc9] = 0x00; /* 0x07 */ - dev->regs[0xca] = 0x0e; /* 0x00 */ - dev->regs[0xcb] = 0x00; /* 0xfe */ - dev->regs[0xcc] = 0x00; /* 0xf9 */ - dev->regs[0xcd] = 0xf0; /* 0x19 */ - dev->regs[0xce] = 0xff; /* 0x98 */ - dev->regs[0xcf] = 0xf5; /* 0xe8 */ - dev->regs[0xd0] = 0xf7; /* 0xea */ - dev->regs[0xd1] = 0xea; /* 0xf3 */ - dev->regs[0xd2] = 0x0b; /* 0x14 */ - /* dev->regs[0xd3] = 0x17; 0x02 */ - dev->regs[0xd4] = 0x01; /* 0x04 */ - dev->regs[0xe2] = 0x02; /* 0x05 */ - /* regs[0xe5] = 0x93; regs[0xe6] = 0x03; */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 915); /* 221*2+1 */ - break; - } - break; - - case 300: - switch (dev->sensor) - { - case SENSOR_TYPE_XPA: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_XPA for 300 dpi\n"); - dev->regs[0x80] = 0xb0; - dev->regs[0x81] = 0x00; - dev->regs[0x82] = 0xb1; - dev->regs[0x83] = 0x00; - dev->regs[0x85] = 0x46; - dev->regs[0x86] = 0x0b; - dev->regs[0x87] = 0x8c; - dev->regs[0x88] = 0x10; - dev->regs[0x89] = 0xb2; - dev->regs[0x8a] = 0x00; - dev->regs[0x8d] = 0x3b; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0x0f; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xf0; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x0f; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0xf1; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x00; - dev->regs[0xce] = 0xf0; - dev->regs[0xcf] = 0xed; - dev->regs[0xd0] = 0xef; - dev->regs[0xd1] = 0xe2; - dev->regs[0xd2] = 0x03; - /* dev->regs[0xd3] = 0x17; */ - dev->regs[0xd4] = 0x01; - /* dev->regs[0xe5] = 0xc9; - dev->regs[0xe6] = 0x01; 0x01c9=457 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 457); - break; - case SENSOR_TYPE_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_BARE for 300 dpi\n"); - dev->regs[0x80] = 0x2e; - dev->regs[0x81] = 0x01; - dev->regs[0x82] = 0x2f; - dev->regs[0x83] = 0x01; - dev->regs[0x85] = 0x8c; - dev->regs[0x86] = 0x10; - dev->regs[0x87] = 0x18; - dev->regs[0x88] = 0x1b; - dev->regs[0x89] = 0x30; - dev->regs[0x8a] = 0x01; - - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; /* low nibble of 8e and 8d are proportional to - the scanned width 1de => 5100 wide scan */ - - dev->regs[0xc0] = 0xff; - dev->regs[0xc1] = 0x0f; - dev->regs[0xc2] = 0x00; - dev->regs[0xc9] = 0x00; - dev->regs[0xca] = 0x0e; - dev->regs[0xcb] = 0x00; - dev->regs[0xcc] = 0x00; - dev->regs[0xcd] = 0xf0; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - - dev->regs[0xd1] = 0xea; - dev->regs[0xd2] = 0x0b; - - /* dev->regs[0xd3] = 0x17; */ - dev->regs[0xd4] = 0x01; - /* dev->regs[0xe5] = 0xc9; - dev->regs[0xe6] = 0x01; 0x1c9=457 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 457); - break; - case SENSOR_TYPE_4400: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400 for 300 dpi\n"); - dev->regs[0x80] = 0x2b; - dev->regs[0x81] = 0x02; - dev->regs[0x82] = 0x2c; - dev->regs[0x83] = 0x02; - dev->regs[0x85] = 0x18; - dev->regs[0x86] = 0x1b; - dev->regs[0x87] = 0x30; - dev->regs[0x88] = 0x30; - dev->regs[0x89] = 0x2d; - dev->regs[0x8a] = 0x02; - dev->regs[0x8d] = 0xef; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0x0f; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xf0; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x0f; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0xf1; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x00; - dev->regs[0xce] = 0xf0; - dev->regs[0xcf] = 0xed; - dev->regs[0xd0] = 0xef; - dev->regs[0xd1] = 0xe2; - dev->regs[0xd2] = 0x03; - /* dev->regs[0xd3] = 0x17; */ - dev->regs[0xd4] = 0x01; - /* 0x0393 = 915 = 2*457+1 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 915); - break; - - case SENSOR_TYPE_4400_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400_BARE for 300 dpi\n"); - return SANE_STATUS_INVAL; - break; - } - break; - - case 600: - switch (dev->sensor) - { - case SENSOR_TYPE_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_BARE for 600 dpi\n"); - dev->regs[0x34] = 0x10; - - dev->regs[0x72] = 0x3a; - dev->regs[0x73] = 0x15; - dev->regs[0x74] = 0x62; - - dev->regs[0x80] = 0x2b; - dev->regs[0x81] = 0x02; - - dev->regs[0x82] = 0x2c; - dev->regs[0x83] = 0x02; - - dev->regs[0x85] = 0x18; - dev->regs[0x86] = 0x1b; - - dev->regs[0x87] = 0x30; - dev->regs[0x88] = 0x30; - - dev->regs[0x89] = 0x2d; - dev->regs[0x8a] = 0x02; - - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; /* low nibble of 8e and 8d are proportional to - the scanned width 1de => 5100 wide scan */ - dev->regs[0xc0] = 0xff; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0xff; - dev->regs[0xc3] = 0x00; - dev->regs[0xc4] = 0xf0; - dev->regs[0xc7] = 0x0f; - dev->regs[0xc8] = 0x00; - dev->regs[0xcb] = 0xe0; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0xff; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xe9; - dev->regs[0xd0] = 0xeb; - - dev->regs[0xd7] = 0x14; - - /* dev->regs[0xe5] = 0x93; - dev->regs[0xe6] = 0x03; 0x393=915 = 457*2+1 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 915); - break; - - case SENSOR_TYPE_XPA: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_XPA for 600 dpi\n"); - light &= 0xfb; /* clear bit 2 */ - dev->regs[0x16] = 0x07; - dev->regs[0x33] = 0x83; /* 0x86 */ - dev->regs[0x34] = 0x10; - dev->regs[0x50] = 0x00; /* 0x18 */ - dev->regs[0x64] = 0x01; /* 0x02 */ - dev->regs[0x65] = 0x20; /* 0x10 */ - dev->regs[0x66] = 0xa6; - dev->regs[0x6c] = 0x92; - dev->regs[0x72] = 0x3a; - dev->regs[0x73] = 0x15; - dev->regs[0x74] = 0x62; - dev->regs[0x80] = 0xb0; - dev->regs[0x81] = 0x00; - dev->regs[0x82] = 0xb1; - dev->regs[0x83] = 0x00; - dev->regs[0x85] = 0x46; - dev->regs[0x86] = 0x0b; - dev->regs[0x87] = 0x8c; - dev->regs[0x88] = 0x10; - dev->regs[0x89] = 0xb2; - dev->regs[0x8a] = 0x00; - dev->regs[0x8d] = 0x3b; /* 0x77 */ - dev->regs[0x8e] = 0x60; - dev->regs[0xc0] = 0xf8; - dev->regs[0xc1] = 0x7f; - dev->regs[0xc2] = 0x00; - dev->regs[0xc3] = 0xf8; - dev->regs[0xc4] = 0x7f; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0xf8; - dev->regs[0xc7] = 0x7f; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0x8f; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x07; - dev->regs[0xcd] = 0x80; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf2; - dev->regs[0xd0] = 0xf4; - dev->regs[0xd1] = 0xe7; - dev->regs[0xd2] = 0x08; - dev->regs[0xd3] = 0x0e; - dev->regs[0xd4] = 0x10; - dev->regs[0xd7] = 0x31; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 915); /* 0x393 */ - break; - - case SENSOR_TYPE_4400: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400 for 600 dpi\n"); - light = 0x23; - - dev->regs[0x13] = 0x39; - dev->regs[0x14] = 0xf0; - dev->regs[0x15] = 0x29; - dev->regs[0x16] = 0x0f; - dev->regs[0x17] = 0x10; - dev->regs[0x23] = 0x00; - dev->regs[0x34] = 0xf0; - dev->regs[0x36] = 0x29; - dev->regs[0x39] = 0x00; - dev->regs[0x72] = 0x3a; - dev->regs[0x73] = 0x15; - dev->regs[0x74] = 0x62; - dev->regs[0x80] = 0x26; - dev->regs[0x81] = 0x04; - dev->regs[0x82] = 0x27; - dev->regs[0x83] = 0x04; - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; - dev->regs[0x89] = 0x28; - dev->regs[0x8a] = 0x04; - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; - dev->regs[0xc0] = 0xf8; - dev->regs[0xc1] = 0x7f; - dev->regs[0xc2] = 0x00; - dev->regs[0xc3] = 0xf8; - dev->regs[0xc4] = 0x7f; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0xf8; - dev->regs[0xc7] = 0x7f; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0x8f; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x07; - dev->regs[0xcd] = 0x80; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf2; - dev->regs[0xd0] = 0xf4; - dev->regs[0xd1] = 0xe7; - dev->regs[0xd2] = 0x08; - dev->regs[0xd3] = 0x0e; - dev->regs[0xd4] = 0x10; - dev->regs[0xd7] = 0x31; - dev->regs[0xe2] = 0x02; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 1832); - - break; - - case SENSOR_TYPE_4400_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400_BARE for 600 dpi\n"); - return SANE_STATUS_INVAL; - break; - } - break; - - case 1200: - switch (dev->sensor) - { - case SENSOR_TYPE_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_BARE for 1200 dpi\n"); - dev->regs[0x34] = 0xf0; - dev->regs[0x40] = 0xa0; - - dev->regs[0x80] = 0x26; - dev->regs[0x81] = 0x04; - - dev->regs[0x82] = 0x27; - dev->regs[0x83] = 0x04; - - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; - - dev->regs[0x89] = 0x28; - dev->regs[0x8a] = 0x04; - - dev->regs[0x8d] = 0xbd; - dev->regs[0x8e] = 0x63; - - dev->regs[0xc0] = 0xff; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0xff; - dev->regs[0xc4] = 0x0f; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0xf0; - dev->regs[0xc9] = 0x00; - dev->regs[0xca] = 0x0e; - dev->regs[0xcb] = 0x00; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0xff; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - dev->regs[0xd1] = 0xea; - dev->regs[0xd2] = 0x0b; - /* dev->regs[0xd3] = 0x17; */ - dev->regs[0xd4] = 0xc1; - dev->regs[0xd7] = 0x14; - dev->regs[0xd8] = 0xa4; - /* dev->regs[0xe5] = 0x28; - dev->regs[0xe6] = 0x07; 0x728=1832=915*2+2 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 1832); - break; - case SENSOR_TYPE_XPA: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_XPA for 1200 dpi\n"); - dev->regs[0x34] = 0xf0; - dev->regs[0x40] = 0xa0; - - dev->regs[0x80] = 0x26; - dev->regs[0x81] = 0x04; - - dev->regs[0x82] = 0x27; - dev->regs[0x83] = 0x04; - - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; - - dev->regs[0x89] = 0x28; - dev->regs[0x8a] = 0x04; - - dev->regs[0x8e] = 0x63; - - dev->regs[0xc1] = 0xff; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 1832); - dev->regs[0x33] = 0x86; - dev->regs[0x50] = 0x18; - dev->regs[0x64] = 0x02; - dev->regs[0x65] = 0x10; - dev->regs[0x8d] = 0xbc; - dev->regs[0xc0] = 0xe0; - dev->regs[0xc2] = 0x01; - dev->regs[0xc3] = 0x1f; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xfe; - dev->regs[0xc6] = 0xff; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0x3f; - dev->regs[0xca] = 0xfe; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x00; - dev->regs[0xcd] = 0x00; - dev->regs[0xd1] = 0xec; - dev->regs[0xd2] = 0x0d; - /* dev->regs[0xd3] = 0x05; */ - dev->regs[0xd4] = 0x67; - dev->regs[0xd7] = 0x10; - dev->regs[0xd8] = 0x52; - break; - - case SENSOR_TYPE_4400: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400 for 1200 dpi\n"); - dev->regs[0x13] = 0x39; - dev->regs[0x14] = 0xf0; - dev->regs[0x15] = 0x29; - dev->regs[0x16] = 0x0f; - dev->regs[0x17] = 0x10; - dev->regs[0x23] = 0x00; - dev->regs[0x34] = 0xf0; - dev->regs[0x36] = 0x29; - dev->regs[0x39] = 0x00; - dev->regs[0x40] = 0xa0; - dev->regs[0x80] = 0x26; - dev->regs[0x81] = 0x04; - dev->regs[0x82] = 0x27; - dev->regs[0x83] = 0x04; - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; - dev->regs[0x89] = 0x28; - dev->regs[0x8a] = 0x04; - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; - dev->regs[0xc0] = 0xe0; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0x01; - dev->regs[0xc3] = 0x1f; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xfe; - dev->regs[0xc6] = 0xff; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0x3f; - dev->regs[0xca] = 0xfe; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x00; - dev->regs[0xcd] = 0x00; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - dev->regs[0xd1] = 0xec; - dev->regs[0xd2] = 0x0d; - /* dev->regs[0xd3] = 0x05; */ - dev->regs[0xd4] = 0x67; - dev->regs[0xd7] = 0x10; - dev->regs[0xd8] = 0x52; - dev->regs[0xe2] = 0x02; - light = 0x23; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 3665); - break; - - case SENSOR_TYPE_4400_BARE: - DBG (DBG_io, - "shading_calibration: setting up SENSOR_TYPE_4400_BARE for 1200 dpi\n"); - return SANE_STATUS_INVAL; - break; - } - break; - } - - /* in logs, the driver use the computed offset minus 2 */ - sanei_rts88xx_set_offset (dev->regs, dev->red_offset, dev->green_offset, - dev->blue_offset); - sanei_rts88xx_set_gain (dev->regs, dev->red_gain, dev->green_gain, - dev->blue_gain); - sanei_rts88xx_set_scan_area (dev->regs, 1, 1 + lines, dev->xstart, - dev->xstart + width); - /* scan shading area */ sanei_rts88xx_set_status (dev->devnum, dev->regs, status1, light); format = rts8891_data_format (dev->xdpi, dev->sensor); - status = - rts8891_simple_scan (dev->devnum, dev->regs, dev->reg_count, format, - size, image); + status = rts8891_simple_scan (dev->devnum, dev->regs, dev->reg_count, format, size, image); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "shading_calibration: failed scan shading area\n"); @@ -6533,12 +6559,13 @@ move_to_scan_area (struct Rts8891_Session *session) /* The windows driver is allways scanning in color, so we do the same. */ /* For now, the only mode that could be done would be 300 dpi gray scan, */ /* based on the register settings of find_origin() */ -static SANE_Status -write_scan_registers (struct Rts8891_Session *session) +#ifndef UNIT_TESTING +static +#endif +SANE_Status +setup_scan_registers (struct Rts8891_Session *session, SANE_Byte *status1, SANE_Byte *status2, SANE_Byte *regs) { SANE_Status status = SANE_STATUS_GOOD; - SANE_Byte control; - SANE_Byte status1, status2; struct Rts8891_Device *dev = session->dev; /* only software gray modes for now */ @@ -6546,516 +6573,510 @@ write_scan_registers (struct Rts8891_Session *session) && (session->dev->model->flags & RTS8891_FLAG_EMULATED_GRAY_MODE) == 0) { DBG (DBG_warn, - "write_scan_registers: native gray modes not implemented for this model, failure expected\n"); + "setup_scan_registers: native gray modes not implemented for this model, failure expected\n"); } - sanei_rts88xx_set_scan_area (dev->regs, dev->ystart, dev->ystart - + dev->lines, dev->xstart, - dev->xstart + dev->pixels); - DBG (DBG_info, "write_scan_registers: xstart=%d, pixels=%d\n", dev->xstart, - dev->pixels); - DBG (DBG_info, "write_scan_registers: ystart=%d, lines =%d\n", dev->ystart, - dev->lines); + sanei_rts88xx_set_scan_area (regs, dev->ystart, dev->ystart + dev->lines, dev->xstart, dev->xstart + dev->pixels); + DBG (DBG_info, "setup_scan_registers: xstart=%d, pixels=%d\n", dev->xstart, dev->pixels); + DBG (DBG_info, "setup_scan_registers: ystart=%d, lines =%d\n", dev->ystart, dev->lines); /* this is full register set from a color preview */ - dev->regs[0x00] = dev->regs[0x00] & 0xef; - dev->regs[0x01] = 0x41; + regs[0x00] = regs[0x00] & 0xef; + regs[0x01] = 0x41; - sanei_rts88xx_set_offset (dev->regs, dev->red_offset, dev->green_offset, - dev->blue_offset); - sanei_rts88xx_set_gain (dev->regs, dev->red_gain, dev->green_gain, - dev->blue_gain); + sanei_rts88xx_set_offset (regs, dev->red_offset, dev->green_offset, dev->blue_offset); + sanei_rts88xx_set_gain (regs, dev->red_gain, dev->green_gain, dev->blue_gain); switch (dev->sensor) { case SENSOR_TYPE_4400: case SENSOR_TYPE_4400_BARE: - status1 = 0x10; - status2 = 0x2a; + *status1 = 0x10; + *status2 = 0x2a; break; case SENSOR_TYPE_XPA: - status1 = 0x20; - status2 = 0x3f; + *status1 = 0x20; + *status2 = 0x3f; break; default: - status1 = 0x20; - status2 = 0x3b; + *status1 = 0x20; + *status2 = 0x3b; } /* default to 75 dpi color scan */ - dev->regs[0x0b] = 0x70; - dev->regs[0x0c] = 0x00; - dev->regs[0x0d] = 0x00; - dev->regs[0x0e] = 0x00; - dev->regs[0x0f] = 0x00; + regs[0x0b] = 0x70; + regs[0x0c] = 0x00; + regs[0x0d] = 0x00; + regs[0x0e] = 0x00; + regs[0x0f] = 0x00; - dev->regs[0x12] = 0xff; - dev->regs[0x13] = 0x20; - dev->regs[0x14] = 0xf8; - dev->regs[0x15] = 0x28; - dev->regs[0x16] = 0x01; - dev->regs[0x17] = 0x00; - dev->regs[0x18] = 0xff; - dev->regs[0x19] = 0x00; - dev->regs[0x1a] = 0x00; - dev->regs[0x1b] = 0x00; - dev->regs[0x1c] = 0x00; - dev->regs[0x1d] = 0x20; - dev->regs[0x1e] = 0x00; - dev->regs[0x1f] = 0x00; + regs[0x12] = 0xff; + regs[0x13] = 0x20; + regs[0x14] = 0xf8; + regs[0x15] = 0x28; + regs[0x16] = 0x01; + regs[0x17] = 0x00; + regs[0x18] = 0xff; + regs[0x19] = 0x00; + regs[0x1a] = 0x00; + regs[0x1b] = 0x00; + regs[0x1c] = 0x00; + regs[0x1d] = 0x20; + regs[0x1e] = 0x00; + regs[0x1f] = 0x00; /* LCD display */ - dev->regs[0x20] = 0x3a; - dev->regs[0x21] = 0xf2; - dev->regs[0x22] = 0x00; + regs[0x20] = 0x3a; + regs[0x21] = 0xf2; + regs[0x22] = 0x00; - dev->regs[0x23] = 0x80; - dev->regs[0x24] = 0xff; - dev->regs[0x25] = 0x00; - dev->regs[0x26] = 0x00; - dev->regs[0x27] = 0x00; - dev->regs[0x28] = 0x00; - dev->regs[0x29] = 0x00; - dev->regs[0x2a] = 0x00; - dev->regs[0x2b] = 0x00; - dev->regs[0x2c] = 0x00; - dev->regs[0x2d] = 0x00; - dev->regs[0x2e] = 0x00; - dev->regs[0x2f] = 0x00; - dev->regs[0x30] = 0x00; - dev->regs[0x31] = 0x00; - dev->regs[0x32] = 0x20; - dev->regs[0x33] = 0x83; - dev->regs[0x34] = 0x10; - dev->regs[0x35] = 0x47; - dev->regs[0x36] = 0x2c; - dev->regs[0x37] = 0x00; - dev->regs[0x38] = 0x00; - dev->regs[0x39] = 0x02; - dev->regs[0x3a] = 0x43; - dev->regs[0x3b] = 0x00; - dev->regs[0x3c] = 0x00; - dev->regs[0x3d] = 0x00; - dev->regs[0x3e] = 0x00; - dev->regs[0x3f] = 0x00; - dev->regs[0x40] = 0x2c; /* 0x0c -> use shading data */ - dev->regs[0x41] = 0x00; - dev->regs[0x42] = 0x00; - dev->regs[0x43] = 0x00; - dev->regs[0x44] = 0x8c; - dev->regs[0x45] = 0x76; - dev->regs[0x46] = 0x00; - dev->regs[0x47] = 0x00; - dev->regs[0x48] = 0x00; - dev->regs[0x49] = 0x00; - dev->regs[0x4a] = 0x00; - dev->regs[0x4b] = 0x00; - dev->regs[0x4c] = 0x00; - dev->regs[0x4d] = 0x00; - dev->regs[0x4e] = 0x00; - dev->regs[0x4f] = 0x00; - dev->regs[0x50] = 0x00; - dev->regs[0x51] = 0x00; - dev->regs[0x52] = 0x00; - dev->regs[0x53] = 0x00; - dev->regs[0x54] = 0x00; - dev->regs[0x55] = 0x00; - dev->regs[0x56] = 0x00; - dev->regs[0x57] = 0x00; - dev->regs[0x58] = 0x00; - dev->regs[0x59] = 0x00; - dev->regs[0x5a] = 0x00; - dev->regs[0x5b] = 0x00; - dev->regs[0x5c] = 0x00; - dev->regs[0x5d] = 0x00; - dev->regs[0x5e] = 0x00; - dev->regs[0x5f] = 0x00; + regs[0x23] = 0x80; + regs[0x24] = 0xff; + regs[0x25] = 0x00; + regs[0x26] = 0x00; + regs[0x27] = 0x00; + regs[0x28] = 0x00; + regs[0x29] = 0x00; + regs[0x2a] = 0x00; + regs[0x2b] = 0x00; + regs[0x2c] = 0x00; + regs[0x2d] = 0x00; + regs[0x2e] = 0x00; + regs[0x2f] = 0x00; + regs[0x30] = 0x00; + regs[0x31] = 0x00; + regs[0x32] = 0x20; + regs[0x33] = 0x83; + regs[0x34] = 0x10; + regs[0x35] = 0x47; + regs[0x36] = 0x2c; + regs[0x37] = 0x00; + regs[0x38] = 0x00; + regs[0x39] = 0x02; + regs[0x3a] = 0x43; + regs[0x3b] = 0x00; + regs[0x3c] = 0x00; + regs[0x3d] = 0x00; + regs[0x3e] = 0x00; + regs[0x3f] = 0x00; + regs[0x40] = 0x2c; /* 0x0c -> use shading data */ + regs[0x41] = 0x00; + regs[0x42] = 0x00; + regs[0x43] = 0x00; + regs[0x44] = 0x8c; + regs[0x45] = 0x76; + regs[0x46] = 0x00; + regs[0x47] = 0x00; + regs[0x48] = 0x00; + regs[0x49] = 0x00; + regs[0x4a] = 0x00; + regs[0x4b] = 0x00; + regs[0x4c] = 0x00; + regs[0x4d] = 0x00; + regs[0x4e] = 0x00; + regs[0x4f] = 0x00; + regs[0x50] = 0x00; + regs[0x51] = 0x00; + regs[0x52] = 0x00; + regs[0x53] = 0x00; + regs[0x54] = 0x00; + regs[0x55] = 0x00; + regs[0x56] = 0x00; + regs[0x57] = 0x00; + regs[0x58] = 0x00; + regs[0x59] = 0x00; + regs[0x5a] = 0x00; + regs[0x5b] = 0x00; + regs[0x5c] = 0x00; + regs[0x5d] = 0x00; + regs[0x5e] = 0x00; + regs[0x5f] = 0x00; - dev->regs[0x64] = 0x01; - dev->regs[0x65] = 0x20; + regs[0x64] = 0x01; + regs[0x65] = 0x20; - dev->regs[0x68] = 0x00; - dev->regs[0x69] = 0x00; - dev->regs[0x6a] = 0x00; - dev->regs[0x6b] = 0x00; + regs[0x68] = 0x00; + regs[0x69] = 0x00; + regs[0x6a] = 0x00; + regs[0x6b] = 0x00; - dev->regs[0x6e] = 0x00; - dev->regs[0x6f] = 0x00; - dev->regs[0x70] = 0x00; - dev->regs[0x71] = 0x00; + regs[0x6e] = 0x00; + regs[0x6f] = 0x00; + regs[0x70] = 0x00; + regs[0x71] = 0x00; - dev->regs[0x72] = 0xe1; - dev->regs[0x73] = 0x14; - dev->regs[0x74] = 0x18; - dev->regs[0x75] = 0x15; + regs[0x72] = 0xe1; + regs[0x73] = 0x14; + regs[0x74] = 0x18; + regs[0x75] = 0x15; - dev->regs[0x76] = 0x00; - dev->regs[0x77] = 0x00; - dev->regs[0x78] = 0x00; - dev->regs[0x79] = 0x20; - dev->regs[0x7a] = 0x01; - dev->regs[0x7b] = 0x00; - dev->regs[0x7c] = 0x00; - dev->regs[0x7d] = 0x00; - dev->regs[0x7e] = 0x00; - dev->regs[0x7f] = 0x00; - dev->regs[0x80] = 0xaf; - dev->regs[0x81] = 0x00; - dev->regs[0x82] = 0xb0; - dev->regs[0x83] = 0x00; - dev->regs[0x84] = 0x00; - dev->regs[0x85] = 0x46; - dev->regs[0x86] = 0x0b; - dev->regs[0x87] = 0x8c; - dev->regs[0x88] = 0x10; - dev->regs[0x89] = 0xb1; - dev->regs[0x8a] = 0x00; - dev->regs[0x8b] = 0xff; - dev->regs[0x8c] = 0x3f; - dev->regs[0x8d] = 0x3b; + regs[0x76] = 0x00; + regs[0x77] = 0x00; + regs[0x78] = 0x00; + regs[0x79] = 0x20; + regs[0x7a] = 0x01; + regs[0x7b] = 0x00; + regs[0x7c] = 0x00; + regs[0x7d] = 0x00; + regs[0x7e] = 0x00; + regs[0x7f] = 0x00; + regs[0x80] = 0xaf; + regs[0x81] = 0x00; + regs[0x82] = 0xb0; + regs[0x83] = 0x00; + regs[0x84] = 0x00; + regs[0x85] = 0x46; + regs[0x86] = 0x0b; + regs[0x87] = 0x8c; + regs[0x88] = 0x10; + regs[0x89] = 0xb1; + regs[0x8a] = 0x00; + regs[0x8b] = 0xff; + regs[0x8c] = 0x3f; + regs[0x8d] = 0x3b; - dev->regs[0x8e] = 0x60; - dev->regs[0x8f] = 0x00; - dev->regs[0x90] = 0x18; /* 0x1c when shading calibration */ + regs[0x8e] = 0x60; + regs[0x8f] = 0x00; + regs[0x90] = 0x18; /* 0x1c when shading calibration */ /* overwritten when calibration data is sent */ - dev->regs[0x91] = 0x00; - dev->regs[0x92] = 0x00; + regs[0x91] = 0x00; + regs[0x92] = 0x00; - dev->regs[0x93] = 0x01; + regs[0x93] = 0x01; - dev->regs[0x94] = 0x0e; - dev->regs[0x95] = 0x00; - dev->regs[0x96] = 0x00; - dev->regs[0x97] = 0x00; - dev->regs[0x98] = 0x00; - dev->regs[0x99] = 0x00; - dev->regs[0x9a] = 0x00; - dev->regs[0x9b] = 0x00; - dev->regs[0x9c] = 0x00; - dev->regs[0x9d] = 0x00; - dev->regs[0x9e] = 0x00; - dev->regs[0x9f] = 0x00; - dev->regs[0xa0] = 0x00; - dev->regs[0xa1] = 0x00; - dev->regs[0xa2] = 0x00; - dev->regs[0xa3] = 0xcc; - dev->regs[0xa4] = 0x27; - dev->regs[0xa5] = 0x64; - dev->regs[0xa6] = 0x00; - dev->regs[0xa7] = 0x00; - dev->regs[0xa8] = 0x00; - dev->regs[0xa9] = 0x00; - dev->regs[0xaa] = 0x00; - dev->regs[0xab] = 0x00; - dev->regs[0xac] = 0x00; - dev->regs[0xad] = 0x00; - dev->regs[0xae] = 0x00; - dev->regs[0xaf] = 0x00; - dev->regs[0xb0] = 0x00; - dev->regs[0xb1] = 0x00; - dev->regs[0xb2] = 0x02; + regs[0x94] = 0x0e; + regs[0x95] = 0x00; + regs[0x96] = 0x00; + regs[0x97] = 0x00; + regs[0x98] = 0x00; + regs[0x99] = 0x00; + regs[0x9a] = 0x00; + regs[0x9b] = 0x00; + regs[0x9c] = 0x00; + regs[0x9d] = 0x00; + regs[0x9e] = 0x00; + regs[0x9f] = 0x00; + regs[0xa0] = 0x00; + regs[0xa1] = 0x00; + regs[0xa2] = 0x00; + regs[0xa3] = 0xcc; + regs[0xa4] = 0x27; + regs[0xa5] = 0x64; + regs[0xa6] = 0x00; + regs[0xa7] = 0x00; + regs[0xa8] = 0x00; + regs[0xa9] = 0x00; + regs[0xaa] = 0x00; + regs[0xab] = 0x00; + regs[0xac] = 0x00; + regs[0xad] = 0x00; + regs[0xae] = 0x00; + regs[0xaf] = 0x00; + regs[0xb0] = 0x00; + regs[0xb1] = 0x00; + regs[0xb2] = 0x02; - dev->regs[0xb4] = 0x00; - dev->regs[0xb5] = 0x00; - dev->regs[0xb6] = 0x00; - dev->regs[0xb7] = 0x00; - dev->regs[0xb8] = 0x00; - dev->regs[0xb9] = 0x00; - dev->regs[0xba] = 0x00; - dev->regs[0xbb] = 0x00; - dev->regs[0xbc] = 0x00; - dev->regs[0xbd] = 0x00; - dev->regs[0xbe] = 0x00; - dev->regs[0xbf] = 0x00; - dev->regs[0xc0] = 0x06; - dev->regs[0xc1] = 0xe6; - dev->regs[0xc2] = 0x67; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0xff; - dev->regs[0xc5] = 0xff; - dev->regs[0xc6] = 0xff; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0xff; - dev->regs[0xc9] = 0x07; - dev->regs[0xca] = 0x00; - dev->regs[0xcb] = 0xfe; - dev->regs[0xcc] = 0xf9; - dev->regs[0xcd] = 0x19; - dev->regs[0xce] = 0x98; - dev->regs[0xcf] = 0xe8; - dev->regs[0xd0] = 0xea; + regs[0xb4] = 0x00; + regs[0xb5] = 0x00; + regs[0xb6] = 0x00; + regs[0xb7] = 0x00; + regs[0xb8] = 0x00; + regs[0xb9] = 0x00; + regs[0xba] = 0x00; + regs[0xbb] = 0x00; + regs[0xbc] = 0x00; + regs[0xbd] = 0x00; + regs[0xbe] = 0x00; + regs[0xbf] = 0x00; + regs[0xc0] = 0x06; + regs[0xc1] = 0xe6; + regs[0xc2] = 0x67; + regs[0xc3] = 0xff; + regs[0xc4] = 0xff; + regs[0xc5] = 0xff; + regs[0xc6] = 0xff; + regs[0xc7] = 0xff; + regs[0xc8] = 0xff; + regs[0xc9] = 0x07; + regs[0xca] = 0x00; + regs[0xcb] = 0xfe; + regs[0xcc] = 0xf9; + regs[0xcd] = 0x19; + regs[0xce] = 0x98; + regs[0xcf] = 0xe8; + regs[0xd0] = 0xea; - dev->regs[0xd1] = 0xf3; - dev->regs[0xd2] = 0x14; + regs[0xd1] = 0xf3; + regs[0xd2] = 0x14; - dev->regs[0xd3] = 0x02; - dev->regs[0xd4] = 0x04; - dev->regs[0xd5] = 0x86; + regs[0xd3] = 0x02; + regs[0xd4] = 0x04; + regs[0xd5] = 0x86; - dev->regs[0xd6] = 0x0f; - dev->regs[0xd7] = 0x30; /* 12303 */ + regs[0xd6] = 0x0f; + regs[0xd7] = 0x30; /* 12303 */ - dev->regs[0xd8] = 0x52; /* 0x5230=21040 */ + regs[0xd8] = 0x52; /* 0x5230=21040 */ - dev->regs[0xd9] = 0xad; - dev->regs[0xda] = 0xa7; - dev->regs[0xdb] = 0x00; - dev->regs[0xdc] = 0x00; - dev->regs[0xdd] = 0x00; - dev->regs[0xde] = 0x00; - dev->regs[0xdf] = 0x00; - dev->regs[0xe0] = 0x00; - dev->regs[0xe1] = 0x00; - dev->regs[0xe2] = 0x0f; - dev->regs[0xe3] = 0x85; - dev->regs[0xe4] = 0x03; + regs[0xd9] = 0xad; + regs[0xda] = 0xa7; + regs[0xdb] = 0x00; + regs[0xdc] = 0x00; + regs[0xdd] = 0x00; + regs[0xde] = 0x00; + regs[0xdf] = 0x00; + regs[0xe0] = 0x00; + regs[0xe1] = 0x00; + regs[0xe2] = 0x0f; + regs[0xe3] = 0x85; + regs[0xe4] = 0x03; - /* dev->regs[0xe5] = 0x52; - dev->regs[0xe6] = 0x00; exposure time 0x0052=82 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 82); + /* regs[0xe5] = 0x52; + regs[0xe6] = 0x00; exposure time 0x0052=82 */ + SET_DOUBLE (regs, EXPOSURE_REG, 82); - dev->regs[0xe7] = 0x75; - dev->regs[0xe8] = 0x01; - dev->regs[0xe9] = 0x0b; - dev->regs[0xea] = 0x54; - dev->regs[0xeb] = 0x01; - dev->regs[0xec] = 0x04; - dev->regs[0xed] = 0xb8; - dev->regs[0xee] = 0x00; - dev->regs[0xef] = 0x03; - dev->regs[0xf0] = 0x70; - dev->regs[0xf1] = 0x00; - dev->regs[0xf2] = 0x01; - dev->regs[0xf3] = 0x00; + regs[0xe7] = 0x75; + regs[0xe8] = 0x01; + regs[0xe9] = 0x0b; + regs[0xea] = 0x54; + regs[0xeb] = 0x01; + regs[0xec] = 0x04; + regs[0xed] = 0xb8; + regs[0xee] = 0x00; + regs[0xef] = 0x03; + regs[0xf0] = 0x70; + regs[0xf1] = 0x00; + regs[0xf2] = 0x01; + regs[0xf3] = 0x00; if (dev->sensor == SENSOR_TYPE_XPA || dev->sensor == SENSOR_TYPE_4400) { - dev->regs[0xc0] = 0x67; - dev->regs[0xc1] = 0x06; - dev->regs[0xc2] = 0xe6; - dev->regs[0xc3] = 0x98; - dev->regs[0xc4] = 0xf9; - dev->regs[0xc5] = 0x19; - dev->regs[0xc6] = 0x67; - dev->regs[0xc7] = 0x06; - dev->regs[0xc8] = 0xe6; - dev->regs[0xc9] = 0x01; - dev->regs[0xca] = 0xf8; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x98; - dev->regs[0xcd] = 0xf9; - dev->regs[0xce] = 0x19; - dev->regs[0xcf] = 0xe0; - dev->regs[0xd0] = 0xe2; + regs[0xc0] = 0x67; + regs[0xc1] = 0x06; + regs[0xc2] = 0xe6; + regs[0xc3] = 0x98; + regs[0xc4] = 0xf9; + regs[0xc5] = 0x19; + regs[0xc6] = 0x67; + regs[0xc7] = 0x06; + regs[0xc8] = 0xe6; + regs[0xc9] = 0x01; + regs[0xca] = 0xf8; + regs[0xcb] = 0xff; + regs[0xcc] = 0x98; + regs[0xcd] = 0xf9; + regs[0xce] = 0x19; + regs[0xcf] = 0xe0; + regs[0xd0] = 0xe2; - dev->regs[0xd1] = 0xeb; - dev->regs[0xd2] = 0x0c; + regs[0xd1] = 0xeb; + regs[0xd2] = 0x0c; - dev->regs[0xd7] = 0x10; + regs[0xd7] = 0x10; } if (dev->sensor == SENSOR_TYPE_4400) { - dev->regs[0x13] = 0x39; /* 0x20 */ - dev->regs[0x14] = 0xf0; /* 0xf8 */ - dev->regs[0x15] = 0x29; /* 0x28 */ - dev->regs[0x16] = 0x00; /* 0x01 */ - dev->regs[0x17] = 0x10; /* 0x00 */ - dev->regs[0x23] = 0x00; /* 0x80 */ - dev->regs[0x35] = 0x47; /* 0x45 */ - dev->regs[0x36] = 0x29; /* 0x2c */ - dev->regs[0x39] = 0x00; /* 0x02 */ - dev->regs[0x80] = 0xaf; /* 0x2e */ - dev->regs[0x81] = 0x00; /* 0x01 */ - dev->regs[0x82] = 0xb0; /* 0x2f */ - dev->regs[0x83] = 0x00; /* 0x01 */ - dev->regs[0x85] = 0x46; /* 0x8c */ - dev->regs[0x86] = 0x0b; /* 0x10 */ - dev->regs[0x87] = 0x8c; /* 0x18 */ - dev->regs[0x88] = 0x10; /* 0x1b */ - dev->regs[0x89] = 0xb1; /* 0x30 */ - dev->regs[0x8a] = 0x00; /* 0x01 */ - dev->regs[0x8d] = 0x3b; /* 0x77 */ + regs[0x13] = 0x39; /* 0x20 */ + regs[0x14] = 0xf0; /* 0xf8 */ + regs[0x15] = 0x29; /* 0x28 */ + regs[0x16] = 0x00; /* 0x01 */ + regs[0x17] = 0x10; /* 0x00 */ + regs[0x23] = 0x00; /* 0x80 */ + regs[0x35] = 0x47; /* 0x45 */ + regs[0x36] = 0x29; /* 0x2c */ + regs[0x39] = 0x00; /* 0x02 */ + regs[0x80] = 0xaf; /* 0x2e */ + regs[0x81] = 0x00; /* 0x01 */ + regs[0x82] = 0xb0; /* 0x2f */ + regs[0x83] = 0x00; /* 0x01 */ + regs[0x85] = 0x46; /* 0x8c */ + regs[0x86] = 0x0b; /* 0x10 */ + regs[0x87] = 0x8c; /* 0x18 */ + regs[0x88] = 0x10; /* 0x1b */ + regs[0x89] = 0xb1; /* 0x30 */ + regs[0x8a] = 0x00; /* 0x01 */ + regs[0x8d] = 0x3b; /* 0x77 */ - dev->regs[0xd3] = 0x02; /* 0x0e */ - dev->regs[0xd4] = 0x04; /* 0x10 */ - dev->regs[0xe2] = 0x07; /* 0x0f */ - dev->regs[0xe3] = 0x84; /* 0x87 */ - /*dev->regs[0xe5] = 0xa5; 0x54 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 165); /* 82*2+1 */ - dev->regs[0xe7] = 0x0e; /* 0xa8 */ - dev->regs[0xe8] = 0x01; /* 0x00 */ - dev->regs[0xe9] = 0x0a; /* 0x0b */ - dev->regs[0xea] = 0xc2; /* 0x56 */ - dev->regs[0xed] = 0xf6; /* 0xba */ - dev->regs[0xef] = 0x02; /* 0x03 */ - dev->regs[0xf0] = 0xa8; /* 0x72 */ + regs[0xd3] = 0x02; /* 0x0e */ + regs[0xd4] = 0x04; /* 0x10 */ + regs[0xe2] = 0x07; /* 0x0f */ + regs[0xe3] = 0x84; /* 0x87 */ + /*regs[0xe5] = 0xa5; 0x54 */ + SET_DOUBLE (regs, EXPOSURE_REG, 165); /* 82*2+1 */ + regs[0xe7] = 0x0e; /* 0xa8 */ + regs[0xe8] = 0x01; /* 0x00 */ + regs[0xe9] = 0x0a; /* 0x0b */ + regs[0xea] = 0xc2; /* 0x56 */ + regs[0xed] = 0xf6; /* 0xba */ + regs[0xef] = 0x02; /* 0x03 */ + regs[0xf0] = 0xa8; /* 0x72 */ } if (dev->sensor == SENSOR_TYPE_4400_BARE) { - dev->regs[0x13] = 0x39; /* 0x20 */ - dev->regs[0x14] = 0xf0; /* 0xf8 */ - dev->regs[0x15] = 0x29; /* 0x28 */ - dev->regs[0x16] = 0x00; /* 0x07 */ - dev->regs[0x17] = 0x10; /* 0x00 */ - dev->regs[0x23] = 0x00; /* 0xff */ - dev->regs[0x35] = 0x47; /* 0x0e */ - dev->regs[0x36] = 0x29; /* 0x2c */ - dev->regs[0x39] = 0x00; /* 0x02 */ - dev->regs[0x3a] = 0x43; /* 0x0e */ - dev->regs[0x40] = 0x2c; /* 0x20 */ - dev->regs[0x80] = 0xaf; /* 0x32 */ - dev->regs[0x82] = 0xb0; /* 0x33 */ - dev->regs[0x85] = 0x46; /* 0x00 */ - dev->regs[0x86] = 0x0b; /* 0x06 */ - dev->regs[0x87] = 0x8c; /* 0x00 */ - dev->regs[0x88] = 0x10; /* 0x06 */ - dev->regs[0x89] = 0xb1; /* 0x34 */ - dev->regs[0x8d] = 0x3b; /* 0x00 */ - dev->regs[0x90] = 0x18; /* 0x1c */ - dev->regs[0xe2] = 0x07; /* 0x05 */ - dev->regs[0xe3] = 0x84; /* 0x00 */ - dev->regs[0xe4] = 0x03; /* 0x00 */ - dev->regs[0xe5] = 0xa5; /* 0xdd */ - dev->regs[0xe7] = 0x0e; /* 0x00 */ - dev->regs[0xe8] = 0x01; /* 0x00 */ - dev->regs[0xe9] = 0x0a; /* 0x00 */ - dev->regs[0xea] = 0xc2; /* 0x00 */ - dev->regs[0xeb] = 0x01; /* 0x00 */ - dev->regs[0xec] = 0x04; /* 0x00 */ - dev->regs[0xed] = 0xf6; /* 0x00 */ - dev->regs[0xef] = 0x02; /* 0x00 */ - dev->regs[0xf0] = 0xa8; /* 0x00 */ - dev->regs[0xf2] = 0x01; /* 0x00 */ + regs[0x13] = 0x39; /* 0x20 */ + regs[0x14] = 0xf0; /* 0xf8 */ + regs[0x15] = 0x29; /* 0x28 */ + regs[0x16] = 0x00; /* 0x07 */ + regs[0x17] = 0x10; /* 0x00 */ + regs[0x23] = 0x00; /* 0xff */ + regs[0x35] = 0x47; /* 0x0e */ + regs[0x36] = 0x29; /* 0x2c */ + regs[0x39] = 0x00; /* 0x02 */ + regs[0x3a] = 0x43; /* 0x0e */ + regs[0x40] = 0x2c; /* 0x20 */ + regs[0x80] = 0xaf; /* 0x32 */ + regs[0x82] = 0xb0; /* 0x33 */ + regs[0x85] = 0x46; /* 0x00 */ + regs[0x86] = 0x0b; /* 0x06 */ + regs[0x87] = 0x8c; /* 0x00 */ + regs[0x88] = 0x10; /* 0x06 */ + regs[0x89] = 0xb1; /* 0x34 */ + regs[0x8d] = 0x3b; /* 0x00 */ + regs[0x90] = 0x18; /* 0x1c */ + regs[0xe2] = 0x07; /* 0x05 */ + regs[0xe3] = 0x84; /* 0x00 */ + regs[0xe4] = 0x03; /* 0x00 */ + regs[0xe5] = 0xa5; /* 0xdd */ + regs[0xe7] = 0x0e; /* 0x00 */ + regs[0xe8] = 0x01; /* 0x00 */ + regs[0xe9] = 0x0a; /* 0x00 */ + regs[0xea] = 0xc2; /* 0x00 */ + regs[0xeb] = 0x01; /* 0x00 */ + regs[0xec] = 0x04; /* 0x00 */ + regs[0xed] = 0xf6; /* 0x00 */ + regs[0xef] = 0x02; /* 0x00 */ + regs[0xf0] = 0xa8; /* 0x00 */ + regs[0xf2] = 0x01; /* 0x00 */ } switch (dev->xdpi) { case 75: break; case 150: - dev->regs[0x35] = 0x45; + regs[0x35] = 0x45; - dev->regs[0x80] = 0x2e; - dev->regs[0x81] = 0x01; + regs[0x80] = 0x2e; + regs[0x81] = 0x01; - dev->regs[0x82] = 0x2f; - dev->regs[0x83] = 0x01; + regs[0x82] = 0x2f; + regs[0x83] = 0x01; - dev->regs[0x85] = 0x8c; - dev->regs[0x86] = 0x10; + regs[0x85] = 0x8c; + regs[0x86] = 0x10; - dev->regs[0x87] = 0x18; - dev->regs[0x88] = 0x1b; + regs[0x87] = 0x18; + regs[0x88] = 0x1b; - dev->regs[0x89] = 0x30; - dev->regs[0x8a] = 0x01; + regs[0x89] = 0x30; + regs[0x8a] = 0x01; - dev->regs[0x8d] = 0x77; + regs[0x8d] = 0x77; - dev->regs[0xe3] = 0x87; + regs[0xe3] = 0x87; - /* dev->regs[0xe5] = 0x54; - dev->regs[0xe6] = 0x00; exposure time 0x0054=84 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 84); + /* regs[0xe5] = 0x54; + regs[0xe6] = 0x00; exposure time 0x0054=84 */ + SET_DOUBLE (regs, EXPOSURE_REG, 84); - dev->regs[0xe7] = 0xa8; - dev->regs[0xe8] = 0x00; - dev->regs[0xea] = 0x56; - dev->regs[0xed] = 0xba; + regs[0xe7] = 0xa8; + regs[0xe8] = 0x00; + regs[0xea] = 0x56; + regs[0xed] = 0xba; - dev->regs[0xf0] = 0x72; + regs[0xf0] = 0x72; switch (dev->sensor) { case SENSOR_TYPE_XPA: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_XPA for 150 dpi\n"); - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0x8e; - dev->regs[0xc2] = 0xff; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x71; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0x8e; - dev->regs[0xc8] = 0xff; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0x1f; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x71; - dev->regs[0xce] = 0x00; - dev->regs[0xcf] = 0xe6; - dev->regs[0xd0] = 0xe8; - dev->regs[0xd1] = 0xf6; - dev->regs[0xd2] = 0x17; - dev->regs[0xd3] = 0x0b; - dev->regs[0xd4] = 0x0d; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_XPA for 150 dpi\n"); + regs[0xc0] = 0x00; + regs[0xc1] = 0x8e; + regs[0xc2] = 0xff; + regs[0xc3] = 0xff; + regs[0xc4] = 0x71; + regs[0xc5] = 0x00; + regs[0xc6] = 0x00; + regs[0xc7] = 0x8e; + regs[0xc8] = 0xff; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0x1f; + regs[0xcc] = 0xff; + regs[0xcd] = 0x71; + regs[0xce] = 0x00; + regs[0xcf] = 0xe6; + regs[0xd0] = 0xe8; + regs[0xd1] = 0xf6; + regs[0xd2] = 0x17; + regs[0xd3] = 0x0b; + regs[0xd4] = 0x0d; break; case SENSOR_TYPE_BARE: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_BARE for 150 dpi\n"); - dev->regs[0xc0] = 0x80; - dev->regs[0xc1] = 0x87; - dev->regs[0xc2] = 0x7f; - dev->regs[0xc9] = 0x00; - dev->regs[0xcb] = 0x78; - dev->regs[0xcc] = 0x7f; - dev->regs[0xcd] = 0x78; - dev->regs[0xce] = 0x80; - dev->regs[0xcf] = 0xe6; - dev->regs[0xd0] = 0xe8; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_BARE for 150 dpi\n"); + regs[0xc0] = 0x80; + regs[0xc1] = 0x87; + regs[0xc2] = 0x7f; + regs[0xc9] = 0x00; + regs[0xcb] = 0x78; + regs[0xcc] = 0x7f; + regs[0xcd] = 0x78; + regs[0xce] = 0x80; + regs[0xcf] = 0xe6; + regs[0xd0] = 0xe8; - dev->regs[0xd1] = 0xf7; - dev->regs[0xd2] = 0x00; + regs[0xd1] = 0xf7; + regs[0xd2] = 0x00; - dev->regs[0xd3] = 0x0e; - dev->regs[0xd4] = 0x10; + regs[0xd3] = 0x0e; + regs[0xd4] = 0x10; break; case SENSOR_TYPE_4400: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_4400 for 150 dpi\n"); - dev->regs[0x35] = 0x47; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_4400 for 150 dpi\n"); + regs[0x35] = 0x47; - dev->regs[0x80] = 0x2e; - dev->regs[0x81] = 0x01; - dev->regs[0x82] = 0x2f; - dev->regs[0x83] = 0x01; - dev->regs[0x85] = 0x8c; - dev->regs[0x86] = 0x10; - dev->regs[0x87] = 0x18; - dev->regs[0x88] = 0x1b; - dev->regs[0x89] = 0x30; - dev->regs[0x8a] = 0x01; - dev->regs[0x8d] = 0x77; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0x8e; - dev->regs[0xc2] = 0xff; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x71; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0x8e; - dev->regs[0xc8] = 0xff; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0x1f; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x71; - dev->regs[0xce] = 0x00; - dev->regs[0xcf] = 0xe6; - dev->regs[0xd0] = 0xe8; - dev->regs[0xd1] = 0xf6; - dev->regs[0xd2] = 0x17; - dev->regs[0xd3] = 0x0b; - dev->regs[0xd4] = 0x0d; - dev->regs[0xe3] = 0x86; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 170); - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x1c; - dev->regs[0xe9] = 0x01; - dev->regs[0xea] = 0x0a; - dev->regs[0xeb] = 0xc4; - dev->regs[0xec] = 0x01; - dev->regs[0xed] = 0x04; - dev->regs[0xee] = 0xf8; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x02; - dev->regs[0xf2] = 0x00; + regs[0x80] = 0x2e; + regs[0x81] = 0x01; + regs[0x82] = 0x2f; + regs[0x83] = 0x01; + regs[0x85] = 0x8c; + regs[0x86] = 0x10; + regs[0x87] = 0x18; + regs[0x88] = 0x1b; + regs[0x89] = 0x30; + regs[0x8a] = 0x01; + regs[0x8d] = 0x77; + regs[0xc0] = 0x00; + regs[0xc1] = 0x8e; + regs[0xc2] = 0xff; + regs[0xc3] = 0xff; + regs[0xc4] = 0x71; + regs[0xc5] = 0x00; + regs[0xc6] = 0x00; + regs[0xc7] = 0x8e; + regs[0xc8] = 0xff; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0x1f; + regs[0xcc] = 0xff; + regs[0xcd] = 0x71; + regs[0xce] = 0x00; + regs[0xcf] = 0xe6; + regs[0xd0] = 0xe8; + regs[0xd1] = 0xf6; + regs[0xd2] = 0x17; + regs[0xd3] = 0x0b; + regs[0xd4] = 0x0d; + regs[0xe3] = 0x86; + SET_DOUBLE (regs, EXPOSURE_REG, 170); + regs[0xe7] = 0x00; + regs[0xe8] = 0x1c; + regs[0xe9] = 0x01; + regs[0xea] = 0x0a; + regs[0xeb] = 0xc4; + regs[0xec] = 0x01; + regs[0xed] = 0x04; + regs[0xee] = 0xf8; + regs[0xef] = 0x00; + regs[0xf0] = 0x02; + regs[0xf2] = 0x00; break; } break; @@ -7064,593 +7085,593 @@ write_scan_registers (struct Rts8891_Session *session) switch (dev->sensor) { case SENSOR_TYPE_XPA: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_XPA for 300 dpi\n"); - dev->regs[0x35] = 0x0e; /* fast ? */ - dev->regs[0x3a] = 0x0e; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_XPA for 300 dpi\n"); + regs[0x35] = 0x0e; /* fast ? */ + regs[0x3a] = 0x0e; - dev->regs[0x80] = 0x2b; - dev->regs[0x81] = 0x02; + regs[0x80] = 0x2b; + regs[0x81] = 0x02; - dev->regs[0x82] = 0x2c; - dev->regs[0x83] = 0x02; /* x8180 +1 */ + regs[0x82] = 0x2c; + regs[0x83] = 0x02; /* x8180 +1 */ - dev->regs[0x85] = 0x18; - dev->regs[0x86] = 0x1b; + regs[0x85] = 0x18; + regs[0x86] = 0x1b; - dev->regs[0x87] = 0x30; - dev->regs[0x88] = 0x30; + regs[0x87] = 0x30; + regs[0x88] = 0x30; - dev->regs[0x89] = 0x2d; - dev->regs[0x8a] = 0x02; /* x8180 +2 */ + regs[0x89] = 0x2d; + regs[0x8a] = 0x02; /* x8180 +2 */ - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0x8d] = 0xef; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0x0f; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xf0; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x0f; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0xf1; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x00; - dev->regs[0xce] = 0xf0; - dev->regs[0xcf] = 0xed; - dev->regs[0xd0] = 0xef; - dev->regs[0xd1] = 0xe2; - dev->regs[0xd2] = 0x03; - dev->regs[0xd3] = 0x17; - dev->regs[0xd4] = 0x01; - dev->regs[0xe2] = 0x07; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - /* dev->regs[0xe5] = 0x56; - dev->regs[0xe6] = 0x01; */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 342); /* 171*2 */ - dev->regs[0xf2] = 0x00; + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0x8d] = 0xef; + regs[0xc0] = 0x00; + regs[0xc1] = 0xff; + regs[0xc2] = 0x0f; + regs[0xc3] = 0xff; + regs[0xc4] = 0x00; + regs[0xc5] = 0xf0; + regs[0xc6] = 0x00; + regs[0xc7] = 0xff; + regs[0xc8] = 0x0f; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0xf1; + regs[0xcc] = 0xff; + regs[0xcd] = 0x00; + regs[0xce] = 0xf0; + regs[0xcf] = 0xed; + regs[0xd0] = 0xef; + regs[0xd1] = 0xe2; + regs[0xd2] = 0x03; + regs[0xd3] = 0x17; + regs[0xd4] = 0x01; + regs[0xe2] = 0x07; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + /* regs[0xe5] = 0x56; + regs[0xe6] = 0x01; */ + SET_DOUBLE (regs, EXPOSURE_REG, 342); /* 171*2 */ + regs[0xf2] = 0x00; break; case SENSOR_TYPE_BARE: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_BARE for 300 dpi\n"); - dev->regs[0x35] = 0x0e; /* fast ? */ - dev->regs[0x3a] = 0x0e; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_BARE for 300 dpi\n"); + regs[0x35] = 0x0e; /* fast ? */ + regs[0x3a] = 0x0e; - dev->regs[0x80] = 0x2b; - dev->regs[0x81] = 0x02; + regs[0x80] = 0x2b; + regs[0x81] = 0x02; - dev->regs[0x82] = 0x2c; - dev->regs[0x83] = 0x02; /* x8180 +1 */ + regs[0x82] = 0x2c; + regs[0x83] = 0x02; /* x8180 +1 */ - dev->regs[0x85] = 0x18; - dev->regs[0x86] = 0x1b; + regs[0x85] = 0x18; + regs[0x86] = 0x1b; - dev->regs[0x87] = 0x30; - dev->regs[0x88] = 0x30; + regs[0x87] = 0x30; + regs[0x88] = 0x30; - dev->regs[0x89] = 0x2d; - dev->regs[0x8a] = 0x02; /* x8180 +2 */ + regs[0x89] = 0x2d; + regs[0x8a] = 0x02; /* x8180 +2 */ - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0x8d] = 0xf0; - dev->regs[0x8e] = 0x60; /* low nibble of 8e and 8d are proportional to + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0x8d] = 0xf0; + regs[0x8e] = 0x60; /* low nibble of 8e and 8d are proportional to the scanned width 1de => 5100 wide scan */ - dev->regs[0xc0] = 0xff; - dev->regs[0xc1] = 0x0f; - dev->regs[0xc2] = 0x00; - dev->regs[0xc9] = 0x00; - dev->regs[0xca] = 0x0e; - dev->regs[0xcb] = 0x00; - dev->regs[0xcc] = 0x00; - dev->regs[0xcd] = 0xf0; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - dev->regs[0xd1] = 0xea; - dev->regs[0xd2] = 0x0b; + regs[0xc0] = 0xff; + regs[0xc1] = 0x0f; + regs[0xc2] = 0x00; + regs[0xc9] = 0x00; + regs[0xca] = 0x0e; + regs[0xcb] = 0x00; + regs[0xcc] = 0x00; + regs[0xcd] = 0xf0; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + regs[0xd1] = 0xea; + regs[0xd2] = 0x0b; - dev->regs[0xd3] = 0x17; - dev->regs[0xd4] = 0x01; + regs[0xd3] = 0x17; + regs[0xd4] = 0x01; - dev->regs[0xe2] = 0x07; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; + regs[0xe2] = 0x07; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; - /* dev->regs[0xe5] = 0x56; - dev->regs[0xe6] = 0x01; exposure time 0x156 (~ 5500 /16) */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 342); + /* regs[0xe5] = 0x56; + regs[0xe6] = 0x01; exposure time 0x156 (~ 5500 /16) */ + SET_DOUBLE (regs, EXPOSURE_REG, 342); break; case SENSOR_TYPE_4400: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_4400 for 300 dpi\n"); - dev->regs[0x11] = 0x22; - dev->regs[0x35] = 0x0e; - dev->regs[0x3a] = 0x0e; - dev->regs[0x80] = 0x2b; - dev->regs[0x81] = 0x02; - dev->regs[0x82] = 0x2c; - dev->regs[0x83] = 0x02; - dev->regs[0x85] = 0x18; - dev->regs[0x86] = 0x1b; - dev->regs[0x87] = 0x30; - dev->regs[0x88] = 0x30; - dev->regs[0x89] = 0x2d; - dev->regs[0x8a] = 0x02; - dev->regs[0x8d] = 0xef; - dev->regs[0xc0] = 0x00; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0x0f; - dev->regs[0xc3] = 0xff; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xf0; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x0f; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0xff; - dev->regs[0xcb] = 0xf1; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0x00; - dev->regs[0xce] = 0xf0; - dev->regs[0xcf] = 0xed; - dev->regs[0xd0] = 0xef; - dev->regs[0xd1] = 0xe2; - dev->regs[0xd2] = 0x03; - dev->regs[0xd3] = 0x17; - dev->regs[0xd4] = 0x01; - dev->regs[0xe2] = 0x03; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_4400 for 300 dpi\n"); + regs[0x11] = 0x22; + regs[0x35] = 0x0e; + regs[0x3a] = 0x0e; + regs[0x80] = 0x2b; + regs[0x81] = 0x02; + regs[0x82] = 0x2c; + regs[0x83] = 0x02; + regs[0x85] = 0x18; + regs[0x86] = 0x1b; + regs[0x87] = 0x30; + regs[0x88] = 0x30; + regs[0x89] = 0x2d; + regs[0x8a] = 0x02; + regs[0x8d] = 0xef; + regs[0xc0] = 0x00; + regs[0xc1] = 0xff; + regs[0xc2] = 0x0f; + regs[0xc3] = 0xff; + regs[0xc4] = 0x00; + regs[0xc5] = 0xf0; + regs[0xc6] = 0x00; + regs[0xc7] = 0xff; + regs[0xc8] = 0x0f; + regs[0xc9] = 0xff; + regs[0xca] = 0xff; + regs[0xcb] = 0xf1; + regs[0xcc] = 0xff; + regs[0xcd] = 0x00; + regs[0xce] = 0xf0; + regs[0xcf] = 0xed; + regs[0xd0] = 0xef; + regs[0xd1] = 0xe2; + regs[0xd2] = 0x03; + regs[0xd3] = 0x17; + regs[0xd4] = 0x01; + regs[0xe2] = 0x03; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; /* 0x2ae=686 = 342*2+2 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 686); - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; + SET_DOUBLE (regs, EXPOSURE_REG, 686); + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; break; } break; case 600: - status1 = 0x28; + *status1 = 0x28; switch (dev->sensor) { case SENSOR_TYPE_BARE: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_BARE for 600 dpi\n"); + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_BARE for 600 dpi\n"); - dev->regs[0x34] = 0xf0; - dev->regs[0x35] = 0x1b; - dev->regs[0x36] = 0x29; - dev->regs[0x3a] = 0x1b; + regs[0x34] = 0xf0; + regs[0x35] = 0x1b; + regs[0x36] = 0x29; + regs[0x3a] = 0x1b; - dev->regs[0x72] = 0x3a; - dev->regs[0x73] = 0x15; - dev->regs[0x74] = 0x62; + regs[0x72] = 0x3a; + regs[0x73] = 0x15; + regs[0x74] = 0x62; - dev->regs[0x80] = 0x25; /* 425=1061 */ - dev->regs[0x81] = 0x04; - dev->regs[0x82] = 0x26; /* 426=1062 */ - dev->regs[0x83] = 0x04; - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; - dev->regs[0x89] = 0x27; /* 427=1063 */ - dev->regs[0x8a] = 0x04; + regs[0x80] = 0x25; /* 425=1061 */ + regs[0x81] = 0x04; + regs[0x82] = 0x26; /* 426=1062 */ + regs[0x83] = 0x04; + regs[0x85] = 0x30; + regs[0x86] = 0x30; + regs[0x87] = 0x60; + regs[0x88] = 0x5a; + regs[0x89] = 0x27; /* 427=1063 */ + regs[0x8a] = 0x04; - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; /* low nibble of 8e and 8d are proportional to + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; /* low nibble of 8e and 8d are proportional to the scanned width 1de => 5100 wide scan */ - dev->regs[0xc0] = 0xff; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0xff; - dev->regs[0xc3] = 0x00; - dev->regs[0xc4] = 0xf0; - dev->regs[0xc7] = 0x0f; - dev->regs[0xc8] = 0x00; - dev->regs[0xcb] = 0xe0; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0xff; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xe9; - dev->regs[0xd0] = 0xeb; + regs[0xc0] = 0xff; + regs[0xc1] = 0xff; + regs[0xc2] = 0xff; + regs[0xc3] = 0x00; + regs[0xc4] = 0xf0; + regs[0xc7] = 0x0f; + regs[0xc8] = 0x00; + regs[0xcb] = 0xe0; + regs[0xcc] = 0xff; + regs[0xcd] = 0xff; + regs[0xce] = 0xff; + regs[0xcf] = 0xe9; + regs[0xd0] = 0xeb; - dev->regs[0xd7] = 0x14; + regs[0xd7] = 0x14; - dev->regs[0xe2] = 0x01; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - /* dev->regs[0xe5] = 0xbd; - dev->regs[0xe6] = 0x0a; exposure time = 0x0abd=2749 (5500/2-1) */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 2749); - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; + regs[0xe2] = 0x01; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + /* regs[0xe5] = 0xbd; + regs[0xe6] = 0x0a; exposure time = 0x0abd=2749 (5500/2-1) */ + SET_DOUBLE (regs, EXPOSURE_REG, 2749); + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; break; case SENSOR_TYPE_XPA: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_XPA for 600 dpi\n"); + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_XPA for 600 dpi\n"); - status2 = 0x3b; - dev->regs[0x33] = 0x83; /* 0x86 */ - dev->regs[0x34] = 0xf0; - dev->regs[0x35] = 0x1b; - dev->regs[0x36] = 0x29; - dev->regs[0x3a] = 0x1b; - dev->regs[0x40] = 0x2c; /* 0x24 */ - dev->regs[0x50] = 0x00; /* 0x18 */ - dev->regs[0x64] = 0x01; /* 0x02 */ - dev->regs[0x65] = 0x20; /* 0x10 */ - dev->regs[0x66] = 0xa6; - dev->regs[0x6c] = 0x92; - dev->regs[0x6d] = 0x14; - dev->regs[0x72] = 0x3a; - dev->regs[0x73] = 0x15; - dev->regs[0x74] = 0x62; + *status2 = 0x3b; + regs[0x33] = 0x83; /* 0x86 */ + regs[0x34] = 0xf0; + regs[0x35] = 0x1b; + regs[0x36] = 0x29; + regs[0x3a] = 0x1b; + regs[0x40] = 0x2c; /* 0x24 */ + regs[0x50] = 0x00; /* 0x18 */ + regs[0x64] = 0x01; /* 0x02 */ + regs[0x65] = 0x20; /* 0x10 */ + regs[0x66] = 0xa6; + regs[0x6c] = 0x92; + regs[0x6d] = 0x14; + regs[0x72] = 0x3a; + regs[0x73] = 0x15; + regs[0x74] = 0x62; - dev->regs[0x80] = 0x25; /* 425=1061 */ - dev->regs[0x81] = 0x04; - dev->regs[0x82] = 0x26; /* 426=1062 */ - dev->regs[0x83] = 0x04; + regs[0x80] = 0x25; /* 425=1061 */ + regs[0x81] = 0x04; + regs[0x82] = 0x26; /* 426=1062 */ + regs[0x83] = 0x04; - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; + regs[0x85] = 0x30; + regs[0x86] = 0x30; + regs[0x87] = 0x60; + regs[0x88] = 0x5a; - dev->regs[0x89] = 0x27; /* 427=1063 */ - dev->regs[0x8a] = 0x04; + regs[0x89] = 0x27; /* 427=1063 */ + regs[0x8a] = 0x04; - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; /* 25054 */ + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; /* 25054 */ - dev->regs[0xc0] = 0xf8; - dev->regs[0xc1] = 0x7f; - dev->regs[0xc2] = 0x00; - dev->regs[0xc3] = 0xf8; - dev->regs[0xc4] = 0x7f; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0xf8; - dev->regs[0xc7] = 0x7f; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0x8f; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x07; - dev->regs[0xcd] = 0x80; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf2; - dev->regs[0xd0] = 0xf4; - dev->regs[0xd1] = 0xe7; - dev->regs[0xd2] = 0x08; - dev->regs[0xd3] = 0x02; - dev->regs[0xd4] = 0x10; - dev->regs[0xd7] = 0x31; - dev->regs[0xe2] = 0x01; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 2749); /* 0x0abd */ + regs[0xc0] = 0xf8; + regs[0xc1] = 0x7f; + regs[0xc2] = 0x00; + regs[0xc3] = 0xf8; + regs[0xc4] = 0x7f; + regs[0xc5] = 0x00; + regs[0xc6] = 0xf8; + regs[0xc7] = 0x7f; + regs[0xc8] = 0x00; + regs[0xc9] = 0xff; + regs[0xca] = 0x8f; + regs[0xcb] = 0xff; + regs[0xcc] = 0x07; + regs[0xcd] = 0x80; + regs[0xce] = 0xff; + regs[0xcf] = 0xf2; + regs[0xd0] = 0xf4; + regs[0xd1] = 0xe7; + regs[0xd2] = 0x08; + regs[0xd3] = 0x02; + regs[0xd4] = 0x10; + regs[0xd7] = 0x31; + regs[0xe2] = 0x01; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; + SET_DOUBLE (regs, EXPOSURE_REG, 2749); /* 0x0abd */ break; case SENSOR_TYPE_4400: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_4400 for 600 dpi\n"); - status1 = 0x10; - status2 = 0x23; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_4400 for 600 dpi\n"); + *status1 = 0x10; + *status2 = 0x23; - dev->regs[0x13] = 0x39; - dev->regs[0x14] = 0xf0; - dev->regs[0x15] = 0x29; - dev->regs[0x16] = 0x00; - dev->regs[0x17] = 0x10; - dev->regs[0x23] = 0x00; - dev->regs[0x34] = 0xf0; - dev->regs[0x35] = 0x1b; - dev->regs[0x36] = 0x29; - dev->regs[0x39] = 0x00; - dev->regs[0x3a] = 0x1b; - dev->regs[0x72] = 0x3a; - dev->regs[0x73] = 0x15; - dev->regs[0x74] = 0x62; - dev->regs[0x80] = 0x25; - dev->regs[0x81] = 0x04; - dev->regs[0x82] = 0x26; - dev->regs[0x83] = 0x04; - dev->regs[0x85] = 0x30; - dev->regs[0x86] = 0x30; - dev->regs[0x87] = 0x60; - dev->regs[0x88] = 0x5a; - dev->regs[0x89] = 0x27; - dev->regs[0x8a] = 0x04; - dev->regs[0x8d] = 0xde; - dev->regs[0x8e] = 0x61; - dev->regs[0xc0] = 0xf8; - dev->regs[0xc1] = 0x7f; - dev->regs[0xc2] = 0x00; - dev->regs[0xc3] = 0xf8; - dev->regs[0xc4] = 0x7f; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0xf8; - dev->regs[0xc7] = 0x7f; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0xff; - dev->regs[0xca] = 0x8f; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x07; - dev->regs[0xcd] = 0x80; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf2; - dev->regs[0xd0] = 0xf4; - dev->regs[0xd1] = 0xe7; - dev->regs[0xd2] = 0x08; - dev->regs[0xd3] = 0x0e; - dev->regs[0xd4] = 0x10; - dev->regs[0xd7] = 0x31; - dev->regs[0xe2] = 0x01; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 2749); + regs[0x13] = 0x39; + regs[0x14] = 0xf0; + regs[0x15] = 0x29; + regs[0x16] = 0x00; + regs[0x17] = 0x10; + regs[0x23] = 0x00; + regs[0x34] = 0xf0; + regs[0x35] = 0x1b; + regs[0x36] = 0x29; + regs[0x39] = 0x00; + regs[0x3a] = 0x1b; + regs[0x72] = 0x3a; + regs[0x73] = 0x15; + regs[0x74] = 0x62; + regs[0x80] = 0x25; + regs[0x81] = 0x04; + regs[0x82] = 0x26; + regs[0x83] = 0x04; + regs[0x85] = 0x30; + regs[0x86] = 0x30; + regs[0x87] = 0x60; + regs[0x88] = 0x5a; + regs[0x89] = 0x27; + regs[0x8a] = 0x04; + regs[0x8d] = 0xde; + regs[0x8e] = 0x61; + regs[0xc0] = 0xf8; + regs[0xc1] = 0x7f; + regs[0xc2] = 0x00; + regs[0xc3] = 0xf8; + regs[0xc4] = 0x7f; + regs[0xc5] = 0x00; + regs[0xc6] = 0xf8; + regs[0xc7] = 0x7f; + regs[0xc8] = 0x00; + regs[0xc9] = 0xff; + regs[0xca] = 0x8f; + regs[0xcb] = 0xff; + regs[0xcc] = 0x07; + regs[0xcd] = 0x80; + regs[0xce] = 0xff; + regs[0xcf] = 0xf2; + regs[0xd0] = 0xf4; + regs[0xd1] = 0xe7; + regs[0xd2] = 0x08; + regs[0xd3] = 0x0e; + regs[0xd4] = 0x10; + regs[0xd7] = 0x31; + regs[0xe2] = 0x01; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; + SET_DOUBLE (regs, EXPOSURE_REG, 2749); break; case SENSOR_TYPE_4400_BARE: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_4400_BARE for 600 dpi\n"); + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_4400_BARE for 600 dpi\n"); return SANE_STATUS_INVAL; break; } break; case 1200: - status1 = 0x28; + *status1 = 0x28; switch (dev->sensor) { case SENSOR_TYPE_BARE: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_BARE for 1200 dpi\n"); + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_BARE for 1200 dpi\n"); - dev->regs[0x34] = 0xf0; - dev->regs[0x35] = 0x1b; - dev->regs[0x36] = 0x29; - dev->regs[0x3a] = 0x1b; - dev->regs[0x40] = 0xac; - dev->regs[0x80] = 0x1a; - dev->regs[0x81] = 0x08; /* 81a=2074 */ - dev->regs[0x82] = 0x1b; - dev->regs[0x83] = 0x08; /* 81b=2075 */ - dev->regs[0x85] = 0x60; - dev->regs[0x86] = 0x5a; - dev->regs[0x87] = 0xc0; - dev->regs[0x88] = 0xae; - dev->regs[0x89] = 0x1c; - dev->regs[0x8a] = 0x08; /* 81c=2076 */ + regs[0x34] = 0xf0; + regs[0x35] = 0x1b; + regs[0x36] = 0x29; + regs[0x3a] = 0x1b; + regs[0x40] = 0xac; + regs[0x80] = 0x1a; + regs[0x81] = 0x08; /* 81a=2074 */ + regs[0x82] = 0x1b; + regs[0x83] = 0x08; /* 81b=2075 */ + regs[0x85] = 0x60; + regs[0x86] = 0x5a; + regs[0x87] = 0xc0; + regs[0x88] = 0xae; + regs[0x89] = 0x1c; + regs[0x8a] = 0x08; /* 81c=2076 */ - dev->regs[0x8d] = 0xbd; /* about twice the 600 dpi values */ - dev->regs[0x8e] = 0x63; /* low nibble of 8e and 8d are proportional to + regs[0x8d] = 0xbd; /* about twice the 600 dpi values */ + regs[0x8e] = 0x63; /* low nibble of 8e and 8d are proportional to the scanned width 3b5 => 10124 wide scan */ - dev->regs[0xc0] = 0xff; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0xff; - dev->regs[0xc4] = 0x0f; - dev->regs[0xc5] = 0x00; - dev->regs[0xc6] = 0x00; - dev->regs[0xc7] = 0xf0; - dev->regs[0xc9] = 0x00; - dev->regs[0xca] = 0x0e; - dev->regs[0xcb] = 0x00; - dev->regs[0xcc] = 0xff; - dev->regs[0xcd] = 0xff; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - dev->regs[0xd1] = 0xea; - dev->regs[0xd2] = 0x0b; - dev->regs[0xd3] = 0x17; - dev->regs[0xd4] = 0xc1; + regs[0xc0] = 0xff; + regs[0xc1] = 0xff; + regs[0xc2] = 0xff; + regs[0xc4] = 0x0f; + regs[0xc5] = 0x00; + regs[0xc6] = 0x00; + regs[0xc7] = 0xf0; + regs[0xc9] = 0x00; + regs[0xca] = 0x0e; + regs[0xcb] = 0x00; + regs[0xcc] = 0xff; + regs[0xcd] = 0xff; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + regs[0xd1] = 0xea; + regs[0xd2] = 0x0b; + regs[0xd3] = 0x17; + regs[0xd4] = 0xc1; - dev->regs[0xd7] = 0x14; - dev->regs[0xd8] = 0xa4; + regs[0xd7] = 0x14; + regs[0xd8] = 0xa4; - dev->regs[0xe2] = 0x01; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - /* dev->regs[0xe5] = 0x7b; - dev->regs[0xe6] = 0x15; exposure time = 0x157b=5499 */ - SET_DOUBLE (dev->regs, EXPOSURE_REG, 5499); - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; + regs[0xe2] = 0x01; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + /* regs[0xe5] = 0x7b; + regs[0xe6] = 0x15; exposure time = 0x157b=5499 */ + SET_DOUBLE (regs, EXPOSURE_REG, 5499); + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; break; case SENSOR_TYPE_XPA: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_XPA for 1200 dpi\n"); - status2 = 0x3f; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_XPA for 1200 dpi\n"); + *status2 = 0x3f; - dev->regs[0x34] = 0xf0; - dev->regs[0x35] = 0x1b; - dev->regs[0x36] = 0x29; - dev->regs[0x3a] = 0x1b; - dev->regs[0x80] = 0x1a; - dev->regs[0x81] = 0x08; /* 81a=2074 */ - dev->regs[0x82] = 0x1b; - dev->regs[0x83] = 0x08; /* 81b=2075 */ - dev->regs[0x85] = 0x60; - dev->regs[0x86] = 0x5a; - dev->regs[0x87] = 0xc0; - dev->regs[0x88] = 0xae; - dev->regs[0x89] = 0x1c; - dev->regs[0x8a] = 0x08; /* 81c=2076 */ + regs[0x34] = 0xf0; + regs[0x35] = 0x1b; + regs[0x36] = 0x29; + regs[0x3a] = 0x1b; + regs[0x80] = 0x1a; + regs[0x81] = 0x08; /* 81a=2074 */ + regs[0x82] = 0x1b; + regs[0x83] = 0x08; /* 81b=2075 */ + regs[0x85] = 0x60; + regs[0x86] = 0x5a; + regs[0x87] = 0xc0; + regs[0x88] = 0xae; + regs[0x89] = 0x1c; + regs[0x8a] = 0x08; /* 81c=2076 */ - dev->regs[0xc1] = 0xff; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; + regs[0xc1] = 0xff; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; - dev->regs[0xe2] = 0x01; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 5499); - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; - dev->regs[0x33] = 0x86; - dev->regs[0x40] = 0xa4; - dev->regs[0x50] = 0x18; - dev->regs[0x64] = 0x02; - dev->regs[0x65] = 0x10; - dev->regs[0x8d] = 0x78; - dev->regs[0x8e] = 0x67; - dev->regs[0xc0] = 0xe0; - dev->regs[0xc2] = 0x01; - dev->regs[0xc3] = 0x1f; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xfe; - dev->regs[0xc6] = 0xff; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0x3f; - dev->regs[0xca] = 0xfe; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x00; - dev->regs[0xcd] = 0x00; - dev->regs[0xd1] = 0xec; - dev->regs[0xd2] = 0x0d; - dev->regs[0xd3] = 0x05; - dev->regs[0xd4] = 0x67; - dev->regs[0xd7] = 0x10; - dev->regs[0xd8] = 0x52; + regs[0xe2] = 0x01; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + SET_DOUBLE (regs, EXPOSURE_REG, 5499); + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; + regs[0x33] = 0x86; + regs[0x40] = 0xa4; + regs[0x50] = 0x18; + regs[0x64] = 0x02; + regs[0x65] = 0x10; + regs[0x8d] = 0x78; + regs[0x8e] = 0x67; + regs[0xc0] = 0xe0; + regs[0xc2] = 0x01; + regs[0xc3] = 0x1f; + regs[0xc4] = 0x00; + regs[0xc5] = 0xfe; + regs[0xc6] = 0xff; + regs[0xc7] = 0xff; + regs[0xc8] = 0x00; + regs[0xc9] = 0x3f; + regs[0xca] = 0xfe; + regs[0xcb] = 0xff; + regs[0xcc] = 0x00; + regs[0xcd] = 0x00; + regs[0xd1] = 0xec; + regs[0xd2] = 0x0d; + regs[0xd3] = 0x05; + regs[0xd4] = 0x67; + regs[0xd7] = 0x10; + regs[0xd8] = 0x52; break; case SENSOR_TYPE_4400: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_4400 for 1200 dpi\n"); - dev->regs[0x13] = 0x39; - dev->regs[0x14] = 0xf0; - dev->regs[0x15] = 0x29; - dev->regs[0x16] = 0x00; - dev->regs[0x17] = 0x10; - dev->regs[0x23] = 0x00; - dev->regs[0x33] = 0x86; - dev->regs[0x34] = 0xf0; - dev->regs[0x35] = 0x0e; - dev->regs[0x39] = 0x00; - dev->regs[0x3a] = 0x0e; - dev->regs[0x40] = 0xac; - dev->regs[0x64] = 0x02; - dev->regs[0x65] = 0x10; - dev->regs[0x80] = 0x1a; - dev->regs[0x81] = 0x08; - dev->regs[0x82] = 0x1b; - dev->regs[0x83] = 0x08; - dev->regs[0x85] = 0x60; - dev->regs[0x86] = 0x5a; - dev->regs[0x87] = 0xc0; - dev->regs[0x88] = 0xae; - dev->regs[0x89] = 0x1c; - dev->regs[0x8a] = 0x08; - dev->regs[0x8d] = 0xbc; - dev->regs[0x8e] = 0x63; - dev->regs[0xc0] = 0xe0; - dev->regs[0xc1] = 0xff; - dev->regs[0xc2] = 0x01; - dev->regs[0xc3] = 0x1f; - dev->regs[0xc4] = 0x00; - dev->regs[0xc5] = 0xfe; - dev->regs[0xc6] = 0xff; - dev->regs[0xc7] = 0xff; - dev->regs[0xc8] = 0x00; - dev->regs[0xc9] = 0x3f; - dev->regs[0xca] = 0xfe; - dev->regs[0xcb] = 0xff; - dev->regs[0xcc] = 0x00; - dev->regs[0xcd] = 0x00; - dev->regs[0xce] = 0xff; - dev->regs[0xcf] = 0xf5; - dev->regs[0xd0] = 0xf7; - dev->regs[0xd1] = 0xec; - dev->regs[0xd2] = 0x0d; - dev->regs[0xd3] = 0x05; - dev->regs[0xd4] = 0x67; - dev->regs[0xd7] = 0x10; - dev->regs[0xd8] = 0x52; - dev->regs[0xe2] = 0x00; - dev->regs[0xe3] = 0x00; - dev->regs[0xe4] = 0x00; - dev->regs[0xe7] = 0x00; - dev->regs[0xe8] = 0x00; - dev->regs[0xe9] = 0x00; - dev->regs[0xea] = 0x00; - dev->regs[0xeb] = 0x00; - dev->regs[0xec] = 0x00; - dev->regs[0xed] = 0x00; - dev->regs[0xef] = 0x00; - dev->regs[0xf0] = 0x00; - dev->regs[0xf2] = 0x00; - SET_DOUBLE (dev->regs, EXPOSURE_REG, 10999); /* max sensors pixels - 1 */ - status1 = 0x10; - status2 = 0x23; + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_4400 for 1200 dpi\n"); + regs[0x13] = 0x39; + regs[0x14] = 0xf0; + regs[0x15] = 0x29; + regs[0x16] = 0x00; + regs[0x17] = 0x10; + regs[0x23] = 0x00; + regs[0x33] = 0x86; + regs[0x34] = 0xf0; + regs[0x35] = 0x0e; + regs[0x39] = 0x00; + regs[0x3a] = 0x0e; + regs[0x40] = 0xac; + regs[0x64] = 0x02; + regs[0x65] = 0x10; + regs[0x80] = 0x1a; + regs[0x81] = 0x08; + regs[0x82] = 0x1b; + regs[0x83] = 0x08; + regs[0x85] = 0x60; + regs[0x86] = 0x5a; + regs[0x87] = 0xc0; + regs[0x88] = 0xae; + regs[0x89] = 0x1c; + regs[0x8a] = 0x08; + regs[0x8d] = 0xbc; + regs[0x8e] = 0x63; + regs[0xc0] = 0xe0; + regs[0xc1] = 0xff; + regs[0xc2] = 0x01; + regs[0xc3] = 0x1f; + regs[0xc4] = 0x00; + regs[0xc5] = 0xfe; + regs[0xc6] = 0xff; + regs[0xc7] = 0xff; + regs[0xc8] = 0x00; + regs[0xc9] = 0x3f; + regs[0xca] = 0xfe; + regs[0xcb] = 0xff; + regs[0xcc] = 0x00; + regs[0xcd] = 0x00; + regs[0xce] = 0xff; + regs[0xcf] = 0xf5; + regs[0xd0] = 0xf7; + regs[0xd1] = 0xec; + regs[0xd2] = 0x0d; + regs[0xd3] = 0x05; + regs[0xd4] = 0x67; + regs[0xd7] = 0x10; + regs[0xd8] = 0x52; + regs[0xe2] = 0x00; + regs[0xe3] = 0x00; + regs[0xe4] = 0x00; + regs[0xe7] = 0x00; + regs[0xe8] = 0x00; + regs[0xe9] = 0x00; + regs[0xea] = 0x00; + regs[0xeb] = 0x00; + regs[0xec] = 0x00; + regs[0xed] = 0x00; + regs[0xef] = 0x00; + regs[0xf0] = 0x00; + regs[0xf2] = 0x00; + SET_DOUBLE (regs, EXPOSURE_REG, 10999); /* max sensors pixels - 1 */ + *status1 = 0x10; + *status2 = 0x23; break; case SENSOR_TYPE_4400_BARE: - DBG (DBG_io, "write_scan_registers: setting up SENSOR_TYPE_4400_BARE for 1200 dpi\n"); + DBG (DBG_io, "setup_scan_registers: setting up SENSOR_TYPE_4400_BARE for 1200 dpi\n"); return SANE_STATUS_INVAL; break; } @@ -7658,14 +7679,39 @@ write_scan_registers (struct Rts8891_Session *session) } /* sets divisor */ - dev->regs[0xd3] = rts8891_data_format (dev->xdpi, dev->sensor); + regs[0xd3] = rts8891_data_format (dev->xdpi, dev->sensor); /* toggle front panel light to signal gray scan */ if (session->params.format == SANE_FRAME_GRAY) { - status1 = (status1 & 0x0F) | 0x10; + *status1 = (*status1 & 0x0F) | 0x10; + } + + return status; +} + +/* set up the shadow registers for scan, depending on scan parameters */ +/* the ultimate goal is to have no direct access to registers, but to */ +/* set them through helper functions */ +/* NOTE : I couldn't manage to get scans that really uses gray settings. */ +/* The windows driver is allways scanning in color, so we do the same. */ +/* For now, the only mode that could be done would be 300 dpi gray scan, */ +/* based on the register settings of find_origin() */ +static SANE_Status +write_scan_registers (struct Rts8891_Session *session) +{ + SANE_Status status = SANE_STATUS_GOOD; + SANE_Byte control; + SANE_Byte status1, status2; + struct Rts8891_Device *dev = session->dev; + + /* setup registers for scan */ + status=setup_scan_registers (session, &status1, &status2, dev->regs); + if (status != SANE_STATUS_GOOD) + { + DBG (DBG_error0, "write_scan_registers: failed to setup registers\n"); + return status; } - sanei_rts88xx_set_status (dev->devnum, dev->regs, status1, status2); /* check if session is idle */ control = 0x00;