Skip to content

Conversation

thaoluonguw
Copy link
Contributor

Add support for Renesas RA CEU (Capture Engine Unit):

  • Add video driver use CEU
  • Add dts for CEU on RA8M1 and RA8D1
  • Enable CEU support for EK-RA8D1
  • Add support for EK-RA8D1 on Video capture to LVGL sample.
    It works with OV7670 camera, and MIPI graphics expansion board included in the Kit

Copy link

github-actions bot commented Jun 25, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_renesas DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Jun 25, 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.

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.

@josuah
Copy link
Contributor

josuah commented Jun 26, 2025

[blocking ❌]
In order to make sure this driver always compiles even after Video APIs are refactored, you may want to add it to this test that will run on CI on every video-related commit:
tests/drivers/build_all/video/app.overlay

}
}

static int video_renesas_ra_ceu_get_format(const struct device *dev, struct video_format *fmt)
Copy link
Contributor

@ngphibang ngphibang Jun 27, 2025

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

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a _csi variant coming at some point. This would become ra_csi_get_format then I guess...

scrot_20250711_142621_1172x179

Copy link
Contributor

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.

Copy link
Contributor

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.

@thaoluonguw thaoluonguw force-pushed the support_renesas_ra_ceu branch from 92a4b3b to 03bdbce Compare July 4, 2025 04:15
@github-actions github-actions bot added the area: Shields Shields (add-on boards) label Jul 4, 2025
Copy link
Contributor

@khoa-nguyen-18 khoa-nguyen-18 left a 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>;
Copy link
Contributor

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

thenguyenyf
thenguyenyf previously approved these changes Jul 21, 2025
Copy link
Contributor

@thenguyenyf thenguyenyf left a 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.

@josuah
Copy link
Contributor

josuah commented Jul 22, 2025

FYI, to summarize what allows this PR to be merged in practice:

  • The "change requests" are both to add this board to the "build-all" target so that CI keeps compiling the driver making sure it works in the future (comment)

  • A git conflict preventing it to be merged.

Then of course letting time for PR author to check all comments.

@leiche-cid
Copy link

Hi, thanks for your work, any plans to move this forward?

@leiche-cid
Copy link

@thaoluonguw @KhanhNguyen-RVC Politely asking, is there any plans to move this work forward?

@quytranpzz
Copy link
Contributor

@thaoluonguw @KhanhNguyen-RVC Politely asking, is there any plans to move this work forward?

@leiche-cid, Sorry for the late response. I’ve rebased and added a test case in the build_all yaml.
@ngphibang , @josuah: Please take a look. Thank you very much.

thenguyenyf
thenguyenyf previously approved these changes Sep 12, 2025
KhanhNguyen-RVC and others added 8 commits September 15, 2025 06:22
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>
@quytranpzz
Copy link
Contributor

Rebasing to resolve conflicts

Copy link

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 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!

Comment on lines +449 to +466
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; \
} \
Copy link
Contributor

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?

Comment on lines +78 to +83
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);
}
Copy link
Contributor

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

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);
Copy link
Contributor

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

result = VIDEO_BUF_ERROR;

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);
Copy link
Contributor

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:

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.

@thenguyenyf
Copy link
Contributor

thenguyenyf commented Sep 17, 2025

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?

Copy link
Contributor

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

@henrikbrixandersen henrikbrixandersen merged commit 009144a into zephyrproject-rtos:main Sep 17, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Pinctrl area: Samples Samples area: Shields Shields (add-on boards) area: Video Video subsystem platform: Renesas RA Renesas Electronics Corporation, RA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants