1/* sane - Scanner Access Now Easy.
2   Copyright (C) 2003 James Perry
3   This file is part of the SANE package.
4
5   This program is free software; you can redistribute it and/or
6   modify it under the terms of the GNU General Public License as
7   published by the Free Software Foundation; either version 2 of the
8   License, or (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
18   As a special exception, the authors of SANE give permission for
19   additional uses of the libraries contained in this release of SANE.
20
21   The exception is that, if you link a SANE library with other files
22   to produce an executable, this does not by itself cause the
23   resulting executable to be covered by the GNU General Public
24   License.  Your use of that executable is in no way restricted on
25   account of linking the SANE library code into it.
26
27   This exception does not, however, invalidate any other reasons why
28   the executable file might be covered by the GNU General Public
29   License.
30
31   If you submit changes to SANE to the maintainers to be included in
32   a subsequent release, you agree by submitting the changes that
33   those changes may be distributed with this exception intact.
34
35   If you write modifications of your own for SANE, it is your choice
36   whether to permit this exception to apply to your modifications.
37   If you do not wish that, delete this exception notice.
38
39   This file implements the SCSI-over-parallel port protocol used in,
40   for example, the Paragon 600 II EP
41*/
42
43#ifndef mustek_scsi_pp_h
44#define mustek_scsi_pp_h
45
46static int mustek_scsi_pp_get_time (void);
47
48/**
49 * Open the connection to a Mustek SCSI-over-pp device.
50 *
51 * @param dev Port address as text.
52 * @param fd  Information about port address and I/O method. fd is not a file
53 *            descriptor. The name and type are used for compatibility reasons.
54 *
55 * @return
56 * - SANE_STATUS_GOOD - on success
57 * - SANE_STATUS_INVAL - if the port address can't be interpreted
58 * - SANE_STATUS_IO_ERROR - if the device file for a port couldn't be accessed
59 */
60static SANE_Status mustek_scsi_pp_open (const char *dev, int *fd);
61
62/**
63 * Close the connection to a Mustek SCSI-over-PP device.
64 *
65 * @param fd  Information about port address and I/O method.
66 *
67 */
68static void mustek_scsi_pp_close (int fd);
69
70/**
71 * Exit Mustek SCSI-over-PP.
72 */
73static void mustek_scsi_pp_exit (void);
74
75/**
76 * Find out if the device is ready to accept new commands.
77 *
78 * @param fd  Information about port address and I/O method.
79 *
80 * @return
81 * - SANE_STATUS_GOOD - if the device is ready
82 * - SANE_STATUS_DEVICE_BUSY if the device is still busy (try again later)
83 */
84static SANE_Status mustek_scsi_pp_test_ready (int fd);
85
86/**
87 * Send a command to the Mustek SCSI-over-pp device.
88 *
89 * @param fd  Information about port address and I/O method.
90 * @param src Data to be sent to the device.
91 * @param src_size Size of data to be sent to the device.
92 * @param dst Data to be received from the device.
93 * @param dst_size Size of data to be received from the device
94 *
95 * @return
96 * - SANE_STATUS_GOOD - on success
97 * - SANE_STATUS_IO_ERROR - if an error occurred during the dialog with the
98 *   device
99 */
100static SANE_Status mustek_scsi_pp_cmd (int fd, const void *src, size_t src_size,
101				       void *dst, size_t * dst_size);
102
103/**
104 * Read scanned image data.
105 *
106 * @param fd  Information about port address and I/O method.
107 * @param planes Bytes per pixel (3 for color, 1 for all other modes)
108 * @param buf Buffer for image data.
109 * @param lines Number of lines
110 * @param bpl Bytes per line
111 *
112 * @return
113 * - SANE_STATUS_GOOD - on success
114 * - SANE_STATUS_IO_ERROR - if an error occurred during the dialog with the
115 *   device
116 */
117static SANE_Status mustek_scsi_pp_rdata (int fd, int planes,
118					 SANE_Byte * buf, int lines, int bpl);
119
120
121#endif /* mustek_scsi_pp_h */
122