-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand sensor_info struct and DTS bindings #62944
Comments
@MaureenHelm for comment soliciting |
I had something like this in mind when I introduced I agree that an application should know if the sample rate configured doesn't equal the sample rate requested. I used to try to enforce sensor drivers returning an error code instead of rounding up to the next supported sample rate, but there were too many reviews and I couldn't keep up with it. |
The sensor channels is limited here by the current enum sensor_channel, this leaves a lot to be desired. It would be great to allow structured data be available for each sensor definition, perhaps allow for named aliases (could be static const defines of a channel spec), metadata about a channel (e.g. its a light reading, with a custom frequency, and index N, with frequency f) See #63830 |
Agreed. We need to ensure that this will work just as well for custom, out-of-tree sensor channels. |
Introduction
Some additional information about the sensor might come in handy both at compile time and at runtime. I'm proposing we add additional sensor attributes to the
sensor-device.yaml
which will allow developers to check capabilities of the sensor at compile time. Additionally a newKconfig.sensor_info
will be added to allow saving this information for runtime.Problem description
In many cases, the runtime selection of the sensor configuration comes from another processor which may be making complex decisions based on the possibilities presented. For example, if the sensor supports 200Hz and 400Hz ODRs. Without knowing this, the host may request a value that's not directly supported (300Hz) which means that 400Hz is likely to be selected and the host will have to downsample. There's a slew of ramifications to this which might have been avoided by the host knowing that 300Hz isn't a viable option.
Proposed change
sensor-device.yaml
bindings to list out some additional sensor attribute values.Kconfig.sensor_info
which will allow saving these attributes to thesensor_info
structDetailed RFC
Proposed change (Detailed)
It should already be possible to check statically if a value is found in a DTS array:
I haven't worked out what the equivalent
min
/max
functions would look like, but that would be the next utility to provide.The runtime changes would be simpler, based on the Kconfig we would either include the new fields in the
sensor_info
struct or not.The text was updated successfully, but these errors were encountered: