diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-09-27 08:20:20 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-09-27 08:20:20 +0200 |
commit | e94622c319e4307617b202f19d3ec05b21a9bb49 (patch) | |
tree | c5ddf44352b9bd47aeb3eb432ba79638079efe25 /backend/genesys_low.c | |
parent | 6f2255c9648b175d51e2c8e5e9670557f9dc4ee1 (diff) |
merge to 1.0.25+git20150927
Diffstat (limited to 'backend/genesys_low.c')
-rw-r--r-- | backend/genesys_low.c | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/backend/genesys_low.c b/backend/genesys_low.c index 0af2149..f28b72c 100644 --- a/backend/genesys_low.c +++ b/backend/genesys_low.c @@ -943,13 +943,18 @@ sanei_genesys_get_triple(Genesys_Register_Set *regs, uint16_t addr, uint32_t *va return SANE_STATUS_GOOD; } -/* Checks if the scan buffer is empty */ +/** @brief Check if the scanner's internal data buffer is empty + * @param *dev device to test for data + * @param *empty return value + * @return empty will be set to SANE_TRUE if there is no scanned data. + **/ SANE_Status sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty) { uint8_t val = 0; SANE_Status status; + usleep(1000); status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { @@ -961,6 +966,10 @@ sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty) if (dev->model->cmd_set->test_buffer_empty_bit (val)) { + /* fix timing issue on USB3 (or just may be too fast) hardware + * spotted by John S. Weber <jweber53@gmail.com> + */ + usleep(1000); DBG (DBG_io2, "sanei_genesys_test_buffer_empty: buffer is empty\n"); *empty = SANE_TRUE; return SANE_STATUS_GOOD; @@ -1317,10 +1326,14 @@ sanei_genesys_send_gamma_table (Genesys_Device * dev) } /** @brief initialize device - * initialize backend and ASIC : registers, motor tables, and gamma tables - * then ensure scanner's head is at home. Designed for gl846+ ASICs + * Initialize backend and ASIC : registers, motor tables, and gamma tables + * then ensure scanner's head is at home. Designed for gl846+ ASICs. + * Detects cold boot (ie first boot since device plugged) in this case + * an extensice setup up is done at hardware level. + * * @param dev device to initialize * @param max_regs umber of maximum used registers + * @return SANE_STATUS_GOOD in case of success */ SANE_Status sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) @@ -1328,7 +1341,8 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) SANE_Status status; uint8_t val; SANE_Bool cold = SANE_TRUE; - int size, i; + int size; /**< size of the device's gamma table */ + int i; DBGSTART; @@ -1354,6 +1368,25 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) } } + /* setup gamma tables */ + size = 256; + for(i=0;i<3;i++) + { + FREE_IFNOT_NULL (dev->sensor.gamma_table[i]); + dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size); + if (dev->sensor.gamma_table[i] == NULL) + { + DBG (DBG_error, "%s: could not allocate memory for gamma table %d\n", + __FUNCTION__, i); + return SANE_STATUS_NO_MEM; + } + sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i], + size, + 65535, + 65535, + dev->sensor.gamma[i]); + } + /* check if the device has already been initialized and powered up * we read register 6 and check PWRBIT, if reset scanner has been * freshly powered up. This bit will be set to later so that following @@ -1380,9 +1413,6 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) /* now hardware part is OK, set up device struct */ FREE_IFNOT_NULL (dev->white_average_data); FREE_IFNOT_NULL (dev->dark_average_data); - FREE_IFNOT_NULL (dev->sensor.gamma_table[0]); - FREE_IFNOT_NULL (dev->sensor.gamma_table[1]); - FREE_IFNOT_NULL (dev->sensor.gamma_table[2]); dev->settings.color_filter = 0; @@ -1392,28 +1422,6 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs) /* Set analog frontend */ RIE (dev->model->cmd_set->set_fe (dev, AFE_INIT)); - /* init gamma tables */ - size = 256; - - for(i=0;i<3;i++) - { - if (dev->sensor.gamma_table[i] == NULL) - { - dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size); - if (dev->sensor.gamma_table[i] == NULL) - { - DBG (DBG_error, "%s: could not allocate memory for gamma table %d\n", - __FUNCTION__, i); - return SANE_STATUS_NO_MEM; - } - sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i], - size, - 65535, - 65535, - dev->sensor.gamma[i]); - } - } - dev->oe_buffer.buffer = NULL; dev->already_initialized = SANE_TRUE; |