custom vibrator implementation
This commit is contained in:
parent
d9414ffb28
commit
b63c840b3f
@ -31,7 +31,7 @@
|
||||
|
||||
# for gps
|
||||
/dev/s3c2410_serial1 0660 root system
|
||||
/dev/tspdrv 0660 shell shell
|
||||
/dev/tspdrv 0660 system system
|
||||
|
||||
# for MTP
|
||||
/dev/usb_mtp_gadget 0660 system system
|
||||
|
60
vibrator/tspdrv.c
Normal file
60
vibrator/tspdrv.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2011 CyanogenMod Project
|
||||
* Copyright (C) 2011 Daniel Hillenbrand
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "tspdrv"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "tspdrv.h"
|
||||
|
||||
int sendit(int timeout_ms)
|
||||
{
|
||||
int nwr, ret, fd, tspd, tspret;
|
||||
char value[20];
|
||||
|
||||
tspd = open(TSPDRV_DEVICE, O_RDWR);
|
||||
if(tspd < 0)
|
||||
LOGE("failed on opening /dev/tspdrv");
|
||||
|
||||
/* send tspdrv magic number */
|
||||
tspret = ioctl(tspd, TSPDRV_MAGIC_NUMBER);
|
||||
if(tspret != 0)
|
||||
LOGE("TSPDRV_MAGIC_NUMBER error");
|
||||
|
||||
/* enable tspdrv amp */
|
||||
tspret = ioctl(tspd, TSPDRV_ENABLE_AMP);
|
||||
if(tspret != 0)
|
||||
LOGE("failed on enabling AMP");
|
||||
|
||||
close(tspd);
|
||||
|
||||
fd = open(THE_DEVICE, O_RDWR);
|
||||
if(fd < 0)
|
||||
return errno;
|
||||
|
||||
nwr = sprintf(value, "%d\n", timeout_ms);
|
||||
ret = write(fd, value, nwr);
|
||||
|
||||
close(fd);
|
||||
|
||||
return (ret == nwr) ? 0 : -1;
|
||||
}
|
30
vibrator/tspdrv.h
Normal file
30
vibrator/tspdrv.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2011 CyanogenMod Project
|
||||
* Copyright (C) 2011 Daniel Hillenbrand
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __TSPDRV_H
|
||||
#define __TSPDRV_H __FILE__
|
||||
|
||||
#define THE_DEVICE "/sys/class/timed_output/vibrator/enable"
|
||||
#define TSPDRV_DEVICE "/dev/tspdrv"
|
||||
|
||||
#define TSPDRV_MAGIC_NUMBER 0x494D4D52
|
||||
#define TSPDRV_STOP_KERNEL_TIMER _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 1)
|
||||
#define TSPDRV_ENABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3)
|
||||
#define TSPDRV_DISABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4)
|
||||
#define TSPDRV_GET_NUM_ACTUATORS _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 5)
|
||||
|
||||
#endif /* __TSPDRV_H */
|
Loading…
Reference in New Issue
Block a user