From patchwork Tue Jul 10 18:36:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10517895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C403E603D7 for ; Tue, 10 Jul 2018 18:37:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B441D2929E for ; Tue, 10 Jul 2018 18:37:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6782292A5; Tue, 10 Jul 2018 18:37:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D5FF2929E for ; Tue, 10 Jul 2018 18:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389964AbeGJSgn (ORCPT ); Tue, 10 Jul 2018 14:36:43 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:44845 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389946AbeGJSgn (ORCPT ); Tue, 10 Jul 2018 14:36:43 -0400 X-Originating-IP: 2.224.242.101 Received: from w540.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 3A4382000E; Tue, 10 Jul 2018 18:36:26 +0000 (UTC) From: Jacopo Mondi To: mchehab@kernel.org, laurent.pinchart@ideasonboard.com, maxime.ripard@bootlin.com, sam@elite-embedded.com, jagan@amarulasolutions.com, festevam@gmail.com, pza@pengutronix.de, steve_longerbeam@mentor.com, hugues.fruchet@st.com, loic.poulain@linaro.org, daniel@zonque.org Cc: Jacopo Mondi , linux-media@vger.kernel.org Subject: [PATCH v2 2/2] media: ov5640: Fix timings setup code Date: Tue, 10 Jul 2018 20:36:08 +0200 Message-Id: <1531247768-15362-3-git-send-email-jacopo@jmondi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531247768-15362-1-git-send-email-jacopo@jmondi.org> References: <1531247768-15362-1-git-send-email-jacopo@jmondi.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Samuel Bobrowicz The current code, when changing the mode and changing the scaling or sampling parameters, will look at the horizontal and vertical total size, which, since 5999f381e023 ("media: ov5640: Add horizontal and vertical totals") has been moved from the static register initialization to after the mode change. That means that the values are no longer set up before the code retrieves them, which is obviously a bug. In addition, restore timings settings in the initial configuration register blob only, to have MIPI capture operations work again. Fixes: 5999f381e023 ("media: ov5640: Add horizontal and vertical totals") Signed-off-by: Samuel Bobrowicz Signed-off-by: Maxime Ripard [re-introduce timing parameters in initial configuration blob] Signed-off-by: Jacopo Mondi --- Compared to Maxime's and Sam's original version, this one re-introduces timing configuration parameters in the init_settings configuration blob. On my testing platform this fixes MIPI capture operations, that with the original patch version applied was failing anyway. Thanks j --- drivers/media/i2c/ov5640.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 7bbd1d7..bbcb908 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -277,7 +277,9 @@ static const struct reg_value ov5640_init_setting_30fps_VGA[] = { {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, - {0x3810, 0x00, 0, 0}, + {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, + {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, + {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, @@ -1484,6 +1486,10 @@ static int ov5640_set_mode_exposure_calc(struct ov5640_dev *sensor, if (ret < 0) return ret; + ret = ov5640_set_timings(sensor, mode); + if (ret < 0) + return ret; + /* read capture VTS */ ret = ov5640_get_vts(sensor); if (ret < 0) @@ -1611,6 +1617,10 @@ static int ov5640_set_mode_direct(struct ov5640_dev *sensor, if (ret < 0) return ret; + ret = ov5640_set_timings(sensor, mode); + if (ret < 0) + return ret; + /* turn auto gain/exposure back on for direct mode */ ret = __v4l2_ctrl_s_ctrl(sensor->ctrls.auto_gain, 1); if (ret) @@ -1658,10 +1668,6 @@ static int ov5640_set_mode(struct ov5640_dev *sensor, if (ret < 0) return ret; - ret = ov5640_set_timings(sensor, mode); - if (ret < 0) - return ret; - ret = ov5640_set_binning(sensor, dn_mode != SCALING); if (ret < 0) return ret;