diff mbox series

MEDIA: Add support for RAW14 and RAW16 to IPUv3 CSI

Message ID m35zcyx2mt.fsf@t19.piap.pl
State New
Headers show
Series MEDIA: Add support for RAW14 and RAW16 to IPUv3 CSI | expand

Commit Message

Krzysztof HaƂasa May 14, 2020, 9:54 a.m. UTC
It appears the i.MX camera interface is missing support for 14- and 16-bit
Bayer and B&W-only formats. Add it.

Signed-off-by: Krzysztof Halasa <khalasa@piap.pl>
diff mbox series

Patch

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index 8ae301eef643..658c173bebdf 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -128,6 +128,7 @@  struct ipu_csi {
 #define MIPI_DT_RAW10		0x2b
 #define MIPI_DT_RAW12		0x2c
 #define MIPI_DT_RAW14		0x2d
+#define MIPI_DT_RAW16		0x2e
 
 /*
  * Bitfield of CSI bus signal polarities and modes.
@@ -157,6 +158,7 @@  enum ipu_csi_data_width {
 	IPU_CSI_DATA_WIDTH_8   = 1,
 	IPU_CSI_DATA_WIDTH_10  = 3,
 	IPU_CSI_DATA_WIDTH_12  = 5,
+	IPU_CSI_DATA_WIDTH_14  = 7,
 	IPU_CSI_DATA_WIDTH_16  = 9,
 };
 
@@ -303,6 +305,24 @@  static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code,
 		cfg->mipi_dt = MIPI_DT_RAW12;
 		cfg->data_width = IPU_CSI_DATA_WIDTH_12;
 		break;
+	case MEDIA_BUS_FMT_SBGGR14_1X14:
+	case MEDIA_BUS_FMT_SGBRG14_1X14:
+	case MEDIA_BUS_FMT_SGRBG14_1X14:
+	case MEDIA_BUS_FMT_SRGGB14_1X14:
+	case MEDIA_BUS_FMT_Y14_1X14:
+		cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
+		cfg->mipi_dt = MIPI_DT_RAW14;
+		cfg->data_width = IPU_CSI_DATA_WIDTH_14;
+		break;
+	case MEDIA_BUS_FMT_SBGGR16_1X16:
+	case MEDIA_BUS_FMT_SGBRG16_1X16:
+	case MEDIA_BUS_FMT_SGRBG16_1X16:
+	case MEDIA_BUS_FMT_SRGGB16_1X16:
+	case MEDIA_BUS_FMT_Y16_1X16:
+		cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
+		cfg->mipi_dt = MIPI_DT_RAW16;
+		cfg->data_width = IPU_CSI_DATA_WIDTH_16;
+		break;
 	case MEDIA_BUS_FMT_JPEG_1X8:
 		/* TODO */
 		cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_JPEG;
diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
index 84fa53ffb13f..60a374374d16 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -64,7 +64,7 @@ 
 #define MEDIA_BUS_FMT_RGB121212_1X36		0x1019
 #define MEDIA_BUS_FMT_RGB161616_1X48		0x101a
 
-/* YUV (including grey) - next is	0x202e */
+/* YUV (including grey) - next is	0x202f */
 #define MEDIA_BUS_FMT_Y8_1X8			0x2001
 #define MEDIA_BUS_FMT_UV8_1X8			0x2015
 #define MEDIA_BUS_FMT_UYVY8_1_5X8		0x2002
@@ -87,6 +87,7 @@ 
 #define MEDIA_BUS_FMT_YUYV12_2X12		0x201e
 #define MEDIA_BUS_FMT_YVYU12_2X12		0x201f
 #define MEDIA_BUS_FMT_Y14_1X14			0x202d
+#define MEDIA_BUS_FMT_Y16_1X16			0x202e
 #define MEDIA_BUS_FMT_UYVY8_1X16		0x200f
 #define MEDIA_BUS_FMT_VYUY8_1X16		0x2010
 #define MEDIA_BUS_FMT_YUYV8_1X16		0x2011