View Single Post
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#24
I have now studied the spi_vibra driver initialization a bit. It seems that the sample upload is done via the following kind of ioctl call.
This bit uploads 612 bytes of sample data to one effect. (Actually I think it is 306 words but that is identical...)
There are 32 effects that need to be uploaded in total.

Code:
int initialize_samples(int fp, int effect)
{
  struct ff_effect new;

  new.type = FF_PERIODIC;
  new.id = -1;
  new.direction = 0;
  new.u.periodic.waveform = FF_CUSTOM;
  new.u.periodic.period = 6;
  new.u.periodic.magnitude = 0;
  new.u.periodic.offset = 0;
  new.u.periodic.phase = 0;
  new.u.periodic.envelope.attack_length = 0;
  new.u.periodic.envelope.attack_level = 0;
  new.u.periodic.envelope.fade_length = 0;
  new.u.periodic.envelope.fade_level = 0;
  new.u.periodic.custom_len = 306;
  new.u.periodic.custom_data = (void *) initstring[effect];

  if(ioctl(fp, EVIOCSFF, &new) < 0) {
    perror("ioctl");
  }

  return ret;
}
The sample bytestring is stored in initstring[][] table in this example.
The full code and bytestrings can be gotten from my svn server, same place as before.

However, even as this ioctl produces exactly same results in the driver as the closed-source initialization, I stll cannot make the device vibrate. There is some element I am missing here in the process.

Actually it just occured to me, how is the initialization done in nitdroid? The vibra device works there. Is the initialization sequence there on an open source component?
 

The Following User Says Thank You to juiceme For This Useful Post: