1 /* @file plustek-pp_scan.h
2  * @brief the global header for the plustek driver
3  *
4  * Copyright (C) 2000-2013 Gerhard Jaeger <gerhard@gjaeger.de>
5  *
6  * History:
7  * 0.30 - initial version
8  * 0.31 - no changes
9  * 0.32 - changed _DODELAY macro to work properly for delays > 5 ms
10  * 0.33 - no changes
11  * 0.34 - no changes
12  * 0.35 - removed _PTDRV_PUT_SCANNER_MODEL from ioctl interface
13  * 0.36 - now including plustek-share.h from the backend path
14  *        changed _INB/_OUTB to _INB_STATUS, _INB_CTRL, _INB_DATA ...
15  * 0.37 - added _OUTB_ECTL/_INB_ECTL, _MAX_PTDEVS, _DRV_NAME and _MAX_BTNS
16  *        added _OUTB_STATUS
17  * 0.38 - added _IS_ASIC96() and _IS_ASIC98() macros
18  * 0.39 - no changes
19  * 0.40 - no changes
20  * 0.41 - no changes
21  * 0.42 - changed include names
22  * 0.43 - no changes
23  * 0.44 - no changes
24  * .
25  * <hr>
26  * This file is part of the SANE package.
27  *
28  * This program is free software; you can redistribute it and/or
29  * modify it under the terms of the GNU General Public License as
30  * published by the Free Software Foundation; either version 2 of the
31  * License, or (at your option) any later version.
32  *
33  * This program is distributed in the hope that it will be useful, but
34  * WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36  * General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License
39  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
40  *
41  * As a special exception, the authors of SANE give permission for
42  * additional uses of the libraries contained in this release of SANE.
43  *
44  * The exception is that, if you link a SANE library with other files
45  * to produce an executable, this does not by itself cause the
46  * resulting executable to be covered by the GNU General Public
47  * License.  Your use of that executable is in no way restricted on
48  * account of linking the SANE library code into it.
49  *
50  * This exception does not, however, invalidate any other reasons why
51  * the executable file might be covered by the GNU General Public
52  * License.
53  *
54  * If you submit changes to SANE to the maintainers to be included in
55  * a subsequent release, you agree by submitting the changes that
56  * those changes may be distributed with this exception intact.
57  *
58  * If you write modifications of your own for SANE, it is your choice
59  * whether to permit this exception to apply to your modifications.
60  * If you do not wish that, delete this exception notice.
61  * <hr>
62  */
63 #ifndef __PLUSTEK_SCAN_H__
64 #define __PLUSTEK_SCAN_H__
65 
66 # include <stdlib.h>
67 # include <stdarg.h>
68 # include <string.h>
69 # include <stdio.h>
70 # include <unistd.h>
71 # include <sys/time.h>
72 # include <signal.h>
73 # include <sys/ioctl.h>
74 # ifdef HAVE_SYS_IO_H
75 #  include <sys/io.h>
76 # endif
77 
78 /*.............................................................................
79  * driver properties
80  */
81 #define _DRV_NAME        "pt_drv"   /**< driver's name         */
82 #define	_MAX_PTDEVS      4          /**< support for 4 devices */
83 #define	_MAX_BTNS        6          /**< support for 6 buttons */
84 #define _PTDRV_MAJOR    40          /**< our major number      */
85 
86 /*.............................................................................
87  * for port operations
88  */
89 # define _OPF	ps->IO.fnOut
90 # define _IPF	ps->IO.fnIn
91 
92 #define _OUTB_CTRL(pSD,port_value)   sanei_pp_outb_ctrl(pSD->pardev, port_value)
93 #define _OUTB_DATA(pSD,port_value)   sanei_pp_outb_data(pSD->pardev, port_value)
94 #define _OUTB_ECTL(pSD,port_value)
95 
96 #define _INB_CTRL(pSD)               sanei_pp_inb_ctrl(pSD->pardev)
97 #define _INB_DATA(pSD)               sanei_pp_inb_data(pSD->pardev)
98 #define _INB_EPPDATA(pSD)            sanei_pp_inb_epp(pSD->pardev)
99 #define _INB_STATUS(pSD)             sanei_pp_inb_stat(pSD->pardev)
100 
101 /*.............................................................................
102  * for memory allocation
103  */
104 # define _KALLOC(x,y)   malloc(x)
105 # define _KFREE(x)		free(x)
106 # define _VMALLOC(x)	malloc(x)
107 # define _VFREE(x)		free(x)
108 
109 /*
110  * WARNING - never use the _SECOND define with the _DODELAY macro !!
111  * they are for use the MiscStartTimer function and the _DO_UDELAY macro
112  */
113 typedef double TimerDef, *pTimerDef;
114 
115 #define _MSECOND    1000             /* based on 1 us */
116 #define _SECOND     (1000*_MSECOND)
117 
118 /*.............................................................................
119  * timer topics
120  */
121 # define _DO_UDELAY(usecs)   sanei_pp_udelay(usecs)
122 # define _DODELAY(msecs)     { int i; for( i = msecs; i--; ) _DO_UDELAY(1000); }
123 
124 /*.............................................................................
125  * include the shared stuff right here, this concerns the ioctl interface
126  * and the communication stuff
127  */
128 #include "plustek-pp.h"
129 
130 /*.............................................................................
131  * WARNING: don't move the following headers above the previous defines !!!!!!!
132  *
133  * the include files for user-mode and kernel-mode program
134  */
135 #include "plustek-pp_types.h"
136 #include "plustek-pp_hwdefs.h"
137 #include "plustek-pp_scandata.h"
138 #include "plustek-pp_procs.h"
139 #include "plustek-pp_dbg.h"
140 
141 /*.............................................................................
142  * some macros for convenience
143  */
144 #define _IS_ASIC96(aid)    ((_ASIC_IS_96001 == aid) || (_ASIC_IS_96003 == aid))
145 #define _IS_ASIC98(aid)    ((_ASIC_IS_98001 == aid) || (_ASIC_IS_98003 == aid))
146 
147 #endif /* guard __PLUSTEK_SCAN_H__ */
148 
149 /* END PLUSTEK-PP_SCAN.H ....................................................*/
150