blob: c5bd5b1ec186ec1ca33a84f017ed8f5c0e63f532 [file] [log] [blame]
Devin Kimba0e9452012-06-21 14:09:34 -07001/*
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/* Constants */
33#define MODULE_NAME "tspdrv"
34#define TSPDRV "/dev/"MODULE_NAME
35#define TSPDRV_MAGIC_NUMBER 0x494D4D52
36#define TSPDRV_STOP_KERNEL_TIMER _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 1)
37/*
38** Obsolete IOCTL command
39** #define TSPDRV_IDENTIFY_CALLER _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 2)
40*/
41#define TSPDRV_ENABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3)
42#define TSPDRV_DISABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4)
43#define TSPDRV_GET_NUM_ACTUATORS _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 5)
44#define VIBE_MAX_DEVICE_NAME_LENGTH 64
45#define SPI_HEADER_SIZE 3 /* DO NOT CHANGE - SPI buffer header size */
46#define VIBE_OUTPUT_SAMPLE_SIZE 50 /* DO NOT CHANGE - maximum number of samples */
47
48/* Type definitions */
49#ifdef __KERNEL__
50typedef int8_t VibeInt8;
51typedef u_int8_t VibeUInt8;
52typedef int16_t VibeInt16;
53typedef u_int16_t VibeUInt16;
54typedef int32_t VibeInt32;
55typedef u_int32_t VibeUInt32;
56typedef u_int8_t VibeBool;
57typedef VibeInt32 VibeStatus;
58
59typedef struct {
60 VibeUInt8 nActuatorIndex; /* 1st byte is actuator index */
61 VibeUInt8 nBitDepth; /* 2nd byte is bit depth */
62 VibeUInt8 nBufferSize; /* 3rd byte is data size */
63 VibeUInt8 dataBuffer[VIBE_OUTPUT_SAMPLE_SIZE];
64} samples_buffer;
65
66typedef struct {
67 VibeInt8 nIndexPlayingBuffer;
68 VibeUInt8 nIndexOutputValue;
69 samples_buffer actuatorSamples[2]; /* Use 2 buffers to receive samples from user mode */
70} actuator_samples_buffer;
71
72#endif
73
74/* Error and Return value codes */
75#define VIBE_S_SUCCESS 0 /* Success */
76#define VIBE_E_FAIL -4 /* Generic error */
77
78#if defined(VIBE_RECORD) && defined(VIBE_DEBUG)
79void _RecorderInit(void);
80void _RecorderTerminate(void);
81void _RecorderReset(int nActuator);
82void _Record(int actuatorIndex, const char *format,...);
83#endif
84
85/* Kernel Debug Macros */
86#ifdef __KERNEL__
87 #if 1 // def VIBE_DEBUG
88 #define DbgOut(_x_) printk _x_
89 #else /* VIBE_DEBUG */
90 #define DbgOut(_x_)
91 #endif /* VIBE_DEBUG */
92
93 #if defined(VIBE_RECORD) && defined(VIBE_DEBUG)
94 #define DbgRecorderInit(_x_) _RecorderInit _x_
95 #define DbgRecorderTerminate(_x_) _RecorderTerminate _x_
96 #define DbgRecorderReset(_x_) _RecorderReset _x_
97 #define DbgRecord(_x_) _Record _x_
98 #else /* defined(VIBE_RECORD) && defined(VIBE_DEBUG) */
99 #define DbgRecorderInit(_x_)
100 #define DbgRecorderTerminate(_x_)
101 #define DbgRecorderReset(_x_)
102 #define DbgRecord(_x_)
103 #endif /* defined(VIBE_RECORD) && defined(VIBE_DEBUG) */
104#endif /* __KERNEL__ */
105
106#endif /* _TSPDRV_H */