2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <cutils/log.h>
24 #include <hardware/hardware.h>
25 #include <hardware/vibrator.h>
27 static int sendit(unsigned int timeout_ms)
30 if (qemu_control_command("vibrator:%u", timeout_ms) < 0) {
39 static int qemu_vibra_on(vibrator_device_t* vibradev __unused, unsigned int timeout_ms)
41 return sendit(timeout_ms);
44 static int qemu_vibra_off(vibrator_device_t* vibradev __unused)
49 static int qemu_vibra_close(hw_device_t *device)
55 static int qemu_vibra_open(const hw_module_t* module, const char* id __unused,
56 hw_device_t** device) {
57 vibrator_device_t *vibradev = calloc(1, sizeof(vibrator_device_t));
60 ALOGE("No memory available to create Goldfish vibrator device!");
64 vibradev->common.tag = HARDWARE_DEVICE_TAG;
65 vibradev->common.module = (hw_module_t *) module;
66 vibradev->common.version = HARDWARE_DEVICE_API_VERSION(1,0);
67 vibradev->common.close = qemu_vibra_close;
69 vibradev->vibrator_on = qemu_vibra_on;
70 vibradev->vibrator_off = qemu_vibra_off;
72 *device = (hw_device_t *) vibradev;
77 /*===========================*/
78 /* Emulator vibrator module */
79 /*===========================*/
81 static struct hw_module_methods_t qemu_vibrator_module_methods = {
82 .open = qemu_vibra_open,
85 struct hw_module_t HAL_MODULE_INFO_SYM = {
86 .tag = HARDWARE_MODULE_TAG,
87 .module_api_version = VIBRATOR_API_VERSION,
88 .hal_api_version = HARDWARE_HAL_API_VERSION,
89 .id = VIBRATOR_HARDWARE_MODULE_ID,
90 .name = "Goldfish vibrator module",
91 .author = "The Android Open Source Project",
92 .methods = &qemu_vibrator_module_methods,