upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / haptic / tspdrv / tspdrv.h
1 /*
2 ** =========================================================================
3 ** File:
4 **     tspdrv.h
5 **
6 ** Description: 
7 **     Constants and type definitions for the TouchSense Kernel Module.
8 **
9 ** Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved. 
10 **
11 ** This file contains Original Code and/or Modifications of Original Code 
12 ** as defined in and that are subject to the GNU Public License v2 - 
13 ** (the 'License'). You may not use this file except in compliance with the 
14 ** License. You should have received a copy of the GNU General Public License 
15 ** along with this program; if not, write to the Free Software Foundation, Inc.,
16 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact 
17 ** TouchSenseSales@immersion.com.
18 **
19 ** The Original Code and all software distributed under the License are 
20 ** distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
21 ** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
22 ** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
23 ** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see 
24 ** the License for the specific language governing rights and limitations 
25 ** under the License.
26 ** =========================================================================
27 */
28
29 #ifndef _TSPDRV_H
30 #define _TSPDRV_H
31
32 #include "ImmVibeOS.h"
33 #include "ImmVibeCore.h"
34 #include "ImmVibeSPI.h"
35
36 #include <linux/i2c.h>
37 #include <asm/mach-types.h>
38
39 #include <linux/workqueue.h>
40 #include <linux/version.h>
41
42 #include <linux/ioctl.h>
43
44 /* Constants */
45 #define MODULE_NAME                         "tspdrv"
46 #define TSPDRV                              "/dev/"MODULE_NAME
47 #define TSPDRV_MAGIC_NUMBER                 0x494D4D52
48 #define TSPDRV_STOP_KERNEL_TIMER            _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 1)
49 /* 
50 ** Obsolete IOCTL command 
51 ** #define TSPDRV_IDENTIFY_CALLER           _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 2)
52 */
53 #define TSPDRV_ENABLE_AMP                   _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3)
54 #define TSPDRV_DISABLE_AMP                  _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4)
55 #define TSPDRV_GET_NUM_ACTUATORS            _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 5)
56 #define VIBE_MAX_DEVICE_NAME_LENGTH                     64
57 #define SPI_HEADER_SIZE                     3   /* DO NOT CHANGE - SPI buffer header size */
58 #define VIBE_OUTPUT_SAMPLE_SIZE             50  /* DO NOT CHANGE - maximum number of samples */
59
60 #define MAX_ACTUATORS   2
61
62 #define ISA1200_I2C_ADDRESS_L   (0x90 >> 1)
63 #define ISA1200_I2C_ADDRESS_H   (0x92 >> 1)
64
65 extern unsigned int system_rev;
66
67 extern int NUM_ACTUATORS;
68 extern int NUM_CONTROLLERS;
69
70 /* Type definitions */
71 #ifdef __KERNEL__
72
73 typedef struct {
74         VibeUInt8 nActuatorIndex;       /* 1st byte is actuator index */
75         VibeUInt8 nBitDepth;    /* 2nd byte is bit depth */
76         VibeUInt8 nBufferSize;  /* 3rd byte is data size */
77         VibeUInt8 dataBuffer[VIBE_OUTPUT_SAMPLE_SIZE];
78 } samples_buffer;
79
80 typedef struct {
81         VibeInt8 nIndexPlayingBuffer;
82         VibeUInt8 nIndexOutputValue;
83         samples_buffer actuatorSamples[2];      /* Use 2 buffers to receive samples from user mode */
84 } actuator_samples_buffer;
85
86 extern char g_bIsPlaying;
87 extern int g_bStopRequested;
88 extern actuator_samples_buffer g_SamplesBuffer[MAX_ACTUATORS];
89 #endif
90
91 struct vibtone_platform_data {
92         int gpio_len;
93         int gpio_hen;
94         int ldo_level;
95         int i2c_adapter_num;
96         int pwm_timer;
97         struct i2c_board_info const *i2c_info;
98 };
99
100 struct controller_chip {
101         struct i2c_client *client;
102         struct device *dev;
103         int pwm_timer;
104         enum chip_type c_type;
105         unsigned int len;
106         unsigned int hen;
107         int powered;
108         void (*control_power)(struct device *, int);
109 };
110
111 /* Error and Return value codes */
112 #define VIBE_S_SUCCESS  0       /* Success */
113 #define VIBE_E_FAIL     -4      /* Generic error */
114
115 #if defined(VIBE_RECORD) && defined(VIBE_DEBUG)
116     void _RecorderInit(void);
117     void _RecorderTerminate(void);
118     void _RecorderReset(int nActuator);
119     void _Record(int actuatorIndex, const char *format,...);
120 #endif
121
122 /* Kernel Debug Macros */
123 #ifdef __KERNEL__
124         #ifdef VIBE_DEBUG
125                 #define DbgOut(_x_) printk _x_
126         #else   /* VIBE_DEBUG */
127                 #define DbgOut(_x_) do { } while (0)
128         #endif  /* VIBE_DEBUG */
129
130         #if defined(VIBE_RECORD) && defined(VIBE_DEBUG)
131                 #define DbgRecorderInit(_x_) _RecorderInit _x_
132                 #define DbgRecorderTerminate(_x_) _RecorderTerminate _x_
133                 #define DbgRecorderReset(_x_) _RecorderReset _x_
134                 #define DbgRecord(_x_) _Record _x_
135         #else /* defined(VIBE_RECORD) && defined(VIBE_DEBUG) */
136                 #define DbgRecorderInit(_x_)  do { } while (0)
137                 #define DbgRecorderTerminate(_x_)  do { } while (0)
138                 #define DbgRecorderReset(_x_)  do { } while (0)
139                 #define DbgRecord(_x_)  do { } while (0)
140         #endif /* defined(VIBE_RECORD) && defined(VIBE_DEBUG) */
141 #endif  /* __KERNEL__ */
142
143 #endif  /* _TSPDRV_H */