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