Skip to content
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

video: emul: virtual driver for an imager and RX engine #79482

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

josuah
Copy link
Collaborator

@josuah josuah commented Oct 6, 2024

This takes inspiration on the other skeleton.c drivers through Zephyr tree:
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/usb/udc/udc_skeleton.c
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/display/display_dummy.c

It acts as a starting point and as a puppet to explain API changes affecting image sensors.

Be used for providing test cases for the entire API, as required for stable APIs.

A video_get_format_index() utility is introduced in the process to find the index of a format inside a capability list.

-> What should the ideal sensor driver look like?

Fixes: #73867

@josuah
Copy link
Collaborator Author

josuah commented Oct 6, 2024

I note that the frame interval API was merged, this will need to include it.

@josuah josuah added DNM This PR should not be merged (Do Not Merge) and removed DNM This PR should not be merged (Do Not Merge) labels Oct 6, 2024
@josuah josuah marked this pull request as draft October 6, 2024 23:23
@josuah josuah force-pushed the pr-video-sensor-skeleton branch 5 times, most recently from eb4a7a4 to cfa3bfb Compare October 13, 2024 13:20
@josuah josuah marked this pull request as ready for review October 13, 2024 13:20
@zephyrbot zephyrbot added the area: Base OS Base OS Library (lib/os) label Oct 13, 2024
@josuah
Copy link
Collaborator Author

josuah commented Oct 13, 2024

  • Aims to cover the most frequent use-cases and facilitate modifications on top
  • Assume that image sensor drivers are apply modes described by pixelformat+resolution+framerate
  • For every new sensor, require filling a few tables and let the ready-made functions hook them to the Zephyr video API

@josuah josuah requested review from pillo79 and uLipe October 13, 2024 13:36
@josuah josuah force-pushed the pr-video-sensor-skeleton branch 2 times, most recently from 64e0235 to 9a1a450 Compare October 14, 2024 12:02
@zephyrbot zephyrbot added platform: STM32 ST Micro STM32 area: Watchdog Watchdog labels Oct 14, 2024
@josuah
Copy link
Collaborator Author

josuah commented Oct 17, 2024

force-push: fix a bug when actually trying to compile it... It shows how important it is to provide code that actually compile, and why not as well: actually run.

@josuah josuah force-pushed the pr-video-sensor-skeleton branch 2 times, most recently from 201c49e to d612f52 Compare October 21, 2024 16:33
@josuah josuah added the DNM This PR should not be merged (Do Not Merge) label Oct 21, 2024
@josuah
Copy link
Collaborator Author

josuah commented Oct 21, 2024

Here is a new WIP approach. Instead of having a skeleton driver that might not compile, and past this might still have bugs, here is a pair of virtual drivers:

  • MIPI RX which emulates a MIPI RX core.
  • Imager which emulates an image sensor

There is a memcpy() call to pass data from the Imager to the MIPI RX other than that, everything is implemented like it would on real hardware, example of complete implementation of existing and proposed APIs (i.e. in PRs).

Next, I need to add ztests, and see if that permits to run the samples on native_sim.

@josuah
Copy link
Collaborator Author

josuah commented Oct 22, 2024

force-push: add unit tests for the generic video_common.h utilities except video_closest_frmival(), taking a struct device * as argument.

@josuah josuah force-pushed the pr-video-sensor-skeleton branch 2 times, most recently from 0b402b7 to 38cf615 Compare October 22, 2024 13:59
@josuah josuah changed the title video: sensor_skeleton: starting point for writing new sensor drivers video: emul: virtual driver for an imager and RX engine Oct 22, 2024
@josuah josuah force-pushed the pr-video-sensor-skeleton branch 2 times, most recently from 12321fb to 9d5cd84 Compare October 23, 2024 09:13
@josuah
Copy link
Collaborator Author

josuah commented Oct 23, 2024

force-push: unit tests for the emulated drivers: this covers the entire video API except set_signal()

To test: west twister --inline-logs --platform native_sim --scenario tests/drivers/video/api/drivers.video.api

@ngphibang
Copy link
Contributor

@josuah : Is the PR ready for review ? Sorry, I asked because I received email notifications of the continuous force-push rather often that make me thinking that this is in development phase. If so, is it better to limit the force push not only to avoid email notifications but also to reduce Zephyr CI kicked-off burden for every push ? If it's not the case, it's OK to do that.

@josuah
Copy link
Collaborator Author

josuah commented Oct 23, 2024

@ngphibang you are right, I should work on a separate wip branch and force-push there instead of directly to the PR branch. Thank you for letting me know. Yes this is ready. Twister, check_compliance, and doc build worked locally.

[EDIT: this was thought as being ready at first, and then I thought "let's add unit tests to the same PR", and then "lets' add some more", etc: I should take some time to let things mature and be more reasonable]

@josuah josuah removed the DNM This PR should not be merged (Do Not Merge) label Oct 23, 2024
@josuah
Copy link
Collaborator Author

josuah commented Nov 2, 2024

force-push:

  • Fix 2 commits being mixed-up
  • Fix bindings and deviceetree (include i2c-device.yaml or base.yaml)
  • Use devicetree macros API like in drivers: video: Add endpoint DT helpers #80649
  • Move video-common.h to video.h as the helpers are usable by the application too.

Introduce a video_get_format_index() utility to help finding a caps
entry out of a given format. Introduce several utilities to seek and
apply frame intervals.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Add a new implementation of a test pattern generator, with the same
architecture as real drivers: split MIPI receiver core and
I2C-controlled sub-device, with changes of video format in
"zephyr,emul-imager" leads to different data produced by
"zephyr,emul-mipi-rx".

Signed-off-by: Josuah Demangeon <me@josuah.net>
@josuah
Copy link
Collaborator Author

josuah commented Nov 3, 2024

force-push:

josuah added a commit to tinyvision-ai-inc/zephyr that referenced this pull request Nov 4, 2024
PR zephyrproject-rtos#79482 is where this commit would be added

Signed-off-by: Josuah Demangeon <me@josuah.net>
josuah added a commit to tinyvision-ai-inc/zephyr that referenced this pull request Nov 4, 2024
PR zephyrproject-rtos#79482 is where this commit would be added

Signed-off-by: Josuah Demangeon <me@josuah.net>
josuah added a commit to tinyvision-ai-inc/zephyr that referenced this pull request Nov 4, 2024
PR zephyrproject-rtos#79482 is where this commit would be added

Signed-off-by: Josuah Demangeon <me@josuah.net>
josuah added a commit to tinyvision-ai-inc/zephyr that referenced this pull request Nov 12, 2024
PR zephyrproject-rtos#79482 is where this commit would be added

Signed-off-by: Josuah Demangeon <me@josuah.net>
josuah added a commit to tinyvision-ai-inc/zephyr that referenced this pull request Nov 12, 2024
PR zephyrproject-rtos#79482 is where this commit would be added

Signed-off-by: Josuah Demangeon <me@josuah.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drivers: video: sensors: add a sensor_skeleton.c to speed-up contribution of simple sensors
6 participants