Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1110355pxx; Tue, 27 Oct 2020 08:28:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySlUe3LcMUdyWwELR6ccIcvvIIMSJGnUVofP99GUy1YuZIakSJq7WP9VxTgvt0TQD5bdpk X-Received: by 2002:a17:906:b841:: with SMTP id ga1mr2943124ejb.29.1603812517463; Tue, 27 Oct 2020 08:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603812517; cv=none; d=google.com; s=arc-20160816; b=yBPYC/tACzCRSllHGG1oy9TLxFpPvUB/vCcwFpljHsf2aJT4r/LVJ7rpi8IEfl4ZJ1 DU1J4uyoflgQSnlw4SraYNsPNkJ6BO9rdC9DmDxoVOAEsOXG2AuW6b1DH1wqXoykjQRq htGJwg80GjXF7BMKXNa2ixquL3Am8HFzTHDzzHLrhQ62EMxAIGaqsTkn2Bkr2Osd6grT 0dHztv+nxp62vB8zvAqInZU2VRt3E+egmVYVBFtD2zguFLNUlh5IQAf89Et60DG8WpGZ KVF4a4WoWGRLJ0m/872/OWbiOc/apiOH/quI4P2Rx4AUpcawqyF7p5n8ghwmHJpsRmhR jW7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5NFKpn1y66E3LXPyIZ3uXphQ6hDj2/aV50oK1tR/RK4=; b=L6hqeRn0wJ/jcJNXutE/EMIvbk0mWHmFGNZlkhklDmDxWtIzYNuTjvD228ReYgKU/A gVtD30Y5icq+oCnyj8ANJwf8mkYWAuzaU1dk/oJQtixj7k3Vc8iGnp3tktqBTasYorce 5W17fLSlCKaz4uBtGQpvSzIqCIzJ08DoT0RUS0FsCohAZ+Oc5QnyUh2qzzBDxt3cp9IW 1pTlUAEDaJJfhFNoUQNqrNWizgT3ckeOKyzN2f+STvnHOiEKCZxCXxhkS4VmMeslM+W9 tO013PuX1V+3f663NwUbx2vJpDvUd3Yk+cCN4yUa6HOpYmnGlqQhJHwdd/fB+b+jGIQR xYxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="BCswkk/N"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch19si1229262ejb.738.2020.10.27.08.28.15; Tue, 27 Oct 2020 08:28:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b="BCswkk/N"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S460370AbgJ0OeL (ORCPT + 99 others); Tue, 27 Oct 2020 10:34:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:59164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760073AbgJ0OcS (ORCPT ); Tue, 27 Oct 2020 10:32:18 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CAD8A20754; Tue, 27 Oct 2020 14:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809136; bh=2KDM5giWTkpSl0vThZqdIFOFtpRLWpZM41aUFH9zGmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BCswkk/Nbynm93t1NxxWyfsBSDhheuYbypoZYX4hfdsqgmYszE0GicHC/wqOSW3+m 8rwIim6rnS6ghR554o86PK/uqSO+yiU+7FEf7MzSWLCbx5yimQq2dDclluNWc7w1rl Of7Xb/3NiK5x4FQeL6gRMai/eId4d+QhTPlexsbM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lad Prabhakar , Biju Das , Jacopo Mondi , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 081/408] media: i2c: ov5640: Enable data pins on poweron for DVP mode Date: Tue, 27 Oct 2020 14:50:19 +0100 Message-Id: <20201027135458.821278055@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lad Prabhakar [ Upstream commit 576f5d4ba8f672953513280510abf9a736b015cc ] During testing this sensor on iW-RainboW-G21D-Qseven platform in 8-bit DVP mode with rcar-vin bridge noticed the capture worked fine for the first run (with yavta), but for subsequent runs the bridge driver waited for the frame to be captured. Debugging further noticed the data lines were enabled/disabled in stream on/off callback and dumping the register contents 0x3017/0x3018 in ov5640_set_stream_dvp() reported the correct values, but yet frame capturing failed. To get around this issue data lines are enabled in s_power callback. (Also the sensor remains in power down mode if not streaming so power consumption shouldn't be affected) Fixes: f22996db44e2d ("media: ov5640: add support of DVP parallel interface") Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das Tested-by: Jacopo Mondi Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov5640.c | 73 +++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 3c6ad2dd9c0e1..be6c882dd1d54 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -274,8 +274,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl) /* YUV422 UYVY VGA@30fps */ static const struct reg_value ov5640_init_setting_30fps_VGA[] = { {0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0}, - {0x3103, 0x03, 0, 0}, {0x3017, 0x00, 0, 0}, {0x3018, 0x00, 0, 0}, - {0x3630, 0x36, 0, 0}, + {0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0}, {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0}, @@ -1272,33 +1271,6 @@ static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on) if (ret) return ret; - /* - * enable VSYNC/HREF/PCLK DVP control lines - * & D[9:6] DVP data lines - * - * PAD OUTPUT ENABLE 01 - * - 6: VSYNC output enable - * - 5: HREF output enable - * - 4: PCLK output enable - * - [3:0]: D[9:6] output enable - */ - ret = ov5640_write_reg(sensor, - OV5640_REG_PAD_OUTPUT_ENABLE01, - on ? 0x7f : 0); - if (ret) - return ret; - - /* - * enable D[5:0] DVP data lines - * - * PAD OUTPUT ENABLE 02 - * - [7:2]: D[5:0] output enable - */ - ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, - on ? 0xfc : 0); - 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); @@ -2055,6 +2027,40 @@ static int ov5640_set_power_mipi(struct ov5640_dev *sensor, bool on) return 0; } +static int ov5640_set_power_dvp(struct ov5640_dev *sensor, bool on) +{ + int ret; + + if (!on) { + /* Reset settings to their default values. */ + ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x00); + ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0x00); + return 0; + } + + /* + * enable VSYNC/HREF/PCLK DVP control lines + * & D[9:6] DVP data lines + * + * PAD OUTPUT ENABLE 01 + * - 6: VSYNC output enable + * - 5: HREF output enable + * - 4: PCLK output enable + * - [3:0]: D[9:6] output enable + */ + ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x7f); + if (ret) + return ret; + + /* + * enable D[5:0] DVP data lines + * + * PAD OUTPUT ENABLE 02 + * - [7:2]: D[5:0] output enable + */ + return ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0xfc); +} + static int ov5640_set_power(struct ov5640_dev *sensor, bool on) { int ret = 0; @@ -2069,11 +2075,12 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on) goto power_off; } - if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) { + if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) ret = ov5640_set_power_mipi(sensor, on); - if (ret) - goto power_off; - } + else + ret = ov5640_set_power_dvp(sensor, on); + if (ret) + goto power_off; if (!on) ov5640_set_power_off(sensor); -- 2.25.1