genesys: Use a wrapper of usleep()

merge-requests/70/head
Povilas Kanapickas 2019-04-28 17:47:43 +03:00
rodzic 71bf2daec6
commit baaa934dce
9 zmienionych plików z 68 dodań i 65 usunięć

Wyświetl plik

@ -1785,7 +1785,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
return status;
}
usleep (200 * 1000); /* wait 200 ms: lamp needs some time to get dark */
sanei_genesys_usleep(200 * 1000); /* wait 200 ms: lamp needs some time to get dark */
status = dev->model->cmd_set->begin_scan (dev, dev->calib_reg, SANE_FALSE);
if (status != SANE_STATUS_GOOD)
@ -1997,7 +1997,7 @@ genesys_white_shading_calibration (Genesys_Device * dev)
}
if (dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION)
usleep (500 * 1000); /* wait 500ms to make sure lamp is bright again */
sanei_genesys_usleep(500 * 1000); /* wait 500ms to make sure lamp is bright again */
status = dev->model->cmd_set->begin_scan (dev, dev->calib_reg, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
@ -3611,7 +3611,7 @@ genesys_wait_not_moving (Genesys_Device * dev, int mseconds)
if (dev->model->cmd_set->test_motor_flag_bit (value))
{
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
mseconds -= 100;
DBG(DBG_io, "%s: motor is moving, %d mseconds to go\n", __func__, mseconds);
}
@ -3697,7 +3697,7 @@ genesys_warmup_lamp (Genesys_Device * dev)
do
{
sanei_genesys_test_buffer_empty (dev, &empty);
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
}
while (empty);
RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line);
@ -3991,7 +3991,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
{
/* wait 1/10th of second between each test to avoid
overloading USB and CPU */
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
status = sanei_genesys_read_feed_steps (dev, &steps);
if (status != SANE_STATUS_GOOD)
{
@ -4012,9 +4012,9 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
/* and scanning start before reading data */
/* the valid data check already waits until the scanner delivers data. this here leads to unnecessary buffer full conditions in the scanner.
if (dev->model->cmd_set->get_fast_feed_bit (dev->reg))
usleep (1000 * 1000);
sanei_genesys_usleep(1000 * 1000);
else
usleep (500 * 1000);
sanei_genesys_usleep(500 * 1000);
*/
/* then we wait for at least one word of valid scan data
@ -4023,7 +4023,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
{
do
{
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
status = sanei_genesys_read_valid_words (dev, &steps);
if (status != SANE_STATUS_GOOD)
{

Wyświetl plik

@ -1853,7 +1853,7 @@ gl124_stop_action (Genesys_Device * dev)
sane_strstatus (status));
return status;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop = 10;
while (loop > 0)
@ -1881,7 +1881,7 @@ gl124_stop_action (Genesys_Device * dev)
return SANE_STATUS_GOOD;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop--;
}
@ -2039,7 +2039,7 @@ SANE_Status gl124_rewind(Genesys_Device * dev)
RIE (gl124_begin_scan (dev, dev->reg, SANE_TRUE));
do
{
usleep(100*1000);
sanei_genesys_usleep(100*1000);
RIE (sanei_genesys_read_register (dev, REG100, &byte));
}
while(byte & REG100_MOTMFLG);
@ -2087,7 +2087,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
sanei_genesys_print_status (val);
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
@ -2191,7 +2191,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}
@ -2603,7 +2603,7 @@ gl124_init_regs_for_scan (Genesys_Device * dev)
{
do
{
usleep(10000);
sanei_genesys_usleep(10000);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
@ -2619,7 +2619,7 @@ gl124_init_regs_for_scan (Genesys_Device * dev)
return status;
}
} while ((val & MOTORENB) || (val40 & REG100_MOTMFLG));
usleep(50000);
sanei_genesys_usleep(50000);
}
/* ensure head is parked in case of calibration */

Wyświetl plik

@ -1521,7 +1521,7 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi)
DBG(DBG_error, "%s: reset failed: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (200000UL);
sanei_genesys_usleep(200000UL);
RIE (sanei_genesys_write_register (dev, 0x50, 0x00));
sanei_genesys_init_fe (dev);
status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]);
@ -2008,7 +2008,7 @@ gl646_load_document (Genesys_Device * dev)
{
DBG(DBG_warn, "%s: no paper detected\n", __func__);
}
usleep (200000UL); /* sleep 200 ms */
sanei_genesys_usleep(200000UL); /* sleep 200 ms */
count++;
}
while (((val & 0x04) != 0x04) && (count < 300)); /* 1 min time out */
@ -2093,7 +2093,7 @@ gl646_load_document (Genesys_Device * dev)
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (200000UL); /* sleep 200 ms */
sanei_genesys_usleep(200000UL); /* sleep 200 ms */
count++;
}
while ((val & REG41_MOTMFLG) && (count < 300));
@ -2256,7 +2256,7 @@ gl646_eject_document (Genesys_Device * dev)
/* wait for motor to stop */
do
{
usleep (200000UL);
sanei_genesys_usleep(200000UL);
status = sanei_genesys_get_status (dev, &state);
if (status != SANE_STATUS_GOOD)
{
@ -2343,7 +2343,7 @@ gl646_eject_document (Genesys_Device * dev)
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (200000UL); /* sleep 200 ms */
sanei_genesys_usleep(200000UL); /* sleep 200 ms */
count++;
}
while (((state & REG41_HOMESNR) == 0) && (count < 150));
@ -2473,7 +2473,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
break; /* leave for loop */
}
usleep (10000UL); /* sleep 100 ms */
sanei_genesys_usleep(10000UL); /* sleep 100 ms */
}
}
}
@ -2509,7 +2509,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
break; /* leave while loop */
}
usleep (10000UL); /* sleep 100 ms */
sanei_genesys_usleep(10000UL); /* sleep 100 ms */
}
}
}
@ -2572,7 +2572,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_error, "%s: failed to stop motor: %s\n", __func__, sane_strstatus(status));
return SANE_STATUS_IO_ERROR;
}
usleep (200000UL);
sanei_genesys_usleep(200000UL);
}
/* when scanhead is moving then wait until scanhead stops or timeout */
@ -2592,7 +2592,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_info, "%s: already at home and not moving\n", __func__);
return SANE_STATUS_GOOD;
}
usleep (100 * 1000); /* sleep 100 ms (todo: fixed to really sleep 100 ms) */
sanei_genesys_usleep(100 * 1000);
}
if (!i) /* the loop counted down to 0, scanner still is busy */
@ -2678,10 +2678,10 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
DBG(DBG_info, "%s: reached home position\n", __func__);
DBG(DBG_proc, "%s: end\n", __func__);
usleep (500000); /* sleep 500 ms before returning */
sanei_genesys_usleep(500 * 1000);
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}
@ -4137,7 +4137,7 @@ gl646_repark_head (Genesys_Device * dev)
expected = value32;
do
{
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
status = sanei_genesys_read_feed_steps (dev, &steps);
if (status != SANE_STATUS_GOOD)
{
@ -4260,7 +4260,7 @@ gl646_init (Genesys_Device * dev)
/* ASIC reset */
RIE (sanei_genesys_write_register (dev, 0x0e, 0x00));
usleep (100000UL); /* sleep 100 ms */
sanei_genesys_usleep(100000UL); /* sleep 100 ms */
/* Write initial registers */
RIE(sanei_genesys_bulk_write_register(dev, dev->reg, GENESYS_GL646_MAX_REGS));
@ -4580,7 +4580,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move,
count = 0;
do
{
usleep (10000UL);
sanei_genesys_usleep(10000UL);
RIE (sanei_genesys_get_status (dev, &val));
if (DBG_LEVEL > DBG_info)
{

Wyświetl plik

@ -2877,7 +2877,7 @@ gl841_save_power(Genesys_Device * dev, SANE_Bool enable) {
sanei_genesys_read_register(dev, REG6D, &val);
sanei_genesys_write_register(dev, REG6D, val | 0x80);
usleep(1000);
sanei_genesys_usleep(1000);
/*enable GPIO9*/
sanei_genesys_read_register(dev, REG6C, &val);
@ -2891,7 +2891,7 @@ gl841_save_power(Genesys_Device * dev, SANE_Bool enable) {
sanei_genesys_read_register(dev, REG6B, &val);
sanei_genesys_write_register(dev, REG6B, val & ~REG6B_GPO18);
usleep(1000);
sanei_genesys_usleep(1000);
sanei_genesys_read_register(dev, REG6D, &val);
sanei_genesys_write_register(dev, REG6D, val & ~0x80);
@ -2920,7 +2920,7 @@ gl841_save_power(Genesys_Device * dev, SANE_Bool enable) {
sanei_genesys_read_register(dev, REG6D, &val);
sanei_genesys_write_register(dev, REG6D, val | 0x80);
usleep(10000);
sanei_genesys_usleep(10000);
/*disable GPIO9*/
sanei_genesys_read_register(dev, REG6C, &val);
@ -3117,7 +3117,7 @@ gl841_stop_action (Genesys_Device * dev)
return SANE_STATUS_GOOD;
}
usleep(100*1000);
sanei_genesys_usleep(100*1000);
loop--;
}
@ -3223,7 +3223,7 @@ gl841_eject_document (Genesys_Device * dev)
DBG(DBG_proc, "%s: finished\n", __func__);
break;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
--loop;
}
@ -3269,7 +3269,7 @@ gl841_eject_document (Genesys_Device * dev)
break;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}
@ -3306,10 +3306,11 @@ gl841_load_document (Genesys_Device * dev)
/* when loading OK, document is here */
dev->document = SANE_TRUE;
usleep (1000000); /* give user 1000ms to place document correctly */
// give user 1000ms to place document correctly
sanei_genesys_usleep(1000000);
break;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
--loop;
}
@ -3536,7 +3537,7 @@ gl841_feed (Genesys_Device * dev, int steps)
dev->scanhead_position_in_steps += steps;
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}
@ -3592,7 +3593,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
sanei_genesys_print_status (val);
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
@ -3671,7 +3672,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_proc, "%s: finished\n", __func__);
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}

Wyświetl plik

@ -1781,7 +1781,7 @@ gl843_stop_action (Genesys_Device * dev)
DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop = 10;
while (loop > 0)
@ -1808,7 +1808,7 @@ gl843_stop_action (Genesys_Device * dev)
return SANE_STATUS_GOOD;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop--;
}
@ -2285,7 +2285,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
gl843_xpa_motor_off(dev);
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}
@ -2329,7 +2329,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
@ -2418,7 +2418,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_proc, "%s: finished\n", __func__);
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}
@ -3640,7 +3640,7 @@ gl843_boot (Genesys_Device * dev, SANE_Bool cold)
RIE (gl843_init_gpio (dev));
gl843_feed (dev, 300);
usleep (100000);
sanei_genesys_usleep(100000);
DBGCOMPLETED;
return SANE_STATUS_GOOD;

Wyświetl plik

@ -506,7 +506,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set)
status = sanei_genesys_get_status (dev, &val8);
while (val8 & REG41_FEBUSY)
{
usleep (10000);
sanei_genesys_usleep(10000);
status = sanei_genesys_get_status (dev, &val8);
};
@ -1627,7 +1627,7 @@ gl846_stop_action (Genesys_Device * dev)
DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop = 10;
while (loop > 0)
@ -1653,7 +1653,7 @@ gl846_stop_action (Genesys_Device * dev)
return SANE_STATUS_GOOD;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop--;
}
@ -1761,7 +1761,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
sanei_genesys_print_status (val);
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
@ -1855,7 +1855,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}

Wyświetl plik

@ -528,7 +528,7 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set)
status = sanei_genesys_get_status (dev, &val8);
while (val8 & REG41_FEBUSY)
{
usleep (10000);
sanei_genesys_usleep(10000);
status = sanei_genesys_get_status (dev, &val8);
};
@ -1642,7 +1642,7 @@ gl847_stop_action (Genesys_Device * dev)
DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status));
return status;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop = 10;
while (loop > 0)
@ -1668,7 +1668,7 @@ gl847_stop_action (Genesys_Device * dev)
return SANE_STATUS_GOOD;
}
usleep (100 * 1000);
sanei_genesys_usleep(100 * 1000);
loop--;
}
@ -1773,7 +1773,7 @@ SANE_Status gl847_rewind(Genesys_Device * dev)
RIE (gl847_begin_scan (dev, dev->reg, SANE_TRUE));
do
{
usleep(100*1000);
sanei_genesys_usleep(100*1000);
RIE (sanei_genesys_read_register (dev, REG40, &byte));
}
while(byte & REG40_MOTMFLG);
@ -1823,7 +1823,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
sanei_genesys_print_status (val);
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
@ -1918,7 +1918,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
sanei_genesys_usleep(100000); /* sleep 100 ms */
++loop;
}

Wyświetl plik

@ -1139,7 +1139,7 @@ sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty)
uint8_t val = 0;
SANE_Status status;
usleep(1000);
sanei_genesys_usleep(1000);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
@ -1152,7 +1152,7 @@ sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty)
/* fix timing issue on USB3 (or just may be too fast) hardware
* spotted by John S. Weber <jweber53@gmail.com>
*/
usleep(1000);
sanei_genesys_usleep(1000);
DBG(DBG_io2, "%s: buffer is empty\n", __func__);
*empty = SANE_TRUE;
return SANE_STATUS_GOOD;
@ -1191,7 +1191,7 @@ sanei_genesys_read_data_from_scanner (Genesys_Device * dev, uint8_t * data,
}
if (words == 0)
{
usleep (10000); /* wait 10 msec */
sanei_genesys_usleep(10000); /* wait 10 msec */
time_count++;
}
}
@ -1701,7 +1701,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
sane_strstatus (status));
return status;
}
usleep (10000);
sanei_genesys_usleep(10000);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
@ -1724,7 +1724,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
do
{
/* wait 100 ms */
usleep (100000);
sanei_genesys_usleep(100000);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
@ -2239,6 +2239,11 @@ sanei_genesys_load_lut (unsigned char * lut,
return ret;
}
void sanei_genesys_usleep(unsigned int useconds)
{
usleep(useconds);
}
Genesys_Vector sanei_gl_vector_create(size_t element_size)
{
Genesys_Vector ret;

Wyświetl plik

@ -1243,9 +1243,6 @@ extern SANE_Status sanei_gl124_init_cmd_set (Genesys_Device * dev);
// same as usleep, except that it does nothing if testing mode is enabled
extern void sanei_genesys_usleep(unsigned int useconds);
// same as sanei_genesys_usleep just that the duration is in milliseconds
extern void sanei_genesys_sleep_ms(unsigned int milliseconds);
typedef struct Genesys_Vector
{
char* data;