Re: [PATCH v5 5/6] media: qcom: camss: Take the link frequency from the CSI-2 transmitter
From: bod
Date: Wed Nov 25 2026 - 10:09:36 EST
On 2026-09-28 17:45 +0530, Hitesh Patel wrote:
> camss_get_link_freq() walks the pipeline up to an entity with the
> MEDIA_ENT_F_CAM_SENSOR function and reads the link frequency there.
> The CSIPHY settle count and the CSID clock are then derived from it.
>
> The frequency the receiver has to be programmed for is the one on the
> CSI-2 bus, which belongs to whatever drives that bus. When the sensor
> is wired straight to the CSIPHY that is the sensor, and the walk gives
> the right answer. When a CSI-2 to CSI-2 bridge sits in between, such
> as a GMSL or FPD-Link deserializer, the bridge re-times the data onto
> its own output at its own rate: it may aggregate several sensors onto
> one link, forward one sensor at a different rate, or generate a test
> pattern with no sensor at all. The sensor's rate is then not what
> arrives at the SoC, and the CSIPHY does not lock.
>
> The walk can also fail before reaching a sensor. A deserializer has
> one sink pad per serial link and the walk always follows pad 0; a
> sensor attached to any other link is never found and streaming is
> refused with "Cannot get CSI2 transmitter's link frequency".
>
> Add camss_find_transmitter_pad(), which stops at the first entity that
> is not a CAMSS receiver, i.e. at the external subdev feeding the
> CSIPHY, and ask that pad with v4l2_get_link_freq(). The helper queries
> the transmitter through .get_mbus_config first and falls back to its
> V4L2_CID_LINK_FREQ and V4L2_CID_PIXEL_RATE controls, so a bridge and a
> bare sensor are both handled by the standard mechanism.
>
> camss_get_pixel_clock() reads V4L2_CID_PIXEL_RATE and describes the
> same bus, so it uses the transmitter pad as well. For a sensor
> connected directly to a CSIPHY the transmitter is the sensor, so
> neither the pad found nor the value returned changes.
>
> camss_find_sensor_pad() stays for the frame skip query in the gen1 VFE,
> which is a genuine sensor operation and whose result that VFE does
> program into the hardware.
This commit log is a wall of text. Please whittle it down to a few
scrutable statements.
The code is straight forward so a commit log as verbose as this smells of
AI gen. It's filler when what is required is information.
> Signed-off-by: Hitesh Patel <hitesh@xxxxxxxxxxxxxx>
> ---
> drivers/media/platform/qcom/camss/camss.c | 80 +++++++++++++++++++----
> 1 file changed, 69 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 23f3cc30a1..79facd0133 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -4619,28 +4619,86 @@ struct media_pad *camss_find_sensor_pad(struct media_entity *entity)
> }
> }
>
> +/*
> + * camss_is_receiver_subdev - Test whether a subdev is a CAMSS CSI-2 receiver
> + * @camss: CAMSS device
> + * @sd: Subdevice to test
> + *
> + * Return true for a CSIPHY or CSID belonging to @camss, false for anything
> + * else, in particular for the external subdev transmitting to them.
> + */
> +static bool camss_is_receiver_subdev(struct camss *camss,
> + struct v4l2_subdev *sd)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < camss->res->csiphy_num; i++)
> + if (sd == &camss->csiphy[i].subdev)
> + return true;
TPG should be included in this disjunction list.
> + for (i = 0; i < camss->res->csid_num; i++)
> + if (sd == &camss->csid[i].subdev)
> + return true;
> +
> + return false;
> +}
> +
> +/*
> + * camss_find_transmitter_pad - Find the pad of the CSI-2 transmitter
> + * @entity: Media entity in the current pipeline
> + *
> + * Walk the pipeline upstream through the CAMSS receiver subdevs and return the
> + * source pad of the first entity that is not one of them: the CSI-2
> + * transmitter driving the SoC.
This text really reads weirdly - looks like LLMese.
"Walk the pipeline of CAMSS subdevices. Return the source-pad of the first
entity that is not a CAMSS subdevice. That entity will be the CSI-2
trasmitter driving the CSI decoder."
---
bod