Create an API for Haptic Driver Devices #64942
Closed
rriveramcrus
started this conversation in
RFC
Replies: 1 comment
-
Closing in favor of #67226, sorry for dropping this, RFC should go into issues. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
Add a kernel device driver API for interacting with haptic driver devices.
Draft PR: #66629
Problem description
Haptic devices are integrated circuits that drive a linear resonant actuator (LRA) when an event occurs to provide the end user haptic feedback. A haptic event can be triggered via GPIO or through a control port. The haptic event sources can be simple PWM inputs, PCM inputs such as I2S/TDM, an integrated buzzer, tables of waveforms from ROM, or synthesized waveform tables in RAM.
There is currently no purpose-built API in Zephyr for interacting with haptic driver device or facilitating haptic events.
Status Quo
Zephyr OS
No known subsystem catering to haptic driver devices. The input subsystem is focused on mice, keyboards, and other HIDs.
The question of how to accomodate haptic LRA drivers has come up in the past (#22486). An embedded controller runinng Zephyr has various haptic feedback applications.
Linux Kernel
Haptic driver devices have been living in the Input Force Feedback subsystem as miscellaneous devices. This subsystem was not originally meant for haptic driver devices, but rather joysticks, mice, keyboards, etc.
It would not be ideal to continue this development architecture in Zephyr and serves as an opportunity to put together something better for haptic driver devices.
Proposed change
Functionally these devices are similar to audio codecs and the proposed haptic_driver_api takes inspiration from the audio_codec_api. The haptic waveform events are to be triggered through a playback state machine with three states and a corresponding handler for each state.
To begin haptic event playback the start_event handler is to be called. The device driver must begin playback of the haptic event that is presently configured. Once complete, the stop_event handler is called to stop playback of the haptic event. Haptic events in a system do have priority and the proposed API offers a preempt_event handler for preempting playback of an event. When starting or preempting an event, an event identifier is passed to the handler. This is useful for configuring the device to playback from the appropriate source,
Configuration of the device at runtime is facilitated through the set_property handler. Drivers that wish to cache multiple settings from the set_property handler and apply the settings atomically can make use of the apply_property handler.
Driver Examples
The code snippets below serve as examples of how a client of the API would interface.
Beta Was this translation helpful? Give feedback.
All reactions