Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2104236pxa; Mon, 3 Aug 2020 07:35:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEKXC45MxIyxZ+QkarQ+8H67gf40PJVM83IKt56wk9S/K892Z5nD5XcVWWFAxAH01pEdXw X-Received: by 2002:a05:6402:1c88:: with SMTP id cy8mr16332779edb.24.1596465346027; Mon, 03 Aug 2020 07:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596465346; cv=none; d=google.com; s=arc-20160816; b=FaRzTT+rz89B6IImW2Muy7xnJwXdkNgogjQr3PeOkn11/S47nY+ymVtlzhsNBYqR7N qID7DfpyP9LQwonBY13DVvmKdWBgh/o7Q55mcUd+iDu7Deh2X+cpx9zoa01TWHOCuJOb j1HVA9vV1ELhQSgO7t2N3phOGMuoBAnev4UzIY72VqHZyZLRxablxqrq/fDcyuA55PBq Q2jJxYeio859VvKpLfJwUhslfHjpMU2MglASjEjleVSsKz/00UYZVHyM0byjgX8MFemW 3pV/hPCcxpIcIMwFMsicFAca6rtCwtd3dPIeDvkfikDvLCrM6BLeUe2IVTRgXhGglwQC 0o9A== 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=wZZlimG+Q6Ee1qnytDZrPKXHyKYmx6lUQuK+FnrxYzM=; b=zXCgJ0lFij20fN74Y4b2NBRqRbwg9evqCsXft6YTNSs9689JZuZkMW/lec3Bq8Ywi7 ljMiWntQ03FUUPl1VkE3+RGJ+ArYgmkwSaQ48tUUUIHo5SKB2DnqUO+kcIIpikGkhX7g pzBiMvNELrxy8aY8RnLDHD+dyXCyFGy5j55qpmoYTGIziqGcQYtQ19FwC4brSySAt+dc YU0GjJgrlIeh2vTNbB8ERHDia5sNk+RmLv7DeK6/ydE6easlufuUy9NCzPyn20RfbR5h hkMVOwAu8OaOoNBWReamXKuQk8rXnXVyvyjfj3kMF/ScObSgjRe/1MTUWjjZUBJy/S4f 17lg== 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 qk3si10961902ejb.323.2020.08.03.07.35.23; Mon, 03 Aug 2020 07:35:46 -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 S1728345AbgHCOc0 (ORCPT + 99 others); Mon, 3 Aug 2020 10:32:26 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:8624 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728258AbgHCOcW (ORCPT ); Mon, 3 Aug 2020 10:32:22 -0400 X-IronPort-AV: E=Sophos;i="5.75,430,1589209200"; d="scan'208";a="53537270" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 03 Aug 2020 23:32:20 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6A59B42ACBDC; Mon, 3 Aug 2020 23:32:17 +0900 (JST) From: Lad Prabhakar To: Jacopo Mondi , Steve Longerbeam , Sakari Ailus , Hugues Fruchet , Mauro Carvalho Chehab , Rob Herring , Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Prabhakar , linux-renesas-soc@vger.kernel.org, Lad Prabhakar Subject: [PATCH v2 3/4] media: i2c: ov5640: Add support for BT656 mode Date: Mon, 3 Aug 2020 15:31:46 +0100 Message-Id: <1596465107-14251-4-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596465107-14251-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <1596465107-14251-1-git-send-email-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 | 40 +++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index ec444bee2ce9..08c67250042f 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 @@ -1216,6 +1217,18 @@ 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_SOFTWARE_WAKEUP : OV5640_SOFTWARE_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 +2035,20 @@ static int ov5640_set_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 +2072,8 @@ static int ov5640_set_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 +2927,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