hp5590: fixed detection of HP4500 devices (tested) and HP5550 (untested) -

these devices need no reading USB-in-USB acknowledgement after each command.
To achieve that, proto_flags are passed down to low-level functions. These
flags are taken from device descriptions
hp5590: fixed up get_status command - index should be 0x00, not 0x20
hp5590: bump up the backend version
merge-requests/1/head
Ilia Sotnikov 2011-03-06 13:30:58 +02:00
rodzic 359114a7a0
commit 10c776769f
5 zmienionych plików z 346 dodań i 181 usunięć

Wyświetl plik

@ -73,7 +73,7 @@
} }
/* #define HAS_WORKING_COLOR_48 */ /* #define HAS_WORKING_COLOR_48 */
#define BUILD 5 #define BUILD 6
#define USB_TIMEOUT 30 * 1000 #define USB_TIMEOUT 30 * 1000
static SANE_Word static SANE_Word
@ -129,7 +129,7 @@ enum hp5590_opt_idx {
struct hp5590_scanner { struct hp5590_scanner {
struct scanner_info *info; struct scanner_info *info;
struct scanner_state *state; enum proto_flags proto_flags;
SANE_Device sane; SANE_Device sane;
SANE_Int dn; SANE_Int dn;
float br_x, br_y, tl_x, tl_y; float br_x, br_y, tl_x, tl_y;
@ -227,33 +227,41 @@ attach_usb_device (SANE_String_Const devname,
unsigned int max_count, count; unsigned int max_count, count;
SANE_Int dn; SANE_Int dn;
SANE_Status ret; SANE_Status ret;
const struct hp5590_model *hp5590_model;
DBG (DBG_proc, "%s: Opening USB device\n", __FUNCTION__); DBG (DBG_proc, "%s: Opening USB device\n", __FUNCTION__);
if (sanei_usb_open (devname, &dn) != SANE_STATUS_GOOD) if (sanei_usb_open (devname, &dn) != SANE_STATUS_GOOD)
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
DBG (DBG_proc, "%s: USB device opened\n", __FUNCTION__); DBG (DBG_proc, "%s: USB device opened\n", __FUNCTION__);
if (hp5590_init_scanner (dn, &info, hp_scanner_type) != 0) ret = hp5590_model_def (hp_scanner_type, &hp5590_model);
if (ret != SANE_STATUS_GOOD)
return ret;
if (hp5590_init_scanner (dn, hp5590_model->proto_flags,
&info, hp_scanner_type) != 0)
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
DBG (1, "%s: found HP%s scanner at '%s'\n", DBG (1, "%s: found HP%s scanner at '%s'\n",
__FUNCTION__, info->model, devname); __FUNCTION__, info->model, devname);
DBG (DBG_verbose, "%s: Reading max scan count\n", __FUNCTION__); DBG (DBG_verbose, "%s: Reading max scan count\n", __FUNCTION__);
if (hp5590_read_max_scan_count (dn, &max_count) != 0) if (hp5590_read_max_scan_count (dn, hp5590_model->proto_flags,
&max_count) != 0)
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
DBG (DBG_verbose, "%s: Max Scanning count %u\n", __FUNCTION__, max_count); DBG (DBG_verbose, "%s: Max Scanning count %u\n", __FUNCTION__, max_count);
DBG (DBG_verbose, "%s: Reading scan count\n", __FUNCTION__); DBG (DBG_verbose, "%s: Reading scan count\n", __FUNCTION__);
if (hp5590_read_scan_count (dn, &count) != 0) if (hp5590_read_scan_count (dn, hp5590_model->proto_flags,
&count) != 0)
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
DBG (DBG_verbose, "%s: Scanning count %u\n", __FUNCTION__, count); DBG (DBG_verbose, "%s: Scanning count %u\n", __FUNCTION__, count);
ret = hp5590_read_part_number (dn); ret = hp5590_read_part_number (dn, hp5590_model->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
ret = hp5590_stop_scan (dn); ret = hp5590_stop_scan (dn, hp5590_model->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -267,6 +275,7 @@ attach_usb_device (SANE_String_Const devname,
scanner->sane.type = info->kind; scanner->sane.type = info->kind;
scanner->sane.name = devname; scanner->sane.name = devname;
scanner->dn = dn; scanner->dn = dn;
scanner->proto_flags = hp5590_model->proto_flags;
scanner->info = info; scanner->info = info;
scanner->bulk_read_state = NULL; scanner->bulk_read_state = NULL;
scanner->opts = NULL; scanner->opts = NULL;
@ -984,7 +993,7 @@ sane_start (SANE_Handle handle)
{ {
DBG (DBG_verbose, "%s: Scanner is scanning, check if more data is available\n", DBG (DBG_verbose, "%s: Scanner is scanning, check if more data is available\n",
__FUNCTION__); __FUNCTION__);
ret = hp5590_is_data_available (scanner->dn); ret = hp5590_is_data_available (scanner->dn, scanner->proto_flags);
if (ret == SANE_STATUS_GOOD) if (ret == SANE_STATUS_GOOD)
{ {
DBG (DBG_verbose, "%s: More data is available\n", __FUNCTION__); DBG (DBG_verbose, "%s: More data is available\n", __FUNCTION__);
@ -1003,7 +1012,9 @@ sane_start (SANE_Handle handle)
enum button_status status; enum button_status status;
for (;;) for (;;)
{ {
ret = hp5590_read_buttons (scanner->dn, &status); ret = hp5590_read_buttons (scanner->dn,
scanner->proto_flags,
&status);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1017,21 +1028,25 @@ sane_start (SANE_Handle handle)
} }
DBG (DBG_verbose, "Init scanner\n"); DBG (DBG_verbose, "Init scanner\n");
ret = hp5590_init_scanner (scanner->dn, NULL, SCANNER_NONE); ret = hp5590_init_scanner (scanner->dn, scanner->proto_flags,
NULL, SCANNER_NONE);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
ret = hp5590_power_status (scanner->dn); ret = hp5590_power_status (scanner->dn, scanner->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
DBG (DBG_verbose, "Wakeup\n"); DBG (DBG_verbose, "Wakeup\n");
ret = hp5590_select_source_and_wakeup (scanner->dn, scanner->source, ret = hp5590_select_source_and_wakeup (scanner->dn, scanner->proto_flags,
scanner->source,
scanner->extend_lamp_timeout); scanner->extend_lamp_timeout);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
ret = hp5590_set_scan_params (scanner->dn, scanner->info, ret = hp5590_set_scan_params (scanner->dn,
scanner->proto_flags,
scanner->info,
scanner->tl_x * scanner->dpi, scanner->tl_x * scanner->dpi,
scanner->tl_y * scanner->dpi, scanner->tl_y * scanner->dpi,
(scanner->br_x - scanner->tl_x) * scanner->dpi, (scanner->br_x - scanner->tl_x) * scanner->dpi,
@ -1041,7 +1056,7 @@ sane_start (SANE_Handle handle)
scanner->source); scanner->source);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return ret; return ret;
} }
@ -1050,7 +1065,7 @@ sane_start (SANE_Handle handle)
&scanner->image_size); &scanner->image_size);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return ret; return ret;
} }
@ -1066,7 +1081,7 @@ sane_start (SANE_Handle handle)
DBG (DBG_err, "Color 24/48 bits: image size doesn't lined up on number of colors (3) " DBG (DBG_err, "Color 24/48 bits: image size doesn't lined up on number of colors (3) "
"(image size: %u, bytes per line %u)\n", "(image size: %u, bytes per line %u)\n",
scanner->image_size, bytes_per_line); scanner->image_size, bytes_per_line);
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
DBG (1, "Color 24/48 bits: image size is correctly aligned on number of colors " DBG (1, "Color 24/48 bits: image size is correctly aligned on number of colors "
@ -1080,7 +1095,7 @@ sane_start (SANE_Handle handle)
DBG (DBG_err, "Color 24/48 bits: image size doesn't lined up on bytes per line " DBG (DBG_err, "Color 24/48 bits: image size doesn't lined up on bytes per line "
"(image size: %u, bytes per line %u)\n", "(image size: %u, bytes per line %u)\n",
scanner->image_size, bytes_per_line); scanner->image_size, bytes_per_line);
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
DBG (1, "Color 24/48 bits: image size correctly aligned on bytes per line " DBG (1, "Color 24/48 bits: image size correctly aligned on bytes per line "
@ -1091,25 +1106,25 @@ sane_start (SANE_Handle handle)
DBG (DBG_verbose, "Final image size: %u\n", scanner->image_size); DBG (DBG_verbose, "Final image size: %u\n", scanner->image_size);
DBG (DBG_verbose, "Reverse calibration maps\n"); DBG (DBG_verbose, "Reverse calibration maps\n");
ret = hp5590_send_reverse_calibration_map (scanner->dn); ret = hp5590_send_reverse_calibration_map (scanner->dn, scanner->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return ret; return ret;
} }
DBG (DBG_verbose, "Forward calibration maps\n"); DBG (DBG_verbose, "Forward calibration maps\n");
ret = hp5590_send_forward_calibration_maps (scanner->dn); ret = hp5590_send_forward_calibration_maps (scanner->dn, scanner->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return ret; return ret;
} }
scanner->scanning = SANE_TRUE; scanner->scanning = SANE_TRUE;
DBG (DBG_verbose, "Starting scan\n"); DBG (DBG_verbose, "Starting scan\n");
ret = hp5590_start_scan (scanner->dn); ret = hp5590_start_scan (scanner->dn, scanner->proto_flags);
/* Check for paper jam */ /* Check for paper jam */
if ( ret == SANE_STATUS_DEVICE_BUSY if ( ret == SANE_STATUS_DEVICE_BUSY
&& ( scanner->source == SOURCE_ADF && ( scanner->source == SOURCE_ADF
@ -1118,7 +1133,7 @@ sane_start (SANE_Handle handle)
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
hp5590_reset_scan_head (scanner->dn); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags);
return ret; return ret;
} }
@ -1254,7 +1269,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
*length = 0; *length = 0;
DBG (DBG_verbose, "Setting scan count\n"); DBG (DBG_verbose, "Setting scan count\n");
ret = hp5590_inc_scan_count (scanner->dn); ret = hp5590_inc_scan_count (scanner->dn, scanner->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1295,7 +1310,8 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
max_length, *length); max_length, *length);
} }
ret = hp5590_read (scanner->dn, data, *length, scanner->bulk_read_state); ret = hp5590_read (scanner->dn, scanner->proto_flags,
data, *length, scanner->bulk_read_state);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
scanner->scanning = SANE_FALSE; scanner->scanning = SANE_FALSE;
@ -1334,7 +1350,7 @@ sane_cancel (SANE_Handle handle)
hp5590_low_free_bulk_read_state (&scanner->bulk_read_state); hp5590_low_free_bulk_read_state (&scanner->bulk_read_state);
ret = hp5590_stop_scan (scanner->dn); ret = hp5590_stop_scan (scanner->dn, scanner->proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return; return;
} }

Wyświetl plik

@ -59,37 +59,33 @@
#include "hp5590_low.h" #include "hp5590_low.h"
#include "hp5590_cmds.h" #include "hp5590_cmds.h"
struct hp5590_model
{
enum hp_scanner_types scanner_type;
unsigned int usb_vendor_id;
unsigned int usb_product_id;
const char *vendor_id;
const char *model;
const char *kind;
};
static const struct hp5590_model static const struct hp5590_model
hp5590_models[] = { hp5590_models[] = {
{ {
SCANNER_HP4570, SCANNER_HP4570,
0x03f0, 0x1305, "SILITEKIElwood", 0x03f0, 0x1305, "SILITEKIElwood",
"4570C/5500C", "Workgroup scanner" "4570C/5500C", "Workgroup scanner",
PF_NONE
}, },
{ {
SCANNER_HP5550, SCANNER_HP5550,
0x03f0, 0x1205, "SILITEKIPenguin", 0x03f0, 0x1205, "SILITEKIPenguin",
"4500C/5550C", "Workgroup scanner" "4500C/5550C", "Workgroup scanner",
PF_NO_USB_IN_USB_ACK /* These devices need no
* acknowledgement after USB-in-USB
* commands */
}, },
{ {
SCANNER_HP5590, SCANNER_HP5590,
0x03f0, 0x1705, "SILITEKIPenguin", 0x03f0, 0x1705, "SILITEKIPenguin",
"5590", "Workgroup scanner" "5590", "Workgroup scanner",
PF_NONE
}, },
{ {
SCANNER_HP7650, SCANNER_HP7650,
0x03f0, 0x1805, "SILITEKIArnold", 0x03f0, 0x1805, "SILITEKIArnold",
"7650", "Document scanner" "7650", "Document scanner",
PF_NONE
} }
}; };
@ -428,21 +424,18 @@ struct reg_03
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_vendor_product_id (enum hp_scanner_types scanner_type, hp5590_model_def (enum hp_scanner_types scanner_type,
SANE_Word * vendor_id, const struct hp5590_model ** model)
SANE_Word * product_id)
{ {
unsigned int i; unsigned int i;
hp5590_cmds_assert (vendor_id != NULL); hp5590_cmds_assert (model != NULL);
hp5590_cmds_assert (product_id != NULL);
for (i = 0; i < sizeof (hp5590_models) / sizeof (struct hp5590_model); i++) for (i = 0; i < sizeof (hp5590_models) / sizeof (struct hp5590_model); i++)
{ {
if (hp5590_models[i].scanner_type == scanner_type) if (hp5590_models[i].scanner_type == scanner_type)
{ {
*vendor_id = hp5590_models[i].usb_vendor_id; *model = &hp5590_models[i];
*product_id = hp5590_models[i].usb_product_id;
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
} }
@ -450,9 +443,31 @@ hp5590_vendor_product_id (enum hp_scanner_types scanner_type,
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
/******************************************************************************/
static SANE_Status
hp5590_vendor_product_id (enum hp_scanner_types scanner_type,
SANE_Word * vendor_id,
SANE_Word * product_id)
{
const struct hp5590_model *model;
SANE_Status ret;
hp5590_cmds_assert (vendor_id != NULL);
hp5590_cmds_assert (product_id != NULL);
ret = hp5590_model_def (scanner_type, &model);
if (ret != SANE_STATUS_GOOD)
return ret;
*vendor_id = model->usb_vendor_id;
*product_id = model->usb_product_id;
return SANE_STATUS_GOOD;
}
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_init_scanner (SANE_Int dn, hp5590_init_scanner (SANE_Int dn,
enum proto_flags proto_flags,
struct scanner_info ** info, struct scanner_info ** info,
enum hp_scanner_types scanner_type) enum hp_scanner_types scanner_type)
{ {
@ -473,7 +488,9 @@ hp5590_init_scanner (SANE_Int dn,
hp5590_cmds_assert (sizeof (init_resp) == 50); hp5590_cmds_assert (sizeof (init_resp) == 50);
/* Init scanner */ /* Init scanner */
ret = hp5590_cmd (dn, CMD_IN | CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN | CMD_VERIFY,
CMD_INIT, CMD_INIT,
(unsigned char *) &init_resp, (unsigned char *) &init_resp,
sizeof (init_resp), CORE_NONE); sizeof (init_resp), CORE_NONE);
@ -572,7 +589,7 @@ hp5590_init_scanner (SANE_Int dn,
} }
} }
ret = hp5590_get_status (dn); ret = hp5590_get_status (dn, proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
DBG (DBG_err, "%s: scanner reports non-zero status: %s\n", DBG (DBG_err, "%s: scanner reports non-zero status: %s\n",
@ -587,6 +604,7 @@ hp5590_init_scanner (SANE_Int dn,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_eeprom (SANE_Int dn, hp5590_read_eeprom (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int addr, unsigned int addr,
unsigned char *data, unsigned int size) unsigned char *data, unsigned int size)
{ {
@ -599,7 +617,9 @@ hp5590_read_eeprom (SANE_Int dn,
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
DBG (DBG_proc, "Reading EEPROM: addr %04x, size %u\n", addr, size); DBG (DBG_proc, "Reading EEPROM: addr %04x, size %u\n", addr, size);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_EEPROM_ADDR, CMD_EEPROM_ADDR,
(unsigned char *) &eeprom_addr, (unsigned char *) &eeprom_addr,
sizeof (eeprom_addr), CORE_NONE); sizeof (eeprom_addr), CORE_NONE);
@ -607,6 +627,7 @@ hp5590_read_eeprom (SANE_Int dn,
return ret; return ret;
ret = hp5590_cmd (dn, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN | CMD_VERIFY, CMD_IN | CMD_VERIFY,
CMD_EEPROM_READ, data, size, CORE_NONE); CMD_EEPROM_READ, data, size, CORE_NONE);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -618,6 +639,7 @@ hp5590_read_eeprom (SANE_Int dn,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_write_eeprom (SANE_Int dn, hp5590_write_eeprom (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int addr, unsigned int addr,
unsigned char *data, unsigned int size) unsigned char *data, unsigned int size)
{ {
@ -630,7 +652,9 @@ hp5590_write_eeprom (SANE_Int dn,
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
DBG (DBG_proc, "Writing EEPROM: addr %04x, size: %u\n", addr, size); DBG (DBG_proc, "Writing EEPROM: addr %04x, size: %u\n", addr, size);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_EEPROM_ADDR, CMD_EEPROM_ADDR,
(unsigned char *) &eeprom_addr, (unsigned char *) &eeprom_addr,
sizeof (eeprom_addr), CORE_NONE); sizeof (eeprom_addr), CORE_NONE);
@ -638,6 +662,7 @@ hp5590_write_eeprom (SANE_Int dn,
return ret; return ret;
ret = hp5590_cmd (dn, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY, CMD_VERIFY,
CMD_EEPROM_WRITE, data, size, CORE_DATA); CMD_EEPROM_WRITE, data, size, CORE_DATA);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -648,7 +673,9 @@ hp5590_write_eeprom (SANE_Int dn,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_scan_count (SANE_Int dn, unsigned int *count) hp5590_read_scan_count (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int *count)
{ {
uint32_t scan_count; uint32_t scan_count;
SANE_Status ret; SANE_Status ret;
@ -659,7 +686,9 @@ hp5590_read_scan_count (SANE_Int dn, unsigned int *count)
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
DBG (DBG_proc, "Reading scan count\n"); DBG (DBG_proc, "Reading scan count\n");
ret = hp5590_read_eeprom (dn, 0x00, ret = hp5590_read_eeprom (dn,
proto_flags,
0x00,
(unsigned char *) &scan_count, (unsigned char *) &scan_count,
sizeof (scan_count)); sizeof (scan_count));
@ -676,7 +705,8 @@ hp5590_read_scan_count (SANE_Int dn, unsigned int *count)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_inc_scan_count (SANE_Int dn) hp5590_inc_scan_count (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint32_t scan_count; uint32_t scan_count;
unsigned int count; unsigned int count;
@ -686,20 +716,22 @@ hp5590_inc_scan_count (SANE_Int dn)
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
hp5590_cmds_assert (sizeof (scan_count) == 4); hp5590_cmds_assert (sizeof (scan_count) == 4);
ret = hp5590_read_scan_count (dn, &count); ret = hp5590_read_scan_count (dn, proto_flags, &count);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
scan_count = ++count; scan_count = ++count;
ret = hp5590_write_eeprom (dn, 0x00, ret = hp5590_write_eeprom (dn,
proto_flags,
0x00,
(unsigned char *) &scan_count, (unsigned char *) &scan_count,
sizeof (scan_count)); sizeof (scan_count));
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
/* Verify its setting */ /* Verify its setting */
ret = hp5590_read_scan_count (dn, &new_count); ret = hp5590_read_scan_count (dn, proto_flags, &new_count);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -714,7 +746,9 @@ hp5590_inc_scan_count (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_max_scan_count (SANE_Int dn, unsigned int *max_count) hp5590_read_max_scan_count (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int *max_count)
{ {
uint8_t max_scan_count[3]; uint8_t max_scan_count[3];
SANE_Status ret; SANE_Status ret;
@ -726,6 +760,7 @@ hp5590_read_max_scan_count (SANE_Int dn, unsigned int *max_count)
DBG (DBG_proc, "Reading max scan count\n"); DBG (DBG_proc, "Reading max scan count\n");
ret = hp5590_read_eeprom (dn, ret = hp5590_read_eeprom (dn,
proto_flags,
0x10, 0x10,
(unsigned char *) max_scan_count, (unsigned char *) max_scan_count,
sizeof (max_scan_count)); sizeof (max_scan_count));
@ -770,14 +805,17 @@ hp5590_read_max_scan_count (SANE_Int dn, unsigned int *max_count)
/******************************************************************************/ /******************************************************************************/
static __sane_unused__ SANE_Status static __sane_unused__ SANE_Status
hp5590_read_eeprom_all_cmd (SANE_Int dn) hp5590_read_eeprom_all_cmd (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint8_t eeprom[255]; uint8_t eeprom[255];
SANE_Status ret; SANE_Status ret;
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
ret = hp5590_read_eeprom (dn, 0x00, ret = hp5590_read_eeprom (dn,
proto_flags,
0x00,
(unsigned char *) eeprom, (unsigned char *) eeprom,
sizeof (eeprom)); sizeof (eeprom));
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -790,7 +828,8 @@ hp5590_read_eeprom_all_cmd (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_part_number (SANE_Int dn) hp5590_read_part_number (SANE_Int dn,
enum proto_flags proto_flags)
{ {
unsigned int part_number_len = PART_NUMBER_LEN; unsigned int part_number_len = PART_NUMBER_LEN;
unsigned char part_number[PART_NUMBER_LEN + 1]; unsigned char part_number[PART_NUMBER_LEN + 1];
@ -800,6 +839,7 @@ hp5590_read_part_number (SANE_Int dn)
memset (part_number, 0, sizeof (part_number)); memset (part_number, 0, sizeof (part_number));
ret = hp5590_read_eeprom (dn, ret = hp5590_read_eeprom (dn,
proto_flags,
0x1a, 0x1a,
part_number, part_number_len); part_number, part_number_len);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -812,7 +852,8 @@ hp5590_read_part_number (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_is_data_available (SANE_Int dn) hp5590_is_data_available (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint8_t data_status; uint8_t data_status;
SANE_Status ret; SANE_Status ret;
@ -823,7 +864,9 @@ hp5590_is_data_available (SANE_Int dn)
hp5590_cmds_assert (sizeof (data_status) == 1); hp5590_cmds_assert (sizeof (data_status) == 1);
data_available = SANE_FALSE; data_available = SANE_FALSE;
ret = hp5590_cmd (dn, CMD_IN | CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN | CMD_VERIFY,
CMD_DATA_STATUS, CMD_DATA_STATUS,
(unsigned char *) &data_status, (unsigned char *) &data_status,
sizeof (data_status), CORE_DATA); sizeof (data_status), CORE_DATA);
@ -844,7 +887,8 @@ hp5590_is_data_available (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_stop_scan (SANE_Int dn) hp5590_stop_scan (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint8_t reg_011b = 0x40; uint8_t reg_011b = 0x40;
SANE_Status ret; SANE_Status ret;
@ -853,7 +897,9 @@ hp5590_stop_scan (SANE_Int dn)
hp5590_cmds_assert (sizeof (reg_011b) == 1); hp5590_cmds_assert (sizeof (reg_011b) == 1);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_STOP_SCAN, CMD_STOP_SCAN,
(unsigned char *) &reg_011b, (unsigned char *) &reg_011b,
sizeof (reg_011b), CORE_NONE); sizeof (reg_011b), CORE_NONE);
@ -867,7 +913,9 @@ hp5590_stop_scan (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_turnon_lamp (SANE_Int dn, enum hp5590_lamp_state state) hp5590_turnon_lamp (SANE_Int dn,
enum proto_flags proto_flags,
enum hp5590_lamp_state state)
{ {
struct lamp_state lamp_state; struct lamp_state lamp_state;
SANE_Status ret; SANE_Status ret;
@ -912,7 +960,9 @@ hp5590_turnon_lamp (SANE_Int dn, enum hp5590_lamp_state state)
DBG (DBG_cmds, "%s: setting long turnoff time\n", __FUNCTION__); DBG (DBG_cmds, "%s: setting long turnoff time\n", __FUNCTION__);
} }
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_CONTROL_LAMP, CMD_CONTROL_LAMP,
(unsigned char *) &lamp_state, (unsigned char *) &lamp_state,
sizeof (lamp_state), CORE_DATA); sizeof (lamp_state), CORE_DATA);
@ -921,7 +971,7 @@ hp5590_turnon_lamp (SANE_Int dn, enum hp5590_lamp_state state)
if (state == LAMP_STATE_TURNON) if (state == LAMP_STATE_TURNON)
{ {
ret = hp5590_init_scanner (dn, NULL, SCANNER_NONE); ret = hp5590_init_scanner (dn, proto_flags, NULL, SCANNER_NONE);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -931,7 +981,8 @@ hp5590_turnon_lamp (SANE_Int dn, enum hp5590_lamp_state state)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_power_status (SANE_Int dn) hp5590_power_status (SANE_Int dn,
enum proto_flags proto_flags)
{ {
struct power_resp power_resp; struct power_resp power_resp;
SANE_Status ret; SANE_Status ret;
@ -940,7 +991,9 @@ hp5590_power_status (SANE_Int dn)
hp5590_cmds_assert (sizeof (power_resp) == 3); hp5590_cmds_assert (sizeof (power_resp) == 3);
ret = hp5590_cmd (dn, CMD_IN | CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN | CMD_VERIFY,
CMD_POWER_STATUS, CMD_POWER_STATUS,
(unsigned char *) &power_resp, (unsigned char *) &power_resp,
sizeof (power_resp), CORE_NONE); sizeof (power_resp), CORE_NONE);
@ -953,7 +1006,7 @@ hp5590_power_status (SANE_Int dn)
if (!(power_resp.flags & POWER_FLAG_ON)) if (!(power_resp.flags & POWER_FLAG_ON))
{ {
DBG (DBG_cmds, "Turning lamp on\n"); DBG (DBG_cmds, "Turning lamp on\n");
ret = hp5590_turnon_lamp (dn, LAMP_STATE_TURNON); ret = hp5590_turnon_lamp (dn, proto_flags, LAMP_STATE_TURNON);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -963,7 +1016,9 @@ hp5590_power_status (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_error_code (SANE_Int dn, unsigned int *adf_flags) hp5590_read_error_code (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int *adf_flags)
{ {
struct reg_03 reg_03; struct reg_03 reg_03;
SANE_Status ret; SANE_Status ret;
@ -975,7 +1030,9 @@ hp5590_read_error_code (SANE_Int dn, unsigned int *adf_flags)
memset (&reg_03, 0, sizeof (reg_03)); memset (&reg_03, 0, sizeof (reg_03));
*adf_flags = 0; *adf_flags = 0;
ret = hp5590_cmd (dn, CMD_IN, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN,
CMD_MISC_STATUS, CMD_MISC_STATUS,
(unsigned char *) &reg_03, (unsigned char *) &reg_03,
sizeof (reg_03), CORE_NONE); sizeof (reg_03), CORE_NONE);
@ -994,19 +1051,20 @@ hp5590_read_error_code (SANE_Int dn, unsigned int *adf_flags)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_reset_scan_head (SANE_Int dn) hp5590_reset_scan_head (SANE_Int dn,
enum proto_flags proto_flags)
{ {
SANE_Status ret; SANE_Status ret;
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
ret = hp5590_turnon_lamp (dn, LAMP_STATE_TURNOFF); ret = hp5590_turnon_lamp (dn, proto_flags, LAMP_STATE_TURNOFF);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
usleep (100 * 1000); usleep (100 * 1000);
ret = hp5590_turnon_lamp (dn, LAMP_STATE_TURNON); ret = hp5590_turnon_lamp (dn, proto_flags, LAMP_STATE_TURNON);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1016,6 +1074,7 @@ hp5590_reset_scan_head (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_select_source_and_wakeup (SANE_Int dn, hp5590_select_source_and_wakeup (SANE_Int dn,
enum proto_flags proto_flags,
enum scan_sources source, enum scan_sources source,
SANE_Bool extend_lamp_timeout) SANE_Bool extend_lamp_timeout)
{ {
@ -1029,13 +1088,14 @@ hp5590_select_source_and_wakeup (SANE_Int dn,
if (source == SOURCE_TMA_SLIDES || source == SOURCE_TMA_NEGATIVES) if (source == SOURCE_TMA_SLIDES || source == SOURCE_TMA_NEGATIVES)
{ {
ret = hp5590_turnon_lamp (dn, LAMP_STATE_TURNOFF); ret = hp5590_turnon_lamp (dn, proto_flags, LAMP_STATE_TURNOFF);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
else else
{ {
ret = hp5590_turnon_lamp (dn, ret = hp5590_turnon_lamp (dn,
proto_flags,
extend_lamp_timeout == SANE_TRUE ? extend_lamp_timeout == SANE_TRUE ?
LAMP_STATE_SET_TURNOFF_TIME_LONG : LAMP_STATE_SET_TURNOFF_TIME_LONG :
LAMP_STATE_SET_TURNOFF_TIME); LAMP_STATE_SET_TURNOFF_TIME);
@ -1068,7 +1128,9 @@ hp5590_select_source_and_wakeup (SANE_Int dn,
DBG (DBG_cmds, "Scan source: %u\n", reg_d6); DBG (DBG_cmds, "Scan source: %u\n", reg_d6);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_SELECT_SOURCE, CMD_SELECT_SOURCE,
(unsigned char *) &reg_d6, (unsigned char *) &reg_d6,
sizeof (reg_d6), CORE_NONE); sizeof (reg_d6), CORE_NONE);
@ -1076,7 +1138,7 @@ hp5590_select_source_and_wakeup (SANE_Int dn,
if (ret != SANE_STATUS_GOOD && ret != SANE_STATUS_DEVICE_BUSY) if (ret != SANE_STATUS_GOOD && ret != SANE_STATUS_DEVICE_BUSY)
return ret; return ret;
ret = hp5590_read_error_code (dn, &adf_flags); ret = hp5590_read_error_code (dn, proto_flags, &adf_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1091,7 +1153,8 @@ hp5590_select_source_and_wakeup (SANE_Int dn,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_lock_unlock_scanner (SANE_Int dn) hp5590_lock_unlock_scanner (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint8_t reg_00 = 0x01; uint8_t reg_00 = 0x01;
SANE_Status ret; SANE_Status ret;
@ -1103,7 +1166,9 @@ hp5590_lock_unlock_scanner (SANE_Int dn)
for (waiting = 0; waiting < WAKEUP_TIMEOUT; waiting++, sleep (1)) for (waiting = 0; waiting < WAKEUP_TIMEOUT; waiting++, sleep (1))
{ {
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_LOCK_UNLOCK, CMD_LOCK_UNLOCK,
(unsigned char *) &reg_00, (unsigned char *) &reg_00,
sizeof (reg_00), CORE_NONE); sizeof (reg_00), CORE_NONE);
@ -1114,7 +1179,7 @@ hp5590_lock_unlock_scanner (SANE_Int dn)
return ret; return ret;
DBG (DBG_cmds, "Waiting for scanner...\n"); DBG (DBG_cmds, "Waiting for scanner...\n");
ret = hp5590_read_error_code (dn, &adf_flags); ret = hp5590_read_error_code (dn, proto_flags, &adf_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1134,6 +1199,7 @@ hp5590_lock_unlock_scanner (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_set_base_dpi (SANE_Int dn, hp5590_set_base_dpi (SANE_Int dn,
enum proto_flags proto_flags,
struct scanner_info *scanner_info, struct scanner_info *scanner_info,
unsigned int base_dpi) unsigned int base_dpi)
{ {
@ -1159,7 +1225,9 @@ hp5590_set_base_dpi (SANE_Int dn,
_base_dpi = htons (base_dpi); _base_dpi = htons (base_dpi);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_SET_BASE_DPI, CMD_SET_BASE_DPI,
(unsigned char *) &_base_dpi, (unsigned char *) &_base_dpi,
sizeof (_base_dpi), CORE_DATA); sizeof (_base_dpi), CORE_DATA);
@ -1171,7 +1239,9 @@ hp5590_set_base_dpi (SANE_Int dn,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_set_color_map (SANE_Int dn, unsigned int base_dpi) hp5590_set_color_map (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int base_dpi)
{ {
struct color_map color_map; struct color_map color_map;
SANE_Status ret; SANE_Status ret;
@ -1206,7 +1276,9 @@ hp5590_set_color_map (SANE_Int dn, unsigned int base_dpi)
color_map.color3[5] = 0x02; color_map.color3[5] = 0x02;
} }
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_SET_COLOR_MAP, CMD_SET_COLOR_MAP,
(unsigned char *) &color_map, (unsigned char *) &color_map,
sizeof (color_map), CORE_DATA); sizeof (color_map), CORE_DATA);
@ -1369,7 +1441,9 @@ hp5590_calc_pixel_bits (unsigned int dpi, enum color_depths color_depth,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_set_scan_area (SANE_Int dn, struct scanner_info *scanner_info, hp5590_set_scan_area (SANE_Int dn,
enum proto_flags proto_flags,
struct scanner_info *scanner_info,
unsigned int top_x, unsigned int top_y, unsigned int top_x, unsigned int top_y,
unsigned int width, unsigned int height, unsigned int width, unsigned int height,
unsigned int dpi, enum color_depths color_depth, unsigned int dpi, enum color_depths color_depth,
@ -1534,7 +1608,9 @@ hp5590_set_scan_area (SANE_Int dn, struct scanner_info *scanner_info,
scan_params.line_width = htons (scanner_line_width); scan_params.line_width = htons (scanner_line_width);
DBG (DBG_cmds, "Line width: %u\n", scanner_line_width); DBG (DBG_cmds, "Line width: %u\n", scanner_line_width);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_SET_SCAN_PARAMS, CMD_SET_SCAN_PARAMS,
(unsigned char *) &scan_params, (unsigned char *) &scan_params,
sizeof (scan_params), CORE_DATA); sizeof (scan_params), CORE_DATA);
@ -1546,7 +1622,8 @@ hp5590_set_scan_area (SANE_Int dn, struct scanner_info *scanner_info,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_image_params (SANE_Int dn) hp5590_read_image_params (SANE_Int dn,
enum proto_flags proto_flags)
{ {
struct image_params image_params; struct image_params image_params;
SANE_Status ret; SANE_Status ret;
@ -1557,7 +1634,9 @@ hp5590_read_image_params (SANE_Int dn)
memset (&image_params, 0, sizeof (image_params)); memset (&image_params, 0, sizeof (image_params));
ret = hp5590_cmd (dn, CMD_IN | CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN | CMD_VERIFY,
CMD_GET_IMAGE_PARAMS, CMD_GET_IMAGE_PARAMS,
(unsigned char *) &image_params, (unsigned char *) &image_params,
sizeof (image_params), CORE_NONE); sizeof (image_params), CORE_NONE);
@ -1585,7 +1664,9 @@ hp5590_read_image_params (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_set_scan_params (SANE_Int dn, struct scanner_info * scanner_info, hp5590_set_scan_params (SANE_Int dn,
enum proto_flags proto_flags,
struct scanner_info * scanner_info,
unsigned int top_x, unsigned int top_y, unsigned int top_x, unsigned int top_y,
unsigned int width, unsigned int height, unsigned int width, unsigned int height,
unsigned int dpi, enum color_depths color_depth, unsigned int dpi, enum color_depths color_depth,
@ -1601,7 +1682,7 @@ hp5590_set_scan_params (SANE_Int dn, struct scanner_info * scanner_info,
hp5590_cmds_assert (dpi != 0); hp5590_cmds_assert (dpi != 0);
/* Lock scanner */ /* Lock scanner */
ret = hp5590_lock_unlock_scanner (dn); ret = hp5590_lock_unlock_scanner (dn, proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1610,49 +1691,51 @@ hp5590_set_scan_params (SANE_Int dn, struct scanner_info * scanner_info,
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
/* Unlock scanner */ /* Unlock scanner */
hp5590_lock_unlock_scanner (dn); hp5590_lock_unlock_scanner (dn, proto_flags);
return ret; return ret;
} }
DBG (DBG_cmds, "Set base DPI: %u\n", base_dpi); DBG (DBG_cmds, "Set base DPI: %u\n", base_dpi);
ret = hp5590_set_base_dpi (dn, scanner_info, base_dpi); ret = hp5590_set_base_dpi (dn, proto_flags, scanner_info, base_dpi);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
/* Unlock scanner */ /* Unlock scanner */
hp5590_lock_unlock_scanner (dn); hp5590_lock_unlock_scanner (dn, proto_flags);
return ret; return ret;
} }
/* Set color map */ /* Set color map */
ret = hp5590_set_color_map (dn, base_dpi); ret = hp5590_set_color_map (dn, proto_flags, base_dpi);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
/* Unlock scanner */ /* Unlock scanner */
hp5590_lock_unlock_scanner (dn); hp5590_lock_unlock_scanner (dn, proto_flags);
return ret; return ret;
} }
ret = hp5590_set_scan_area (dn, scanner_info, ret = hp5590_set_scan_area (dn,
proto_flags,
scanner_info,
top_x, top_y, top_x, top_y,
width, height, width, height,
dpi, color_depth, scan_mode, scan_source); dpi, color_depth, scan_mode, scan_source);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
/* Unlock scanner */ /* Unlock scanner */
hp5590_lock_unlock_scanner (dn); hp5590_lock_unlock_scanner (dn, proto_flags);
return ret; return ret;
} }
ret = hp5590_read_image_params (dn); ret = hp5590_read_image_params (dn, proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
/* Unlock scanner */ /* Unlock scanner */
hp5590_lock_unlock_scanner (dn); hp5590_lock_unlock_scanner (dn, proto_flags);
return ret; return ret;
} }
/* Unlock scanner */ /* Unlock scanner */
ret = hp5590_lock_unlock_scanner (dn); ret = hp5590_lock_unlock_scanner (dn, proto_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1661,7 +1744,8 @@ hp5590_set_scan_params (SANE_Int dn, struct scanner_info * scanner_info,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_send_reverse_calibration_map (SANE_Int dn) hp5590_send_reverse_calibration_map (SANE_Int dn,
enum proto_flags proto_flags)
{ {
unsigned int reverse_map_size = REVERSE_MAP_LEN; unsigned int reverse_map_size = REVERSE_MAP_LEN;
uint16_t reverse_map[REVERSE_MAP_LEN]; uint16_t reverse_map[REVERSE_MAP_LEN];
@ -1699,7 +1783,9 @@ hp5590_send_reverse_calibration_map (SANE_Int dn)
DBG (DBG_proc, "Done preparing reverse calibration map\n"); DBG (DBG_proc, "Done preparing reverse calibration map\n");
ret = hp5590_bulk_write (dn, 0x2b, ret = hp5590_bulk_write (dn,
proto_flags,
0x2b,
(unsigned char *) reverse_map, (unsigned char *) reverse_map,
reverse_map_size * sizeof (uint16_t)); reverse_map_size * sizeof (uint16_t));
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -1710,7 +1796,8 @@ hp5590_send_reverse_calibration_map (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_send_forward_calibration_maps (SANE_Int dn) hp5590_send_forward_calibration_maps (SANE_Int dn,
enum proto_flags proto_flags)
{ {
unsigned int forward_map_size = FORWARD_MAP_LEN; unsigned int forward_map_size = FORWARD_MAP_LEN;
uint16_t forward_map[FORWARD_MAP_LEN]; uint16_t forward_map[FORWARD_MAP_LEN];
@ -1729,19 +1816,25 @@ hp5590_send_forward_calibration_maps (SANE_Int dn)
} }
DBG (DBG_proc, "Done preparing forward calibration map\n"); DBG (DBG_proc, "Done preparing forward calibration map\n");
ret = hp5590_bulk_write (dn, 0x012a, ret = hp5590_bulk_write (dn,
proto_flags,
0x012a,
(unsigned char *) forward_map, (unsigned char *) forward_map,
forward_map_size * sizeof (uint16_t)); forward_map_size * sizeof (uint16_t));
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
ret = hp5590_bulk_write (dn, 0x022a, ret = hp5590_bulk_write (dn,
proto_flags,
0x022a,
(unsigned char *) forward_map, (unsigned char *) forward_map,
forward_map_size * sizeof (uint16_t)); forward_map_size * sizeof (uint16_t));
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
ret = hp5590_bulk_write (dn, 0x032a, ret = hp5590_bulk_write (dn,
proto_flags,
0x032a,
(unsigned char *) forward_map, (unsigned char *) forward_map,
forward_map_size * sizeof (uint16_t)); forward_map_size * sizeof (uint16_t));
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -1752,7 +1845,9 @@ hp5590_send_forward_calibration_maps (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read (SANE_Int dn, unsigned char *bytes, unsigned int size, hp5590_read (SANE_Int dn,
enum proto_flags proto_flags,
unsigned char *bytes, unsigned int size,
void *state) void *state)
{ {
SANE_Status ret; SANE_Status ret;
@ -1762,7 +1857,7 @@ hp5590_read (SANE_Int dn, unsigned char *bytes, unsigned int size,
hp5590_cmds_assert (bytes != NULL); hp5590_cmds_assert (bytes != NULL);
hp5590_cmds_assert (state != NULL); hp5590_cmds_assert (state != NULL);
ret = hp5590_bulk_read (dn, bytes, size, state); ret = hp5590_bulk_read (dn, proto_flags, bytes, size, state);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -1771,7 +1866,8 @@ hp5590_read (SANE_Int dn, unsigned char *bytes, unsigned int size,
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_start_scan (SANE_Int dn) hp5590_start_scan (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint8_t reg_051b = 0x40; uint8_t reg_051b = 0x40;
SANE_Status ret; SANE_Status ret;
@ -1780,7 +1876,9 @@ hp5590_start_scan (SANE_Int dn)
hp5590_cmds_assert (sizeof (reg_051b) == 1); hp5590_cmds_assert (sizeof (reg_051b) == 1);
ret = hp5590_cmd (dn, CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_VERIFY,
CMD_START_SCAN, CMD_START_SCAN,
(unsigned char *) &reg_051b, (unsigned char *) &reg_051b,
sizeof (reg_051b), CORE_NONE); sizeof (reg_051b), CORE_NONE);
@ -1792,7 +1890,9 @@ hp5590_start_scan (SANE_Int dn)
/******************************************************************************/ /******************************************************************************/
static SANE_Status static SANE_Status
hp5590_read_buttons (SANE_Int dn, enum button_status * status) hp5590_read_buttons (SANE_Int dn,
enum proto_flags proto_flags,
enum button_status * status)
{ {
uint16_t button_status; uint16_t button_status;
SANE_Status ret; SANE_Status ret;
@ -1802,7 +1902,9 @@ hp5590_read_buttons (SANE_Int dn, enum button_status * status)
hp5590_cmds_assert (status != NULL); hp5590_cmds_assert (status != NULL);
hp5590_cmds_assert (sizeof (button_status) == 2); hp5590_cmds_assert (sizeof (button_status) == 2);
ret = hp5590_cmd (dn, CMD_IN | CMD_VERIFY, ret = hp5590_cmd (dn,
proto_flags,
CMD_IN | CMD_VERIFY,
CMD_BUTTON_STATUS, CMD_BUTTON_STATUS,
(unsigned char *) &button_status, (unsigned char *) &button_status,
sizeof (button_status), CORE_NONE); sizeof (button_status), CORE_NONE);

Wyświetl plik

@ -109,6 +109,17 @@ enum hp5590_lamp_state
LAMP_STATE_SET_TURNOFF_TIME_LONG LAMP_STATE_SET_TURNOFF_TIME_LONG
}; };
struct hp5590_model
{
enum hp_scanner_types scanner_type;
unsigned int usb_vendor_id;
unsigned int usb_product_id;
const char *vendor_id;
const char *model;
const char *kind;
enum proto_flags proto_flags;
};
#define FEATURE_NONE 0 #define FEATURE_NONE 0
#define FEATURE_ADF 1 << 0 #define FEATURE_ADF 1 << 0
#define FEATURE_TMA 1 << 1 #define FEATURE_TMA 1 << 1
@ -130,22 +141,31 @@ struct scanner_info
unsigned int normal_motor_param; unsigned int normal_motor_param;
}; };
static SANE_Status hp5590_model_def (enum hp_scanner_types scanner_type,
const struct hp5590_model ** model);
static SANE_Status hp5590_vendor_product_id (enum hp_scanner_types scanner_type, static SANE_Status hp5590_vendor_product_id (enum hp_scanner_types scanner_type,
SANE_Word * vendor_id, SANE_Word * vendor_id,
SANE_Word * product_id); SANE_Word * product_id);
static SANE_Status hp5590_init_scanner (SANE_Int dn, static SANE_Status hp5590_init_scanner (SANE_Int dn,
enum proto_flags proto_flags,
struct scanner_info **info, struct scanner_info **info,
enum hp_scanner_types scanner_type); enum hp_scanner_types scanner_type);
static SANE_Status hp5590_power_status (SANE_Int dn); static SANE_Status hp5590_power_status (SANE_Int dn,
enum proto_flags proto_flags);
static SANE_Status hp5590_read_max_scan_count (SANE_Int dn, static SANE_Status hp5590_read_max_scan_count (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int *max_count); unsigned int *max_count);
static SANE_Status hp5590_select_source_and_wakeup (SANE_Int dn, static SANE_Status hp5590_select_source_and_wakeup (SANE_Int dn,
enum proto_flags proto_flags,
enum scan_sources source, enum scan_sources source,
SANE_Bool extend_lamp_timeout); SANE_Bool extend_lamp_timeout);
static SANE_Status hp5590_stop_scan (SANE_Int dn); static SANE_Status hp5590_stop_scan (SANE_Int dn,
enum proto_flags proto_flags);
static SANE_Status hp5590_read_scan_count (SANE_Int dn, static SANE_Status hp5590_read_scan_count (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int *count); unsigned int *count);
static SANE_Status hp5590_set_scan_params (SANE_Int dn, static SANE_Status hp5590_set_scan_params (SANE_Int dn,
enum proto_flags proto_flags,
struct scanner_info *scanner_info, struct scanner_info *scanner_info,
unsigned int top_x, unsigned int top_y, unsigned int top_x, unsigned int top_y,
unsigned int width, unsigned int height, unsigned int width, unsigned int height,
@ -153,21 +173,30 @@ static SANE_Status hp5590_set_scan_params (SANE_Int dn,
enum color_depths color_depth, enum color_depths color_depth,
enum scan_modes scan_mode, enum scan_modes scan_mode,
enum scan_sources scan_source); enum scan_sources scan_source);
static SANE_Status hp5590_send_forward_calibration_maps (SANE_Int dn); static SANE_Status hp5590_send_forward_calibration_maps (SANE_Int dn,
static SANE_Status hp5590_send_reverse_calibration_map (SANE_Int dn); enum proto_flags proto_flags);
static SANE_Status hp5590_inc_scan_count (SANE_Int dn); static SANE_Status hp5590_send_reverse_calibration_map (SANE_Int dn,
static SANE_Status hp5590_start_scan (SANE_Int dn); enum proto_flags proto_flags);
static SANE_Status hp5590_inc_scan_count (SANE_Int dn,
enum proto_flags proto_flags);
static SANE_Status hp5590_start_scan (SANE_Int dn,
enum proto_flags proto_flags);
static SANE_Status hp5590_read (SANE_Int dn, static SANE_Status hp5590_read (SANE_Int dn,
enum proto_flags proto_flags,
unsigned char *bytes, unsigned char *bytes,
unsigned int size, void *state); unsigned int size, void *state);
static SANE_Status hp5590_read_buttons (SANE_Int dn, static SANE_Status hp5590_read_buttons (SANE_Int dn,
enum proto_flags proto_flags,
enum button_status *status); enum button_status *status);
static SANE_Status hp5590_read_part_number (SANE_Int dn); static SANE_Status hp5590_read_part_number (SANE_Int dn,
enum proto_flags proto_flags);
static SANE_Status hp5590_calc_pixel_bits (unsigned int dpi, static SANE_Status hp5590_calc_pixel_bits (unsigned int dpi,
enum color_depths color_depth, enum color_depths color_depth,
unsigned int *pixel_bits); unsigned int *pixel_bits);
static SANE_Status hp5590_is_data_available (SANE_Int dn); static SANE_Status hp5590_is_data_available (SANE_Int dn,
static SANE_Status hp5590_reset_scan_head (SANE_Int dn); enum proto_flags proto_flags);
static SANE_Status hp5590_reset_scan_head (SANE_Int dn,
enum proto_flags proto_flags);
#endif /* HP5590_H */ #endif /* HP5590_H */
/* vim: sw=2 ts=8 /* vim: sw=2 ts=8
*/ */

Wyświetl plik

@ -131,11 +131,16 @@ struct bulk_read_state
* SANE_STATUS_DEVICE_BUSY - otherwise * SANE_STATUS_DEVICE_BUSY - otherwise
*/ */
static SANE_Status static SANE_Status
hp5590_get_ack (SANE_Int dn) hp5590_get_ack (SANE_Int dn,
enum proto_flags proto_flags)
{ {
uint8_t status; uint8_t status;
SANE_Status ret; SANE_Status ret;
/* Bypass reading acknowledge if the device doesn't need it */
if (proto_flags & PF_NO_USB_IN_USB_ACK)
return SANE_STATUS_GOOD;
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
/* Check if USB-in-USB operation was accepted */ /* Check if USB-in-USB operation was accepted */
@ -173,7 +178,8 @@ hp5590_get_ack (SANE_Int dn)
* SANE_STATUS_DEVICE_BUSY - otherwise * SANE_STATUS_DEVICE_BUSY - otherwise
*/ */
static SANE_Status static SANE_Status
hp5590_get_status (SANE_Int dn) hp5590_get_status (SANE_Int dn,
__sane_unused__ enum proto_flags proto_flags)
{ {
uint8_t status; uint8_t status;
SANE_Status ret; SANE_Status ret;
@ -181,7 +187,7 @@ hp5590_get_status (SANE_Int dn)
DBG (DBG_proc, "%s\n", __FUNCTION__); DBG (DBG_proc, "%s\n", __FUNCTION__);
ret = sanei_usb_control_msg (dn, USB_DIR_IN | USB_TYPE_VENDOR, ret = sanei_usb_control_msg (dn, USB_DIR_IN | USB_TYPE_VENDOR,
0x0c, 0x8e, 0x20, 0x0c, 0x8e, 0x00,
sizeof (status), &status); sizeof (status), &status);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
{ {
@ -222,6 +228,7 @@ hp5590_get_status (SANE_Int dn)
*/ */
static SANE_Status static SANE_Status
hp5590_control_msg (SANE_Int dn, hp5590_control_msg (SANE_Int dn,
enum proto_flags proto_flags,
int requesttype, int request, int requesttype, int request,
int value, int index, unsigned char *bytes, int value, int index, unsigned char *bytes,
int size, int core_flags) int size, int core_flags)
@ -262,9 +269,8 @@ hp5590_control_msg (SANE_Int dn,
return ret; return ret;
} }
DBG (DBG_usb, "%s: USB-in-USB: checking acknowledge for control message\n", /* USB-in-USB: checking acknowledge for control message */
__FUNCTION__); ret = hp5590_get_ack (dn, proto_flags);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -304,9 +310,8 @@ hp5590_control_msg (SANE_Int dn,
return -1; return -1;
} }
DBG (DBG_usb, "%s: USB-in-USB: checking if confirmation was acknowledged\n", /* USB-in-USB: checking if confirmation was acknowledged */
__FUNCTION__); ret = hp5590_get_ack (dn, proto_flags);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -334,9 +339,8 @@ hp5590_control_msg (SANE_Int dn,
return ret; return ret;
} }
DBG (DBG_usb, "%s: USB-in-USB: checking acknowledge for control message\n", /* USB-in-USB: checking acknowledge for control message */
__FUNCTION__); ret = hp5590_get_ack (dn, proto_flags);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -363,9 +367,8 @@ hp5590_control_msg (SANE_Int dn,
/* CORE data is acknowledged packet by packet */ /* CORE data is acknowledged packet by packet */
if (core_flags & CORE_DATA) if (core_flags & CORE_DATA)
{ {
DBG (DBG_usb, "%s: USB-in-USB: checking if data was accepted\n", /* USB-in-USB: checking if data was accepted */
__FUNCTION__); ret = hp5590_get_ack (dn, proto_flags);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -377,9 +380,8 @@ hp5590_control_msg (SANE_Int dn,
/* Normal (non-CORE) data is acknowledged after its full transmission */ /* Normal (non-CORE) data is acknowledged after its full transmission */
if (!(core_flags & CORE_DATA)) if (!(core_flags & CORE_DATA))
{ {
DBG (3, "%s: USB-in-USB: checking if data was accepted\n", /* USB-in-USB: checking if data was accepted */
__FUNCTION__); ret = hp5590_get_ack (dn, proto_flags);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -429,10 +431,8 @@ hp5590_control_msg (SANE_Int dn,
return ret; return ret;
} }
/* Check acknowledge for bulk flags transmission */ /* USB-in-USB: checking confirmation for bulk flags */
DBG (DBG_usb, "%s: USB-in-USB: checking confirmation for bulk flags\n", ret = hp5590_get_ack (dn, proto_flags);
__FUNCTION__);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -455,7 +455,9 @@ hp5590_control_msg (SANE_Int dn,
* all other SANE_Status values - otherwise * all other SANE_Status values - otherwise
*/ */
static SANE_Status static SANE_Status
hp5590_verify_last_cmd (SANE_Int dn, unsigned int cmd) hp5590_verify_last_cmd (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int cmd)
{ {
uint16_t verify_cmd; uint16_t verify_cmd;
unsigned int last_cmd; unsigned int last_cmd;
@ -466,7 +468,9 @@ hp5590_verify_last_cmd (SANE_Int dn, unsigned int cmd)
__FUNCTION__); __FUNCTION__);
/* Read last command along with CORE status */ /* Read last command along with CORE status */
ret = hp5590_control_msg (dn, USB_DIR_IN, ret = hp5590_control_msg (dn,
proto_flags,
USB_DIR_IN,
0x04, 0xc5, 0x00, 0x04, 0xc5, 0x00,
(unsigned char *) &verify_cmd, (unsigned char *) &verify_cmd,
sizeof (verify_cmd), CORE_NONE); sizeof (verify_cmd), CORE_NONE);
@ -518,7 +522,9 @@ hp5590_verify_last_cmd (SANE_Int dn, unsigned int cmd)
* all other SANE_Status values - otherwise * all other SANE_Status values - otherwise
*/ */
static SANE_Status static SANE_Status
hp5590_cmd (SANE_Int dn, unsigned int flags, hp5590_cmd (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int flags,
unsigned int cmd, unsigned char *data, unsigned int size, unsigned int cmd, unsigned char *data, unsigned int size,
unsigned int core_flags) unsigned int core_flags)
{ {
@ -527,6 +533,7 @@ hp5590_cmd (SANE_Int dn, unsigned int flags,
DBG (3, "%s: USB-in-USB: command : %04x\n", __FUNCTION__, cmd); DBG (3, "%s: USB-in-USB: command : %04x\n", __FUNCTION__, cmd);
ret = hp5590_control_msg (dn, ret = hp5590_control_msg (dn,
proto_flags,
flags & CMD_IN ? USB_DIR_IN : USB_DIR_OUT, flags & CMD_IN ? USB_DIR_IN : USB_DIR_OUT,
0x04, cmd, 0x00, data, size, core_flags); 0x04, cmd, 0x00, data, size, core_flags);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
@ -536,7 +543,7 @@ hp5590_cmd (SANE_Int dn, unsigned int flags,
/* Verify last command if requested */ /* Verify last command if requested */
if (flags & CMD_VERIFY) if (flags & CMD_VERIFY)
{ {
ret = hp5590_verify_last_cmd (dn, cmd); ret = hp5590_verify_last_cmd (dn, proto_flags, cmd);
} }
return ret; return ret;
@ -632,7 +639,9 @@ hp5590_low_free_bulk_read_state (void **state)
* state - pointer to initialized bulk read state structure * state - pointer to initialized bulk read state structure
*/ */
static SANE_Status static SANE_Status
hp5590_bulk_read (SANE_Int dn, unsigned char *bytes, unsigned int size, hp5590_bulk_read (SANE_Int dn,
enum proto_flags proto_flags,
unsigned char *bytes, unsigned int size,
void *state) void *state)
{ {
struct usb_in_usb_bulk_setup ctrl; struct usb_in_usb_bulk_setup ctrl;
@ -712,10 +721,8 @@ hp5590_bulk_read (SANE_Int dn, unsigned char *bytes, unsigned int size,
return ret; return ret;
} }
/* Check acknowledge for bulk flags just sent */ /* USB-in-USB: checking confirmation for bulk flags\n" */
DBG (DBG_usb, "%s: USB-in-USB: checking confirmation for bulk flags\n", ret = hp5590_get_ack (dn, proto_flags);
__FUNCTION__);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -739,10 +746,8 @@ hp5590_bulk_read (SANE_Int dn, unsigned char *bytes, unsigned int size,
return ret; return ret;
} }
/* Check acknowledge for bulk read request */ /* USB-in-USB: checking if control msg was accepted */
DBG (DBG_usb, "%s: USB-in-USB: checking if control msg was accepted\n", ret = hp5590_get_ack (dn, proto_flags);
__FUNCTION__);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
} }
@ -864,7 +869,9 @@ hp5590_bulk_read (SANE_Int dn, unsigned char *bytes, unsigned int size,
* all other SANE_Status value - otherwise * all other SANE_Status value - otherwise
*/ */
static SANE_Status static SANE_Status
hp5590_bulk_write (SANE_Int dn, int cmd, unsigned char *bytes, hp5590_bulk_write (SANE_Int dn,
enum proto_flags proto_flags,
int cmd, unsigned char *bytes,
unsigned int size) unsigned int size)
{ {
struct usb_in_usb_bulk_setup ctrl; struct usb_in_usb_bulk_setup ctrl;
@ -888,7 +895,9 @@ hp5590_bulk_write (SANE_Int dn, int cmd, unsigned char *bytes,
/* Send bulk write request */ /* Send bulk write request */
DBG (3, "%s: USB-in-USB: total %u pages (each of %u bytes)\n", DBG (3, "%s: USB-in-USB: total %u pages (each of %u bytes)\n",
__FUNCTION__, bulk_size.size, BULK_WRITE_PAGE_SIZE); __FUNCTION__, bulk_size.size, BULK_WRITE_PAGE_SIZE);
ret = hp5590_control_msg (dn, USB_DIR_OUT, ret = hp5590_control_msg (dn,
proto_flags,
USB_DIR_OUT,
0x04, cmd, 0, 0x04, cmd, 0,
(unsigned char *) &bulk_size, sizeof (bulk_size), (unsigned char *) &bulk_size, sizeof (bulk_size),
CORE_DATA | CORE_BULK_OUT); CORE_DATA | CORE_BULK_OUT);
@ -921,10 +930,8 @@ hp5590_bulk_write (SANE_Int dn, int cmd, unsigned char *bytes,
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
/* Check acknowledge for bulk write request */ /* USB-in-USB: checking if command was accepted */
DBG (DBG_usb, "%s: USB-in-USB: checking if command was accepted\n", ret = hp5590_get_ack (dn, proto_flags);
__FUNCTION__);
ret = hp5590_get_ack (dn);
if (ret != SANE_STATUS_GOOD) if (ret != SANE_STATUS_GOOD)
return ret; return ret;
@ -948,7 +955,7 @@ hp5590_bulk_write (SANE_Int dn, int cmd, unsigned char *bytes,
} }
/* Verify bulk command */ /* Verify bulk command */
return hp5590_verify_last_cmd (dn, cmd); return hp5590_verify_last_cmd (dn, proto_flags, cmd);
} }
/* vim: sw=2 ts=8 /* vim: sw=2 ts=8
*/ */

Wyświetl plik

@ -47,6 +47,12 @@
#include "../include/sane/sane.h" #include "../include/sane/sane.h"
enum proto_flags {
PF_NONE = 0,
PF_NO_USB_IN_USB_ACK = 1 << 0 /* Getting acknowledge after USB-in-USB command
* will be skipped */
};
/* Flags for hp5590_cmd() */ /* Flags for hp5590_cmd() */
#define CMD_IN 1 << 0 /* Indicates IN direction, otherwise - OUT */ #define CMD_IN 1 << 0 /* Indicates IN direction, otherwise - OUT */
#define CMD_VERIFY 1 << 1 /* Requests last command verification */ #define CMD_VERIFY 1 << 1 /* Requests last command verification */
@ -61,16 +67,21 @@
* transfer * transfer
*/ */
static SANE_Status hp5590_cmd (SANE_Int dn, static SANE_Status hp5590_cmd (SANE_Int dn,
enum proto_flags proto_flags,
unsigned int flags, unsigned int flags,
unsigned int cmd, unsigned char *data, unsigned int cmd, unsigned char *data,
unsigned int size, unsigned int core_flags); unsigned int size, unsigned int core_flags);
static SANE_Status hp5590_bulk_read (SANE_Int dn, static SANE_Status hp5590_bulk_read (SANE_Int dn,
enum proto_flags proto_flags,
unsigned char *bytes, unsigned char *bytes,
unsigned int size, void *state); unsigned int size, void *state);
static SANE_Status hp5590_bulk_write (SANE_Int dn, int cmd, static SANE_Status hp5590_bulk_write (SANE_Int dn,
enum proto_flags proto_flags,
int cmd,
unsigned char *bytes, unsigned char *bytes,
unsigned int size); unsigned int size);
static SANE_Status hp5590_get_status (SANE_Int dn); static SANE_Status hp5590_get_status (SANE_Int dn,
enum proto_flags proto_flags);
static SANE_Status hp5590_low_init_bulk_read_state (void **state); static SANE_Status hp5590_low_init_bulk_read_state (void **state);
static SANE_Status hp5590_low_free_bulk_read_state (void **state); static SANE_Status hp5590_low_free_bulk_read_state (void **state);
#endif /* HP5590_LOW_H */ #endif /* HP5590_LOW_H */