genesys: Return errors as exceptions from *offset_calibration()

merge-requests/104/head
Povilas Kanapickas 2019-07-20 11:02:23 +03:00
rodzic 1eaa889632
commit faea78eae6
8 zmienionych plików z 26 dodań i 70 usunięć

Wyświetl plik

@ -2985,12 +2985,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION)
{
sanei_usb_testing_record_message("offset_calibration");
status = dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status));
return status;
}
dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
/* since all the registers are set up correctly, just use them */
sanei_usb_testing_record_message("coarse_gain_calibration");
@ -3028,12 +3023,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION)
{
sanei_usb_testing_record_message("offset_calibration");
status = dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status));
return status;
}
dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
/* since all the registers are set up correctly, just use them */
@ -3208,12 +3198,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
/* calibrate afe */
if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION)
{
status = dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status));
return status;
}
dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
/* since all the registers are set up correctly, just use them */

Wyświetl plik

@ -2557,12 +2557,10 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
}
static SANE_Status
gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void gl124_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
uint8_t reg0a;
unsigned int channels, bpp;
int pass = 0, avg, total_size;
@ -2573,7 +2571,7 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
sanei_genesys_read_register(dev, REG0A, &reg0a);
if(((reg0a & REG0A_SIFSEL)>>REG0AS_SIFSEL)==3)
{
return status;
return;
}
/* offset calibration is always done in color mode */
@ -2696,8 +2694,6 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return SANE_STATUS_GOOD;
}

Wyświetl plik

@ -2695,11 +2695,9 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
* we do simple scan until all black_pixels are higher than 0,
* raising offset at each turn.
*/
static SANE_Status
ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor)
{
DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
unsigned int channels;
int pass = 0;
SANE_Int resolution;
@ -2775,15 +2773,13 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
while (pass < 128 && min == 0);
if (pass == 128)
{
DBG(DBG_error, "%s: failed to find correct offset\n", __func__);
return SANE_STATUS_INVAL;
throw SaneException(SANE_STATUS_INVAL, "failed to find correct offset");
}
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return status;
}
#define DARK_TARGET 8
@ -2795,13 +2791,11 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
* @param dev scanner's device
* @return SANE_STATUS_GOOD if success, else error code is failure
*/
static SANE_Status
gl646_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
(void) regs;
SANE_Status status = SANE_STATUS_GOOD;
unsigned int channels;
int pass = 0, avg;
SANE_Int resolution;
@ -2812,7 +2806,7 @@ gl646_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
/* Analog Device fronted have a different calibration */
if (dev->model->dac_type == DAC_AD_XP200)
{
return ad_fe_offset_calibration (dev, sensor);
ad_fe_offset_calibration(dev, sensor);
}
DBG(DBG_proc, "%s: start\n", __func__); // TODO
@ -2940,7 +2934,6 @@ gl646_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return status;
}
/** @brief gain calibration for Analog Device frontends

Wyświetl plik

@ -3500,12 +3500,10 @@ gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Reg
* 0x0006 : is offset
* We scan a line with no gain until average offset reaches the target
*/
static SANE_Status
ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
int num_pixels;
int total_size;
int i;
@ -3518,7 +3516,7 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor,
/* don't impact 3600 behavior since we can't test it */
if (dev->model->ccd_type == CCD_PLUSTEK_3600)
{
return status;
return;
}
SetupParams params;
@ -3604,7 +3602,6 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return status;
}
/* this function does the offset calibration by scanning one line of the calibration
@ -3614,15 +3611,13 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor,
this function expects the slider to be where?
*/
static SANE_Status
gl841_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
int num_pixels;
int total_size;
int i, j;
SANE_Status status = SANE_STATUS_GOOD;
int val;
int channels;
int off[3],offh[3],offl[3],off1[3],off2[3];
@ -3964,8 +3959,6 @@ gl841_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.set_offset(1, dev->frontend.get_offset(0));
dev->frontend.set_offset(2, dev->frontend.get_offset(0));
}
return status;
}

Wyświetl plik

@ -3021,9 +3021,8 @@ dark_average_channel (uint8_t * data, unsigned int pixels, unsigned int lines,
* color line is scanned at a time. Scanning head doesn't move.
* @param dev device to calibrate
*/
static SANE_Status
gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void gl843_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
@ -3233,8 +3232,6 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return SANE_STATUS_GOOD;
}

Wyświetl plik

@ -2597,12 +2597,10 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
return average;
}
static SANE_Status
gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void gl846_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
uint8_t reg04;
unsigned int channels, bpp;
int pass = 0, avg, total_size;
@ -2613,7 +2611,7 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
sanei_genesys_read_register(dev, REG04, &reg04);
if ((reg04 & REG04_FESET) == 0x02)
{
return status;
return;
}
/* offset calibration is always done in color mode */
@ -2736,8 +2734,6 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return SANE_STATUS_GOOD;
}
static SANE_Status

Wyświetl plik

@ -2702,12 +2702,10 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
return average;
}
static SANE_Status
gl847_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
static void gl847_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
uint8_t reg04;
unsigned int channels, bpp;
int pass = 0, avg, total_size;
@ -2718,7 +2716,7 @@ gl847_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
sanei_genesys_read_register(dev, REG04, &reg04);
if ((reg04 & REG04_FESET) == 0x02)
{
return status;
return;
}
/* offset calibration is always done in color mode */
@ -2841,8 +2839,6 @@ gl847_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
dev->frontend.get_offset(0),
dev->frontend.get_offset(1),
dev->frontend.get_offset(2));
return SANE_STATUS_GOOD;
}
static SANE_Status

Wyświetl plik

@ -1076,8 +1076,8 @@ struct Genesys_Command_Set
void (*send_gamma_table) (Genesys_Device* dev, const Genesys_Sensor& sensor);
void (*search_start_position) (Genesys_Device* dev);
SANE_Status (*offset_calibration) (Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs);
void (*offset_calibration) (Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs);
SANE_Status (*coarse_gain_calibration) (Genesys_Device * dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi);