1 /* sane - Scanner Access Now Easy.
2 
3    based on sources acquired from Plustek Inc.
4    Copyright (C) 2002-2003 Gerhard Jaeger <gerhard@gjaeger.de>
5 
6    This file is part of the SANE package.
7 
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2 of the
11    License, or (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 
21    As a special exception, the authors of SANE give permission for
22    additional uses of the libraries contained in this release of SANE.
23 
24    The exception is that, if you link a SANE library with other files
25    to produce an executable, this does not by itself cause the
26    resulting executable to be covered by the GNU General Public
27    License.  Your use of that executable is in no way restricted on
28    account of linking the SANE library code into it.
29 
30    This exception does not, however, invalidate any other reasons why
31    the executable file might be covered by the GNU General Public
32    License.
33 
34    If you submit changes to SANE to the maintainers to be included in
35    a subsequent release, you agree by submitting the changes that
36    those changes may be distributed with this exception intact.
37 
38    If you write modifications of your own for SANE, it is your choice
39    whether to permit this exception to apply to your modifications.
40    If you do not wish that, delete this exception notice.
41 
42 */
43 
44 /** @file sanei_lm983x.h
45  *  Interface files for the NS LM9831/2/3 USB chip.
46  *
47  *  The National Semiconductor LM9831, LM9832, and LM9833 chips are used in
48  *  many USB scanners. Examples include Plustek and Mustek devices.
49  *
50  * @sa sanei_usb.h
51  */
52 
53 #ifndef sanei_lm983x_h
54 #define sanei_lm983x_h
55 
56 #include "../include/sane/config.h"
57 #include "../include/sane/sane.h"
58 
59 /**
60  * Read one data byte from a specific LM983x register.
61  *
62  * @param fd    - device file descriptor (SANE_Int)
63  * @param reg   - number of register (SANE_Byte)
64  * @param value - byte value to be written (SANE_Byte *)
65  *
66  * @return The SANE status code for the operation (SANE_Status):
67  * - SANE_STATUS_GOOD     - on success
68  * - SANE_STATUS_IO_ERROR - system write function failed
69  * - SANE_STATUS_INVAL    - register out of range
70  */
71 #define sanei_lm983x_read_byte(fd, reg, value) \
72           sanei_lm983x_read (fd, reg, value, 1, 0)
73 
74 /**
75  * Initialize sanei_lm983x.
76  *
77  * Currently, this function only enables the debugging functionality.
78  */
79 extern void sanei_lm983x_init( void );
80 
81 /**
82  * Write one data byte to a specific LM983x register.
83  *
84  * @param fd    - device file descriptor
85  * @param reg   - number of register
86  * @param value - byte value to be written
87  *
88  * @return
89  * - SANE_STATUS_GOOD     - on success
90  * - SANE_STATUS_IO_ERROR - system write function failed
91  * - SANE_STATUS_INVAL    - register out of range
92  */
93 extern SANE_Status sanei_lm983x_write_byte( SANE_Int fd,
94                                             SANE_Byte reg, SANE_Byte value );
95 
96 /**
97  * Write one or more data bytes to one or more specific LM983x
98  * registers.
99  *
100  * @param fd        - device file descriptor
101  * @param reg       - number of start-register
102  * @param buffer    - buffer to be written
103  * @param len       - number of bytes to be written
104  * @param increment - SANE_TRUE enables the autoincrement of the register
105  *                    value during the write cycle, SANE_FALSE disables this
106  *
107  * @return
108  * - SANE_STATUS_GOOD     - on success
109  * - SANE_STATUS_IO_ERROR - system read function failed
110  * - SANE_STATUS_INVAL    - register out of range or len field was 0
111  */
112 extern SANE_Status sanei_lm983x_write( SANE_Int fd, SANE_Byte reg,
113                                        SANE_Byte *buffer, SANE_Word len,
114                                                          SANE_Bool increment );
115 
116 /**
117  * Read one or more data bytes from one ore more specific LM983x
118  * registers.
119  *
120  * @param fd        - device file descriptor
121  * @param reg       - number of start-register
122  * @param buffer    - buffer to receive the data
123  * @param len       - number of bytes to receive
124  * @param increment - SANE_TRUE enables the autoincrement of the register
125  *                    value during the read cylce, SANE_FALSE disables this
126  *
127  * @return
128  * - SANE_STATUS_GOOD     - on success
129  * - SANE_STATUS_IO_ERROR - system read function failed
130  * - SANE_STATUS_INVAL    - register out of range
131  * - SANE_STATUS_EOF      - if nothing can't be read
132  */
133 extern SANE_Status sanei_lm983x_read( SANE_Int fd, SANE_Byte reg,
134                                       SANE_Byte *buffer, SANE_Word len,
135                                                          SANE_Bool increment );
136 
137 /**
138  * Reset the LM983x chip.
139  *
140  * @param fd    - device file descriptor
141  * @return
142  * - SANE_TRUE  - reset successfully done
143  * - SANE_FALSE - reset failed
144  */
145 extern SANE_Bool sanei_lm983x_reset( SANE_Int fd );
146 
147 #endif /* sanei_lm983x_h */
148