genesys: Return errors as exceptions from *coarse_gain_calibration()

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

Wyświetl plik

@ -2989,13 +2989,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
/* since all the registers are set up correctly, just use them */
sanei_usb_testing_record_message("coarse_gain_calibration");
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, coarse_res);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status));
return status;
}
dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, coarse_res);
}
else
/* since we have 2 gain calibration proc, skip second if first one was
@ -3028,12 +3022,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
/* since all the registers are set up correctly, just use them */
sanei_usb_testing_record_message("coarse_gain_calibration");
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, coarse_res);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status));
return status;
}
dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, coarse_res);
}
else
/* since we have 2 gain calibration proc, skip second if first one was
@ -3202,12 +3191,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
/* since all the registers are set up correctly, just use them */
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, xres);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status));
return status;
}
dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, xres);
}
else
/* since we have 2 gain calibration proc, skip second if first one was

Wyświetl plik

@ -2706,16 +2706,14 @@ static void gl124_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
a reasonable shape. the fine calibration of the upper and lower bounds will
be done with shading.
*/
static SANE_Status
gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void gl124_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER_ARGS(dbg, "dpi = %d", dpi);
int pixels;
int total_size;
uint8_t reg0a;
int i, j, channels;
SANE_Status status = SANE_STATUS_GOOD;
int max[3];
float gain[3],coeff;
int val, code, lines;
@ -2726,7 +2724,7 @@ gl124_coarse_gain_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;
}
/* coarse gain calibration is always done in color mode */
@ -2850,8 +2848,6 @@ gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl124_stop_action(dev);
gl124_slow_back_home(dev, SANE_TRUE);
return status;
}
// wait for lamp warmup by scanning the same line until difference

Wyświetl plik

@ -2939,15 +2939,13 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
/** @brief gain calibration for Analog Device frontends
* Alternative coarse gain calibration
*/
static SANE_Status
ad_fe_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER(dbg);
(void) regs;
unsigned int i, channels, val;
unsigned int size, count, resolution, pass;
SANE_Status status = SANE_STATUS_GOOD;
float average;
Genesys_Settings settings;
char title[32];
@ -3028,7 +3026,6 @@ ad_fe_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
dev->frontend.get_gain(0),
dev->frontend.get_gain(1),
dev->frontend.get_gain(2));
return status;
}
/**
@ -3038,21 +3035,19 @@ ad_fe_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
* @param dev device for scan
* @param dpi resolutnio to calibrate at
*/
static SANE_Status
gl646_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER(dbg);
unsigned int i, j, k, channels, val, maximum, idx;
unsigned int count, resolution, pass;
SANE_Status status = SANE_STATUS_GOOD;
float average[3];
Genesys_Settings settings;
char title[32];
if (dev->model->ccd_type == CIS_XP200)
{
return ad_fe_coarse_gain_calibration (dev, sensor, regs, sensor.optical_res);
return ad_fe_coarse_gain_calibration(dev, sensor, regs, sensor.optical_res);
}
/* setup for a RGB scan, one full sensor's width line */
@ -3192,7 +3187,6 @@ gl646_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
dev->frontend.get_gain(0),
dev->frontend.get_gain(1),
dev->frontend.get_gain(2));
return status;
}
/**

Wyświetl plik

@ -3971,15 +3971,13 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
a reasonable shape. the fine calibration of the upper and lower bounds will
be done with shading.
*/
static SANE_Status
gl841_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void gl841_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER_ARGS(dbg, "dpi=%d", dpi);
int num_pixels;
int total_size;
int i, j, channels;
SANE_Status status = SANE_STATUS_GOOD;
int max[3];
float gain[3];
int val;
@ -4092,7 +4090,7 @@ gl841_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
DBG (DBG_error0, "**** ****\n");
DBG (DBG_error0, "**********************************************\n");
DBG (DBG_error0, "**********************************************\n");
return SANE_STATUS_JAMMED;
throw SaneException(SANE_STATUS_JAMMED, "scanning head is locked");
}
}
@ -4123,8 +4121,6 @@ gl841_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl841_stop_action(dev);
gl841_slow_back_home(dev, SANE_TRUE);
return status;
}
// wait for lamp warmup by scanning the same line until difference

Wyświetl plik

@ -3244,15 +3244,13 @@ static void gl843_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
a reasonable shape. the fine calibration of the upper and lower bounds will
be done with shading.
*/
static SANE_Status
gl843_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void gl843_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER_ARGS(dbg, "dpi = %d", dpi);
int pixels, factor, dpihw;
int total_size;
int i, j, channels;
SANE_Status status = SANE_STATUS_GOOD;
float coeff;
int val, lines;
int resolution;
@ -3428,8 +3426,6 @@ gl843_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl843_stop_action(dev);
gl843_slow_back_home(dev, SANE_TRUE);
return status;
}
// wait for lamp warmup by scanning the same line until difference

Wyświetl plik

@ -2736,16 +2736,14 @@ static void gl846_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
dev->frontend.get_offset(2));
}
static SANE_Status
gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void gl846_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER(dbg);
int pixels;
int total_size;
uint8_t reg04;
int i, j, channels;
SANE_Status status = SANE_STATUS_GOOD;
int max[3];
float gain[3],coeff;
int val, code, lines;
@ -2758,7 +2756,7 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
sanei_genesys_read_register(dev, REG04, &reg04);
if ((reg04 & REG04_FESET) == 0x02)
{
return status;
return;
}
/* coarse gain calibration is always done in color mode */
@ -2864,8 +2862,6 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl846_stop_action(dev);
gl846_slow_back_home(dev, SANE_TRUE);
return status;
}

Wyświetl plik

@ -2841,16 +2841,14 @@ static void gl847_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
dev->frontend.get_offset(2));
}
static SANE_Status
gl847_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
static void gl847_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER_ARGS(dbg, "dpi = %d", dpi);
int pixels;
int total_size;
uint8_t reg04;
int i, j, channels;
SANE_Status status = SANE_STATUS_GOOD;
int max[3];
float gain[3],coeff;
int val, code, lines;
@ -2861,7 +2859,7 @@ gl847_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
sanei_genesys_read_register(dev, REG04, &reg04);
if ((reg04 & REG04_FESET) == 0x02)
{
return status;
return;
}
/* coarse gain calibration is always done in color mode */
@ -2986,8 +2984,6 @@ gl847_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl847_stop_action(dev);
gl847_slow_back_home(dev, SANE_TRUE);
return status;
}

Wyświetl plik

@ -1078,9 +1078,8 @@ struct Genesys_Command_Set
void (*search_start_position) (Genesys_Device* dev);
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);
void (*coarse_gain_calibration) (Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs, int dpi);
SANE_Status (*led_calibration) (Genesys_Device * dev, Genesys_Sensor& sensor,
Genesys_Register_Set& regs);