Skip to content

Support for max9295d and continous clock for ov5640 and imx708 - #3511

Merged
btogorean merged 5 commits into
analogdevicesinc:gmsl/rpi-6.13.yfrom
adivd15:gmsl/rpi-6.13.y-max9295d
Sep 9, 2026
Merged

btogorean merged 5 commits into
analogdevicesinc:gmsl/rpi-6.13.yfrom
adivd15:gmsl/rpi-6.13.y-max9295d

Conversation

@adivd15

@adivd15 adivd15 commented Aug 25, 2026

Copy link
Copy Markdown
  • Added support for max9295d
  • Added support for continous clock for imx708 and ov5640
  • Added deserializer support for multiple cameras over a single GMSL link

PR Description

Serializer (max96717.c, max_ser.c)

  • New max9295d compatible / max9295d_info.
  • max_ser now emits one route per enabled PHY (MAX_SER_NUM_PHYS 1→2). Other serializers serializers report num_phys=1, so their init routing is unchanged.

Deserializer (max_des.c, max9296a.c)

  • Multiple video pipes can share one GMSL link
  • needs_unique_stream_id + set_pipe_link wired for max96716a so each camera gets a unique stream ID and is demuxed correctly.

Sensors (imx708.c, ov5640.c)

  • Continuous clock support

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from 647b8ea to cacc7d4 Compare August 25, 2026 14:22
@gastmaier gastmaier added the llm review Request a review from a LLM Reviewer label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

LLM review

This series adds MAX9295D serializer support and multi-camera-over-one-GMSL-link
support (deserializer/serializer core, imx708/ov5640 continuous-clock mode,
and a matching gen_gmsl_dts overlay example).

run: 32879832079

950477fd8712 - MAX9295D and multi-camera GMSL support

Deserializer default routing not extended for multi-pipe links: max_ser_init_state()
had its break removed so every enabled PHY gets a default route (needed for
MAX9295D's two independent camera PHYs). max_des_init_state() was only touched
by bumping routes[MAX_DES_NUM_LINKS] to routes[MAX_DES_NUM_PIPES]; its own
break after the first enabled link is still there. For the new "two cameras
behind one MAX9295D link" topology, both camera pipes live on the same
deserializer sink pad (distinguished only by sink_stream 0/1), so only the
first camera gets a default route out of the box - the second stream needs an
explicit VIDIOC_SUBDEV_S_ROUTING from userspace. This mirrors a pre-existing
limitation for multi-link setups, so it may be intentional/Streams-API-by-design,
but the new example JSON
(max96716_1_max9295d_ov5640_imx708_rpi5.json) and gen_gmsl_dts/README.md
don't mention any required manual routing step. Please confirm whether this is
expected (and document it) or whether max_des_init_state() also needs updating
to expose all pipes on a link by default.

Missing rationale comment: ov5640_set_stream_mipi() adds a SW_PWDN ->
sleep -> SW_PWUP toggle for continuous clock mode with no explanation, unlike
other OV5640 quirks documented elsewhere in the same file. See suggested fixup.

Datasheet verification

MAX96717's docling-converted datasheet (max96717.md, register map
0x330-0x335) was used to confirm the shared register logic in max96717.c is
correct (e.g. max96717_init_phy()'s phy_id * 4 shift reproduces bits[5:4]
for existing chips since their phy_hw_ids[] is {1}, not {0} - not a
regression). The MAX9295D-specific fields could not be independently verified:
the ADI docling mirror's max9295d.pdf is mismapped and returns an unrelated
legacy ADSP-216x DSP datasheet instead of the GMSL serializer datasheet. This
is a docs-infrastructure issue, not a kernel bug, but worth reporting to the
doctools maintainers.

Build/CI

bcm2712_adi_gmsl_defconfig + gcc_aarch64, make W=1: no new warnings on
the touched objects. checkpatch.pl: clean (only an informational MAINTAINERS
note, pre-existing gap for gen_gmsl_dts/, unrelated to this series).
Rendered the new example JSON with gen_gmsl_dts.py and compiled it with the
in-tree dtc: succeeds with the same pre-existing warnings as an existing
example, and reproduces identical DT output for unmodified existing configs
(no regression from the new enable_gpio/enable_vcm/clock_continuous
template options).

Suggested patches

Apply the suggested patches with:

cd path/to/repository
export GITHUB_TOKEN=ghp_***
apply-patches --repo=analogdevicesinc/linux 32879832079
Install instructions

The following one-liner installs the script if not present already:

curl -fSsL "https://raw.githubusercontent.com/analogdevicesinc/doctools/refs/heads/main/ci/scripts/apply-patches.sh"      -o ~/.local/bin/apply-patches.sh &&   grep -q "/apply-patches.sh" ~/.bashrc || echo "source ~/.local/bin/apply-patches.sh" >> $_ ; . $_

More information at AI Usage.

@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from cacc7d4 to 82dbf0d Compare August 25, 2026 19:53
@adivd15

adivd15 commented Aug 25, 2026 •

Copy link
Copy Markdown
Author

Yes the stream api is intended. Documented in gen_gmsl_dts/README.md.

Also documented the ov5640 sleep toggle for continuous mode. Leaving this scope capture here with what happens before the toggle (going from lp00->hs, this resulted in the serializer complaining about invalid clock) and after the toggle (lp11->hs transition which works).

RigolDS1

@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from 82dbf0d to ced5341 Compare August 26, 2026 07:48
@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from ced5341 to b74717a Compare August 31, 2026 12:24
Comment thread drivers/media/i2c/ov5640.c Resolved
@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from b74717a to fd537dc Compare September 3, 2026 12:13
Comment thread drivers/media/i2c/imx708.c Resolved
@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from fd537dc to bd98191 Compare September 4, 2026 12:01

@btogorean btogorean left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please split commit "media: i2c: maxim-serdes: add MAX9295D support" in 2 separate commits. One adding support for multiple cameras per GMSL link and the other one adding support for MAX9295D

Comment thread drivers/media/i2c/ov5640.c Resolved
* Add continuous clock option in the ov5640 driver.
* Add continuous clock flag in ov5640.dtsi.in.

Signed-off-by: Adrian Costea <Adrian.Costea@analog.com>
Added continuous clock option in the imx708 driver.

Added continuous clock flag in imx708.dtsi.in.

Signed-off-by: Adrian Costea <Adrian.Costea@analog.com>
Add deserializer support for routing multiple camera streams arriving
over a single GMSL link to separate pipes, and let a serializer expose
more than one camera input.

Update the DTS generator so a serializer's output port index follows the
number of connected cameras.

Signed-off-by: Adrian Costea <Adrian.Costea@analog.com>
@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from bd98191 to 3a281b0 Compare September 9, 2026 10:36
@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from 3a281b0 to c2b7e9d Compare September 9, 2026 11:35
Add the maxim,max9295d compatible, handled by the max96717 driver.

Signed-off-by: Adrian Costea <Adrian.Costea@analog.com>
Add MAX9295D serializer support in max96717.

Add a MAX9295D template and example config to the DTS generator.

Signed-off-by: Adrian Costea <Adrian.Costea@analog.com>
@adivd15
adivd15 force-pushed the gmsl/rpi-6.13.y-max9295d branch from c2b7e9d to 91aae0b Compare September 9, 2026 11:49
@btogorean
btogorean merged commit a34c3f3 into analogdevicesinc:gmsl/rpi-6.13.y Sep 9, 2026
2 checks passed
@vivekanandad-hub

Copy link
Copy Markdown

Hi ADI team,

Following the Hawk discussion with Thomas, here are the technical findings from integrating the MAX9295D support in
this PR and the subsequent internal-FSYNC support.

Our setup is:

AR0234 left ── CSI input A ─┐
MAX9295D ── one GMSL link ── MAX96724 ── KV260
AR0234 right ── CSI input B ─┘

The requirement is reliable capture from both sensors, in free-running mode and with internally generated FSYNC. The
following downstream changes address the problems encountered.

  1. Transport-ID negotiation must identify the routed serializer pipe.

References: 0002*patch

The existing deserializer code negotiates only the first pipe on each link. Both serializer stream-ID helpers also
select:

struct max_ser_pipe *pipe = &ser->pipes[0];

Consequently, the second stream depends on matching defaults instead of having its transport ID negotiated.

The MAX96724 descriptor also needs the unique-ID setting already used by MAX96716A. In the ADI branch’s layout, the
corresponding change is:

static const struct max_des_ops max96724_ops = {

  • .needs_unique_stream_id = true,
    .num_phys = 4,
    

That corrects the initial assignments, but the helpers must also resolve the actual routed transmit pipe. Our
downstream implementation adds:

static struct max_ser_pipe *
max_ser_stream_to_pipe(struct max_ser *ser, struct v4l2_subdev_state *state,
u32 pad, u32 stream)
{
struct v4l2_subdev_route *route;

    if (!max_ser_pad_is_source(ser, pad))
            return NULL;

    for_each_active_route(&state->routing, route) {
            struct max_ser_phy *phy;

            if (route->source_pad != pad || route->source_stream != stream)
                    continue;

            /* The existing internal test-pattern path uses logical pipe 0. */
            if (max_ser_pad_is_tpg(ser, route->sink_pad))
                    return &ser->pipes[0];

            phy = max_ser_pad_to_phy(ser, route->sink_pad);
            if (!phy)
                    return NULL;

            return max_ser_find_phy_pipe(ser, phy);
    }

    return NULL;

}

The setter/getter take the source pad and stream and perform this lookup under the serializer’s active-state lock. For
our single-link configuration, the deserializer iterates the active routes and reads each corresponding transmitter
ID:

ret = max_ser_get_stream_id(hw.source->sd, hw.source->pad,
route->sink_stream, &stream_id);

It then programs the matching receive pipe. This handles, for example, input B exposing software stream 0 while
transmitting transport ID 1.

The full patch also validates IDs, rejects changes to running pipes, updates cached IDs only after successful writes,
and avoids renegotiating IDs during STREAMOFF.

  1. Pixel reception must honor the programmed stream selection.

Reference: 0003*patch

The generic driver programs each receive pipe’s link and transport ID, but MAX96724’s STREAM_SEL_ALL automatic-
selection mode can interfere with that mapping. This becomes visible when receive pipe 0 must select transport ID 1.

In max96724_set_pipe_enable(), our fix sets the selection policy before enabling reception:

if (enable && priv->info->supports_pipe_stream_autoselect) {
ret = regmap_assign_bits(priv->regmap, MAX96724_VIDEO_PIPE_EN,
MAX96724_VIDEO_PIPE_EN_STREAM_SEL_ALL,
des->mode == MAX_SERDES_GMSL_TUNNEL_MODE);
if (ret)
return ret;
}

return regmap_assign_bits(priv->regmap, MAX96724_VIDEO_PIPE_EN,
MAX96724_VIDEO_PIPE_EN_MASK(index), enable);

This clears STREAM_SEL_ALL in pixel mode while retaining the existing tunnel-mode policy. The capability check
protects variants without that control, and the masked writes preserve other pipe-enable bits.

  1. FSYNC must start after both participating sources are armed.

Reference: 0007*

The existing implementation can program FSYNC when an inactive control changes and can start it before the upstream
sources are enabled.

Our fix caches the requested configuration while inactive and determines FSYNC transitions from all configured active
sensor routes:

old_fsync_active = max_des_all_streams_active(priv,
priv->streams_masks);
new_fsync_active = max_des_all_streams_active(priv, streams_masks);

start_fsync = !old_fsync_active && new_fsync_active;
stop_fsync = old_fsync_active && !new_fsync_active;

max_des_all_streams_active() compares the requested stream masks with the expected masks collected from active
routing. For this Hawk configuration, both sensor routes must be present.

Receive pipes are enabled as their streams are requested. The generator starts only after the final required upstream
enable succeeds:

if (enable) {
ret = max_des_enable_disable_streams(priv, state, pad,
updated_streams_mask, enable);
if (ret)
goto err_revert_active_enable;

    if (start_fsync) {
            ret = max_des_set_fsync(des, true);
            if (ret)
                    goto err_disable_enabled_streams;
    }

}

The full patch also stops FSYNC before disarming the first participating sensor, includes error-path cleanup, and
rejects active mode or interval changes with -EBUSY.

  1. FSYNC membership must include both receive pipes.

Reference: 0008*

This correction resolved the remaining one-eye FSYNC failure.

With both streams arriving over physical link A, AUTO_FS_LINKS in register 0x04AF allowed one pipe to output frames
while the other produced no CSI output from a retained LOW trigger level.

The FS_LINK_x bits select video pipes. Both bits are needed even though both streams arrive over the same physical
link.

The patch adds:

#define MAX96724_FSYNC_15_FS_LINKS GENMASK(3, 0)

In max96724_set_fsync(), the mask defaults to the existing automatic policy. For variants with the new fsync_per_pipe
capability, it selects enabled pipes explicitly:

unsigned int fs_links = MAX96724_FSYNC_15_AUTO_FS_LINKS;

/* Within the enabled-FSYNC configuration path: */
if (priv->info->fsync_per_pipe) {
fs_links = 0;
for (i = 0; i < des->info->num_pipes; i++) {
if (des->pipes[i].enabled)
fs_links |= BIT(i);
}
fs_links = FIELD_PREP(MAX96724_FSYNC_15_FS_LINKS, fs_links);
}

ret = regmap_write(priv->regmap, MAX96724_FSYNC_15,
MAX96724_FSYNC_15_FS_USE_XTAL |
MAX96724_FSYNC_15_FS_GPIO_TYPE |
fs_links);
if (ret)
return ret;

The capability is enabled for MAX96724/F, preserving MAX96712’s existing behavior.

Please carry this together with patch 0007, so all participating pipes are enabled before the mask is computed. The
FSYNC selection control at 0x04AF is separate from the pixel-stream selection control at 0x00F4 addressed by patch
0003.

  1. Serializer teardown must follow the resource allocated during probe.

Reference: 0001 / 61a89bf5ad64.

Our camera peripherals use the serializer’s i2c-gate bus. Overlay removal through xmutil/dfx-mgrd caused:

i2c_atr_del_adapter
max_ser_i2c_adapter_deinit
max_ser_remove
max96717_remove
...
of_overlay_remove
...
configfs_rmdir

Probe had allocated a mux, but teardown looked up i2c-gate again after the node had been detached. It then selected
ATR cleanup with priv->atr == NULL.

The corrected selection is:

static void max_ser_i2c_adapter_deinit(struct max_ser_priv *priv)
{
if (priv->mux)
max_ser_i2c_mux_deinit(priv);
else
max_ser_i2c_atr_deinit(priv);
}

The cleanup helpers guard NULL resources, remove their child adapters, and clear the saved pointers after cleanup.
This makes teardown independent of the firmware hierarchy being dismantled.

  1. Complete the MAX9295D binding and AR0234 trigger support.

References: 0004 / bc7d06c26230

The MAX9295D binding needs its compatible-specific port layout:

Interface MAX9295D port
━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━
CSI input A 0
───────────── ───────────────
CSI input B 1
───────────── ───────────────
GMSL output 2

The existing single-input binding describes port 1 as the GMSL output. Patch 0004 corrects this while preserving the
layout for other compatibles.

// references
0001-media-i2c-maxim-serdes-fix-serializer-overlay-teardown.patch
0002-media-i2c-maxim-serdes-negotiate-stream-IDs-per-rout.patch
0003-media-i2c-max96724-select-pixel-streams-explicitly-b.patch
0004-dt-bindings-media-maxim-max96717-describe-MAX9295D-p.patch
0007-media-i2c-maxim-serdes-arm-sources-before-fsync.patch
0008-media-i2c-max96724-select-enabled-video-pipes-for-fsync.patch

Could you please fold these fixes, or equivalent implementations, into the maintained ADI driver and next upstream
revision, preserving existing single-sensor configurations?

Thanks,
Vivekananda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm review Request a review from a LLM Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants