h3600_ts.h

Go to the documentation of this file.
00001 /*
00002  * File Name: h3600_ts.h
00003  */
00004 
00005 /*
00006  * This file is part of gtktscal.
00007  *
00008  * gtktscal is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * gtktscal is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021  
00022 /*
00023  * Driver for the H3600 Touch Screen and other Atmel controlled devices.
00024  *
00025  * Copyright 2000 Compaq Computer Corporation.
00026  *
00027  * Use consistent with the GNU GPL is permitted,
00028  * provided that this copyright notice is
00029  * preserved in its entirety in all copies and derived works.
00030  *
00031  * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
00032  * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
00033  * FITNESS FOR ANY PARTICULAR PURPOSE.
00034  *
00035  * Author: Charles Flynn.
00036  */
00037 
00038 #ifndef __H3600_TS_H__
00039 #define __H3600_TS_H__
00040 
00041 #include <linux/ioctl.h>
00042 
00043 enum h3600_ts_minor_devices {
00044    TS_MINOR    = 0,
00045    TSRAW_MINOR = 1,
00046    KEY_MINOR   = 2
00047 };
00048 
00049 typedef struct h3600_ts_calibration {
00050         int xscale;
00051         int xtrans;
00052         int yscale;
00053         int ytrans;
00054         int xyswap;
00055 } TS_CAL;
00056 
00057 typedef struct h3600_ts_event {
00058         unsigned short pressure;
00059         unsigned short x;
00060         unsigned short y;
00061         unsigned short pad;
00062 } TS_EVENT;
00063 
00064 /* Deprecated - do not use */
00065 typedef struct h3600_ts_return {
00066         unsigned short pressure;
00067         unsigned short x;
00068         unsigned short y;
00069         unsigned short pad;
00070 } TS_RET;
00071 
00072 enum power_button_mode {
00073    PBM_SUSPEND           = 0,
00074    PBM_GENERATE_KEYPRESS = 1
00075 };
00076 
00077 
00078 /* ++++++++++++++ +++++++++++++++++++++++++++++++++++++ */
00079 
00080 typedef struct therm_dev {
00081    short data;
00082 } THERM_DEV;
00083 
00084 #define H3600_BATT_CHEM_ALKALINE        0x01
00085 #define H3600_BATT_CHEM_NICD            0x02
00086 #define H3600_BATT_CHEM_NIMH            0x03
00087 #define H3600_BATT_CHEM_LION            0x04
00088 #define H3600_BATT_CHEM_LIPOLY          0x05
00089 #define H3600_BATT_CHEM_NOT_INSTALLED   0x06
00090 #define H3600_BATT_CHEM_UNKNOWN         0xff
00091 
00092 /* These should match the apm_bios.h definitions */
00093 #define H3600_AC_STATUS_AC_OFFLINE  0x00
00094 #define H3600_AC_STATUS_AC_ONLINE   0x01
00095 #define H3600_AC_STATUS_AC_BACKUP   0x02   /* What does this mean? */
00096 #define H3600_AC_STATUS_AC_UNKNOWN  0xff
00097 
00098 /* These bitfields are rarely "or'd" together */
00099 #define H3600_BATT_STATUS_HIGH      0x01
00100 #define H3600_BATT_STATUS_LOW    0x02
00101 #define H3600_BATT_STATUS_CRITICAL  0x04
00102 #define H3600_BATT_STATUS_CHARGING  0x08
00103 #define H3600_BATT_STATUS_CHARGE_MAIN   0x10
00104 #define H3600_BATT_STATUS_DEAD          0x20   /* Battery will not charge */
00105 #define H3600_BATT_NOT_INSTALLED        0x20   /* For expansion pack batteries */
00106 #define H3600_BATT_STATUS_FULL          0x40   /* Battery fully charged (and connected to AC) */
00107 #define H3600_BATT_STATUS_NOBATT 0x80
00108 #define H3600_BATT_STATUS_UNKNOWN   0xff
00109 
00110 struct battery_data {
00111    unsigned char  chemistry;
00112    unsigned char  status;
00113    unsigned short voltage;    /* Voltage for battery #0; unknown for battery #1 */
00114    unsigned short percentage; /* Percentage of full charge */
00115    unsigned short life;       /* Life remaining in minutes */
00116 };
00117 
00118 struct h3600_battery {
00119         unsigned char       ac_status;
00120    unsigned char       battery_count;  /* How many batteries we have */
00121    struct battery_data battery[2];
00122 };
00123 
00124 /* -------- EEPROM and SPI Interfaces ---------------*/
00125 
00126 #define EEPROM_RD_BUFSIZ 6 /* EEPROM reads are 16 bits */
00127 #define EEPROM_WR_BUFSIZ 5 /* Allow room for 8bit 'addr' field in buffer*/ 
00128 #define SPI_RD_BUFSIZ    16   /* SPI reads are 8 bits */
00129 #define SPI_WR_BUFSIZ    7
00130 
00131 /* The EEPROM is where internal programs are stored on the Amtel.
00132    You probably don't want to read or write these values */
00133 
00134 typedef struct h3600_eeprom_read_request {
00135    unsigned char addr;    /* 8bit Address Offset 0-255 */
00136    unsigned char len;     /* Number of 16bit words to read 0-128  */
00137    unsigned short buff[EEPROM_RD_BUFSIZ];
00138 } EEPROM_READ;
00139 
00140 typedef struct h3600_eeprom_write_request {
00141    unsigned char len;   /* used only to compute the number of bytes to send */
00142    unsigned char addr;    /* 0-128  */
00143    unsigned short buff[EEPROM_WR_BUFSIZ];
00144 } EEPROM_WRITE;
00145 
00146 /* The SPI bus connects to EEPROMs located on sleeves plugged into
00147    the iPAQ.  You may want to read these values  */
00148 
00149 typedef struct h3600_spi_read_request {
00150    unsigned short addr;    /* 16bit Address Offset 0-128 */
00151    unsigned char len;      /* Number of bytes to read */
00152    unsigned char buff[SPI_RD_BUFSIZ];
00153 } SPI_READ;
00154 
00155 #define SPI_READ_STATUS_BYTE  0xffff   /* Use this address to read the status byte */
00156 
00157 typedef struct h3600_spi_write_request {
00158    unsigned short len;  /* used only to compute the number of bytes to send */
00159    unsigned short addr; /* this 16bit address accesses a single byte */
00160    unsigned char  buff[SPI_WR_BUFSIZ];
00161 } SPI_WRITE;
00162 
00163 
00164 /* -------- end of EEPROM and SPI Interfaces ---------------*/
00165 
00166 /* User space structures for IOCTL calls */
00167 
00168 typedef struct h3600_ts_version {
00169    unsigned char host_version[8];   /* ascii "x.yy" */
00170    unsigned char pack_version[8];   /* ascii "x.yy" */
00171    unsigned char boot_type;      /* TODO ?? */
00172 } VER_RET;
00173 
00174 typedef struct h3600_ts_led {
00175         unsigned char OffOnBlink;       /* 0=off 1=on 2=Blink */
00176         unsigned char TotalTime;        /* Units of 5 seconds */
00177         unsigned char OnTime;           /* units of 100m/s */
00178         unsigned char OffTime;          /* units of 100m/s */
00179 } LED_IN;
00180 
00181 enum flite_mode {
00182         FLITE_MODE1 = 1,
00183    FLITE_AUTO_MODE   = 1,     /* for reference only */
00184    FLITE_MANUAL_MODE = 2,     /* Use this normally? */
00185    FLITE_GET_LIGHT_SENSOR = 3 /* Returns light reading in "brightness" field */
00186 };
00187 enum flite_pwr {
00188         FLITE_PWR_OFF = 0,
00189         FLITE_PWR_ON  = 1
00190 };
00191 
00192 typedef struct h3600_ts_flite {
00193         unsigned char mode;
00194         unsigned char pwr;
00195         unsigned char brightness;
00196 } FLITE_IN;
00197 
00198 /*************************** Updated "universal" structures *******************/
00199 
00200 /* Sets backlight for both H3100 and H3600 models - technically "frontlight" for H3600 */
00201 struct h3600_ts_backlight {
00202    enum flite_pwr power;          /* 0 = off, 1 = on */
00203    unsigned char  brightness;     /* 0 - 255         */
00204 };
00205 
00206 struct h3600_ts_contrast {            /* Only useful on H3100 model */
00207    unsigned char contrast;       /* 0 - 255 */
00208 };
00209 
00210 /* IOCTL cmds  user or kernel space */
00211 
00212 /* Use 'f' as magic number */
00213 #define IOC_H3600_TS_MAGIC  'f'
00214 
00215 /* TODO: Some of these IOWR values are just plain wrong */
00216 #define GET_VERSION     _IOR(IOC_H3600_TS_MAGIC,  1, struct h3600_ts_version )
00217 #define READ_EEPROM     _IOWR(IOC_H3600_TS_MAGIC, 2, struct h3600_eeprom_read_request)
00218 #define WRITE_EEPROM    _IOWR(IOC_H3600_TS_MAGIC, 3, struct h3600_eeprom_write_request)
00219 #define GET_THERMAL     _IOR(IOC_H3600_TS_MAGIC,  4, struct therm_dev)
00220 #define LED_ON       _IOW(IOC_H3600_TS_MAGIC,  5, struct h3600_ts_led)
00221 #define GET_BATTERY_STATUS _IOR(IOC_H3600_TS_MAGIC,  6, struct h3600_battery)
00222 #define FLITE_ON     _IOW(IOC_H3600_TS_MAGIC,  7, struct h3600_ts_flite)
00223 #define READ_SPI     _IOWR(IOC_H3600_TS_MAGIC, 8, struct h3600_spi_read_request)
00224 #define WRITE_SPI    _IOWR(IOC_H3600_TS_MAGIC, 9, struct h3600_spi_write_request)
00225 #define TS_GET_CAL      _IOR(IOC_H3600_TS_MAGIC, 10, struct h3600_ts_calibration)
00226 #define TS_SET_CAL      _IOW(IOC_H3600_TS_MAGIC, 11, struct h3600_ts_calibration)
00227 
00228 /* New IOCTL interfaces - defined to be more user friendly */
00229 #define TS_GET_BACKLIGHT        _IOR(IOC_H3600_TS_MAGIC, 20, struct h3600_ts_backlight)
00230 #define TS_SET_BACKLIGHT        _IOW(IOC_H3600_TS_MAGIC, 20, struct h3600_ts_backlight)
00231 #define TS_GET_CONTRAST         _IOR(IOC_H3600_TS_MAGIC, 21, struct h3600_ts_contrast)
00232 #define TS_SET_CONTRAST         _IOW(IOC_H3600_TS_MAGIC, 21, struct h3600_ts_contrast)
00233 
00234 #endif
Generated by  doxygen 1.6.2-20100208