Home | History | Annotate | Line # | Download | only in ic
lcdkp_subr.h revision 1.1
      1  1.1  soren /* $NetBSD: lcdkp_subr.h,v 1.1 2003/01/20 01:26:12 soren Exp $ */
      2  1.1  soren 
      3  1.1  soren /*
      4  1.1  soren  * Copyright (c) 2002 Dennis I. Chernoivanov
      5  1.1  soren  * All rights reserved.
      6  1.1  soren  *
      7  1.1  soren  * Redistribution and use in source and binary forms, with or without
      8  1.1  soren  * modification, are permitted provided that the following conditions
      9  1.1  soren  * are met:
     10  1.1  soren  * 1. Redistributions of source code must retain the above copyright
     11  1.1  soren  *    notice, this list of conditions and the following disclaimer.
     12  1.1  soren  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  soren  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  soren  *    documentation and/or other materials provided with the distribution.
     15  1.1  soren  * 3. The name of the author may not be used to endorse or promote products
     16  1.1  soren  *    derived from this software without specific prior written permission
     17  1.1  soren  *
     18  1.1  soren  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  1.1  soren  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  1.1  soren  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  1.1  soren  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  1.1  soren  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23  1.1  soren  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24  1.1  soren  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25  1.1  soren  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  1.1  soren  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  1.1  soren  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.1  soren  */
     29  1.1  soren 
     30  1.1  soren #ifndef _DEV_IC_LCDKP_SUBR_H_
     31  1.1  soren #define _DEV_IC_LCDKP_SUBR_H_
     32  1.1  soren 
     33  1.1  soren #ifdef _KERNEL
     34  1.1  soren #include <sys/lock.h>
     35  1.1  soren 
     36  1.1  soren /* Key code translation */
     37  1.1  soren struct lcdkp_xlate {
     38  1.1  soren 	u_int8_t x_keycode;
     39  1.1  soren 	u_int8_t x_outcode;
     40  1.1  soren };
     41  1.1  soren 
     42  1.1  soren /* Keypad control structure */
     43  1.1  soren struct lcdkp_chip {
     44  1.1  soren 	bus_space_tag_t sc_iot;
     45  1.1  soren 	bus_space_handle_t sc_ioh;	/* keypad i/o register */
     46  1.1  soren 
     47  1.1  soren #define LCDKP_HAS_BUF	0x1
     48  1.1  soren 	u_char sc_flags;
     49  1.1  soren 	u_int8_t sc_buf;		/* pending character */
     50  1.1  soren 
     51  1.1  soren 	u_int8_t sc_knum;		/* number of buttons */
     52  1.1  soren 	struct lcdkp_xlate *sc_kpad;	/* recognized keycodes */
     53  1.1  soren 
     54  1.1  soren 	u_int8_t (* sc_rread)(bus_space_tag_t, bus_space_handle_t);
     55  1.1  soren 
     56  1.1  soren #if defined(MULTIPROCESSOR)
     57  1.1  soren 	struct simplelock sc_lock;
     58  1.1  soren #endif
     59  1.1  soren };
     60  1.1  soren 
     61  1.1  soren #define lcdkp_dr_read(sc) \
     62  1.1  soren 	(sc)->sc_rread((sc)->sc_iot, (sc)->sc_ioh);
     63  1.1  soren 
     64  1.1  soren #if defined(MULTIPROCESSOR)
     65  1.1  soren #define lcdkp_lock(sc)		simple_lock(&(sc)->sc_lock)
     66  1.1  soren #define lcdkp_unlock(sc)	simple_unlock(&(sc)->sc_lock)
     67  1.1  soren #define lcdkp_lockaddr(sc)	(&(sc)->sc_lock)
     68  1.1  soren #define lcdkp_lock_init(sc)	simple_lock_init(&(sc)->sc_lock)
     69  1.1  soren #else
     70  1.1  soren #define lcdkp_lock(sc)		((void)0)
     71  1.1  soren #define lcdkp_unlock(sc)	((void)0)
     72  1.1  soren #define lcdkp_lockaddr(sc)	(NULL)
     73  1.1  soren #define lcdkp_lock_init(sc)	((void)0)
     74  1.1  soren #endif
     75  1.1  soren 
     76  1.1  soren void lcdkp_attach_subr(struct lcdkp_chip *);
     77  1.1  soren int  lcdkp_scankey(struct lcdkp_chip *);
     78  1.1  soren int  lcdkp_readkey(struct lcdkp_chip *, u_int8_t *);
     79  1.1  soren 
     80  1.1  soren #endif /* _KERNEL */
     81  1.1  soren 
     82  1.1  soren #endif /* _DEV_IC_LCDKP_SUBR_H_ */
     83