-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
add new feature about sensor driver model #2215
Conversation
Change-Id: Ib9b6866951b46f34aa9faaa1c9a6edb0b217b719 Signed-off-by: dongjiuzhu <[email protected]>
N/A Change-Id: Idd11461f933dd21b7271cd3ca87a2e33127a9d34 Signed-off-by: dongjiuzhu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pointing out some typos and improvement opportunities in the documentation.
Thank you very much, I'll study this documentation guide and modify them. |
1.support for multi-user access 2.support special cmd to control sensor 3.support userspace to set size of intermediate buffer by ioctl: SNOIC_SET_BUFFER_SIZE Change-Id: I9ce3a65b88b12c28388ec397431f1a277b120c2a Signed-off-by: dongjiuzhu <[email protected]>
1.use userspace buffer rather than intermediate buffer of upperhalf driver 2.support block and non-block ways. Change-Id: I1d0cecfaa20ce54961c58713d8f2f8857e349791 Signed-off-by: dongjiuzhu <[email protected]>
I'm looking at the changes. I wanted to ask, any reason why you are defining your own queue structure instead of using definitions in queue.h? |
Also, shouldn't the buffer be released on close() on the last reference? Right now it requires the unregistration of the sensor |
And if I understand correctly, the internal buffer is always allocated to the sensor structure size, even when only fetch() will be used, right? It would be better to only do so if fetch() will not be used, otherwise it is just wasted memory. Also, would it be possible (and would it make sense) to let the driver define its own structure? I'm thinking about custom sensors types which may not map exactly to any of the structs defined. Maybe this could be done by letting the lower part define the struct size and dev prefix string. That is all the comments I have. I feel I would have to try to use this interface to really understand it and see if there's any limitation, but it looks good so far. |
The circualr buffer and queue are different for their behavior. We need to overwrite old data when buffer is full, and it's better to operate buffer directly rather than queue node. |
I will add mm/circ_buf for circular buffer management on other patch later, and driver/sensor and driver/rc will call these api about circ_buf_xxx to use circular buffer. |
Thank you. |
I see. But the call to the buffer creation function is still done and if I understand correctly, due to the rounding up, one struct will be allocated in the buffer still.
I agree, but I'm thinking in the lines of something that wouldn't necessarily be ported upstream, leaving downstream user the possibility of defining a particular driver with specific needs. But we can go back to this later on.
|
Are you sure there's no circular buffer structure defined anywhere else in NuttX? |
What about this? |
It isn't an issue more with new mm/circ_buf, so we can temporarily ignore it here.
Ok, we can add a special register api later.
We can't find one, could you point to a general and standalone implementation?
Since the upcomming patch will replace the buffer implemenation to a common one, how about move this change to that PR? |
I grepped the sources and found various mentions to circular buffers being used, but they all appear to be ad-hoc implementations, so a separate ring buffer structure could be useful to have. I agree to making the memory related changes later. |
Summary
driver/sensor: add new feature about sensor driver
1.support for multi-user access
2.support special cmd to control sensor
3.support userspace to set size of intermediate buffer by ioctl: SNOIC_SET_BUFFER_SIZE
4.add fetch api to use userspace buffer rather than intermediate buffer of upperhalf driver
5.fetch api support block and non-block ways.
It will directly access sensor register by i2c/spi when open mode is non-block,
It will wait until sensor data ready and call fetch api.
Impact
disable intermediate buffer by lowerhalf driver use fetch api.
Testing
daily test