All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Rui Miguel Silva <rmfrfs@gmail.com>,
	kernel@pengutronix.de, Fabio Estevam <festevam@gmail.com>,
	linux-imx@nxp.com, Steve Longerbeam <slongerbeam@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Marek Vasut <marex@denx.de>
Subject: [PATCH 10/23] media: imx: imx7_mipi_csis: Store CSI-2 data type in format structure
Date: Tue, 13 Apr 2021 05:30:01 +0300	[thread overview]
Message-ID: <20210413023014.28797-11-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20210413023014.28797-1-laurent.pinchart@ideasonboard.com>

Replace the register value stored in the csis_pix_format structure with
the CSI-2 data type. The register value is simply computed from the data
type using a shift. This prepares for i.MX8MP support that needs the
same data type in a different hardware register.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 71 +++++++++++++---------
 1 file changed, 42 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 695cb8aebcab..94afb103f951 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -170,13 +170,7 @@
 #define MIPI_CSIS_ISPCFG_PIXEL_MODE_DUAL	(1 << 12)
 #define MIPI_CSIS_ISPCFG_PIXEL_MODE_QUAD	(2 << 12)	/* i.MX8M[MNP] only */
 #define MIPI_CSIS_ISPCFG_ALIGN_32BIT		BIT(11)
-#define MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT	(0x1e << 2)
-#define MIPI_CSIS_ISPCFG_FMT_RAW8		(0x2a << 2)
-#define MIPI_CSIS_ISPCFG_FMT_RAW10		(0x2b << 2)
-#define MIPI_CSIS_ISPCFG_FMT_RAW12		(0x2c << 2)
-#define MIPI_CSIS_ISPCFG_FMT_RAW14		(0x2d << 2)
-/* User defined formats, x = 1...4 */
-#define MIPI_CSIS_ISPCFG_FMT_USER(x)		((0x30 + (x) - 1) << 2)
+#define MIPI_CSIS_ISPCFG_FMT(fmt)		((fmt) << 2)
 #define MIPI_CSIS_ISPCFG_FMT_MASK		(0x3f << 2)
 
 /* ISP Image Resolution register */
@@ -223,6 +217,25 @@
 
 #define DEFAULT_SCLK_CSIS_FREQ			166000000UL
 
+/* MIPI CSI-2 Data Types */
+#define MIPI_CSI2_DATA_TYPE_YUV420_8		0x18
+#define MIPI_CSI2_DATA_TYPE_YUV420_10		0x19
+#define MIPI_CSI2_DATA_TYPE_LE_YUV420_8		0x1a
+#define MIPI_CSI2_DATA_TYPE_CS_YUV420_8		0x1c
+#define MIPI_CSI2_DATA_TYPE_CS_YUV420_10	0x1d
+#define MIPI_CSI2_DATA_TYPE_YUV422_8		0x1e
+#define MIPI_CSI2_DATA_TYPE_YUV422_10		0x1f
+#define MIPI_CSI2_DATA_TYPE_RGB565		0x22
+#define MIPI_CSI2_DATA_TYPE_RGB666		0x23
+#define MIPI_CSI2_DATA_TYPE_RGB888		0x24
+#define MIPI_CSI2_DATA_TYPE_RAW6		0x28
+#define MIPI_CSI2_DATA_TYPE_RAW7		0x29
+#define MIPI_CSI2_DATA_TYPE_RAW8		0x2a
+#define MIPI_CSI2_DATA_TYPE_RAW10		0x2b
+#define MIPI_CSI2_DATA_TYPE_RAW12		0x2c
+#define MIPI_CSI2_DATA_TYPE_RAW14		0x2d
+#define MIPI_CSI2_DATA_TYPE_USER(x)		(0x30 + (x))
+
 enum {
 	ST_POWERED	= 1,
 	ST_STREAMING	= 2,
@@ -324,7 +337,7 @@ struct csi_state {
 
 struct csis_pix_format {
 	u32 code;
-	u32 fmt_reg;
+	u32 data_type;
 	u8 width;
 };
 
@@ -332,85 +345,85 @@ static const struct csis_pix_format mipi_csis_formats[] = {
 	/* YUV formats. */
 	{
 		.code = MEDIA_BUS_FMT_UYVY8_1X16,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
+		.data_type = MIPI_CSI2_DATA_TYPE_YUV422_8,
 		.width = 16,
 	},
 	/* RAW (Bayer and greyscale) formats. */
 	{
 		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW8,
 		.width = 8,
 	}, {
 		.code = MEDIA_BUS_FMT_SGBRG8_1X8,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW8,
 		.width = 8,
 	}, {
 		.code = MEDIA_BUS_FMT_SGRBG8_1X8,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW8,
 		.width = 8,
 	}, {
 		.code = MEDIA_BUS_FMT_SRGGB8_1X8,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW8,
 		.width = 8,
 	}, {
 		.code = MEDIA_BUS_FMT_Y8_1X8,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW8,
 		.width = 8,
 	}, {
 		.code = MEDIA_BUS_FMT_SBGGR10_1X10,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW10,
 		.width = 10,
 	}, {
 		.code = MEDIA_BUS_FMT_SGBRG10_1X10,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW10,
 		.width = 10,
 	}, {
 		.code = MEDIA_BUS_FMT_SGRBG10_1X10,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW10,
 		.width = 10,
 	}, {
 		.code = MEDIA_BUS_FMT_SRGGB10_1X10,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW10,
 		.width = 10,
 	}, {
 		.code = MEDIA_BUS_FMT_Y10_1X10,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW10,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW10,
 		.width = 10,
 	}, {
 		.code = MEDIA_BUS_FMT_SBGGR12_1X12,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW12,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW12,
 		.width = 12,
 	}, {
 		.code = MEDIA_BUS_FMT_SGBRG12_1X12,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW12,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW12,
 		.width = 12,
 	}, {
 		.code = MEDIA_BUS_FMT_SGRBG12_1X12,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW12,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW12,
 		.width = 12,
 	}, {
 		.code = MEDIA_BUS_FMT_SRGGB12_1X12,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW12,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW12,
 		.width = 12,
 	}, {
 		.code = MEDIA_BUS_FMT_Y12_1X12,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW12,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW12,
 		.width = 12,
 	}, {
 		.code = MEDIA_BUS_FMT_SBGGR14_1X14,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW14,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW14,
 		.width = 14,
 	}, {
 		.code = MEDIA_BUS_FMT_SGBRG14_1X14,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW14,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW14,
 		.width = 14,
 	}, {
 		.code = MEDIA_BUS_FMT_SGRBG14_1X14,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW14,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW14,
 		.width = 14,
 	}, {
 		.code = MEDIA_BUS_FMT_SRGGB14_1X14,
-		.fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW14,
+		.data_type = MIPI_CSI2_DATA_TYPE_RAW14,
 		.width = 14,
 	}
 };
@@ -502,7 +515,7 @@ static void __mipi_csis_set_format(struct csi_state *state)
 	/* Color format */
 	val = mipi_csis_read(state, MIPI_CSIS_ISP_CONFIG_CH(0));
 	val &= ~(MIPI_CSIS_ISPCFG_ALIGN_32BIT | MIPI_CSIS_ISPCFG_FMT_MASK);
-	val |= state->csis_fmt->fmt_reg;
+	val |= MIPI_CSIS_ISPCFG_FMT(state->csis_fmt->data_type);
 	mipi_csis_write(state, MIPI_CSIS_ISP_CONFIG_CH(0), val);
 
 	/* Pixel resolution */
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2021-04-13  2:31 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  2:29 [PATCH 00/23] media: imx: imx7-mipi-csis: Add i.MX8MM support Laurent Pinchart
2021-04-13  2:29 ` [PATCH 01/23] media: imx: imx7_mipi_csis: Fix logging of only error event counters Laurent Pinchart
2021-04-26 11:01   ` Frieder Schrempf
2021-05-15 21:54     ` Laurent Pinchart
2021-04-13  2:29 ` [PATCH 02/23] media: imx: imx7_mipi_csis: Count the CSI-2 debug interrupts Laurent Pinchart
2021-04-26 11:39   ` Frieder Schrempf
2021-04-13  2:29 ` [PATCH 03/23] media: imx: imx7_mipi_csis: Update ISP_CONFIG macros for quad pixel mode Laurent Pinchart
2021-04-26 11:41   ` Frieder Schrempf
2021-04-13  2:29 ` [PATCH 04/23] media: imx: imx7_mipi_csis: Move static data to top of mipi_csis_dump_regs() Laurent Pinchart
2021-04-26 11:46   ` Frieder Schrempf
2021-04-13  2:29 ` [PATCH 05/23] media: imx: imx7_mipi_csis: Minimize locking in get/set format Laurent Pinchart
2021-04-13  2:29 ` [PATCH 06/23] media: imx: imx7_mipi_csis: Don't set subdev data Laurent Pinchart
2021-04-13  2:29 ` [PATCH 07/23] media: imx: imx7-mipi-csis: Reorganize code in sections Laurent Pinchart
2021-04-13  2:29 ` [PATCH 08/23] media: imx: imx7_mipi_csis: Set the CLKSETTLE register field Laurent Pinchart
2021-04-13  2:30 ` [PATCH 09/23] media: imx: imx7_mipi_csis: Drop unused csis_hw_reset structure Laurent Pinchart
2021-04-13  2:30 ` Laurent Pinchart [this message]
2021-04-13  2:30 ` [PATCH 11/23] media: imx: imx7_mipi_csis: Drop csi_state phy field Laurent Pinchart
2021-04-13  2:30 ` [PATCH 12/23] media: imx: imx7_mipi_csis: Rename mipi_sd to sd Laurent Pinchart
2021-04-13  2:30 ` [PATCH 13/23] media: imx: imx7_mipi_csis: Rename csi_state flag field to state Laurent Pinchart
2021-04-13  2:30 ` [PATCH 14/23] media: imx: imx7_mipi_csis: Turn csi_state irq field into local variable Laurent Pinchart
2021-04-13  2:30 ` [PATCH 15/23] media: imx: imx7_mipi_csis: Don't pass pdev to mipi_csis_parse_dt() Laurent Pinchart
2021-04-13  2:30 ` [PATCH 16/23] media: imx: imx7_mipi_csis: Pass csi_state to mipi_csis_subdev_init() Laurent Pinchart
2021-04-13  2:30 ` [PATCH 17/23] media: imx: imx7_mipi_csis: Drop csi_state pdev field Laurent Pinchart
2021-04-13  2:30 ` [PATCH 18/23] media: imx: imx7_mipi_csis: Make csi_state num_clocks field unsigned Laurent Pinchart
2021-04-13  2:30 ` [PATCH 19/23] media: imx: imx7_mipi_csis: Reorganize csi_state structure Laurent Pinchart
2021-04-13  2:30 ` [PATCH 20/23] media: imx: imx7_mipi_csis: Reorganize mipi_csis_probe() Laurent Pinchart
2021-04-13  2:30 ` [PATCH 21/23] media: imx: imx7_mipi_csis: Reject invalid data-lanes settings Laurent Pinchart
2021-04-13  2:30 ` [PATCH 22/23] dt-bindings: media: nxp,imx7-mipi-csi2: Add i.MX8MM support Laurent Pinchart
2021-04-13 16:00   ` Rob Herring
2021-04-18 20:15   ` [PATCH v1.1 " Laurent Pinchart
2021-04-13  2:30 ` [PATCH 23/23] media: imx: imx7_mipi_csis: " Laurent Pinchart
2021-04-27 10:57   ` Marco Felsch
2021-05-15 22:10     ` Laurent Pinchart
2021-04-15  9:27 ` [PATCH 00/23] media: imx: imx7-mipi-csis: " Rui Miguel Silva
2021-04-18 20:21   ` Laurent Pinchart
2021-04-18 20:14 ` [PATCH 24/23] media: imx: imx7_mipi_csis: Update MAINTAINERS Laurent Pinchart
2021-04-18 22:22   ` Rui Miguel Silva
2021-04-21 15:27 ` [PATCH 00/23] media: imx: imx7-mipi-csis: Add i.MX8MM support Tim Harvey
2021-04-26 10:35   ` Frieder Schrempf
2021-04-27 11:00     ` Marco Felsch
2021-05-15 22:46       ` Laurent Pinchart
2021-05-04 15:59 ` [PATCH 00/23] media: imx: imx7-mipi-csis: Add i.MX8MM support / imx8mq support Martin Kepplinger
2021-05-15 22:55   ` Laurent Pinchart
2021-05-18 14:39     ` Martin Kepplinger
2021-05-19  1:14       ` Laurent Pinchart
2021-05-19  9:33         ` Martin Kepplinger
2021-05-19 15:21         ` Martin Kepplinger
2021-05-19 15:46           ` Laurent Pinchart
2021-05-20 10:54             ` Martin Kepplinger
2021-05-20 12:37               ` Laurent Pinchart
2021-05-21  9:25                 ` Martin Kepplinger
2021-05-21  9:43                   ` Laurent Pinchart
2021-05-21 11:02                     ` Martin Kepplinger
2021-05-21 13:36                       ` Laurent Pinchart
2021-05-25  7:32                         ` Martin Kepplinger
2021-05-25 11:25                           ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210413023014.28797-11-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-media@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=p.zabel@pengutronix.de \
    --cc=rmfrfs@gmail.com \
    --cc=slongerbeam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.