OMAP4 Audio Vibra

From OMAPpedia

Jump to: navigation, search


[edit] Audio Vibra Driver

Phoenix (TWL6040) supports the integration of two vibra transducers usually placed at 90 degree angles from each other.

OMAP4 audio vibra.jpg

Vibra duty cycle is controlled through internal PWM generator. PWM can be driven through PDM or PCM data:

[edit] Assumptions

[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");
	/* define the new event type */ 
	effects.type = FF_RUMBLE; = -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 =;
	play.value = 1;

	if (write(fd, (const void*) &play, sizeof(play)) == -1) {
		perror("Play error");

	/* Stop the effects */
	stop.type = EV_FF;
	stop.code =;
	stop.value = 0;

	if (write(fd, (const void*) &stop, sizeof(stop)) == -1) {
		perror("Stop effect");

Personal tools