xref: /netbsd-src/usr.sbin/tpctl/tpctl.h (revision 50010e742d7715992428e391d175087da72c3fcf)
1*50010e74Snonaka /*	$NetBSD: tpctl.h,v 1.6 2009/04/28 10:57:24 nonaka Exp $	*/
2b8ce6e82Stakemura 
3b8ce6e82Stakemura /*-
4bb756166Stakemura  * Copyright (c) 2002, 2003 TAKEMRUA Shin
5b8ce6e82Stakemura  * All rights reserved.
6b8ce6e82Stakemura  *
7b8ce6e82Stakemura  * Redistribution and use in source and binary forms, with or without
8b8ce6e82Stakemura  * modification, are permitted provided that the following conditions
9b8ce6e82Stakemura  * are met:
10b8ce6e82Stakemura  * 1. Redistributions of source code must retain the above copyright
11b8ce6e82Stakemura  *    notice, this list of conditions and the following disclaimer.
12b8ce6e82Stakemura  * 2. Redistributions in binary form must reproduce the above copyright
13b8ce6e82Stakemura  *    notice, this list of conditions and the following disclaimer in the
14b8ce6e82Stakemura  *    documentation and/or other materials provided with the distribution.
155d1469bdSmartin  * 3. Neither the name of The NetBSD Foundation nor the names of its
165d1469bdSmartin  *    contributors may be used to endorse or promote products derived
175d1469bdSmartin  *    from this software without specific prior written permission.
18b8ce6e82Stakemura  *
19b8ce6e82Stakemura  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20b8ce6e82Stakemura  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21b8ce6e82Stakemura  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22b8ce6e82Stakemura  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23b8ce6e82Stakemura  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24b8ce6e82Stakemura  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b8ce6e82Stakemura  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b8ce6e82Stakemura  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27b8ce6e82Stakemura  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b8ce6e82Stakemura  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29b8ce6e82Stakemura  * POSSIBILITY OF SUCH DAMAGE.
30b8ce6e82Stakemura  */
31b8ce6e82Stakemura 
32b8ce6e82Stakemura #ifndef __TPCTL_H__
33b8ce6e82Stakemura #define __TPCTL_H__
34b8ce6e82Stakemura 
35b8ce6e82Stakemura #include <sys/queue.h>
36b8ce6e82Stakemura #include <dev/wscons/wsconsio.h>
37b8ce6e82Stakemura #include <dev/wscons/wsdisplay_usl_io.h>
38b8ce6e82Stakemura #include <dev/hpc/hpcfbio.h>
39b8ce6e82Stakemura 
40b8ce6e82Stakemura #define MAXDATALEN		128
41b8ce6e82Stakemura #define TPCTL_DB_FILENAME	"/etc/tpctl.dat"
42b8ce6e82Stakemura #define TPCTL_TMP_FILENAME	"tpctl.tmp"
43b8ce6e82Stakemura #define TPCTL_TP_DEVICE		"/dev/wsmux0"
44b8ce6e82Stakemura #define TPCTL_FB_DEVICE		"/dev/ttyE0"
45b8ce6e82Stakemura 
46b8ce6e82Stakemura 
47b8ce6e82Stakemura enum tpctl_data_type {
48b8ce6e82Stakemura 	TPCTL_CALIBCOORDS,
49b8ce6e82Stakemura 	TPCTL_COMMENT,
50b8ce6e82Stakemura };
51b8ce6e82Stakemura 
52b8ce6e82Stakemura enum tpctl_data_ERROR {
53b8ce6e82Stakemura 	ERR_NONE,
54b8ce6e82Stakemura 	ERR_NOFILE,
55b8ce6e82Stakemura 	ERR_IO,
56b8ce6e82Stakemura 	ERR_SYNTAX,
57b8ce6e82Stakemura 	ERR_DUPNAME,
58b8ce6e82Stakemura };
59b8ce6e82Stakemura 
60b8ce6e82Stakemura struct tpctl_data_elem {
61b8ce6e82Stakemura 	enum tpctl_data_type type;
62b8ce6e82Stakemura 	TAILQ_ENTRY(tpctl_data_elem) link;
63b8ce6e82Stakemura 	char *name;
64b8ce6e82Stakemura 	struct wsmouse_calibcoords calibcoords;
65b8ce6e82Stakemura };
66b8ce6e82Stakemura 
67b8ce6e82Stakemura struct tpctl_data {
68b8ce6e82Stakemura 	int lineno;
69b8ce6e82Stakemura 	TAILQ_HEAD(,tpctl_data_elem) list;
70b8ce6e82Stakemura };
71b8ce6e82Stakemura 
72b8ce6e82Stakemura struct tp {
73b8ce6e82Stakemura 	int fd;
74bb756166Stakemura 	char id[WSMOUSE_ID_MAXLEN];
75b8ce6e82Stakemura };
76b8ce6e82Stakemura 
77b8ce6e82Stakemura typedef u_int32_t fb_pixel_t;
78b8ce6e82Stakemura struct fb {
79b8ce6e82Stakemura 	int fd;
80b8ce6e82Stakemura 	int dispmode;
81b8ce6e82Stakemura 	struct hpcfb_fbconf conf;
82b8ce6e82Stakemura 	unsigned char *baseaddr;
83b8ce6e82Stakemura 	fb_pixel_t *linecache, *workbuf;
84b8ce6e82Stakemura 	fb_pixel_t white, black;
85b8ce6e82Stakemura 	int linecache_y;
86b8ce6e82Stakemura };
87b8ce6e82Stakemura 
88b8ce6e82Stakemura int init_data(struct tpctl_data *);
89*50010e74Snonaka int read_data(const char *, struct tpctl_data *);
90*50010e74Snonaka int write_data(const char *, struct tpctl_data *);
91b8ce6e82Stakemura void write_coords(FILE *, char *, struct wsmouse_calibcoords *);
92b8ce6e82Stakemura void free_data(struct tpctl_data *);
93b8ce6e82Stakemura int replace_data(struct tpctl_data *, char *, struct wsmouse_calibcoords *);
94b8ce6e82Stakemura struct wsmouse_calibcoords *search_data(struct tpctl_data *, char *);
95b8ce6e82Stakemura 
96b8ce6e82Stakemura int tp_init(struct tp *, int);
97b8ce6e82Stakemura int tp_setrawmode(struct tp *);
98b8ce6e82Stakemura int tp_setcalibcoords(struct tp *, struct wsmouse_calibcoords *);
99b8ce6e82Stakemura int tp_flush(struct tp *);
100b8ce6e82Stakemura int tp_get(struct tp *, int *, int *, int (*)(void *), void *);
101b8ce6e82Stakemura int tp_waitup(struct tp *, int, int (*)(void *), void *);
102b8ce6e82Stakemura 
103b8ce6e82Stakemura int fb_dispmode(struct fb *, int);
104b8ce6e82Stakemura int fb_init(struct fb *, int);
105b8ce6e82Stakemura void fb_getline(struct fb *, int);
106b8ce6e82Stakemura void fb_putline(struct fb *, int);
107b8ce6e82Stakemura void fb_fetchline(struct fb *, int);
108b8ce6e82Stakemura void fb_flush(struct fb *);
109b8ce6e82Stakemura void fb_drawline(struct fb *, int, int, int, int, fb_pixel_t);
110b8ce6e82Stakemura void fb_drawpixel(struct fb *, int, int, fb_pixel_t);
111b8ce6e82Stakemura 
112e8eb6502Suwe #endif /* __TPCTL_TP_H__ */
113