Home | History | Annotate | Line # | Download | only in tpctl
tpctl.h revision 1.4
      1 /*	$NetBSD: tpctl.h,v 1.4 2008/04/29 06:53:04 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  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #ifndef __TPCTL_H__
     30 #define __TPCTL_H__
     31 
     32 #include <sys/queue.h>
     33 #include <dev/wscons/wsconsio.h>
     34 #include <dev/wscons/wsdisplay_usl_io.h>
     35 #include <dev/hpc/hpcfbio.h>
     36 
     37 #define MAXDATALEN		128
     38 #define TPCTL_DB_FILENAME	"/etc/tpctl.dat"
     39 #define TPCTL_TMP_FILENAME	"tpctl.tmp"
     40 #define TPCTL_TP_DEVICE		"/dev/wsmux0"
     41 #define TPCTL_FB_DEVICE		"/dev/ttyE0"
     42 
     43 
     44 enum tpctl_data_type {
     45 	TPCTL_CALIBCOORDS,
     46 	TPCTL_COMMENT,
     47 };
     48 
     49 enum tpctl_data_ERROR {
     50 	ERR_NONE,
     51 	ERR_NOFILE,
     52 	ERR_IO,
     53 	ERR_SYNTAX,
     54 	ERR_DUPNAME,
     55 };
     56 
     57 struct tpctl_data_elem {
     58 	enum tpctl_data_type type;
     59 	TAILQ_ENTRY(tpctl_data_elem) link;
     60 	char *name;
     61 	struct wsmouse_calibcoords calibcoords;
     62 };
     63 
     64 struct tpctl_data {
     65 	int lineno;
     66 	TAILQ_HEAD(,tpctl_data_elem) list;
     67 };
     68 
     69 struct tp {
     70 	int fd;
     71 	char id[WSMOUSE_ID_MAXLEN];
     72 };
     73 
     74 typedef u_int32_t fb_pixel_t;
     75 struct fb {
     76 	int fd;
     77 	int dispmode;
     78 	struct hpcfb_fbconf conf;
     79 	unsigned char *baseaddr;
     80 	fb_pixel_t *linecache, *workbuf;
     81 	fb_pixel_t white, black;
     82 	int linecache_y;
     83 };
     84 
     85 int init_data(struct tpctl_data *);
     86 int read_data(char *, struct tpctl_data *);
     87 int write_data(char *, struct tpctl_data *);
     88 void write_coords(FILE *, char *, struct wsmouse_calibcoords *);
     89 void free_data(struct tpctl_data *);
     90 int replace_data(struct tpctl_data *, char *, struct wsmouse_calibcoords *);
     91 struct wsmouse_calibcoords *search_data(struct tpctl_data *, char *);
     92 
     93 int tp_init(struct tp *, int);
     94 int tp_setrawmode(struct tp *);
     95 int tp_setcalibcoords(struct tp *, struct wsmouse_calibcoords *);
     96 int tp_flush(struct tp *);
     97 int tp_get(struct tp *, int *, int *, int (*)(void *), void *);
     98 int tp_waitup(struct tp *, int, int (*)(void *), void *);
     99 
    100 int fb_dispmode(struct fb *, int);
    101 int fb_init(struct fb *, int);
    102 void fb_getline(struct fb *, int);
    103 void fb_putline(struct fb *, int);
    104 void fb_fetchline(struct fb *, int);
    105 void fb_flush(struct fb *);
    106 void fb_drawline(struct fb *, int, int, int, int, fb_pixel_t);
    107 void fb_drawpixel(struct fb *, int, int, fb_pixel_t);
    108 
    109 #endif /* __TPCTL_TP_H__ */
    110