From 409e1d29d2f8108281c4316c025e76b14dbc368e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Mon, 30 Nov 2009 06:58:42 +0100 Subject: [PATCH] add document presence detection request to gt6816 --- backend/gt68xx_devices.c | 12 ++++++++---- backend/gt68xx_gt6816.c | 25 +++++++++++++++++++++++++ backend/gt68xx_gt6816.h | 2 ++ backend/gt68xx_low.h | 8 ++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/backend/gt68xx_devices.c b/backend/gt68xx_devices.c index 66d8b3fc3..afcfb45d5 100644 --- a/backend/gt68xx_devices.c +++ b/backend/gt68xx_devices.c @@ -86,7 +86,8 @@ static GT68xx_Command_Set mustek_gt6816_command_set = { gt68xx_generic_set_afe, gt68xx_generic_set_exposure_time, gt68xx_generic_get_id, - /* gt68xx_generic_move_paper */ NULL + /* gt68xx_generic_move_paper */ NULL, + /* gt6816_document_present */ NULL }; static GT68xx_Command_Set mustek_gt6816_sheetfed_command_set = { @@ -126,7 +127,8 @@ static GT68xx_Command_Set mustek_gt6816_sheetfed_command_set = { gt68xx_generic_set_afe, gt68xx_generic_set_exposure_time, gt68xx_generic_get_id, - gt68xx_generic_move_paper + gt68xx_generic_move_paper, + gt6816_document_present }; static GT68xx_Command_Set mustek_gt6801_command_set = { @@ -167,7 +169,8 @@ static GT68xx_Command_Set mustek_gt6801_command_set = { gt68xx_generic_set_afe, gt68xx_generic_set_exposure_time, gt68xx_generic_get_id, - /* gt68xx_generic_move_paper */ NULL + /* gt68xx_generic_move_paper */ NULL, + /* gt6816_document_present */ NULL }; static GT68xx_Command_Set plustek_gt6801_command_set = { @@ -207,7 +210,8 @@ static GT68xx_Command_Set plustek_gt6801_command_set = { gt68xx_generic_set_afe, /* set_exposure_time */ NULL, gt68xx_generic_get_id, - /* gt68xx_generic_move_paper */ NULL + /* gt68xx_generic_move_paper */ NULL, + /* gt6816_document_present */ NULL }; static GT68xx_Model unknown_model = { diff --git a/backend/gt68xx_gt6816.c b/backend/gt68xx_gt6816.c index 2a7cbfe13..045194a45 100644 --- a/backend/gt68xx_gt6816.c +++ b/backend/gt68xx_gt6816.c @@ -236,3 +236,28 @@ gt6816_stop_scan (GT68xx_Device * dev) return gt68xx_device_small_req (dev, req, req); } + +SANE_Status +gt6816_document_present (GT68xx_Device * dev, SANE_Bool * present) +{ + SANE_Status status; + GT68xx_Packet req; + + memset (req, 0, sizeof (req)); + req[0] = 0x59; + req[1] = 0x01; + + RIE (gt68xx_device_req (dev, req, req)); + + if (req[0] == 0x00 && req[1] == 0x59) + { + if (req[2] == 0) + *present = SANE_FALSE; + else + *present = SANE_TRUE; + } + else + return SANE_STATUS_IO_ERROR; + + return SANE_STATUS_GOOD; +} diff --git a/backend/gt68xx_gt6816.h b/backend/gt68xx_gt6816.h index ba9fe41b7..7b7207196 100644 --- a/backend/gt68xx_gt6816.h +++ b/backend/gt68xx_gt6816.h @@ -67,4 +67,6 @@ static SANE_Status gt6816_carriage_home (GT68xx_Device * dev); static SANE_Status gt6816_stop_scan (GT68xx_Device * dev); +static SANE_Status gt6816_document_present (GT68xx_Device * dev, SANE_Bool * present); + #endif /* not GT68XX_GT6816_H */ diff --git a/backend/gt68xx_low.h b/backend/gt68xx_low.h index b4fae18ed..f1e3bb6ee 100644 --- a/backend/gt68xx_low.h +++ b/backend/gt68xx_low.h @@ -399,6 +399,14 @@ struct GT68xx_Command_Set */ SANE_Status (*move_paper) (GT68xx_Device * dev, GT68xx_Scan_Request * request); + + /** Detect if a document is inserted in the feeder + * + * @param dev Device object. + * @param present + */ + SANE_Status (*document_present) (GT68xx_Device * dev, + SANE_Bool *present); /*@} */ };