From: Arash Golgol <arash.golgol@gmail.com>
To: linux-media@vger.kernel.org
Cc: paulk@sys-base.io, mchehab@kernel.org, wens@kernel.org,
jernej.skrabec@gmail.com, samuel@sholland.org,
linux-sunxi@lists.linux.dev,
Arash Golgol <arash.golgol@gmail.com>
Subject: [PATCH] media: sun6i-mipi-csi2: Propagate format to source pad in TRY mode
Date: Mon, 26 Jan 2026 13:51:49 +0330 [thread overview]
Message-ID: <20260126102149.39563-1-arash.golgol@gmail.com> (raw)
sun6i-mipi-csi2 does not support any format conversion. So the format
on sink and source pad must always match. This limitation is handled for
ACTIVE state via mbus_format member of bridge private structure.
To enforce this limitation in TRY state, user space should only be able
to set format on sink pad. The sink format must be propagated to source
pad to ensure consistent behavior.
This also aligns the driver with userspace relying on media controller
based format negotiation.
Signed-off-by: Arash Golgol <arash.golgol@gmail.com>
---
.../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
index b06cb73015cd..6ee0f6685663 100644
--- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
@@ -369,15 +369,26 @@ static int sun6i_mipi_csi2_set_fmt(struct v4l2_subdev *subdev,
struct v4l2_mbus_framefmt *mbus_format = &format->format;
struct mutex *lock = &csi2_dev->bridge.lock;
+ /* The format on the source pad always matches the sink pad. */
+ if (format->pad != SUN6I_MIPI_CSI2_PAD_SINK)
+ return v4l2_subdev_get_fmt(subdev, state, format);
+
mutex_lock(lock);
sun6i_mipi_csi2_mbus_format_prepare(mbus_format);
- if (format->which == V4L2_SUBDEV_FORMAT_TRY)
- *v4l2_subdev_state_get_format(state, format->pad) =
- *mbus_format;
- else
+ if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+ struct v4l2_mbus_framefmt *fmt;
+
+ fmt = v4l2_subdev_state_get_format(state, format->pad);
+ *fmt = *mbus_format;
+
+ /* Propagate the format to the source pad. */
+ fmt = v4l2_subdev_state_get_format(state, SUN6I_MIPI_CSI2_PAD_SOURCE);
+ *fmt = *mbus_format;
+ } else {
csi2_dev->bridge.mbus_format = *mbus_format;
+ }
mutex_unlock(lock);
--
2.34.1
next reply other threads:[~2026-01-26 10:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 10:21 Arash Golgol [this message]
2026-02-04 0:02 ` [PATCH] media: sun6i-mipi-csi2: Propagate format to source pad in TRY mode Laurent Pinchart
2026-02-04 6:15 ` arash golgol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260126102149.39563-1-arash.golgol@gmail.com \
--to=arash.golgol@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=paulk@sys-base.io \
--cc=samuel@sholland.org \
--cc=wens@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox