From 9d32b06230f7477afdef9b9eb100f3cda0d8ba2e Mon Sep 17 00:00:00 2001
From: Naushir Patuck <naush@raspberrypi.com>
Date: Tue, 14 Feb 2023 20:58:59 +0000
Subject: [PATCH 0542/1085] v4l2: Add pisp compression format support to v4l2

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c  | 12 ++++++++----
 include/uapi/linux/media-bus-format.h | 14 ++++++++++++++
 include/uapi/linux/videodev2.h        | 12 ++++++++----
 3 files changed, 30 insertions(+), 8 deletions(-)

--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1520,10 +1520,14 @@ static void v4l_fill_fmtdesc(struct v4l2
 		case V4L2_PIX_FMT_MT2110T:	descr = "Mediatek 10bit Tile Mode"; break;
 		case V4L2_PIX_FMT_MT2110R:	descr = "Mediatek 10bit Raster Mode"; break;
 		case V4L2_PIX_FMT_RPI_BE:	descr = "PiSP Opaque Format"; break;
-		case V4L2_PIX_FMT_PISP_COMP_RGGB:
-		case V4L2_PIX_FMT_PISP_COMP_GRBG:
-		case V4L2_PIX_FMT_PISP_COMP_GBRG:
-		case V4L2_PIX_FMT_PISP_COMP_BGGR: descr = "PiSP Bayer Compressed Format"; break;
+		case V4L2_PIX_FMT_PISP_COMP1_RGGB:
+		case V4L2_PIX_FMT_PISP_COMP1_GRBG:
+		case V4L2_PIX_FMT_PISP_COMP1_GBRG:
+		case V4L2_PIX_FMT_PISP_COMP1_BGGR: descr = "PiSP Bayer Compressed Format"; break;
+		case V4L2_PIX_FMT_PISP_COMP2_RGGB:
+		case V4L2_PIX_FMT_PISP_COMP2_GRBG:
+		case V4L2_PIX_FMT_PISP_COMP2_GBRG:
+		case V4L2_PIX_FMT_PISP_COMP2_BGGR: descr = "PiSP Bayer Comp 2"; break;
 		default:
 			if (fmt->description[0])
 				return;
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -176,4 +176,18 @@
 /* Sensor ancillary metadata formats - next is 0x7002 */
 #define MEDIA_BUS_FMT_SENSOR_DATA		0x7002
 
+/* PiSP Formats */
+#define MEDIA_BUS_FMT_PISP_COMP1_RGGB		0x8001
+#define MEDIA_BUS_FMT_PISP_COMP1_GRBG		0x8002
+#define MEDIA_BUS_FMT_PISP_COMP1_GBRG		0x8003
+#define MEDIA_BUS_FMT_PISP_COMP1_BGGR		0x8004
+#define MEDIA_BUS_FMT_PISP_COMP2_RGGB		0x8005
+#define MEDIA_BUS_FMT_PISP_COMP2_GRBG		0x8006
+#define MEDIA_BUS_FMT_PISP_COMP2_GBRG		0x8007
+#define MEDIA_BUS_FMT_PISP_COMP2_BGGR		0x8008
+
+#define MEDIA_BUS_FMT_PISP_FE_CONFIG		0x8100
+#define MEDIA_BUS_FMT_PISP_FE_STATS		0x8101
+#define MEDIA_BUS_FMT_PISP_BE_CONFIG		0x8200
+
 #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -824,10 +824,14 @@ struct v4l2_pix_format {
 
 /* The pixel format for all our buffers (the precise format is found in the config buffer). */
 #define V4L2_PIX_FMT_RPI_BE		v4l2_fourcc('R', 'P', 'B', 'P')
-#define V4L2_PIX_FMT_PISP_COMP_RGGB	v4l2_fourcc('P', 'C', 'R', 'G')
-#define V4L2_PIX_FMT_PISP_COMP_GRBG	v4l2_fourcc('P', 'C', 'G', 'R')
-#define V4L2_PIX_FMT_PISP_COMP_GBRG	v4l2_fourcc('P', 'C', 'G', 'B')
-#define V4L2_PIX_FMT_PISP_COMP_BGGR	v4l2_fourcc('P', 'C', 'B', 'G')
+#define V4L2_PIX_FMT_PISP_COMP1_RGGB	v4l2_fourcc('P', 'C', '1', 'R')
+#define V4L2_PIX_FMT_PISP_COMP1_GRBG	v4l2_fourcc('P', 'C', '1', 'G')
+#define V4L2_PIX_FMT_PISP_COMP1_GBRG	v4l2_fourcc('P', 'C', '1', 'g')
+#define V4L2_PIX_FMT_PISP_COMP1_BGGR	v4l2_fourcc('P', 'C', '1', 'B')
+#define V4L2_PIX_FMT_PISP_COMP2_RGGB	v4l2_fourcc('P', 'C', '2', 'R')
+#define V4L2_PIX_FMT_PISP_COMP2_GRBG	v4l2_fourcc('P', 'C', '2', 'G')
+#define V4L2_PIX_FMT_PISP_COMP2_GBRG	v4l2_fourcc('P', 'C', '2', 'g')
+#define V4L2_PIX_FMT_PISP_COMP2_BGGR	v4l2_fourcc('P', 'C', '2', 'B')
 
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
