1 /* sane - Scanner Access Now Easy. 2 Copyright (C) 2000-2003 Jochen Eisinger <jochen.eisinger@gmx.net> 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 40 /** @file sanei_pa4s2.h 41 * This file implements an interface for the Mustek PP chipset A4S2 42 * 43 * @sa sanei_usb.h, sanei_ab306.h, sanei_lm983x.h, sanei_scsi.h, sanei_pio.h 44 */ 45 46 #ifndef sanei_pa4s2_h 47 #define sanei_pa4s2_h 48 49 #include <sys/types.h> 50 #include <sane/sane.h> 51 52 /** @name Options to control interface operations */ 53 /* @{ */ 54 #define SANEI_PA4S2_OPT_DEFAULT 0 /* normal mode */ 55 #define SANEI_PA4S2_OPT_TRY_MODE_UNI 1 /* enable UNI protocol */ 56 #define SANEI_PA4S2_OPT_ALT_LOCK 2 /* use alternative lock cmd */ 57 #define SANEI_PA4S2_OPT_NO_EPP 4 /* do not try to use EPP */ 58 /* @} */ 59 60 /** Get list of possibly available devices 61 * 62 * Returns a list of arguments accepted as *dev by sanei_pa4s2_open 63 * 64 * @return 65 * - array of known *devs. The last entry is marked as NULL pointer. The 66 * user has to make sure, the array, but not the entries are freed. 67 * 68 * @sa sanei_pa4s2_open 69 * 70 */ 71 extern const char ** sanei_pa4s2_devices(void); 72 73 /** Open pa4s2 device 74 * 75 * Opens *dev as pa4s2 device. 76 * 77 * @param dev IO port address ("0x378", "0x278", or "0x3BC") 78 * @param fd file descriptor 79 * 80 * @return 81 * - SANE_STATUS_GOOD - on success 82 * - SANE_STATUS_INVAL - if no scanner was found or the port number was wrong 83 * - SANE_STATUS_DEVICE_BUSY - if the device is already in use 84 * - SANE_STATUS_IO_ERROR - if the port couldn't be accessed 85 * 86 */ 87 extern SANE_Status sanei_pa4s2_open (const char *dev, int *fd); 88 89 /** Open pa4s2 SCSI-over-parallel device 90 * 91 * Opens *dev as pa4s2 SCSI-over-parallel device. 92 * 93 * @param dev IO port address ("0x378", "0x278", or "0x3BC") 94 * @param fd file descriptor 95 * 96 * @return 97 * - SANE_STATUS_GOOD - on success 98 * - SANE_STATUS_INVAL - if no scanner was found or the port number was wrong 99 * - SANE_STATUS_DEVICE_BUSY - if the device is already in use 100 * - SANE_STATUS_IO_ERROR - if the port couldn't be accessed 101 * 102 */ 103 extern SANE_Status sanei_pa4s2_scsi_pp_open (const char *dev, int *fd); 104 105 /** Close pa4s2 device 106 * 107 * @param fd file descriptor 108 */ 109 extern void sanei_pa4s2_close (int fd); 110 111 /** Set/get options 112 * 113 * Sets/gets interface options. Options will be taken over, when set is 114 * SANE_TRUE. These options should be set before the first device is opened 115 * 116 * @param options pointer to options 117 * @param set set (SANE_TRUE) or get (SANE_FALSE) options 118 * 119 * @return 120 * - SANE_STATUS_GOOD - on success 121 */ 122 extern SANE_Status sanei_pa4s2_options (u_int * options, int set); 123 124 /** Enables/disable device 125 * 126 * When the device is disabled, the printer can be accessed, when it's enabled 127 * data can be read/written. 128 * 129 * @param fd file descriptor 130 * @param enable enable (SANE_TRUE) or disable (SANE_FALSE) device 131 * 132 * @return 133 * - SANE_STATUS_GOOD - on success 134 * - SANE_STATUS_INVAL - if fd is invalid or device not in use 135 */ 136 extern SANE_Status sanei_pa4s2_enable (int fd, int enable); 137 138 /** Select a register 139 * 140 * The function to read a register is split up in three parts, so a register 141 * can be read more than once. 142 * 143 * @param fd file descriptor 144 * @param reg register 145 * 146 * @return 147 * - SANE_STATUS_GOOD - on success 148 * - SANE_STATUS_INVAL - if fd is invalid or device not in use 149 * 150 * @sa sanei_pa4s2_readbyte(), sanei_pa4s2_readend() 151 */ 152 extern SANE_Status sanei_pa4s2_readbegin (int fd, u_char reg); 153 154 /** Return port status information 155 * 156 * @param fd file descriptor 157 * @param status variable to receive status 158 * 159 * @return 160 * - SANE_STATUS_GOOD - on success 161 * - SANE_STATUS_INVAL - if fd is invalid or device not in use 162 */ 163 extern SANE_Status sanei_pa4s2_scsi_pp_get_status (int fd, u_char *status); 164 165 /** Selects a register number on a SCSI-over-parallel scanner 166 * 167 * @param fd file descriptor 168 * @param reg register number 169 * 170 * @return 171 * - SANE_STATUS_GOOD - on success 172 * - SANE_STATUS_INVAL - if fd is invalid 173 */ 174 extern SANE_Status sanei_pa4s2_scsi_pp_reg_select (int fd, int reg); 175 176 /** Read a register 177 * 178 * The function to read a register is split up in three parts, so a register 179 * can be read more than once. 180 * 181 * @param fd file descriptor 182 * @param val pointer to value 183 * 184 * @return 185 * - SANE_STATUS_GOOD - on success 186 * - SANE_STATUS_INVAL - if fd is invalid or device not in use 187 * 188 * @sa sanei_pa4s2_readbegin(), sanei_pa4s2_readend() 189 */ 190 extern SANE_Status sanei_pa4s2_readbyte (int fd, u_char * val); 191 192 /** Terminate reading sequence 193 * 194 * The function to read a register is split up in three parts, so a register 195 * can be read more than once. 196 * 197 * @param fd file descriptor 198 * 199 * @return 200 * - SANE_STATUS_GOOD - on success 201 * - SANE_STATUS_INVAL - if fd is invalid or device not in use 202 * @sa sanei_pa4s2_readbegin(), sanei_pa4s2_readbyte() 203 */ 204 extern SANE_Status sanei_pa4s2_readend (int fd); 205 206 /** Write a register 207 * 208 * @param fd file descriptor 209 * @param reg register 210 * @param val value to be written 211 * 212 * @return 213 * - SANE_STATUS_GOOD - on success 214 * - SANE_STATUS_INVAL - if fd is invalid or device not in use 215 */ 216 extern SANE_Status sanei_pa4s2_writebyte (int fd, u_char reg, u_char val); 217 218 #endif 219