QPNP (Qualcomm Plug Plug N Play) vibrator is a peripheral on Qualcomm PMICs. The PMIC is connected to MSM8909 via SPMI bus. Its driver uses the timed-output framework to interface with the userspace.
1. MSM8909 Vibrator driver implementation and DTS file
The vibrator is connected on the VIB_DRV_N line of the QPNP PMIC, and the PMIC vibrator driver can be used to program the voltage from 1.2 V to 3.1 V in 100 mV step through VIB_DRV_N pin.
DTSI documentation
1 2 3 4 5 6 |
|
Documentation/devicetree/bindings/platform/msm/qpnp-vibrator.txt
Required Properties:
- status: default status is set to "disabled. Must be "okay"
- compatible: must be "qcom,qpnp-vibrator"
- label: name which describes the device
- reg: address of device
Optional Properties:
- qcom,vib-timeout-ms: timeout of vibrator, in ms. Default 15000 ms
- qcom,vib-vtg-level-mV: voltage level, in mV. Default 3100 mV
vibrator driver source
QPNP vibrator operates in two modes – manual and PWM (Pulse Width Modulation). PWM is supported through one of dtest lines connected to the vibrator. Manual mode is used on MSM8909 platform.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
Uses timed output framework
callback .enable and .get_time of struct timed_output_dev is hooked by qpnp_vib_enable()
and qpnp_vib_get_time()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
wq is scheduled to execute work of qpnp_vib_update() and turns off vibrator via qpnp_vibrator_suspend() at suspend callback.
Inside qpnp_vib_update()
and qpnp_vibrator_suspend()
, they both call qpnp_vib_set()
to turn on/off vibrator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
2. Timed output class driver
Timed output is a class drvier to allow changing a state and restore is automatically after a specfied timeout. This exposes a user space interface under /sys/class/timed_output/vibrator/enable used by vibrator code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
3. Android vibrator HAL
Its interface to linux device drivers call with the specified timeout in millisecond via vibrator_on()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
4. Native layer through JNI between HAL and vibrator service
Controls of vibrator service reaches via vibratorOn()
, vibratorOff()
, and vibratorExists()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
5. Java Vibrator Service
In application layer before controling vibrator, applications have to get the access to the vibrator service.
The control goes into the vibrator service (Framework Layer) thru binder inteface.
For example, App. creates Vibrator object and start the vibration via startVibrationLocked(vib)
.
Inside startVibrationLocked()
:
If mTimeout != 0, then call the JNI function vibratorOn()
.
else, call the code, which handle the rhythmic vibration pattern, which intern call the vibratorOn()
through VibrateThread()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|