[RESEND PATCH 2/2] media: i2c: maxim-serdes: resolve V4L2_FIELD_ANY in set_fmt
From: vunny . sodhi
Date: Wed Dec 02 2026 - 06:36:51 EST
From: "Sodhi, Vunny" <vunny.sodhi@xxxxxxxxx>
V4L2_FIELD_ANY (0) is the value applications use to tell the driver that
any field order is acceptable, and it is also what a zero-initialized
struct v4l2_mbus_framefmt carries when userspace does not care about the
field. Per Documentation/userspace-api/media/v4l/field-order.rst, the
driver must then pick a field order supported by the hardware, and
"Drivers must never return V4L2_FIELD_ANY".
max_ser_set_fmt() and max_des_set_fmt() instead copy the requested format
into the pad state unchanged. V4L2_FIELD_ANY is thus stored as the active
format and returned to userspace, violating the API. It also breaks
pipeline validation, since the upstream sensor correctly reports a
concrete field (V4L2_FIELD_NONE):
v4l2_subdev_link_validate_default: field does not match (source 1, sink 0)
and VIDIOC_STREAMON fails with -EPIPE.
Resolve V4L2_FIELD_ANY to V4L2_FIELD_NONE, matching the default format
the drivers already use. Other field values are left untouched.
Signed-off-by: Sodhi, Vunny <vunny.sodhi@xxxxxxxxx>
---
drivers/media/i2c/maxim-serdes/max_des.c | 3 +++
drivers/media/i2c/maxim-serdes/max_ser.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/drivers/media/i2c/maxim-serdes/max_des.c b/drivers/media/i2c/maxim-serdes/max_des.c
index 37f438608616..8e9ebfae0956 100644
--- a/drivers/media/i2c/maxim-serdes/max_des.c
+++ b/drivers/media/i2c/maxim-serdes/max_des.c
@@ -1923,6 +1923,9 @@ static int max_des_set_fmt(struct v4l2_subdev *sd,
if (format->format.code == ~0U)
format->format.code = MEDIA_BUS_FMT_UYVY8_1X16;
+ if (format->format.field == V4L2_FIELD_ANY)
+ format->format.field = V4L2_FIELD_NONE;
+
fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream);
if (!fmt)
return -EINVAL;
diff --git a/drivers/media/i2c/maxim-serdes/max_ser.c b/drivers/media/i2c/maxim-serdes/max_ser.c
index 1c4cec2efb95..b4c1afd6cad4 100644
--- a/drivers/media/i2c/maxim-serdes/max_ser.c
+++ b/drivers/media/i2c/maxim-serdes/max_ser.c
@@ -510,6 +510,9 @@ static int max_ser_set_fmt(struct v4l2_subdev *sd,
if (format->format.code == ~0U)
format->format.code = MEDIA_BUS_FMT_UYVY8_1X16;
+ if (format->format.field == V4L2_FIELD_ANY)
+ format->format.field = V4L2_FIELD_NONE;
+
fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream);
if (!fmt)
return -EINVAL;
--
2.43.0