genesys: Return errors as exceptions from *init_motor_regs_scan()

merge-requests/101/head
Povilas Kanapickas 2019-07-14 23:41:05 +03:00
rodzic 9c9a118e12
commit c19ab1fce5
5 zmienionych plików z 114 dodań i 180 usunięć

Wyświetl plik

@ -617,18 +617,17 @@ static int gl124_compute_exposure(Genesys_Device *dev, int xres, int half_ccd)
}
static SANE_Status
gl124_init_motor_regs_scan (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
unsigned int scan_exposure_time,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
ScanColorMode scan_mode,
unsigned int flags)
static void gl124_init_motor_regs_scan(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
unsigned int scan_exposure_time,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
ScanColorMode scan_mode,
unsigned int flags)
{
DBG_HELPER(dbg);
int use_fast_fed;
@ -811,8 +810,6 @@ gl124_init_motor_regs_scan (Genesys_Device * dev,
/* FMOVDEC */
sanei_genesys_set_double(reg,REG_FMOVDEC,fast_steps);
return SANE_STATUS_GOOD;
}
@ -1190,7 +1187,6 @@ gl124_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */
unsigned optical_res;
SANE_Status status = SANE_STATUS_GOOD;
debug_dump(DBG_info, params);
@ -1310,24 +1306,16 @@ gl124_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
move = params.starty;
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
mflags=0;
if(params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)
mflags|=MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
if(params.flags & SCAN_FLAG_FEEDING)
mflags|=MOTOR_FLAG_FEED;
status = gl124_init_motor_regs_scan (dev, sensor,
reg,
exposure_time,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt * params.channels : lincnt,
dummy,
move,
params.scan_mode,
mflags);
if (status != SANE_STATUS_GOOD)
return status;
mflags = 0;
if (params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
}
if (params.flags & SCAN_FLAG_FEEDING) {
mflags |= MOTOR_FLAG_FEED;
}
gl124_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
dev->model->is_cis ? lincnt * params.channels : lincnt,
dummy, move, params.scan_mode, mflags);
/*** prepares data reordering ***/

Wyświetl plik

@ -882,12 +882,8 @@ static void gl841_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
#define MOTOR_ACTION_GO_HOME 2
#define MOTOR_ACTION_HOME_FREE 3
/** @brief turn off motor
*
*/
static SANE_Status
gl841_init_motor_regs_off(Genesys_Register_Set * reg,
unsigned int scan_lines)
// @brief turn off motor
static void gl841_init_motor_regs_off(Genesys_Register_Set* reg, unsigned int scan_lines)
{
DBG_HELPER_ARGS(dbg, "scan_lines=%d", scan_lines);
unsigned int feedl;
@ -945,8 +941,6 @@ gl841_init_motor_regs_off(Genesys_Register_Set * reg,
r = sanei_genesys_get_address (reg, 0x5f);
r->value = 0;
return SANE_STATUS_GOOD;
}
/** @brief write motor table frequency
@ -1152,19 +1146,18 @@ HOME_FREE: 3
return SANE_STATUS_GOOD;
}
static SANE_Status
gl841_init_motor_regs_scan(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
unsigned int scan_exposure_time,/*pixel*/
float scan_yres,/*dpi, motor resolution*/
int scan_step_type,/*0: full, 1: half, 2: quarter*/
unsigned int scan_lines,/*lines, scan resolution*/
unsigned int scan_dummy,
/*number of scan lines to add in a scan_lines line*/
unsigned int feed_steps,/*1/base_ydpi*/
/*maybe float for half/quarter step resolution?*/
int scan_power_mode,
unsigned int flags)
static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
unsigned int scan_exposure_time,/*pixel*/
float scan_yres,/*dpi, motor resolution*/
int scan_step_type,/*0: full, 1: half, 2: quarter*/
unsigned int scan_lines,/*lines, scan resolution*/
unsigned int scan_dummy,
// number of scan lines to add in a scan_lines line
unsigned int feed_steps,/*1/base_ydpi*/
// maybe float for half/quarter step resolution?
int scan_power_mode,
unsigned int flags)
{
DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d,"
" scan_dummy=%d, feed_steps=%d, scan_power_mode=%d, flags=%x",
@ -1464,8 +1457,6 @@ HOME_FREE: 3
r = sanei_genesys_get_address (reg, 0x5f);
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
return SANE_STATUS_GOOD;
}
static int
@ -1826,7 +1817,6 @@ gl841_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */
int optical_res;
SANE_Status status = SANE_STATUS_GOOD;
unsigned int oflags; /**> optical flags */
debug_dump(DBG_info, params);
@ -2041,24 +2031,16 @@ dummy \ scanned lines
/* move = ((move + dummy) / (dummy + 1)) * (dummy + 1);
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);*/
if (params.flags & SCAN_FLAG_SINGLE_LINE)
status = gl841_init_motor_regs_off(reg, dev->model->is_cis?lincnt* params.channels:lincnt);
else
status = gl841_init_motor_regs_scan(dev, sensor,
reg,
exposure_time,
slope_dpi,
scan_step_type,
dev->model->is_cis?lincnt* params.channels:lincnt,
dummy,
move,
scan_power_mode,
(params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)?
MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE:0
);
if (params.flags & SCAN_FLAG_SINGLE_LINE) {
gl841_init_motor_regs_off(reg, dev->model->is_cis?lincnt* params.channels:lincnt);
} else {
gl841_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
dev->model->is_cis?lincnt* params.channels:lincnt,
dummy, move, scan_power_mode,
(params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)?
MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE:0);
}
if (status != SANE_STATUS_GOOD)
return status;
/*** prepares data reordering ***/
@ -2534,7 +2516,7 @@ gl841_stop_action (Genesys_Device * dev)
gl841_init_optical_regs_off(&local_reg);
gl841_init_motor_regs_off(&local_reg,0);
gl841_init_motor_regs_off(&local_reg,0);
sanei_genesys_bulk_write_register(dev, local_reg);
/* looks like writing the right registers to zero is enough to get the chip

Wyświetl plik

@ -829,18 +829,17 @@ static void gl843_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
}
static SANE_Status
gl843_init_motor_regs_scan (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
unsigned int exposure,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
int scan_power_mode,
unsigned int flags)
static void gl843_init_motor_regs_scan(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
unsigned int exposure,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
int scan_power_mode,
unsigned int flags)
{
DBG_HELPER_ARGS(dbg, "exposure=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, "
"feed_steps=%d, scan_power_mode=%d, flags=%x",
@ -1020,8 +1019,6 @@ gl843_init_motor_regs_scan (Genesys_Device * dev,
}
}
}
return SANE_STATUS_GOOD;
}
@ -1375,8 +1372,6 @@ static SANE_Status gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Senso
int scan_power_mode = 0;
size_t requested_buffer_size, read_buffer_size;
SANE_Status status = SANE_STATUS_GOOD;
debug_dump(DBG_info, session.params);
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, session.num_staggered_lines);
@ -1467,27 +1462,22 @@ static SANE_Status gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Senso
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
mflags=0;
if(session.params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)
mflags|=MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
if(session.params.flags & SCAN_FLAG_FEEDING)
mflags|=MOTOR_FLAG_FEED;
if (session.params.flags & SCAN_FLAG_USE_XPA)
mflags |= MOTOR_FLAG_USE_XPA;
mflags = 0;
if (session.params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
}
if (session.params.flags & SCAN_FLAG_FEEDING) {
mflags |= MOTOR_FLAG_FEED;
}
if (session.params.flags & SCAN_FLAG_USE_XPA) {
mflags |= MOTOR_FLAG_USE_XPA;
}
status = gl843_init_motor_regs_scan (dev, sensor,
reg,
exposure,
slope_dpi,
scan_step_type,
dev->model->is_cis ? session.output_line_count * session.params.channels
: session.output_line_count,
dummy,
move,
scan_power_mode,
mflags);
if (status != SANE_STATUS_GOOD)
return status;
unsigned scan_lines = dev->model->is_cis ? session.output_line_count * session.params.channels
: session.output_line_count;
gl843_init_motor_regs_scan(dev, sensor, reg, exposure, slope_dpi, scan_step_type,
scan_lines, dummy, move, scan_power_mode, mflags);
/* since we don't have sheetfed scanners to handle,
* use huge read buffer */

Wyświetl plik

@ -525,20 +525,18 @@ static void gl846_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
}
/** @brief set up motor related register for scan
*/
static SANE_Status
gl846_init_motor_regs_scan (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
unsigned int scan_exposure_time,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
int scan_power_mode,
unsigned int flags)
// @brief set up motor related register for scan
static void gl846_init_motor_regs_scan(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
unsigned int scan_exposure_time,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
int scan_power_mode,
unsigned int flags)
{
DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d, "
"scan_dummy=%d, feed_steps=%d, scan_power_mode=%d, flags=%x",
@ -759,8 +757,6 @@ gl846_init_motor_regs_scan (Genesys_Device * dev,
r = sanei_genesys_get_address (reg, REG_FMOVDEC);
r->value = fast_steps;
return SANE_STATUS_GOOD;
}
@ -1039,7 +1035,6 @@ gl846_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */
int optical_res;
SANE_Status status = SANE_STATUS_GOOD;
debug_dump(DBG_info, params);
@ -1151,25 +1146,17 @@ gl846_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
move = params.starty;
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
mflags=0;
if(params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
if(params.flags & SCAN_FLAG_FEEDING)
mflags |= MOTOR_FLAG_FEED;
status = gl846_init_motor_regs_scan (dev, sensor,
reg,
exposure_time,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt *
params.channels : lincnt, dummy, move,
scan_power_mode,
mflags);
if (status != SANE_STATUS_GOOD)
return status;
mflags = 0;
if (params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
}
if (params.flags & SCAN_FLAG_FEEDING) {
mflags |= MOTOR_FLAG_FEED;
}
gl846_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
dev->model->is_cis ? lincnt * params.channels : lincnt, dummy, move,
scan_power_mode, mflags);
/*** prepares data reordering ***/

Wyświetl plik

@ -557,20 +557,18 @@ static void gl847_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
}
/** @brief set up motor related register for scan
*/
static SANE_Status
gl847_init_motor_regs_scan (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
unsigned int scan_exposure_time,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
int scan_power_mode,
unsigned int flags)
// @brief set up motor related register for scan
static void gl847_init_motor_regs_scan(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
unsigned int scan_exposure_time,
float scan_yres,
int scan_step_type,
unsigned int scan_lines,
unsigned int scan_dummy,
unsigned int feed_steps,
int scan_power_mode,
unsigned int flags)
{
DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, can_yres=%g, scan_step_type=%d, scan_lines=%d, "
"scan_dummy=%d, feed_steps=%d, scan_power_mode=%d, flags=%x",
@ -772,8 +770,6 @@ gl847_init_motor_regs_scan (Genesys_Device * dev,
r = sanei_genesys_get_address (reg, REG_FMOVDEC);
r->value = fast_steps;
return SANE_STATUS_GOOD;
}
@ -1054,7 +1050,6 @@ gl847_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */
int optical_res;
SANE_Status status = SANE_STATUS_GOOD;
debug_dump(DBG_info, params);
@ -1167,24 +1162,16 @@ gl847_init_scan_regs(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
mflags=0;
if(params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
if(params.flags & SCAN_FLAG_FEEDING)
mflags |= MOTOR_FLAG_FEED;
status = gl847_init_motor_regs_scan (dev, sensor,
reg,
exposure_time,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt *
params.channels : lincnt, dummy, move,
scan_power_mode,
mflags);
if (status != SANE_STATUS_GOOD)
return status;
if (params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
}
if (params.flags & SCAN_FLAG_FEEDING) {
mflags |= MOTOR_FLAG_FEED;
}
gl847_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
dev->model->is_cis ? lincnt * params.channels : lincnt, dummy, move,
scan_power_mode, mflags);
/*** prepares data reordering ***/