Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1587374pxk; Fri, 4 Sep 2020 13:20:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxka53s/IArIHuPH4JLbhbC9/twPXTewYI2V4/dXNFivtoY6UH17ykeTqB9GP3M7cgLQdVX X-Received: by 2002:a17:906:7856:: with SMTP id p22mr9066852ejm.262.1599250828433; Fri, 04 Sep 2020 13:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599250828; cv=none; d=google.com; s=arc-20160816; b=MeJbRyH2ZGhKmlUlwb2DMZHzc52HIpR7xIDhSmqvglXDF8uDao+vZssvlx1CvW1IXg bMVV/20jUYhasgU+u/Wa6EvVRJ3fMOGeY/HSwwXpAMQYaFvN7qU1dbt+rbqlQooanMii bsvhWHxqsIg5D/y174Wks3HXHWqZUr2Pk5lnAyehPIeVZsL12Hegv5GEddBgDDkMNtnS AZBLfFrslI8V6pyuMeLqNaVhjFKOOuPcF92BLoHLVfIbULKreg8JUykoyfc5jVM5JQ+y NlJbF1slE1E+I2gYiaorbJ65kEtd1td+Y12E3ib0ec2V9ju3f1PIU2FmJbVn/wx9PEUo 6JsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=T6kpBV+Wg3SLgyzsevgVsWKkNjsyq9oe/k/rPjAyfUE=; b=WBh24lq9vVGt49HxJFdF2PURSMXjaPezaRL613Y2JqSRYIfLVEkTAEaewCjLjQPeIP Tc3PlKlKOvmopFTjxrf4vbwskKsJ4FhHktuBNVGgGbp7QZeGY8omY98LI1XQ17RHEaNb DJCQ3dmeZqn7EknhD56mmGncJHgodfvsVoFh0MByeJ36W9iZVOC+hH0dortKhes8XrZW cIYajzONXwx7teif+3mStzJj3VaHmX5Bn91VhswGgVmaWBusXGSHFb1W8geewLN0XrEI 0FMxdq37y9e8bQ+CqDf5oh5CiQJ37dm4ltYk/Orc7fGrJtqXZb2XCmV2mc/G4h7kYYkN W5Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si5768462ejl.424.2020.09.04.13.20.05; Fri, 04 Sep 2020 13:20:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbgIDUTI (ORCPT + 99 others); Fri, 4 Sep 2020 16:19:08 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:15105 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728157AbgIDUTB (ORCPT ); Fri, 4 Sep 2020 16:19:01 -0400 X-IronPort-AV: E=Sophos;i="5.76,391,1592838000"; d="scan'208";a="56193963" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 05 Sep 2020 05:18:59 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 1F18B400C4EC; Sat, 5 Sep 2020 05:18:56 +0900 (JST) From: Lad Prabhakar To: Jacopo Mondi , Sakari Ailus , Laurent Pinchart , Steve Longerbeam , Paul , Hugues Fruchet Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lad Prabhakar , Biju Das , Prabhakar , Mauro Carvalho Chehab Subject: [PATCH v4 5/6] media: i2c: ov5640: Add support for BT656 mode Date: Fri, 4 Sep 2020 21:18:34 +0100 Message-Id: <20200904201835.5958-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200904201835.5958-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20200904201835.5958-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable support for BT656 mode. Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 46 ++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 6834ebc1995f..96daeb5d6a27 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -84,6 +84,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 @@ -1215,6 +1216,20 @@ static int ov5640_set_autogain(struct ov5640_dev *sensor, bool on) BIT(1), on ? 0 : BIT(1)); } +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 ? + OV5640_REG_SYS_CTRL0_SW_PWUP : + OV5640_REG_SYS_CTRL0_SW_PWDN); +} + static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on) { return ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0, on ? @@ -2020,18 +2035,21 @@ static int ov5640_set_power_dvp(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; + 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); - ret = ov5640_write_reg(sensor, OV5640_REG_POLARITY_CTRL00, - (pclk_pol << 5) | (hsync_pol << 1) | vsync_pol); - - if (ret) - return ret; + if (ret) + return ret; + } /* * powerdown MIPI TX/RX PHY & disable MIPI @@ -2055,7 +2073,9 @@ static int ov5640_set_power_dvp(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) return ret; @@ -2905,6 +2925,8 @@ 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 if (sensor->ep.bus_type == V4L2_MBUS_BT656) + ret = ov5640_set_stream_bt656(sensor, enable); else ret = ov5640_set_stream_dvp(sensor, enable); -- 2.17.1