Closed rriveramcrus closed 1 week ago
CC: @fabiobaltieri
Hi Marcus, thanks for the proposal. I've been peeking at some datasheets and I'm trying to understand if there's even enough commonalities between haptic controllers of different vendors to justify a subsystem or if maybe this should live as misc device driver that supports multiple p/n from the same vendor that are designed around a common model.
Do you have any insight on that? I'm thinking it may help to add some details and higlight how the API would cover various devices, maybe comparing the CS40L26 (or another device from CL) to a DRV2605L (it seems to be a popular part number in the QMK world, just got myself one to play with :-)).
At first sight from me I think it may make sense, there's certainly overlap on the start/stop output APIs, but the interesting part is how the whole configuration and property (is there a difference?) may pan out. Could you expand on those?
Hey @fabiobaltieri, Thanks for taking a look! I added a comparison table in the Problem Description section. The playback controls and input sources are very similar across the board but as you mentioned the controls set through properties can really differ.
The intention with the configure
would be to atomically configure the haptic driver for a desired input source. If it is a I2S input source the would mean configure clocks and a data interface. If it is ROM input source there's little to do besides make sure the command is valid.
The intention of the properties
was more so for facilitating LRA calibration, configuring the integrated boost converter, setting protections, etc. I think some basic properties can be enumerated in the haptics API but it may be wise to allow it to be extended beyond that with vendor specific properties in a separate library.
An unknown for me is how to handle waveform synthesis. Should I just expose the various controls of the hardware synthesizer as properties
or should the API try define and take in standardize waveform instructions, parse them, and issue them in the configuration
handler? I think it's more of a question of what is more Zephyr-like.
Ricardo
Right but the configuration part of those devices I reckon is
So I'm thinking that it may not be much sense to try and enumerate a ton of properties where they are implemented in groups, but rather just implement the basic common stuff (start/stop effect, not sure what else) and then have the configuration either handled in the driver init or with a per-driver extension that can be shared between a group of drivers.
The playback part I'd imagine being the more intersting part, not sure what to do about it but for i2s I'd imagine it's just use the i2s subsystem, for RAM wavefrom maybe just a simple write_samples
API?
So I'm thinking that it may not be much sense to try and enumerate a ton of properties where they are implemented in groups, but rather just implement the basic common stuff (start/stop effect, not sure what else) and then have the configuration either handled in the driver init or with a per-driver extension that can be shared between a group of drivers.
I am okay with this. Are there any vendor specific extensions you recommend to draw inspiration from? I would like to rewrite the draft PR to be closer to this vision to make the rest of the discussion a bit easier.
@rriveramcrus do the subsystem api with the common stuff and a sample driver using driver specific APIs for configuration, there's few of those in code base, for example https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/sensor/ccs811.h.
hi rriveram, great suggestion & overview
suggest to also add upstream events to the haptic_driver_api that can be used for driver IC's offering protection features like over temp, current monitoring and various diagnostics events / alerts.
these could be tied to real irq inputs or soft irq's based on some condition. also neat for zephyr shell when working with tuning and bring-up
@fabiobaltieri @rriveramcrus should we bring this up in the next Architecture WG meeting?
Sounds good to me! Next Tuesday at 8AM PT/17h CET, correct?
Actually if we could push to the following week, June 11th, that would work better.
Discussed in https://github.com/zephyrproject-rtos/zephyr/discussions/64942