blob: 795d23eb4651dab4b0f06c51378d3ed857ba78d7 [file] [log] [blame]
Vincent Becker022224f2012-08-10 14:40:49 +02001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _HARDWARE_VIBRATOR_H
18#define _HARDWARE_VIBRATOR_H
19
20#include <hardware/hardware.h>
21
22__BEGIN_DECLS
23
24#define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0)
25
26/**
27 * The id of this module
28 */
29#define VIBRATOR_HARDWARE_MODULE_ID "vibrator"
30
31/**
32 * The id of the main vibrator device
33 */
34#define VIBRATOR_DEVICE_ID_MAIN "main_vibrator"
35
36struct vibrator_device;
37typedef struct vibrator_device {
38 struct hw_device_t common;
39
40 /** Turn on vibrator
41 *
42 * What happens when this function is called while the the timeout of a
43 * previous call has not expired is implementation dependent.
44 *
45 * @param timeout_ms number of milliseconds to vibrate
46 *
47 * @return 0 in case of success, negative errno code else
48 */
49 int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms);
50
51 /** Turn off vibrator
52 *
53 * It is not guaranteed that the vibrator will be immediately stopped: the
54 * behaviour is implementation dependent.
55 *
56 * @return 0 in case of success, negative errno code else
57 */
58 int (*vibrator_off)(struct vibrator_device* vibradev);
59} vibrator_device_t;
60
61static inline int vibrator_open(const struct hw_module_t* module, vibrator_device_t** device)
62{
63 return module->methods->open(module, VIBRATOR_DEVICE_ID_MAIN, (struct hw_device_t**)device);
64}
65
66__END_DECLS
67
68#endif // _HARDWARE_VIBRATOR_H