Skip to content

Add Arducam mega camera driver#96234

Open
kristosb wants to merge 3 commits intozephyrproject-rtos:mainfrom
kristosb:update_arducam_mega_driver
Open

Add Arducam mega camera driver#96234
kristosb wants to merge 3 commits intozephyrproject-rtos:mainfrom
kristosb:update_arducam_mega_driver

Conversation

@kristosb
Copy link

The Arducam mega is an low power, rolling shutter camera, support connect one or more cameras any Microcontroller. It provides high-quality image capture and processing capabilities, making it highly suitable for various application fields, including machine vision, image recognition, and robotics, among others.

@github-actions
Copy link

Hello @kristosb, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@josuah josuah self-requested a review September 18, 2025 17:32
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this is an incomplete review, but I lack more time for finishing it today, and will have to come back later

Thank you very much for picking Arducam PR #66994 and bringing it closer to completion!

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 5606ed3 to 5fa321b Compare October 3, 2025 12:39
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for such a long silence.

Here is another round of review to react to some of your comment as well as follow-up modifications to reduce the custom APIs that this driver requires.

Thank you for your previous changes!

@josuah josuah added area: Video Video subsystem area: camera labels Oct 9, 2025
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some other things I noticed that Arducam left along the way.
I wish I did catch these few extra things on previous review.

@josuah
Copy link
Contributor

josuah commented Oct 26, 2025

Thank you for all the changes @kristosb!
I will give it another review ASAP.
I think this is getting quite close, extensive refactoring was needed!

Note that there were a few PRs merged and you might want to git fetch upstream then git rebase upstream/main (or origin instead of upstream) and manually fix the conflict.

@kristosb
Copy link
Author

Thank you for all the changes @kristosb! I will give it another review ASAP. I think this is getting quite close, extensive refactoring was needed!

Note that there were a few PRs merged and you might want to git fetch upstream then git rebase upstream/main (or origin instead of upstream) and manually fix the conflict.

Thanks for all the feedback and suggestions. There is still some work required. I rebased not long ago but will do that again soon.

@josuah
Copy link
Contributor

josuah commented Oct 26, 2025

There has been a hurricane of PR merges just before the 4.3.0 release RC1, probably why so many conflicts in such short time.

https://github.com/zephyrproject-rtos/zephyr/wiki/Release-Management

No rush of course!

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from f63f0ea to d7ab999 Compare October 29, 2025 12:20
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these changes!

This time, some focus on error handling to make a "try/catch" replacement in C appear, to help proof reading driver code (which almost always look the same).

I have annotated them all so that you have some kind of to-do list.

Last but not least, we can reorganize the commits into just a few commits.

You can "squash" all the commits into just 3 (or more if you want to segment more):

  • vendor-prefixes.txt changes
  • video-controls.h changes
  • everything else in just one commit

Past this, I think it would be ready for being upstreamed!

Thanks again for this long refactoring!

@josuah
Copy link
Contributor

josuah commented Nov 3, 2025

This looks like one of the most complete/featureful camera driver of Zephyr so far. Congrats. :)

Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all these changes, that was a large batch of small things.

So here is a small batch for one last thing and I think this would be ready. :)

struct video_buffer *vbuf;
int ret = 0;

vbuf = k_fifo_get(&drv_data->fifo_in, K_NO_WAIT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to add error handling in case vbuf == NULL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added checking for NULL vbuf

Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did spot a few more details, but I think we are almost there!

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 1a77fe1 to f1a979f Compare November 24, 2025 20:40
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was starting a review, and realized this was on an older commit.

This is a good example why it's helping to not have "fixup commits" in a same patch: commits that modify issues introduced by the previous other commits.

It seems like what reviewers look at is the "File changed" tab, but this is the biggest fallacy of Github ever, as reviewers are expected to exclusively review the "Commits" tab.

If you switch to the Commits tab, and see code that is not looking ideal (even though it looks ideal on the "files changed" tab), then likely this will not be good for review...

So this is fine to drop the commits from arducam. You can eventually add the original authors as Co-authored-by: User Name <email> in a line after/before Signed-off-by:.

Keeping the original comments below to outline the issues, but they don't need to be fixed I think as you already did all the fixups in latter commits (which you can then merge with the original commits).

Thank you! Getting really close!

@kristosb
Copy link
Author

Keeping the original comments below to outline the issues, but they don't need to be fixed I think as you already did all the fixups in latter commits (which you can then merge with the original commits).

Made the changes for completeness.

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 98a6f76 to 9a9c8ad Compare November 28, 2025 22:38
@kristosb
Copy link
Author

So this is fine to drop the commits from arducam. You can eventually add the original authors as Co-authored-by: User Name <email> in a line after/before Signed-off-by:.

I squashed the commits again and included original co-author in a commit message.

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 9a9c8ad to 175eb26 Compare November 29, 2025 11:37
@kristosb
Copy link
Author

So this is fine to drop the commits from arducam. You can eventually add the original authors as Co-authored-by: User Name <email> in a line after/before Signed-off-by:.

I squashed the commits again and included original co-author in a commit message.

There was a missing first commit and wrong file under commit for prefixes. Should be fine now. I will rebase now to sync with upstream.

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 175eb26 to 9c0ccee Compare November 29, 2025 12:03
@kristosb
Copy link
Author

Branch rebased and in sync with upstream now.

Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we enter in the polishing phase now really.

Only the commit message, order of commits are mandatory, and the others are more a recommendation and less blocking.

Thank you again for this very long fine-tuning session!

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 5cd2705 to 0fe7102 Compare December 11, 2025 21:49
@kristosb kristosb requested a review from josuah December 12, 2025 15:26
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes! I think we are at the last mile now.

Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The driver needs to be at least built in CI, see tests/drivers/build_all/video.
Also, the last commit's message is not that useful, it's just an advertisement of the hardware. What could be useful is pointing out for ex. any known limitations of the current driver, justifying design choices... in general info that will be helpful for someone debugging the driver or trying to improve it.

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 0fe7102 to 2079bdd Compare December 19, 2025 19:14
static const struct arducam_mega_config arducam_mega_cfg_##inst = { \
.bus = SPI_DT_SPEC_INST_GET(inst, \
SPI_OP_MODE_MASTER | SPI_WORD_SET(8) | \
SPI_CS_ACTIVE_HIGH | SPI_LINES_SINGLE | \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm questioning this SPI_CS_ACTIVE_HIGH here. The camera datasheet shows that the SS line to the camera is active low, as is typical for SPI devices.

I've been working with this camera for the last couple of days on a platform that does not support active high CS lines (and returns an error when you try to use it that way), so I had to remove this setting. Seems like it would make more sense to be in the device tree if this was needed on a particular platform.

Copy link
Contributor

@josuah josuah Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the report, and sorry for the long wait.
Could you give a hint about which platform that was if it is public information?

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from 2079bdd to e260a90 Compare February 23, 2026 17:43
@zephyrbot zephyrbot added the area: Devicetree Binding PR modifies or adds a Device Tree binding label Feb 23, 2026
@kristosb kristosb requested a review from josuah February 23, 2026 18:03
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for coming back to this driver!

There does not seem to be a lot of changes in the video API since last time luckily, so very few adjustments (which I missed) but otherwise I see it ready for being merged!

@kristosb kristosb force-pushed the update_arducam_mega_driver branch from e260a90 to bf46e5e Compare February 24, 2026 13:23
kristosb and others added 3 commits February 24, 2026 15:56
Added automatic exposure compensation control under base camera class.

Signed-off-by: Krystian Balicki <kristos_b@wp.pl>
Added arducam company name to vendor name list.

Signed-off-by: Krystian Balicki <kristos_b@wp.pl>
The Arducam mega is a low power, rolling shutter camera, supports
connecting one or more cameras to any microcontroller. It provides
high-quality image capture and processing capabilities, making it
highly suitable for various application fields, including machine
vision, image recognition, and robotics, among others. In current
implementation connecting multiple instances of the same camera
system is problematic.

Co-authored-by: Lee Jackson <lee.jackson@arducam.com>
Signed-off-by: Krystian Balicki <kristos_b@wp.pl>
@kristosb kristosb force-pushed the update_arducam_mega_driver branch from bf46e5e to d854cd4 Compare February 24, 2026 14:57
@kristosb kristosb requested a review from josuah February 24, 2026 15:13
@kristosb kristosb requested a review from randyscott February 25, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment