G4050 XPA progress

- define and tune move_to_ta for gl843
- GPIO settings to light XPA lamp
- GPIO settings to enable XPA lamp motor
- park XPA lamp function for gl843
merge-requests/1/head
Stphane Voltz 2011-11-09 15:20:29 +01:00
rodzic 23727765f8
commit 6ddaf6fbc1
5 zmienionych plików z 248 dodań i 57 usunięć

Wyświetl plik

@ -515,7 +515,7 @@ static Genesys_Sensor Sensor[] = {
/* 08 09 0a 0b */
{0x00, 0x00, 0x18, 0x69} ,
/* 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
{0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x6f} ,
1.0, 1.0, 1.0,
@ -1231,7 +1231,7 @@ static Genesys_Model hpg4050_model = {
SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */
SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */
SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */
SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */
SANE_FIX (0.0), /* Size of scan area after paper sensor stops
sensing document in mm */

Wyświetl plik

@ -1301,9 +1301,6 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set)
return SANE_STATUS_GOOD;
}
#define MOTOR_FLAG_AUTO_GO_HOME 1
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 2
#define MOTOR_ACTION_FEED 1
#define MOTOR_ACTION_GO_HOME 2
#define MOTOR_ACTION_HOME_FREE 3

Wyświetl plik

@ -553,7 +553,7 @@ gl843_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi)
sanei_genesys_set_triple(regs,REG_CK3MAP,sensor->ck3map);
sanei_genesys_set_triple(regs,REG_CK4MAP,sensor->ck4map);
DBG (DBG_proc, "gl843_setup_sensor: completed \n");
DBGCOMPLETED;
}
@ -699,6 +699,15 @@ gl843_init_registers (Genesys_Device * dev)
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);
@ -1212,7 +1221,7 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
/* select XPA */
r->value &= ~REG03_XPASEL;
if (dev->settings.scan_method == SCAN_METHOD_TRANSPARENCY)
if (flags & OPTICAL_FLAG_USE_XPA)
{
r->value |= REG03_XPASEL;
}
@ -1492,6 +1501,8 @@ gl843_init_scan_regs (Genesys_Device * dev,
oflags |= OPTICAL_FLAG_DISABLE_DOUBLE;
if(stagger)
oflags |= OPTICAL_FLAG_STAGGER;
if (flags & SCAN_FLAG_USE_XPA)
oflags |= OPTICAL_FLAG_USE_XPA;
/* now _LOGICAL_ optical values used are known, setup registers */
@ -1542,17 +1553,19 @@ gl843_init_scan_regs (Genesys_Device * dev,
mflags|=MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
if(flags & SCAN_FLAG_FEEDING)
mflags|=MOTOR_FLAG_FEED;
if (flags & SCAN_FLAG_USE_XPA)
mflags |= MOTOR_FLAG_USE_XPA;
status = gl843_init_motor_regs_scan (dev,
reg,
exposure,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt * channels : lincnt,
dummy,
move,
scan_power_mode,
mflags);
status = gl843_init_motor_regs_scan (dev,
reg,
exposure,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt * channels : lincnt,
dummy,
move,
scan_power_mode,
mflags);
if (status != SANE_STATUS_GOOD)
return status;
@ -1824,7 +1837,7 @@ gl843_set_lamp_power (Genesys_Device * dev,
sanei_genesys_set_reg_from_set (regs, REG03, val);
for (i = 0; i < 6; i++)
{
r = sanei_genesys_get_address (dev->calib_reg, 0x10 + i);
r = sanei_genesys_get_address (regs, 0x10 + i);
r->value = dev->sensor.regs_0x10_0x1d[i];
}
}
@ -1834,7 +1847,7 @@ gl843_set_lamp_power (Genesys_Device * dev,
sanei_genesys_set_reg_from_set (regs, REG03, val);
for (i = 0; i < 6; i++)
{
r = sanei_genesys_get_address (dev->calib_reg, 0x10 + i);
r = sanei_genesys_get_address (regs, 0x10 + i);
r->value = 0x00;
}
}
@ -2162,7 +2175,7 @@ gl843_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
SANE_Bool start_motor)
{
SANE_Status status;
uint8_t val;
uint8_t val,r03;
uint16_t dpiset, dpihw;
DBGSTART;
@ -2198,11 +2211,11 @@ gl843_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
RIE (sanei_genesys_write_register (dev, REGA6, 0x44));
}
/* XPA lamp */
val = sanei_genesys_read_reg_from_set (reg, REG03);
if (val & REG03_XPASEL)
/* turn on XPA lamp if XPA is selected and lamp power on*/
r03 = sanei_genesys_read_reg_from_set (reg, REG03);
if ((r03 & REG03_XPASEL) && (r03 & REG03_LAMPPWR))
{
sanei_genesys_read_register (dev, REGA6, &val);
RIE (sanei_genesys_read_register (dev, REGA6, &val));
/* switch off regular lamp */
val &= 0xbf;
@ -2213,6 +2226,31 @@ gl843_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
RIE (sanei_genesys_write_register (dev, REGA6, val));
}
/* enable XPA lamp motor */
if (r03 & REG03_XPASEL)
{
/* set MULTFILM et GPOADF */
RIE (sanei_genesys_read_register (dev, REG6B, &val));
val |=REG6B_MULTFILM|REG6B_GPOADF;
RIE (sanei_genesys_write_register (dev, REG6B, val));
RIE (sanei_genesys_read_register (dev, REG6C, &val));
val &= ~REG6C_GPIO15;
RIE (sanei_genesys_write_register (dev, REG6C, val));
RIE (sanei_genesys_read_register (dev, REGA6, &val));
val |= REGA6_GPIO20;
RIE (sanei_genesys_write_register(dev,REGA6,val));
RIE (sanei_genesys_read_register (dev, REGA8, &val));
val &= ~REGA8_GPO27;
RIE (sanei_genesys_write_register (dev, REGA8, val));
RIE (sanei_genesys_read_register (dev, REGA9, &val));
val |= REGA9_GPO32|REGA9_GPO31;
RIE (sanei_genesys_write_register (dev, REGA9, val));
}
/* blinking led */
RIE (sanei_genesys_write_register (dev, REG7E, 0x01));
}
@ -2249,6 +2287,7 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
SANE_Bool check_stop)
{
SANE_Status status;
uint8_t val;
DBG (DBG_proc, "gl843_end_scan (check_stop = %d)\n", check_stop);
if (reg == NULL)
@ -2257,6 +2296,21 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
/* post scan gpio */
RIE(sanei_genesys_write_register(dev,0x7e,0x00));
/* turn off XPA lamp if XPA is selected and lamp power on*/
val = sanei_genesys_read_reg_from_set (reg, REG03);
if (val & (REG03_XPASEL|REG03_LAMPPWR))
{
sanei_genesys_read_register (dev, REGA6, &val);
/* switch on regular lamp */
val |= 0x40;
/* no XPA lamp power (2 bits for level: __11 ____) */
val &= ~0x30;
RIE (sanei_genesys_write_register (dev, REGA6, val));
}
if (dev->model->is_sheetfed == SANE_TRUE)
{
status = SANE_STATUS_GOOD;
@ -2277,6 +2331,82 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
return status;
}
/** @brief park XPA lamp
* park the XPA lamp if needed
*/
static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
{
Genesys_Register_Set local_reg[GENESYS_GL843_MAX_REGS];
SANE_Status status;
Genesys_Register_Set *r;
uint8_t val;
int loop = 0;
DBGSTART;
/* copy scan settings */
memset (local_reg, 0, sizeof (local_reg));
memcpy (local_reg, dev->reg, GENESYS_GL843_MAX_REGS * sizeof (Genesys_Register_Set));
/* set a huge feedl and reverse direction */
sanei_genesys_set_triple(local_reg,REG_FEEDL,0xbdcd);
/* clear scan and feed count */
RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT | REG0D_CLRMCNT));
/* set up for reverse and no scan */
r = sanei_genesys_get_address (local_reg, REG02);
r->value |= REG02_MTRREV;
r = sanei_genesys_get_address (local_reg, REG01);
r->value &= ~REG01_SCAN;
/* write to scanner and start action */
RIE (gl843_bulk_write_register (dev, local_reg, GENESYS_GL843_MAX_REGS));
status = gl843_start_action (dev);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, "%s: failed to start motor: %s\n",__FUNCTION__, sane_strstatus (status));
gl843_stop_action (dev);
/* restore original registers */
gl843_bulk_write_register (dev, dev->reg, GENESYS_GL843_MAX_REGS);
return status;
}
while (loop < 600) /* do not wait longer then 60 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n",__FUNCTION__,
sane_strstatus (status));
return status;
}
if (DBG_LEVEL >= DBG_io2)
{
sanei_genesys_print_status (val);
}
if (val & REG41_HOMESNR) /* home sensor */
{
DBG (DBG_info, "%s: reached home position\n",__FUNCTION__);
DBG (DBG_proc, "%s: finished\n",__FUNCTION__);
/* clear GPOADF to avoid reparking again */
sanei_genesys_read_register (dev, REG6B, &val);
val &= ~REG6B_GPOADF;
sanei_genesys_write_register (dev, REG6B, val);
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
++loop;
}
/* we are not parked here.... should we fail ? */
DBG (DBG_info, "%s: XPA lamp is not parked\n", __FUNCTION__);
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
/** @brief Moves the slider to the home (top) position slowly
* */
@ -2296,15 +2426,24 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG (DBG_proc, "gl843_slow_back_home (wait_until_home = %d)\n",
wait_until_home);
if (dev->model->gpo_type == GPO_G4050)
{
/* test if we need to park XPA lamp, we check GPOADF */
RIE (sanei_genesys_read_register (dev, REG6B, &val));
if(val & REG6B_GPOADF)
{
RIE(gl843_park_xpa_lamp(dev));
}
}
/* regular slow back home */
dev->scanhead_position_in_steps = 0;
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"gl124_slow_back_home: failed to read home sensor: %s\n",
sane_strstatus (status));
DBG (DBG_error, "%s: failed to read home sensor: %s\n", __FUNCTION__, sane_strstatus (status));
return status;
}
usleep (100000); /* sleep 100 ms */
@ -2407,7 +2546,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
return SANE_STATUS_IO_ERROR;
}
DBG (DBG_info, "gl124_slow_back_home: scanhead is still moving\n");
DBG (DBG_info, "%s: scanhead is still moving\n", __FUNCTION__);
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
@ -2632,9 +2771,6 @@ gl843_feed (Genesys_Device * dev, unsigned int steps)
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_FEEDING |
SCAN_FLAG_IGNORE_LINE_DISTANCE);
sanei_genesys_set_triple(local_reg,REG_EXPR,0);
sanei_genesys_set_triple(local_reg,REG_EXPG,0);
sanei_genesys_set_triple(local_reg,REG_EXPB,0);
/* clear scan and feed count */
RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT));
@ -3823,6 +3959,31 @@ gl843_update_hardware_sensors (Genesys_Scanner * s)
return status;
}
#ifndef UNIT_TESTING
static
#endif
SANE_Status
gl843_move_to_ta (Genesys_Device * dev)
{
SANE_Status status = SANE_STATUS_GOOD;
float resolution;
unsigned int feed;
DBGSTART;
resolution=sanei_genesys_get_lowest_ydpi(dev);
feed = 16*(SANE_UNFIX (dev->model->y_offset_calib_ta) * resolution) / MM_PER_INCH;
status = gl843_feed (dev, feed);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, "%s: failed to move to XPA calibration area\n", __FUNCTION__);
return status;
}
DBGCOMPLETED;
return status;
}
/** @brief search for a full width black or white strip.
* This function searches for a black or white stripe across the scanning area.
@ -4274,7 +4435,7 @@ static Genesys_Command_Set gl843_cmd_set = {
gl843_search_strip,
sanei_genesys_is_compatible_calibration,
NULL,
gl843_move_to_ta,
gl843_send_shading_data,
gl843_calculate_current_setup
};

Wyświetl plik

@ -327,8 +327,10 @@ SANE_Status gl843_bulk_write_register (Genesys_Device * dev, Genesys_Register_Se
#define REG6B_GPOM13 0x40
#define REG6B_GPOM12 0x20
#define REG6B_GPOM11 0x10
#define REG6B_GPO18 0x02
#define REG6B_GPO17 0x01
#define REG6B_GPOCK4 0x08
#define REG6B_GPOCP 0x04
#define REG6B_GPOLEDB 0x02
#define REG6B_GPOADF 0x01
#define REG6C 0x6c
#define REG6C_GPIO16 0x80
@ -361,9 +363,37 @@ SANE_Status gl843_bulk_write_register (Genesys_Device * dev, Genesys_Register_Se
#define REG87_LEDADD 0x04
#define REGA6 0xa6
#define REGA6_GPIO24 0x80
#define REGA6_GPIO23 0x40
#define REGA6_GPIO22 0x20
#define REGA6_GPIO21 0x10
#define REGA6_GPIO20 0x08
#define REGA6_GPIO19 0x04
#define REGA6_GPIO18 0x02
#define REGA6_GPIO17 0x01
#define REGA7 0xa7
#define REGA7_GPOE24 0x80
#define REGA7_GPOE23 0x40
#define REGA7_GPOE22 0x20
#define REGA7_GPOE21 0x10
#define REGA7_GPOE20 0x08
#define REGA7_GPOE19 0x04
#define REGA7_GPOE18 0x02
#define REGA7_GPOE17 0x01
#define REGA8 0xa8
#define REGA8_GPOE27 0x20
#define REGA8_GPOE26 0x10
#define REGA8_GPOE25 0x08
#define REGA8_GPO27 0x04
#define REGA8_GPO26 0x02
#define REGA8_GPO25 0x01
#define REGA9 0xa9
#define REGA9_GPO33 0x20
#define REGA9_GPO32 0x10
#define REGA9_GPO31 0x08
#define REGA9_GPO30 0x04
#define REGA9_GPO29 0x02
#define REGA9_GPO28 0x01
#define SCAN_TABLE 0 /* table 1 at 0x4000 */
#define BACKTRACK_TABLE 1 /* table 2 at 0x4800 */
@ -587,22 +617,22 @@ static Sensor_Profile sensors[]={
},
{CCD_G4050 , 600, 8016, 0x0001ff, 0x03ffff, 0x03ffff, 5168, 0, 0x2a, 0, 0, 0, 0x00, 0x00, 0x02, 0x00, 0x00,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
{0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
},
{CCD_G4050 , 1200, 56064, 0x0fffff, 0x0001ff, 0x0001ff, 5168, 0, 0x2a, 0, 0, 0, 0x20, 0x08, 0x0c, 0xc0, 0x05,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0x00, 0x08} ,
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0x00, 0x08} ,
{0x02, 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x1b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
},
{CCD_G4050 , 2400, 56064, 0x0fffff, 0x000000, 0x000000, 5168, 0, 0x2a, 0, 0, 0, 0x20, 0x08, 0x0a, 0xc0, 0x05,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0xc0, 0x08} ,
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0xc0, 0x08} ,
{0x02, 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x1b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
},
{CCD_G4050 , 4800, 42752, 0x0fffff, 0x000000, 0x000000, 5168, 0, 0x2a, 0, 0, 0, 0x21, 0x08, 0x0a, 0xc0, 0x07,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0xc1, 0x08} ,
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x3b, 0x0c, 0x10, 0x2a, 0x38, 0x10, 0xc1, 0x08} ,
{0x02, 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x1b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63},
},
};

Wyświetl plik

@ -748,27 +748,30 @@ typedef struct {
#define FAST_TABLE 3 /* table 4 at 0x5800 for gl124 */
#define HOME_TABLE 4 /* table 5 at 0x6000 for gl124 */
#define SCAN_FLAG_SINGLE_LINE 0x001
#define SCAN_FLAG_DISABLE_SHADING 0x002
#define SCAN_FLAG_DISABLE_GAMMA 0x004
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_USE_OPTICAL_RES 0x020
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SCAN_FLAG_CALIBRATION 0x100
#define SCAN_FLAG_FEEDING 0x200
#define SCAN_FLAG_SINGLE_LINE 0x001
#define SCAN_FLAG_DISABLE_SHADING 0x002
#define SCAN_FLAG_DISABLE_GAMMA 0x004
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_USE_OPTICAL_RES 0x020
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SCAN_FLAG_CALIBRATION 0x100
#define SCAN_FLAG_FEEDING 0x200
#define SCAN_FLAG_USE_XPA 0x400
#define MOTOR_FLAG_AUTO_GO_HOME 1
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 2
#define MOTOR_FLAG_FEED 4
#define MOTOR_FLAG_AUTO_GO_HOME 0x01
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 0x02
#define MOTOR_FLAG_FEED 0x04
#define MOTOR_FLAG_USE_XPA 0x08
#define OPTICAL_FLAG_DISABLE_GAMMA 1
#define OPTICAL_FLAG_DISABLE_SHADING 2
#define OPTICAL_FLAG_DISABLE_LAMP 4
#define OPTICAL_FLAG_ENABLE_LEDADD 8
#define OPTICAL_FLAG_DISABLE_DOUBLE 16
#define OPTICAL_FLAG_STAGGER 32
#define OPTICAL_FLAG_DISABLE_GAMMA 0x01
#define OPTICAL_FLAG_DISABLE_SHADING 0x02
#define OPTICAL_FLAG_DISABLE_LAMP 0x04
#define OPTICAL_FLAG_ENABLE_LEDADD 0x08
#define OPTICAL_FLAG_DISABLE_DOUBLE 0x10
#define OPTICAL_FLAG_STAGGER 0x20
#define OPTICAL_FLAG_USE_XPA 0x20
/*--------------------------------------------------------------------------*/
/* common functions needed by low level specific functions */