summaryrefslogtreecommitdiff
path: root/backend/hp5400_internal.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:44:51 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:44:51 +0200
commitad38bc6ecb80ddeb562841b33258dd53659b1da6 (patch)
treee02e9c3ff760554fd87f70df0e18b88594091a48 /backend/hp5400_internal.c
parent9c23ed018d72eed2554f4f9cff1ae6e6bb0cd479 (diff)
New upstream version 1.0.31upstream/1.0.31
Diffstat (limited to 'backend/hp5400_internal.c')
-rw-r--r--backend/hp5400_internal.c130
1 files changed, 129 insertions, 1 deletions
diff --git a/backend/hp5400_internal.c b/backend/hp5400_internal.c
index 34bf55d..1d81358 100644
--- a/backend/hp5400_internal.c
+++ b/backend/hp5400_internal.c
@@ -1,4 +1,5 @@
/* sane - Scanner Access Now Easy.
+ Copyright (C) 2020 Ralph Little <skelband@gmail.com>
Copyright (C) 2003 Martijn van Oosterhout <kleptog@svana.org>
Copyright (C) 2003 Thomas Soumarmon <thomas.soumarmon@cogitae.net>
Copyright (c) 2003 Henning Meier-Geinitz, <henning@meier-geinitz.de>
@@ -149,11 +150,138 @@ SetLamp (THWParams * pHWParams, int fLampOn)
if (fLampOn)
{
if (WriteByte (pHWParams->iXferHandle, 0x0000, 0x01) == 0)
- return 0;
+ return 0;
}
return -1;
}
+
+HP5400_SANE_STATIC
+int
+GetSensors(THWParams * pHWParams, uint16_t *sensorMap)
+{
+ /*
+ * Read until we get 0.
+ * Max 10 iterations for safety.
+ *
+ */
+ *sensorMap = 0;
+ uint16_t thisSensorMap = 0;
+ size_t iterCount = 10;
+ do
+ {
+ if (hp5400_command_read
+ (pHWParams->iXferHandle, CMD_GETSENSORS, sizeof (uint16_t), &thisSensorMap) < 0)
+ {
+ HP5400_DBG (DBG_MSG, "failed to read sensors\n");
+ return -1;
+ }
+ *sensorMap |= thisSensorMap;
+ } while (iterCount-- && (thisSensorMap > 0));
+
+ return 0;
+}
+
+HP5400_SANE_STATIC
+int
+GetPanelInfo (THWParams * pHWParams, TPanelInfo *panelInfo)
+{
+ struct PanelInfo info;
+ if (hp5400_command_read (pHWParams->iXferHandle, CMD_READPANEL,
+ sizeof(info), &info) < 0)
+ {
+ HP5400_DBG (DBG_MSG, "failed to read panel info\n");
+ return -1;
+ }
+
+ panelInfo->copycount = (SANE_Word)info.copycount;
+ panelInfo->bwcolour = (SANE_Word)info.bwcolour;
+
+ return 0;
+}
+
+HP5400_SANE_STATIC
+int
+SetCopyCount(THWParams * pHWParams, SANE_Word copyCount)
+{
+
+ /*
+ * I don't know what most of these things are but it is
+ * necessary to send something sane otherwise we get an error from the scanner.
+ * I got these settings from a USB trace.
+ * Hopefully, we will learn what it is all about at some point
+ * and hopefully it doesn't screw with other settings.
+ *
+ */
+ uint8_t packetImage[] = {0x02, 0x06, 0x32, 0x01,
+ 0xf2, 0x40, 0x16, 0x01,
+ 0x7b, 0x41, 0x16, 0x01,
+ 0xdc, 0x06, 0x32, 0x01,
+ 0xd7, 0x5b, 0x16, 0x01,
+ 0xac, 0x06, 0x32, 0x01,
+ 0xf8, 0xd7, 0x18, 0x01,
+ 0xd8, 0x06, 0x32, 0x01,
+ 0x2c, 0xf3, 0x12, 0x00,
+ 0x70, 0x8d, 0x18, 0x01,
+ 0x7b, 0x00, 0x00, 0x00};
+
+ struct PanelInfo workingInfo;
+ (void)memcpy(&workingInfo, packetImage, sizeof(workingInfo));
+
+ workingInfo.copycount = (uint8_t)copyCount;
+
+ if (hp5400_command_write (pHWParams->iXferHandle, CMD_WRITEPANEL,
+ sizeof(workingInfo), &workingInfo) < 0)
+ {
+ HP5400_DBG (DBG_MSG, "failed to write panel info\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+HP5400_SANE_STATIC
+int
+SetColourBW(THWParams * pHWParams, SANE_Word colourBW)
+{
+
+ /*
+ * I don't know what most of these things are but it is
+ * necessary to send something sane otherwise we get an error from the scanner.
+ * I got these settings from a USB trace.
+ * Hopefully, we will learn what it is all about at some point
+ * and hopefully it doesn't screw with other settings.
+ *
+ */
+ uint8_t packetImage[] = {0x03, 0x06, 0x32, 0x01,
+ 0xf2, 0x40, 0x16, 0x01,
+ 0x7b, 0x41, 0x16, 0x01,
+ 0xdc, 0x06, 0x32, 0x01,
+ 0xd7, 0x5b, 0x16, 0x01,
+ 0xac, 0x06, 0x32, 0x01,
+ 0xf8, 0xd7, 0x18, 0x01,
+ 0xd8, 0x06, 0x32, 0x01,
+ 0x68, 0xf5, 0x12, 0x00,
+ 0x70, 0x8d, 0x18, 0x01,
+ 0x7b, 0x00, 0x00, 0x00};
+
+ struct PanelInfo workingInfo;
+ (void)memcpy(&workingInfo, packetImage, sizeof(workingInfo));
+
+ workingInfo.bwcolour = (uint8_t)colourBW;
+
+ if (hp5400_command_write (pHWParams->iXferHandle, CMD_WRITEPANEL,
+ sizeof(workingInfo), &workingInfo) < 0)
+ {
+ HP5400_DBG (DBG_MSG, "failed to write panel info\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
HP5400_SANE_STATIC
int
WarmupLamp (int iHandle)