Skip to content

drivers: video: alif_cam: handle dual endpoint stream control#458

Open
Shivakumar-AlifSemi wants to merge 1 commit intoalifsemi:mainfrom
Shivakumar-AlifSemi:video-alif-cam-dual-ep-support
Open

drivers: video: alif_cam: handle dual endpoint stream control#458
Shivakumar-AlifSemi wants to merge 1 commit intoalifsemi:mainfrom
Shivakumar-AlifSemi:video-alif-cam-dual-ep-support

Conversation

@Shivakumar-AlifSemi
Copy link
Copy Markdown
Contributor

Skip video_stream_stop on endpoint_dev when ISP endpoint is active to avoid stopping a shared stream. Ignore -EBUSY on stream start as the pipeline may already be running via ISP. Add CAM_CFG register log on stream start for debugging.

Skip video_stream_stop on endpoint_dev when ISP endpoint is active
to avoid stopping a shared stream. Ignore -EBUSY on stream start as
the pipeline may already be running via ISP. Add CAM_CFG register
log on stream start for debugging.

Signed-off-by: Shivakumar Malke <shivakumar.malke@alifsemi.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts stream start/stop behavior for the Alif camera driver when dual endpoints (direct + ISP) can share the same underlying pipeline, preventing unintended stream shutdowns and tolerating “already running” scenarios.

Changes:

  • Skip video_stream_stop() on endpoint_dev when the ISP endpoint is active to avoid stopping a shared pipeline.
  • Treat -EBUSY from video_stream_start() as non-fatal and continue startup.
  • Add a CAM_CFG register log on stream start to aid debugging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

data->is_streaming = false;
video_stream_stop(config->endpoint_dev);
if (!config->isp_ep) {
video_stream_stop(config->endpoint_dev);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

video_stream_stop() return value is ignored. If stopping the endpoint fails (e.g., transient I/O error), the driver will continue as if the stream stopped cleanly. Capture and handle/log the return code (at least LOG_WRN/LOG_ERR) so failures are visible during debugging and triage.

Suggested change
video_stream_stop(config->endpoint_dev);
int ret = video_stream_stop(config->endpoint_dev);
if (ret < 0) {
LOG_WRN("Failed to stop video endpoint stream: %d", ret);
}

Copilot uses AI. Check for mistakes.
if (ret) {
if (ret && ret != -EBUSY) {
LOG_ERR("Failed to start streaming of Video pipeline!");
return -EIO;
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

On error (excluding -EBUSY), this discards the underlying video_stream_start() error by always returning -EIO. Returning ret (or mapping specific errors intentionally) makes failures actionable for callers and preserves error semantics.

Suggested change
return -EIO;
return ret;

Copilot uses AI. Check for mistakes.
Comment on lines +541 to +544
LOG_INF("CAM_CFG: 0x%08x | AXI_PORT_EN: %d | ISP_PORT_EN: %d",
sys_read32(regs + CAM_CFG),
!!(sys_read32(regs + CAM_CFG) & CAM_CFG_AXI_PORT_EN),
!!(sys_read32(regs + CAM_CFG) & CAM_CFG_ISP_PORT_EN));
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

This reads CAM_CFG three times. Read the register once into a local variable and derive the fields from that value to avoid redundant bus reads and potential inconsistencies if the register can change between reads.

Suggested change
LOG_INF("CAM_CFG: 0x%08x | AXI_PORT_EN: %d | ISP_PORT_EN: %d",
sys_read32(regs + CAM_CFG),
!!(sys_read32(regs + CAM_CFG) & CAM_CFG_AXI_PORT_EN),
!!(sys_read32(regs + CAM_CFG) & CAM_CFG_ISP_PORT_EN));
uint32_t cam_cfg = sys_read32(regs + CAM_CFG);
LOG_INF("CAM_CFG: 0x%08x | AXI_PORT_EN: %d | ISP_PORT_EN: %d",
cam_cfg,
!!(cam_cfg & CAM_CFG_AXI_PORT_EN),
!!(cam_cfg & CAM_CFG_ISP_PORT_EN));

Copilot uses AI. Check for mistakes.
hw_cam_start_video_capture(dev);
LOG_DBG("Stream started");

LOG_INF("CAM_CFG: 0x%08x | AXI_PORT_EN: %d | ISP_PORT_EN: %d",
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

LOG_INF on every stream start may be noisy in production and can add overhead during frequent start/stop cycles. Consider downgrading to LOG_DBG or gating behind a debug/config option if this is primarily for troubleshooting.

Suggested change
LOG_INF("CAM_CFG: 0x%08x | AXI_PORT_EN: %d | ISP_PORT_EN: %d",
LOG_DBG("CAM_CFG: 0x%08x | AXI_PORT_EN: %d | ISP_PORT_EN: %d",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants