Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
To: Jacopo Mondi <jacopo@jmondi.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org,
	Hugues Fruchet <hugues.fruchet@st.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Biju Das <biju.das.jz@bp.renesas.com>,
	Prabhakar <prabhakar.csengg@gmail.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: [PATCH 2/2] media: i2c: ov5640: Add support for BT656 mode
Date: Fri, 31 Jul 2020 10:24:47 +0100
Message-ID: <1596187487-31403-3-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw)
In-Reply-To: <1596187487-31403-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com>

Enable support for BT656 mode.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/media/i2c/ov5640.c | 48 +++++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index ac305a5..2b23988 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -82,6 +82,7 @@
 #define OV5640_REG_VFIFO_HSIZE		0x4602
 #define OV5640_REG_VFIFO_VSIZE		0x4604
 #define OV5640_REG_JPG_MODE_SELECT	0x4713
+#define OV5640_REG_CCIR656_CTRL00	0x4730
 #define OV5640_REG_POLARITY_CTRL00	0x4740
 #define OV5640_REG_MIPI_CTRL00		0x4800
 #define OV5640_REG_DEBUG_MODE		0x4814
@@ -1213,6 +1214,17 @@ static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on)
 	return ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0, on ? 0x2 : 0x42);
 }
 
+static int ov5640_set_stream_bt656(struct ov5640_dev *sensor, bool on)
+{
+	int ret;
+
+	ret = ov5640_write_reg(sensor, OV5640_REG_CCIR656_CTRL00, on ? 0x1 : 0x00);
+	if (ret)
+		return ret;
+
+	return ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0, on ? 0x2 : 0x42);
+}
+
 static int ov5640_set_stream_mipi(struct ov5640_dev *sensor, bool on)
 {
 	int ret;
@@ -1998,18 +2010,21 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
 			 *		datasheet and hardware, 0 is active high
 			 *		and 1 is active low...)
 			 */
-			if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
-				pclk_pol = 1;
-			if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-				hsync_pol = 1;
-			if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
-				vsync_pol = 1;
-
-			ret = ov5640_write_reg(sensor, OV5640_REG_POLARITY_CTRL00,
-					       (pclk_pol << 5) | (hsync_pol << 1) | vsync_pol);
-
-			if (ret)
-				goto power_off;
+			if (sensor->ep.bus_type == V4L2_MBUS_PARALLEL) {
+				if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
+					pclk_pol = 1;
+				if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
+					hsync_pol = 1;
+				if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+					vsync_pol = 1;
+
+				ret = ov5640_write_reg(sensor, OV5640_REG_POLARITY_CTRL00,
+						       (pclk_pol << 5) | (hsync_pol << 1) |
+						       vsync_pol);
+
+				if (ret)
+					goto power_off;
+			}
 
 			/*
 			 * powerdown MIPI TX/RX PHY & disable MIPI
@@ -2033,7 +2048,9 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
 			 * - 4:		PCLK output enable
 			 * - [3:0]:	D[9:6] output enable
 			 */
-			ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x7f);
+			ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01,
+					       sensor->ep.bus_type == V4L2_MBUS_PARALLEL ?
+					       0x7f : 0x1f);
 			if (ret)
 				goto power_off;
 
@@ -2047,7 +2064,6 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
 			if (ret)
 				goto power_off;
 		}
-
 	} else {
 		if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
 			/* Reset MIPI bus settings to their default values. */
@@ -2875,8 +2891,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
 
 		if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY)
 			ret = ov5640_set_stream_mipi(sensor, enable);
-		else
+		else if (sensor->ep.bus_type == V4L2_MBUS_PARALLEL)
 			ret = ov5640_set_stream_dvp(sensor, enable);
+		else
+			ret = ov5640_set_stream_bt656(sensor, enable);
 
 		if (!ret)
 			sensor->streaming = enable;
-- 
2.7.4


  parent reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31  9:24 [PATCH 0/2] media: ov5640 feature enhancement and fixes Lad Prabhakar
2020-07-31  9:24 ` [PATCH 1/2] media: i2c: ov5640: Enable data pins on startup for DVP mode Lad Prabhakar
2020-07-31 13:03   ` Sakari Ailus
2020-07-31 13:18     ` Lad, Prabhakar
2020-07-31 15:19       ` Sakari Ailus
2020-07-31 15:23         ` Lad, Prabhakar
2020-07-31 15:31       ` Laurent Pinchart
2020-08-01  8:51         ` Lad, Prabhakar
2020-07-31 15:27   ` Laurent Pinchart
2020-08-01  8:46     ` Lad, Prabhakar
2020-07-31  9:24 ` Lad Prabhakar [this message]
2020-07-31 15:23   ` [PATCH 2/2] media: i2c: ov5640: Add support for BT656 mode Sakari Ailus
2020-07-31 15:28     ` Lad, Prabhakar

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=1596187487-31403-3-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com \
    --to=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=hugues.fruchet@st.com \
    --cc=jacopo@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=sakari.ailus@linux.intel.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

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org
	public-inbox-index linux-renesas-soc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git