-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add support for Renesas RA CEU (Capture Engine Unit) for RA8M1 and RA8D1 #92146
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 support for Renesas RA CEU (Capture Engine Unit) for RA8M1 and RA8D1 #92146
Conversation
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
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 for implementing the Renesas video driver!
The driver appears in a good shape WRT video APIs, with a few key points to modify (marked with :x), and a few proposal to improve it further, non-blocking (i.e. could be improved over time eventually, although appreciated if modified now).
Let me know if anything needs clarifications.
[blocking ❌] |
} | ||
} | ||
|
||
static int video_renesas_ra_ceu_get_format(const struct device *dev, struct video_format *fmt) |
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.
Function name is rather long, could it be shorten like ra_ceu_get_format
?. Idem for others
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.
@thaoluonguw : This is a small point but do you think it's better to shorten the function name a bit ? The prefix video_renesas_
seems not needed as all these functions are static, no worry that other functions will have the same name
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.
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.
As my viewpoint, better to keep the video_renesas_ra_*
prefix for consistency with the name-spacing rule. With the *_ceu
surfix, as mentioned by @josuah , an *_csi
variant driver will be sent out later, so let's keep it to specific hardware function.
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.
With the csi variant coming : ceu_get_format()
/ csi_get_format()
is sufficient.
video_renesas_
could be simplified. But well, it's up to you.
92a4b3b
to
03bdbce
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.
I have some comments regarding camera support on the board and in the shield layer
ceu: ceu@40348000 { | ||
compatible = "renesas,ra-ceu"; | ||
reg = <0x40348000 0x8000>; | ||
clocks = <&pclka MSTPC 16>; |
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.
I think it's missing clock-names
here
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 a comment for nit. Others LGTM.
FYI, to summarize what allows this PR to be merged in practice:
Then of course letting time for PR author to check all comments. |
Hi, thanks for your work, any plans to move this forward? |
@thaoluonguw @KhanhNguyen-RVC Politely asking, is there any plans to move this work forward? |
356db7a
to
cff8ae6
Compare
@leiche-cid, Sorry for the late response. I’ve rebased and added a test case in the build_all yaml. |
Add support for the Renesas RA Capture Engine Unit (CEU), including driver source files, Kconfig options, and DTS bindings. - Add initial implementation of the RA CEU driver - Add dedicated Kconfig and CMake integration - Provide Devicetree bindings for the RA CEU - Update module Kconfig to include the new driver This enables image capture functionality using the CEU peripheral on Renesas RA series MCUs. Signed-off-by: Duy Vo <duy.vo.xc@bp.renesas.com> Signed-off-by: Khanh Nguyen <khanh.nguyen.wz@bp.renesas.com>
Add pin definitions required by the RA Capture Engine Unit Signed-off-by: Duy Vo <duy.vo.xc@bp.renesas.com> Signed-off-by: Khanh Nguyen <khanh.nguyen.wz@bp.renesas.com>
Add CEU to r7fa8d1xh.dtsi and r7fa8m1xh.dtsi Signed-off-by: Khanh Nguyen <khanh.nguyen.wz@bp.renesas.com>
- Add CEU pin configuration to ek_ra8d1-pinctrl.dtsi - Enable CEU node and Arducam 20-pin connector in ek_ra8d1.dts - Configure PWM3 as external XCLK via pwm-clock node - Update board YAML to declare video support Signed-off-by: Duy Vo <duy.vo.xc@bp.renesas.com> Signed-off-by: Khanh Nguyen <khanh.nguyen.wz@bp.renesas.com>
Support OV7670 DVP 20-pin shield on the EK-RA8D1 board Signed-off-by: Khanh Nguyen <khanh.nguyen.wz@bp.renesas.com>
Add EK-RA8D1 board support for capture and capture_to_lvgl samples Signed-off-by: Khanh Nguyen <khanh.nguyen.wz@bp.renesas.com>
Add SW1 configuration for using Camera Exapansion Port (J59) Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
Enable video driver build for Renesas RA8D1 Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
cff8ae6
to
2136555
Compare
Rebasing to resolve conflicts |
|
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.
I do not find anything blocking anymore.
Waiting on feedback from other reviewers who might want some modifications done before or after merging...
I would still recommend to:
- Remove the POLL API, which is optional, and currently incompletely supported. This intermediate situation would lead to some video samples to work (capture) and others to not work (UVC webcam).
- Open an issue for filtering the video formats of the source to only support the formats allowed by this device, as soon as the API making it is introduced (no RFC for it yet).
- Consider moving the call to enable the clock in the
_init()
function, if this is possible and makes sense in your opiinion.
Thank you for the modifications and for your patience!
static int video_renesas_ra_ceu_cam_clock_init##inst(void) \ | ||
{ \ | ||
const struct device *dev = DEVICE_DT_INST_GET(inst); \ | ||
const struct video_renesas_ra_ceu_config *config = dev->config; \ | ||
int ret; \ | ||
\ | ||
if (!device_is_ready(config->cam_xclk_dev)) { \ | ||
LOG_DBG("Camera clock control device not ready"); \ | ||
return -ENODEV; \ | ||
} \ | ||
\ | ||
ret = clock_control_on(config->cam_xclk_dev, (clock_control_subsys_t)0); \ | ||
if (ret < 0) { \ | ||
LOG_DBG("Failed to enable camera clock control"); \ | ||
return ret; \ | ||
} \ | ||
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.
Would it work to call this inside video_renesas_ra_ceu_init()
directly?
if (p_args->event & CEU_EVENT_FRAME_END) { | ||
curr_vbuf = atomic_ptr_get(&data->vbuf); | ||
if (curr_vbuf && atomic_ptr_cas(&data->vbuf, curr_vbuf, NULL)) { | ||
curr_vbuf->timestamp = k_uptime_get_32(); | ||
k_fifo_put(&data->fifo_out, curr_vbuf); | ||
} |
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.
If wanting a complete support for the polling API, you may want to raise a completion signal here, or remove support for the polling API altogether (given this will be automated soon).
zephyr/drivers/video/video_sw_generator.c
Lines 312 to 314 in 5525941
if (IS_ENABLED(CONFIG_POLL) && data->sig) { | |
k_poll_signal_raise(data->sig, VIDEO_BUF_DONE); | |
} |
err = R_CEU_CaptureStart(data->fsp_ctrl, next_vbuf->buffer); | ||
if (err != FSP_SUCCESS) { | ||
atomic_ptr_clear(&data->vbuf); | ||
k_fifo_put(&data->fifo_out, next_vbuf); |
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.
If wanting a complete support for the polling API, you may want to raise a error signal here, or remove support for the polling API altogether (given this will be automated soon).
zephyr/drivers/video/video_mcux_csi.c
Line 55 in 5525941
result = VIDEO_BUF_ERROR; |
zephyr/drivers/video/video_esp32_dvp.c
Line 116 in 5525941
VIDEO_ESP32_RAISE_OUT_SIG_IF_ENABLED(VIDEO_BUF_ERROR) |
caps->min_line_count = LINE_COUNT_HEIGHT; | ||
caps->max_line_count = LINE_COUNT_HEIGHT; | ||
|
||
return video_get_caps(config->source_dev, caps); |
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.
It seems like not all image sensor resolutions will be supported because of VIDEO_RA_CEU_WIDTH_ALIGN
requirements.
The complete solution would have been to filter the list of video formats from the source to apply the padding requirement (via .width_step
and .height_step
for instance).
However this is currently slightly inconvenient as this requires setting a temporary buffer that is not freed:
zephyr/drivers/video/video_mcux_csi.c
Lines 292 to 322 in 5525941
if (config->source_dev) { | |
err = video_get_caps(config->source_dev, caps); | |
#if defined(CONFIG_VIDEO_MCUX_MIPI_CSI2RX) | |
/* | |
* On i.MX RT11xx SoCs which have MIPI CSI-2 Rx, image data from the camera sensor | |
* after passing through the pipeline (MIPI CSI-2 Rx --> Video Mux --> CSI) will be | |
* implicitly converted to a 32-bits pixel format. For example, an input in RGB565 | |
* or YUYV (2-bytes format) will become an XRGB32 or XYUV32 (4-bytes format) | |
* respectively, at the output of the CSI. So, we change the pixel formats of the | |
* source caps to reflect this. | |
*/ | |
int ind = 0; | |
while (caps->format_caps[ind].pixelformat) { | |
ind++; | |
} | |
k_heap_free(&csi_heap, fmts); | |
fmts = k_heap_alloc(&csi_heap, (ind + 1) * sizeof(struct video_format_cap), | |
K_FOREVER); | |
for (int i = 0; i <= ind; i++) { | |
memcpy(&fmts[i], &caps->format_caps[i], sizeof(fmts[i])); | |
if (fmts[i].pixelformat == VIDEO_PIX_FMT_RGB565) { | |
fmts[i].pixelformat = VIDEO_PIX_FMT_XRGB32; | |
} else if (fmts[i].pixelformat == VIDEO_PIX_FMT_YUYV) { | |
fmts[i].pixelformat = VIDEO_PIX_FMT_XYUV32; | |
} | |
} | |
caps->format_caps = fmts; | |
#endif | |
} |
So it might be possible to wait a better API to become available first.
Hello @ngphibang . All change requests have been addressed. Still remain small nits as your comment but it can be sent out later as a subsequence PR. Could you please revisit and verify it? |
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 for this contribution !
There are a few reviewer comments that haven’t been addressed yet, though none are blocking. For future PRs, it might be helpful to share more of your thoughts on the commented points — it can really help reviewers better understand your perspective.
Add support for Renesas RA CEU (Capture Engine Unit):
It works with OV7670 camera, and MIPI graphics expansion board included in the Kit