1 #ifndef __HPSJ5S_MIDDLE_LEVEL_API_HEADER__ 2 #define __HPSJ5S_MIDDLE_LEVEL_API_HEADER__ 3 4 5 #include <ieee1284.h> 6 7 /*Scanner hardware registers*/ 8 #define REGISTER_FUNCTION_CODE 0x70 /*Here goes function code */ 9 #define REGISTER_FUNCTION_PARAMETER 0x60 /*Here goes function param */ 10 11 #define ADDRESS_RESULT 0x20 /*Here we get result */ 12 13 /*Scanner functions (not all - some of them I can't identify)*/ 14 #define FUNCTION_SETUP_HARDWARE 0xA0 15 16 /*Scanner hardware control flags:*/ 17 /*Set this flag and non-zero speed to start rotation*/ 18 #define FLAGS_HW_MOTOR_READY 0x1 19 /*Set this flag to turn on lamp*/ 20 #define FLAGS_HW_LAMP_ON 0x2 21 /*Set this flag to turn indicator lamp off*/ 22 #define FLAGS_HW_INDICATOR_OFF 0x4 23 24 25 /* 26 Types: 27 */ 28 /*Color modes we support: 1-bit Drawing, 2-bit Halftone, 8-bit Gray Scale, 24-bt True Color*/ 29 typedef enum 30 { Drawing, Halftone, GrayScale, TrueColor } 31 enumColorDepth; 32 33 /*Middle-level API:*/ 34 35 static int OpenScanner (const char *scanner_path); 36 37 static void CloseScanner (int handle); 38 39 static int DetectScanner (void); 40 41 static void StandByScanner (void); 42 43 static void SwitchHardwareState (SANE_Byte mask, SANE_Byte invert_mask); 44 45 static int CheckPaperPresent (void); 46 47 static int ReleasePaper (void); 48 49 static int PaperFeed (SANE_Word wLinesToFeed); 50 51 static void TransferScanParameters (enumColorDepth enColor, 52 SANE_Word wResolution, 53 SANE_Word wCorrectedLength); 54 55 static void TurnOnPaperPulling (enumColorDepth enColor, 56 SANE_Word wResolution); 57 58 static void TurnOffPaperPulling (void); 59 60 static SANE_Byte GetCalibration (void); 61 62 static void CalibrateScanElements (void); 63 64 /*Internal-use functions:*/ 65 66 static int OutputCheck (void); 67 static int InputCheck (void); 68 static int CallCheck (void); 69 static void LoadingPaletteToScanner (void); 70 71 /*Low level warappers:*/ 72 73 static void WriteAddress (SANE_Byte Address); 74 75 static void WriteData (SANE_Byte Data); 76 77 static void WriteScannerRegister (SANE_Byte Address, SANE_Byte Data); 78 79 static void CallFunctionWithParameter (SANE_Byte Function, 80 SANE_Byte Parameter); 81 82 static SANE_Byte CallFunctionWithRetVal (SANE_Byte Function); 83 84 static SANE_Byte ReadDataByte (void); 85 86 static void ReadDataBlock (SANE_Byte * Buffer, int length); 87 88 /*Daisy chaining API: (should be moved to ieee1284 library in future)*/ 89 90 /*Deselect all devices in chain on this port.*/ 91 static void daisy_deselect_all (struct parport *port); 92 93 /*Select device with number 'daisy' in 'mode'.*/ 94 static int daisy_select (struct parport *port, int daisy, int mode); 95 96 /*Setup address for device in chain on this port*/ 97 static int assign_addr (struct parport *port, int daisy); 98 99 /* Send a daisy-chain-style CPP command packet. */ 100 static int cpp_daisy (struct parport *port, int cmd); 101 102 #endif 103