-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
drivers: video: ov7670: introduce driver for ov7670 camera #72826
Conversation
d5dada1
to
695c7ba
Compare
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.
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:
Would this work? |
Sure. |
695c7ba
to
0f92f6f
Compare
@loicpoulain could you revisit this PR when you get a chance? I've updated the commit message as requested |
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.
LGTM! Thanks
@ngphibang or @josuah, FYI in case either of you would like to provide feedback. |
the binding is fairly trivial, reassigning to video area |
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]>
0f92f6f
to
cfb16b7
Compare
LGTM ! +1 |
@loicpoulain can you return to this PR for final review |
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.
LGTM
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.
(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
if (!memcmp(&data->fmt, fmt, sizeof(data->fmt))) { | ||
/* nothing to do */ | ||
return 0; | ||
} |
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 curious: Is this a performance optimization to reduce I2C traffic?
Is setting the format happening often in some cases?
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.
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
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.
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; |
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.
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) |
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.
#73013 will fix the sorting later
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}}; |
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.
This looks convenient and easy to review.
This might be a good addition to #73867 later.
if (fmt->pixelformat != VIDEO_PIX_FMT_RGB565 && fmt->pixelformat != VIDEO_PIX_FMT_YUYV) { | ||
LOG_ERR("Only RGB565 and YUYV supported!"); | ||
return -ENOTSUP; | ||
} |
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.
Is this not already handled below?
https://github.com/zephyrproject-rtos/zephyr/pull/72826/files#diff-1fe02c52aeadf74decf28b87839e35abfd3f96e3548f5d1518276ca2439bd6afR353-R354
No harm done checking twice in practice though...
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.
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.
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.
Thank you! It makes sense, and brings a better error log message too when the wrong format gets sent.
Introduce driver for ov7670 camera, supporting QCIF,QVGA,CIF, and VGA
resolution in YUV and RGB mode.