genesys: Return errors as exceptions from *init_regs_for_warmup()

merge-requests/104/head
Povilas Kanapickas 2019-07-20 11:02:19 +03:00
rodzic 7514468332
commit 61f74af249
6 zmienionych plików z 21 dodań i 58 usunięć

Wyświetl plik

@ -3421,13 +3421,11 @@ genesys_warmup_lamp (Genesys_Device * dev)
double second_average = 0;
int difference = 255;
int empty, lines = 3;
SANE_Status status = SANE_STATUS_IO_ERROR;
SANE_Status status = SANE_STATUS_GOOD;
/* check if the current chipset implements warmup */
if(dev->model->cmd_set->init_regs_for_warmup==NULL)
{
DBG(DBG_error,"%s: init_regs_for_warmup not implemented\n", __func__);
return status;
if (dev->model->cmd_set->init_regs_for_warmup == NULL) {
throw SaneException("init_regs_for_warmup not implemented");
}
const auto& sensor = sanei_genesys_find_sensor_any(dev);

Wyświetl plik

@ -2868,22 +2868,14 @@ gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
return status;
}
/*
* wait for lamp warmup by scanning the same line until difference
* between 2 scans is below a threshold
*/
static SANE_Status
gl124_init_regs_for_warmup (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
int *channels, int *total_size)
// wait for lamp warmup by scanning the same line until difference
// between 2 scans is below a threshold
static void gl124_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, int* channels, int* total_size)
{
DBG_HELPER(dbg);
int num_pixels;
if (dev == NULL || reg == NULL || channels == NULL || total_size == NULL)
return SANE_STATUS_INVAL;
*channels=3;
*reg = dev->reg;
@ -2913,8 +2905,6 @@ gl124_init_regs_for_warmup (Genesys_Device * dev,
sanei_genesys_set_motor_power(*reg, false);
dev->model->cmd_set->bulk_write_register(dev, *reg);
return SANE_STATUS_GOOD;
}
/** @brief default GPIO values

Wyświetl plik

@ -3218,14 +3218,11 @@ gl646_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
* sets up the scanner's register for warming up. We scan 2 lines without moving.
*
*/
static SANE_Status
gl646_init_regs_for_warmup (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * local_reg,
int *channels, int *total_size)
static void gl646_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* local_reg, int* channels,
int* total_size)
{
DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
Genesys_Settings settings;
int resolution, lines;
@ -3275,8 +3272,6 @@ gl646_init_regs_for_warmup (Genesys_Device * dev,
// now registers are ok, write them to scanner
gl646_set_fe(dev, sensor, AFE_SET, settings.xres);
sanei_genesys_bulk_write_register(dev, *local_reg);
return status;
}

Wyświetl plik

@ -4144,20 +4144,14 @@ gl841_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
return status;
}
/*
* wait for lamp warmup by scanning the same line until difference
* between 2 scans is below a threshold
*/
static SANE_Status
gl841_init_regs_for_warmup (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * local_reg,
int *channels, int *total_size)
// wait for lamp warmup by scanning the same line until difference
// between 2 scans is below a threshold
static void gl841_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* local_reg, int* channels,
int* total_size)
{
DBG_HELPER(dbg);
int num_pixels = (int) (4 * 300);
SANE_Status status = SANE_STATUS_GOOD;
*local_reg = dev->reg;
/* okay.. these should be defaults stored somewhere */
@ -4197,8 +4191,6 @@ gl841_init_regs_for_warmup (Genesys_Device * dev,
*total_size = num_pixels * 3 * 2 * 1; /* colors * bytes_per_color * scan lines */
sanei_genesys_bulk_write_register(dev, *local_reg);
return status;
}

Wyświetl plik

@ -3445,15 +3445,10 @@ gl843_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
return status;
}
/*
* wait for lamp warmup by scanning the same line until difference
* between 2 scans is below a threshold
*/
static SANE_Status
gl843_init_regs_for_warmup (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * reg,
int *channels, int *total_size)
// wait for lamp warmup by scanning the same line until difference
// between 2 scans is below a threshold
static void gl843_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, int* channels, int* total_size)
{
DBG_HELPER(dbg);
int num_pixels;
@ -3461,9 +3456,6 @@ gl843_init_regs_for_warmup (Genesys_Device * dev,
int resolution;
int factor;
if (dev == NULL || reg == NULL || channels == NULL || total_size == NULL)
return SANE_STATUS_INVAL;
/* setup scan */
*channels=3;
resolution=600;
@ -3500,8 +3492,6 @@ gl843_init_regs_for_warmup (Genesys_Device * dev,
sanei_genesys_set_motor_power(*reg, false);
dev->model->cmd_set->bulk_write_register(dev, *reg);
return SANE_STATUS_GOOD;
}
/**

Wyświetl plik

@ -1045,10 +1045,8 @@ struct Genesys_Command_Set
/** For ASIC initialization */
void (*init) (Genesys_Device* dev);
SANE_Status (*init_regs_for_warmup) (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set * regs,
int *channels, int *total_size);
void (*init_regs_for_warmup) (Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* regs, int*channels, int* total_size);
void (*init_regs_for_coarse_calibration) (Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs);
SANE_Status (*init_regs_for_shading) (Genesys_Device * dev, const Genesys_Sensor& sensor,