blob: 5b83218e87392c5ac04fc3a29fa8aff4fdbcc606 [file] [log] [blame]
Devin Kimba0e9452012-06-21 14:09:34 -07001/*
Devin Kimc68f4162012-09-18 11:48:20 -07002 * File: tspdrv.h
3 *
4 * Description:
5 * Constants and type definitions for the TouchSense Kernel Module.
6 *
7 * Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved.
8 *
9 * This file contains Original Code and/or Modifications of Original Code
10 * as defined in and that are subject to the GNU Public License v2 -
11 * (the 'License'). You may not use this file except in compliance with the
12 * License. You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact
15 * TouchSenseSales@immersion.com.
16 *
17 * The Original Code and all software distributed under the License are
18 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19 * EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
20 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
21 * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
22 * the License for the specific language governing rights and limitations
23 * under the License.
24 */
Devin Kimba0e9452012-06-21 14:09:34 -070025
26#ifndef _TSPDRV_H
27#define _TSPDRV_H
28
29/* Constants */
30#define MODULE_NAME "tspdrv"
31#define TSPDRV "/dev/"MODULE_NAME
32#define TSPDRV_MAGIC_NUMBER 0x494D4D52
33#define TSPDRV_STOP_KERNEL_TIMER _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 1)
34/*
35** Obsolete IOCTL command
36** #define TSPDRV_IDENTIFY_CALLER _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 2)
37*/
38#define TSPDRV_ENABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3)
39#define TSPDRV_DISABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4)
40#define TSPDRV_GET_NUM_ACTUATORS _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 5)
Devin Kimc68f4162012-09-18 11:48:20 -070041#define VIBE_MAX_DEVICE_NAME_LENGTH 64
Devin Kimba0e9452012-06-21 14:09:34 -070042#define SPI_HEADER_SIZE 3 /* DO NOT CHANGE - SPI buffer header size */
43#define VIBE_OUTPUT_SAMPLE_SIZE 50 /* DO NOT CHANGE - maximum number of samples */
44
45/* Type definitions */
46#ifdef __KERNEL__
47typedef int8_t VibeInt8;
48typedef u_int8_t VibeUInt8;
49typedef int16_t VibeInt16;
50typedef u_int16_t VibeUInt16;
51typedef int32_t VibeInt32;
52typedef u_int32_t VibeUInt32;
53typedef u_int8_t VibeBool;
54typedef VibeInt32 VibeStatus;
55
56typedef struct {
57 VibeUInt8 nActuatorIndex; /* 1st byte is actuator index */
58 VibeUInt8 nBitDepth; /* 2nd byte is bit depth */
59 VibeUInt8 nBufferSize; /* 3rd byte is data size */
60 VibeUInt8 dataBuffer[VIBE_OUTPUT_SAMPLE_SIZE];
61} samples_buffer;
62
63typedef struct {
64 VibeInt8 nIndexPlayingBuffer;
65 VibeUInt8 nIndexOutputValue;
66 samples_buffer actuatorSamples[2]; /* Use 2 buffers to receive samples from user mode */
67} actuator_samples_buffer;
68
69#endif
70
71/* Error and Return value codes */
72#define VIBE_S_SUCCESS 0 /* Success */
73#define VIBE_E_FAIL -4 /* Generic error */
74
75#if defined(VIBE_RECORD) && defined(VIBE_DEBUG)
76void _RecorderInit(void);
77void _RecorderTerminate(void);
78void _RecorderReset(int nActuator);
79void _Record(int actuatorIndex, const char *format,...);
80#endif
81
82/* Kernel Debug Macros */
83#ifdef __KERNEL__
84 #if 1 // def VIBE_DEBUG
85 #define DbgOut(_x_) printk _x_
86 #else /* VIBE_DEBUG */
87 #define DbgOut(_x_)
88 #endif /* VIBE_DEBUG */
89
90 #if defined(VIBE_RECORD) && defined(VIBE_DEBUG)
91 #define DbgRecorderInit(_x_) _RecorderInit _x_
92 #define DbgRecorderTerminate(_x_) _RecorderTerminate _x_
93 #define DbgRecorderReset(_x_) _RecorderReset _x_
94 #define DbgRecord(_x_) _Record _x_
95 #else /* defined(VIBE_RECORD) && defined(VIBE_DEBUG) */
96 #define DbgRecorderInit(_x_)
97 #define DbgRecorderTerminate(_x_)
98 #define DbgRecorderReset(_x_)
99 #define DbgRecord(_x_)
100 #endif /* defined(VIBE_RECORD) && defined(VIBE_DEBUG) */
101#endif /* __KERNEL__ */
102
103#endif /* _TSPDRV_H */