revise close device function to don't stop effect in other processes
[platform/core/system/haptic-module-tizen.git] / tizen / DEVICE / include / file.h
1 /*
2  * haptic-module-tizen
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18
19 #ifndef __FILE_H__
20 #define __FILE_H__
21
22 #define GCC_PACK        __attribute__((packed))
23
24 /* little-endian form */
25 #define mmioHeaderID(ch0,ch1,ch2,ch3)   \
26         ((unsigned int)(unsigned char)(ch0) | ((unsigned int)(unsigned char)(ch1) << 8) |       \
27         ((unsigned int)(unsigned char)(ch2) << 16) | ((unsigned int)(unsigned char)(ch3) << 24))
28
29 #define HEADER_ID               mmioHeaderID('T','H','F','M')           // 0x4D464854
30 #define FMT_ID                  mmioHeaderID('f','m','t',' ')           // 0x20746D66
31 #define DATA_ID                 mmioHeaderID('d','a','t','a')           // 0x61746164
32
33 typedef unsigned int ID;        /* a four character code */
34
35 typedef struct _FormatChunk {
36         ID chunkID;                                             /* chunk ID */
37         int chunkSize;                                  /* chunk Size */
38         unsigned short wChannels;               /* number of channels (Mono = 1, Stereo = 2, etc.) */
39         unsigned short wBlockAlign;             /* block size of data (wChannels*1byte) */
40         unsigned int dwMagnitude;               /* max magnitude */
41         unsigned int dwDuration;                /* duration */
42 } GCC_PACK FormatChunk;
43
44 typedef struct _DataChunk {
45         ID chunkID;
46         int chunkSize;
47         unsigned char pData[];
48 } GCC_PACK DataChunk;
49
50 typedef struct _HapticFile {
51         ID chunkID;                     /* chunk ID */
52         int chunkSize;          /* chunk Size */
53         FormatChunk fmt;        /* Format chunk */
54         DataChunk data;         /* Data chunk */
55 } GCC_PACK HapticFile;
56
57 typedef struct _HapticElement {
58         int duration;
59         int level;
60 } HapticElement;
61
62 int GetHapticLevelMax(int *max);
63 int SetHapticEnable(int value);
64 int SetHapticLevel(int value);
65 int SetHapticOneshot(int value);
66
67 int InitializeHapticBuffer(unsigned char *vibe_buffer, int max_bufsize);
68 int InsertHapticElement(unsigned char *vibe_buffer, int max_bufsize, HapticElement *element);
69 int GetHapticBufferSize(const unsigned char *vibe_buffer, int *size);
70 int GetHapticBufferDuration(const unsigned char *vibe_buffer, int *duration);
71 int PlayHapticBuffer(const unsigned char *vibe_buffer, int iteration, int level, int *effect_handle);
72 int OpenHapticDevice(void);
73 int CloseHapticDevice(void);
74 int StopHaptic(void);
75
76 #endif // __FIEL_H__