2 ** =========================================================================
7 ** Constants and type definitions for the TouchSense Kernel Module.
9 ** Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved.
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.
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
26 ** =========================================================================
32 #include "ImmVibeOS.h"
33 #include "ImmVibeCore.h"
34 #include "ImmVibeSPI.h"
36 #include <linux/i2c.h>
37 #include <asm/mach-types.h>
39 #include <linux/workqueue.h>
40 #include <linux/version.h>
42 #include <linux/ioctl.h>
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)
50 ** Obsolete IOCTL command
51 ** #define TSPDRV_IDENTIFY_CALLER _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 2)
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 */
60 #define MAX_ACTUATORS 2
62 #define ISA1200_I2C_ADDRESS_L (0x90 >> 1)
63 #define ISA1200_I2C_ADDRESS_H (0x92 >> 1)
65 extern unsigned int system_rev;
67 extern int NUM_ACTUATORS;
68 extern int NUM_CONTROLLERS;
70 /* Type definitions */
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];
81 VibeInt8 nIndexPlayingBuffer;
82 VibeUInt8 nIndexOutputValue;
83 samples_buffer actuatorSamples[2]; /* Use 2 buffers to receive samples from user mode */
84 } actuator_samples_buffer;
86 extern char g_bIsPlaying;
87 extern int g_bStopRequested;
88 extern actuator_samples_buffer g_SamplesBuffer[MAX_ACTUATORS];
91 struct vibtone_platform_data {
97 struct i2c_board_info const *i2c_info;
100 struct controller_chip {
101 struct i2c_client *client;
104 enum chip_type c_type;
108 void (*control_power)(struct device *, int);
111 /* Error and Return value codes */
112 #define VIBE_S_SUCCESS 0 /* Success */
113 #define VIBE_E_FAIL -4 /* Generic error */
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,...);
122 /* Kernel Debug Macros */
125 #define DbgOut(_x_) printk _x_
126 #else /* VIBE_DEBUG */
127 #define DbgOut(_x_) do { } while (0)
128 #endif /* VIBE_DEBUG */
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__ */
143 #endif /* _TSPDRV_H */