From 8d53cc5b4b2a6f9baed7a0aa801a39ad9dce9bf8 Mon Sep 17 00:00:00 2001
From: Naushir Patuck <naush@raspberrypi.com>
Date: Thu, 26 Oct 2023 08:55:24 +0100
Subject: [PATCH] drivers: media: pisp_be: Add back V4L2_PIX_FMT_RPI_BE format

Add the opaque V4L2_PIX_FMT_RPI_BE format back to the format list as it
is needed for the verification test suite. Also set the default format
to YUV420 non-multiplanar.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 drivers/media/platform/raspberrypi/pisp_be/pisp_be.c     | 9 ++++++---
 .../media/platform/raspberrypi/pisp_be/pisp_be_formats.h | 5 +++++
 2 files changed, 11 insertions(+), 3 deletions(-)

--- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
+++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
@@ -1230,8 +1230,11 @@ static int try_format(struct v4l2_format
 		return verify_be_pix_format(f, node);
 
 	fmt = find_format(pixfmt);
-	if (!fmt)
-		fmt = find_format(V4L2_PIX_FMT_YUV420M);
+	if (!fmt) {
+		dev_dbg(pispbe->dev, "%s: [%s] Format not found, defaulting to YUV420\n",
+			__func__, NODE_NAME(node));
+		fmt = find_format(V4L2_PIX_FMT_YUV420);
+	}
 
 	f->fmt.pix_mp.pixelformat = fmt->fourcc;
 	f->fmt.pix_mp.num_planes = fmt->num_planes;
@@ -1576,7 +1579,7 @@ static void node_set_default_format(stru
 	} else {
 		struct v4l2_format f = {0};
 
-		f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YUV420M;
+		f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YUV420;
 		f.fmt.pix_mp.width = 1920;
 		f.fmt.pix_mp.height = 1080;
 		f.type = node->buf_type;
--- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be_formats.h
+++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be_formats.h
@@ -457,6 +457,11 @@ static const struct pisp_be_format suppo
 		.colorspace_mask    = V4L2_COLORSPACE_MASK_RAW,
 		.colorspace_default = V4L2_COLORSPACE_RAW,
 	},
+	/* Opaque BE format for HW verification. */
+	{
+		.fourcc		    = V4L2_PIX_FMT_RPI_BE,
+		.align		    = 32,
+	},
 };
 
 static const struct pisp_be_format meta_out_supported_formats[] = {
