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

drivers: video: ov7670: introduce driver for ov7670 camera #72826

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

danieldegrasse
Copy link
Collaborator

Introduce driver for ov7670 camera, supporting QCIF,QVGA,CIF, and VGA
resolution in YUV and RGB mode.

Copy link
Collaborator

@loicpoulain loicpoulain left a comment

Choose a reason for hiding this comment

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

neat! For the record, could you add in the commit message the board/devkit with wich you tested this.

@danieldegrasse
Copy link
Collaborator Author

neat! For the record, could you add in the commit message the board/devkit with wich you tested this.

Sure- it was tested on the FRDM-MCXN947, but that support requires PR #72827, which is dependent on this driver. I can add something like the following to the commit message:

Support was verified on the FRDM-MCXN947, using the SmartDMA camera engine, which is enabled in the following PR: #72827

Would this work?

@loicpoulain
Copy link
Collaborator

Support was verified on the FRDM-MCXN947, using the SmartDMA camera engine, which is enabled in the following PR: #72827

Would this work?

Sure.

@danieldegrasse danieldegrasse force-pushed the feature/ov7670-driver branch from 695c7ba to 0f92f6f Compare May 20, 2024 17:36
@danieldegrasse
Copy link
Collaborator Author

@loicpoulain could you revisit this PR when you get a chance? I've updated the commit message as requested

loicpoulain
loicpoulain previously approved these changes May 31, 2024
Copy link
Collaborator

@loicpoulain loicpoulain left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@danieldegrasse
Copy link
Collaborator Author

@ngphibang or @josuah, FYI in case either of you would like to provide feedback.

@danieldegrasse
Copy link
Collaborator Author

@decsny would you be willing to review this when you have a chance (or @galak, I'd just like someone to take a look at this from the DTS side based on the assignee the bot selected)

decsny
decsny previously approved these changes May 31, 2024
@decsny
Copy link
Member

decsny commented May 31, 2024

the binding is fairly trivial, reassigning to video area

@decsny decsny assigned loicpoulain and unassigned galak and loicpoulain May 31, 2024
drivers/video/ov7670.c Outdated Show resolved Hide resolved
drivers/video/ov7670.c Outdated Show resolved Hide resolved
drivers/video/ov7670.c Outdated Show resolved Hide resolved
dts/bindings/video/ovti,ov7670.yaml Outdated Show resolved Hide resolved
drivers/video/ov7670.c Outdated Show resolved Hide resolved
drivers/video/ov7670.c Outdated Show resolved Hide resolved
Introduce driver for ov7670 camera, supporting QCIF,QVGA,CIF, and VGA
resolution in YUV and RGB mode.

Support was verified on the FRDM-MCXN947, using the SmartDMA camera
engine, which is enabled in the following PR:
zephyrproject-rtos#72827

Signed-off-by: Daniel DeGrasse <[email protected]>
Add ov7670 camera driver to build test for video drivers

Signed-off-by: Daniel DeGrasse <[email protected]>
@danieldegrasse danieldegrasse dismissed stale reviews from decsny and loicpoulain via cfb16b7 June 1, 2024 18:01
@danieldegrasse danieldegrasse force-pushed the feature/ov7670-driver branch from 0f92f6f to cfb16b7 Compare June 1, 2024 18:01
@ngphibang
Copy link
Contributor

LGTM ! +1

@danieldegrasse danieldegrasse requested a review from decsny June 3, 2024 16:02
@dleach02
Copy link
Member

dleach02 commented Jun 4, 2024

@loicpoulain can you return to this PR for final review

Copy link
Collaborator

@loicpoulain loicpoulain left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@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.

(note: this is purely informative: not collaborator, not maintainer, just an extra pair of eyeballs)

Good to have this starting point!

For reference, although I did not read them when reviewing:
https://web.mit.edu/6.111/www/f2016/tools/OV7670_2006.pdf
https://www.electronicscomp.com/datasheet/ov7670-sensor-datasheet.pdf

Comment on lines +319 to +322
if (!memcmp(&data->fmt, fmt, sizeof(data->fmt))) {
/* nothing to do */
return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious: Is this a performance optimization to reduce I2C traffic?
Is setting the format happening often in some cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it is a performance optimization. Other drivers in tree have the same code, so I figured it would make sense to include the feature here as well

Copy link
Collaborator

@josuah josuah Jun 7, 2024

Choose a reason for hiding this comment

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

Thank you this makes sense!

Note to self: also add it to #73013

memcpy(&data->fmt, fmt, sizeof(data->fmt));

if (fmt->pixelformat == VIDEO_PIX_FMT_RGB565) {
com7 |= 0x4;
Copy link
Collaborator

Choose a reason for hiding this comment

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

For reference if anyone wonders, in Linux driver:

#define   COM7_RGB        0x04    /* bits 0 and 2 - RGB format */

@@ -11,3 +11,4 @@ zephyr_library_sources_ifdef(CONFIG_VIDEO_OV7725 ov7725.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV2640 ov2640.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_STM32_DCMI video_stm32_dcmi.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV5640 ov5640.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV7670 ov7670.c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

#73013 will fix the sorting later

Comment on lines +135 to +144
static const struct video_format_cap fmts[] = {
OV7670_VIDEO_FORMAT_CAP(176, 144, VIDEO_PIX_FMT_RGB565), /* QCIF */
OV7670_VIDEO_FORMAT_CAP(320, 240, VIDEO_PIX_FMT_RGB565), /* QVGA */
OV7670_VIDEO_FORMAT_CAP(352, 288, VIDEO_PIX_FMT_RGB565), /* CIF */
OV7670_VIDEO_FORMAT_CAP(640, 480, VIDEO_PIX_FMT_RGB565), /* VGA */
OV7670_VIDEO_FORMAT_CAP(176, 144, VIDEO_PIX_FMT_YUYV), /* QCIF */
OV7670_VIDEO_FORMAT_CAP(320, 240, VIDEO_PIX_FMT_YUYV), /* QVGA */
OV7670_VIDEO_FORMAT_CAP(352, 288, VIDEO_PIX_FMT_YUYV), /* CIF */
OV7670_VIDEO_FORMAT_CAP(640, 480, VIDEO_PIX_FMT_YUYV), /* VGA */
{0}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks convenient and easy to review.
This might be a good addition to #73867 later.

Comment on lines +314 to +317
if (fmt->pixelformat != VIDEO_PIX_FMT_RGB565 && fmt->pixelformat != VIDEO_PIX_FMT_YUYV) {
LOG_ERR("Only RGB565 and YUYV supported!");
return -ENOTSUP;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is-the advantage to this check is that skip the array search for formats we know we don't support. We could also manually check resolution using if statements like these, but that would be trickier.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you! It makes sense, and brings a better error log message too when the wrong format gets sent.

@nashif nashif merged commit 1ef4273 into zephyrproject-rtos:main Jun 7, 2024
22 checks passed
@danieldegrasse danieldegrasse deleted the feature/ov7670-driver branch June 7, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Video Video subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants