On Wed Apr 30 02:28:59 2025 +0300, Laurent Pinchart wrote:
> The RWPF source pad media bus code can only be different from the sink
> pad code when enabling color space conversion, which can only convert
> between RGB and YUV. If the sink pad code is HSV, no conversion is
> possible. Fix the pad set format handler to reflect this hardware
> limitation.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> Reviewed-by: Tomi Valkeinen <tomi.valkeinen+rene...@ideasonboard.com>
> Link: 
> https://lore.kernel.org/r/20250429232904.26413-5-laurent.pinchart+rene...@ideasonboard.com
> Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/platform/renesas/vsp1/vsp1_rwpf.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c 
b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c
index 9d38203e73d0..1b4bac7b7cfa 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c
@@ -76,11 +76,20 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
        format = v4l2_subdev_state_get_format(state, fmt->pad);
 
        if (fmt->pad == RWPF_PAD_SOURCE) {
+               const struct v4l2_mbus_framefmt *sink_format =
+                       v4l2_subdev_state_get_format(state, RWPF_PAD_SINK);
+
                /*
                 * The RWPF performs format conversion but can't scale, only the
-                * format code can be changed on the source pad.
+                * format code can be changed on the source pad when converting
+                * between RGB and YUV.
                 */
-               format->code = fmt->format.code;
+               if (sink_format->code != MEDIA_BUS_FMT_AHSV8888_1X32 &&
+                   fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32)
+                       format->code = fmt->format.code;
+               else
+                       format->code = sink_format->code;
+
                fmt->format = *format;
                goto done;
        }

Reply via email to