Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1525011pxa; Thu, 13 Aug 2020 10:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4JHU9KRjPPAHnibZtO/t6qMMcXDOjCAIcp17dEbqpcqN323/TdeiN66BBR5ZK7R3fOleb X-Received: by 2002:aa7:c382:: with SMTP id k2mr5525662edq.249.1597339014954; Thu, 13 Aug 2020 10:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597339014; cv=none; d=google.com; s=arc-20160816; b=diBkkcdDkyUjkdtyTc1vPRtq+05jOPEoBhMlkyKLB4YVi7lJkk2Rg7v5fY+ojcpptI gGJad2TJfv1oABOm2H+VBORAGgwR+sLYRzbs3f4uINIPLd8wd+XcSSUpsPypMcLlSB+7 460Ml0NaPeMmm97ckbZMRPWjaHYjjzuq7gATl71m+LgF+KxPyJA3QWucbYy5b6HKQokc aMzmdF0OmT+6CB0qpryl0JHeudWxa+qtRYgBq5KuGJnXaslTJ2WzFyw3ZZv1pXCFUlfm maifovR46RypqikTrfcnS7ZN2rNllNyeq7AKGG6126pcysMvBKd2o3Xbt/ks3XN7wuC0 6y1w== 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=Nv6PkBYK4X/3DnbmmmG4vxQGGoY5txKLB/AJdTc3QbY=; b=fxCIxQYjoTSobJtxclODVS/+gf0BzPwfJffC8Q5qxgyKRq58KgWWWFegW0dWknEjhu r8w5j1POQbBdVTZGcNZ8PbfduVOGxf+7keuxsnK/Sdo1PL1MD331KNMZsv25wPqIGu3C 5l1BygKp40PMBuKQpkas7ZqGyEGCJ/+MHV0V0V6cyxHI0CFLuQ41faLxdzjZSZwzfeEF XGcgUR/FUFhCRaD5/ROXV9vOYLhfm98Lm09UZQefoVXRqgJNJM9zApqwePnO8EAczSVd jkGiXdSGOZ+pca5v03RKFyD1NmDreKW61sXgNfmK+DSiq7VNi9GYRMM0ph9r8P+GQN+v HoWw== 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 q12si3681075edh.55.2020.08.13.10.16.32; Thu, 13 Aug 2020 10:16:54 -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 S1726578AbgHMROJ (ORCPT + 99 others); Thu, 13 Aug 2020 13:14:09 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:10620 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726248AbgHMROG (ORCPT ); Thu, 13 Aug 2020 13:14:06 -0400 X-IronPort-AV: E=Sophos;i="5.76,309,1592838000"; d="scan'208";a="54526448" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 14 Aug 2020 02:14:05 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 2AFF84005E0F; Fri, 14 Aug 2020 02:14:02 +0900 (JST) From: Lad Prabhakar To: Steve Longerbeam , Jacopo Mondi , Sakari Ailus , Laurent Pinchart , Paul , Hugues Fruchet Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lad Prabhakar , Prabhakar Subject: [PATCH v3 2/3] media: i2c: ov5640: Add support for BT656 mode Date: Thu, 13 Aug 2020 18:13:36 +0100 Message-Id: <20200813171337.5540-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200813171337.5540-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20200813171337.5540-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 --- 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 e36bc08bc17f..160d2857352a 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 ? @@ -2022,18 +2037,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 @@ -2057,7 +2075,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; @@ -2911,6 +2931,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