1/* $NetBSD: tpctl.h,v 1.5 2008/05/10 15:31:05 martin 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 47enum tpctl_data_type { 48 TPCTL_CALIBCOORDS, 49 TPCTL_COMMENT, 50}; 51 52enum tpctl_data_ERROR { 53 ERR_NONE, 54 ERR_NOFILE, 55 ERR_IO, 56 ERR_SYNTAX, 57 ERR_DUPNAME, 58}; 59 60struct 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 67struct tpctl_data { 68 int lineno; 69 TAILQ_HEAD(,tpctl_data_elem) list; 70}; 71 72struct tp { 73 int fd; 74 char id[WSMOUSE_ID_MAXLEN]; 75}; 76 77typedef u_int32_t fb_pixel_t; 78struct 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 88int init_data(struct tpctl_data *); 89int read_data(const char *, struct tpctl_data *); 90int write_data(const char *, struct tpctl_data *); 91void write_coords(FILE *, char *, struct wsmouse_calibcoords *); 92void free_data(struct tpctl_data *); 93int replace_data(struct tpctl_data *, char *, struct wsmouse_calibcoords *); 94struct wsmouse_calibcoords *search_data(struct tpctl_data *, char *); 95 96int tp_init(struct tp *, int); 97int tp_setrawmode(struct tp *); 98int tp_setcalibcoords(struct tp *, struct wsmouse_calibcoords *); 99int tp_flush(struct tp *); 100int tp_get(struct tp *, int *, int *, int (*)(void *), void *); 101int tp_waitup(struct tp *, int, int (*)(void *), void *); 102 103int fb_dispmode(struct fb *, int); 104int fb_init(struct fb *, int); 105void fb_getline(struct fb *, int); 106void fb_putline(struct fb *, int); 107void fb_fetchline(struct fb *, int); 108void fb_flush(struct fb *); 109void fb_drawline(struct fb *, int, int, int, int, fb_pixel_t); 110void fb_drawpixel(struct fb *, int, int, fb_pixel_t); 111 112#endif /* __TPCTL_TP_H__ */ 113