View Single Post
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#21
OK, I have bee struggling with the vibration device for some time, as it was extremely annoying why I could not make it work.

I did quite a lot of searching, before it hit home that the device actually needs to be initialized with a set of waveform samples before it is usable. I kind of thought it is enough to write a set of input_event structures to it to make it work, but turns out those events only trigger the internal works to play out a pre-loaded sample on the vibrator device.

There is some user-space utility that initializes the vifrator device with the waveform samples in init phase, and that was the reason I could not tickle it in pre-init phase.

So, I added some debug code to vibra_spi.c, recompiled the module and was actually able to capture the data needed to initialize it. It turns out there are 36 different sample sequences, each 612 bytes long, that need to be fed to the device.

Here is one sample aas seen on kernel log:

Code:
Sep 13 09:27:31 (2012) kernel: [   34.296295] Entered vibra_spi_upload()
Sep 13 09:27:31 (2012) kernel: [   34.296295] einfo->buflen       = 612
Sep 13 09:27:31 (2012) kernel: [   34.296295] einfo->flags        = 8
Sep 13 09:27:31 (2012) kernel: [   34.296295] einfo->remaining_ms = 0
Sep 13 09:27:31 (2012) kernel: [   34.296325] einfo->len_ms       = 6
Sep 13 09:27:31 (2012) kernel: [   34.296325] einfo->buf: 00000000: aa aa aa aa ab aa aa aa 6a 55 55 55 56 55 ad aa
Sep 13 09:27:31 (2012) kernel: [   34.296325] 00000010: 6a 55 ad aa ad 6a 55 ab 5a d5 aa 55 56 ad 5a ad
Sep 13 09:27:31 (2012) kernel: [   34.296356] 00000020: 5a ad 5a ad ad d6 6a b5 5a ab d5 5a d6 6a ad d5
Sep 13 09:27:31 (2012) kernel: [   34.296356] 00000030: 56 6b ad b5 6b ad b5 b6 b6 d6 da 5a ad ad b5 b5
Sep 13 09:27:31 (2012) kernel: [   34.296356] 00000040: 6d 6d 6d 6d ad ad 6d 6d b6 b6 b5 ad 6d 5b db d6
Sep 13 09:27:31 (2012) kernel: [   34.296356] 00000050: db b6 b6 6d b6 b5 6d 5b b6 b5 6d db db b6 6d db
Sep 13 09:27:31 (2012) kernel: [   34.296386] 00000060: 6d db b6 6d b6 6d db b6 6d b7 6d db db 6e db b6
Sep 13 09:27:31 (2012) kernel: [   34.296386] 00000070: b6 6d b7 6d b6 db b6 dd 76 db 76 db b6 db 76 db
Sep 13 09:27:31 (2012) kernel: [   34.296386] 00000080: b6 dd b6 db bb 6d b7 ed db 76 db 6e 6d b7 ed b6
Sep 13 09:27:31 (2012) kernel: [   34.296417] 00000090: b6 db 6e db db 6d b7 ed ed b6 db 76 76 db 6d b7
Sep 13 09:27:31 (2012) kernel: [   34.296417] 000000a0: b7 ed b6 db db 6e db 6d ed b6 dd b6 6d bb 6d b7
Sep 13 09:27:31 (2012) kernel: [   34.296417] 000000b0: 76 db 6e db 76 db 76 db 6e db 76 db 6d db 6d db
Sep 13 09:27:31 (2012) kernel: [   34.296447] 000000c0: db b6 6d b7 b6 6d db b6 6d db b6 ed b6 6d db b6
Sep 13 09:27:31 (2012) kernel: [   34.296447] 000000d0: db b6 6d db db da b6 6d db da b6 6d da b6 b5 6d
Sep 13 09:27:31 (2012) kernel: [   34.296447] 000000e0: b5 6d 6d db db da d6 b6 6d 6b 6b 5b 6d 6d 6d 6d
Sep 13 09:27:31 (2012) kernel: [   34.296447] 000000f0: 6b 6d 6d 6d d6 5a 5b 6b ad ad b5 d6 b5 d6 5a 6b
Sep 13 09:27:31 (2012) kernel: [   34.296478] 00000100: b5 d6 6a ad ad d5 5a ab 56 ab d5 5a aa d5 6a b5
Sep 13 09:27:31 (2012) kernel: [   34.296478] 00000110: ab 55 ab d5 6a d5 aa 55 55 ab 56 b5 5a 55 ab 5a
Sep 13 09:27:31 (2012) kernel: [   34.296478] 00000120: 6a 55 d5 aa 55 55 b5 aa aa aa aa 6a 55 55 55 d5
Sep 13 09:27:31 (2012) kernel: [   34.296508] 00000130: 55 55 55 55 54 55 55 55 aa aa aa aa aa 52 55 55
Sep 13 09:27:31 (2012) kernel: [   34.296508] 00000140: aa 54 55 aa a9 2a 55 a9 52 a5 2a 55 95 2a 55 aa
Sep 13 09:27:31 (2012) kernel: [   34.296508] 00000150: 95 2a 95 2a 52 a9 54 2a a9 54 4a a5 4a a9 94 4a
Sep 13 09:27:31 (2012) kernel: [   34.296539] 00000160: 4a 29 a5 52 29 a5 94 52 94 94 52 4a 29 29 25 a5
Sep 13 09:27:31 (2012) kernel: [   34.296539] 00000170: 4a 4a 4a 49 4a 4a 4a 4a 29 49 49 49 94 a4 24 25
Sep 13 09:27:31 (2012) kernel: [   34.296539] 00000180: 49 49 52 92 4a 92 a4 24 92 92 24 49 49 92 24 49
Sep 13 09:27:31 (2012) kernel: [   34.296539] 00000190: 49 92 24 25 24 49 92 24 49 92 24 89 92 24 92 24
Sep 13 09:27:31 (2012) kernel: [   34.296569] 000001a0: 24 49 24 49 44 92 24 91 48 92 48 92 48 92 48 92
Sep 13 09:27:31 (2012) kernel: [   34.296569] 000001b0: 44 92 44 92 24 91 24 92 12 49 24 89 91 44 92 48
Sep 13 09:27:31 (2012) kernel: [   34.296569] 000001c0: 49 22 89 24 24 91 44 12 92 48 22 89 49 24 91 44
Sep 13 09:27:31 (2012) kernel: [   34.296600] 000001d0: 44 92 48 22 22 89 24 91 92 44 12 49 89 24 91 24
Sep 13 09:27:31 (2012) kernel: [   34.296600] 000001e0: 49 22 49 24 48 12 49 12 49 92 48 92 49 12 49 12
Sep 13 09:27:31 (2012) kernel: [   34.296600] 000001f0: 91 24 49 24 12 49 92 24 49 92 24 49 92 24 49 22
Sep 13 09:27:31 (2012) kernel: [   34.296630] 00000200: 49 92 24 49 49 4a 92 24 29 49 92 24 49 4a 92 24
Sep 13 09:27:31 (2012) kernel: [   34.296630] 00000210: 52 92 a4 24 24 25 49 49 92 92 94 a4 4a 4a 52 52
Sep 13 09:27:31 (2012) kernel: [   34.296630] 00000220: 4a 4a 4a 4a 92 52 52 52 29 a5 a4 94 94 52 4a 49
Sep 13 09:27:31 (2012) kernel: [   34.296661] 00000230: 52 4a 29 a5 94 4a 29 a5 a9 54 4a a9 54 2a 95 4a
Sep 13 09:27:31 (2012) kernel: [   34.296661] 00000240: 4a a5 52 a9 52 a5 4a a5 55 aa 54 a9 2a 55 a9 4a
Sep 13 09:27:31 (2012) kernel: [   34.296661] 00000250: aa 4a 55 a9 aa 4a 55 95 55 55 55 aa aa aa aa 2a
Sep 13 09:27:31 (2012) kernel: [   34.296661] 00000260: aa aa aa aa
A bit of digging produced the culprit; there is something called "meegofeedbackd" that is loading and initializing the sample maps to the vibra_spi driver:

Code:
Sep 13 09:27:31 (2012) meegofeedbackd: Loaded backend plugin "/usr/lib/meegofeedbackd/non-threaded-backends/00-libmeegofeedback-pulseaudio.so"
Sep 13 09:27:31 (2012) meegofeedbackd: Loaded backend plugin "/usr/lib/meegofeedbackd/non-threaded-backends/01-libmeegofeedback-vibra.so"
Sep 13 09:27:31 (2012) meegofeedbackd: MfManager: Lib directory "/usr/lib/meegofeedbackd/threaded-backends" doesn't exist.
Sep 13 09:27:31 (2012) meegofeedbackd: Loaded source plugin "/usr/lib/meegofeedbackd/sources/libmeegofeedback-reactionmap.so"
Sep 13 09:27:31 (2012) meegofeedbackd: Loaded source plugin "/usr/lib/meegofeedbackd/sources/libmeegofeedback-wakeup.so"
There seems to be sources available for the following packages, so I need to dig into the sources to see how the initialization is done. Propably it is via ioctl() to /dev/input/vibra or something like that:
meegofeedbackd_0.10.7-5+0m6.tar
meegofeedback-reactionmaps_0.15.1-3+0m8.tar
 

The Following 3 Users Say Thank You to juiceme For This Useful Post: