OMAP4 Audio Vibra
From OMAPpedia
Contents |
[edit] Audio Vibra Driver
Phoenix (TWL6040) supports the integration of two vibra transducers usually placed at 90 degree angles from each other.
Vibra duty cycle is controlled through internal PWM generator. PWM can be driven through PDM or PCM data:
- PDM : PDM DL 5th channel
- PCM : PDM Ctrl channel or I2C
[edit] Assumptions
- For INC1 work, only supporting I2C path
- Based on TWL6040 MFD (resource requirement)/TWL core / I2C driver
- Fixed Duty cycle
- Supported effects:
- Sine Vibration
- Constant Force
- Spring Condition
- Damping Condition
- Strong Rumble
- Weak Rumble
[edit] Configuration
Configuration of the vibra effect is accomplished using the ff_effect structure from input.h
struct ff_effect {
__u16 type;
__s16 id;
__u16 direction;
struct ff_trigger trigger;
struct ff_replay replay;
union {
struct ff_constant_effect constant;
struct ff_ramp_effect ramp;
struct ff_periodic_effect periodic;
struct ff_condition_effect condition[2]; /* One for each axis */
struct ff_rumble_effect rumble;
} u;
};
When defining an effect, the id should be set to -1. the kernel will reset the id to be a unique identifier that can later be used to update or delete the effect.
[edit] Example Code
struct ff_effect effects;
struct input_event play, stop;
int fd;
char device_file_name[64];
strncpy(device_file_name, "/dev/input/event0", 64);
/* Open device */
fd = open(device_file_name, O_RDWR);
if (fd == -1) {
perror("Open device file");
exit(1);
}
/* define the new event type */
effects.type = FF_RUMBLE;
effects.id = -1;
effects.u.rumble.strong_magnitude = 0x8000;
effects.u.rumble.weak_magnitude = 0;
effects.replay.length = 5000;
effects.replay.delay = 1000;
/* Write the new event */
if (ioctl(fd, EVIOCSFF, &effects) == -1) {
perror("Upload effects[4]");
}
/* play effect */
play.type = EV_FF;
play.code = effects.id;
play.value = 1;
if (write(fd, (const void*) &play, sizeof(play)) == -1) {
perror("Play error");
exit(1);
}
/* Stop the effects */
stop.type = EV_FF;
stop.code = effects.id;
stop.value = 0;
if (write(fd, (const void*) &stop, sizeof(stop)) == -1) {
perror("Stop effect");
exit(1);
}
