Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13383271ybl; Sun, 29 Dec 2019 10:33:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwWONSx+wyA49CquIJOQLJoJp3S3aVJhiIFgzUTk6yuuRH2TCNjiArF5nqOUWR0DpI9T/VN X-Received: by 2002:a05:6830:3001:: with SMTP id a1mr57319010otn.254.1577644435040; Sun, 29 Dec 2019 10:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577644435; cv=none; d=google.com; s=arc-20160816; b=wx5hhLrUE1IBoFqvrmPPSKvOiuhQrQqFmywvDRhdr+cjqzGkcPX5xByfNDvR7Kk6pI Q3LXz7dzw/Lfu9sKgPdAs+PjCyf9qvw+vjW629+uhP8HWN8tIGUva78hniWx7gHvZ9BE fJhfufsj1kwhsQ5nBtEHO2kx2qiGjVOTw1OHr0lnEbSvRxVeaniwKRpnec7VV8j1w7mE XU9ylgLKad3xhdKPiDZ84IIMhi/4vG2AIddXirW8ScOXMaaXMYE4kVYLzMQ6VMU83jbm cJqn6KHHiO1vEJ73eiqUVSHIB89KJZa2Smda+agBufpy1EFwM3iYw0RJ2lMROKfmSq2a +g7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sqS46LUjjKIRX3IVtNCP+OYtSCYoOagNuZWL2YkLNCw=; b=KMunk0+pq95FQaumtQGwWLVptWM1Dtu9OkToYpnggj44yxhaVCe8sQYf2KbZxDzYxl nwrhNLvl2oROdiDgpUqjdYrjXZVlaX31OGKScONxNNyGsOYqk/2ylTpIb5wT58TfQXJB K1lF/LjoQLIq8fitfu1FI6R+wWayGiqjQMiJjlwabAfjINhT6Dfg4LSY4Mil7Ugc6mUj HFJ2S2TJBHYxgoYcI5JGkFlBkR33t8M22XPP6Tynree8JmpFbcQW1uygwgOxenUOa6oI QLyjElQYdsTx+tFhxQa6y6oUR9L8Id0HEeoOJhaaXwryCJgSQ/pZazarl/lEEeOGbezx rinw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bWI2XDaM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k23si15022096oiw.238.2019.12.29.10.33.30; Sun, 29 Dec 2019 10:33:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bWI2XDaM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727275AbfL2RWY (ORCPT + 99 others); Sun, 29 Dec 2019 12:22:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:38618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbfL2RWV (ORCPT ); Sun, 29 Dec 2019 12:22:21 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A924121D7E; Sun, 29 Dec 2019 17:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640141; bh=J0M+hVSbn3Atgj5jvsgT6mAvuARmsdyTjsgas4eUwH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bWI2XDaMx60vnNnRlTpsydmUNgazCLsNsgQOwu94sRJzzcU7GZehT38Co49YBFqz8 mAmhlEPDGbssPatTTZ48RsnGMdKaOk4+KIqiW43jnPt9QanCiJdSo2o4gvqRrtBC9q gHqoih1llvYTMP458RYlXytXzlSUPXbgppJDi6hQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janusz Krzysztofik , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 034/161] media: ov6650: Fix stored crop rectangle not in sync with hardware Date: Sun, 29 Dec 2019 18:18:02 +0100 Message-Id: <20191229162408.819102087@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Janusz Krzysztofik [ Upstream commit 1463b371aff0682c70141f7521db13cc4bbf3016 ] The driver stores crop rectangle settings supposed to be in line with hardware state in a device private structure. Since the driver initial submission, crop rectangle width and height settings are not updated correctly when rectangle offset settings are applied on hardware. If an error occurs while the device is updated, the stored settings my no longer reflect hardware state and consecutive calls to .get_selection() as well as .get/set_fmt() may return incorrect information. That in turn may affect ability of a bridge device to use correct DMA transfer settings if such incorrect informamtion on active frame format returned by .get/set_fmt() is used. Assuming a failed update of the device means its actual settings haven't changed, update crop rectangle width and height settings stored in the device private structure correctly while the rectangle offset is successfully applied on hardware so the stored values always reflect actual hardware state to the extent possible. Fixes: 2f6e2404799a ("[media] SoC Camera: add driver for OV6650 sensor") Signed-off-by: Janusz Krzysztofik Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov6650.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 81fa21ed2599..348296be4925 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -485,6 +485,7 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1); if (!ret) { + priv->rect.width += priv->rect.left - sel->r.left; priv->rect.left = sel->r.left; ret = ov6650_reg_write(client, REG_HSTOP, (sel->r.left + sel->r.width) >> 1); @@ -494,6 +495,7 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, ret = ov6650_reg_write(client, REG_VSTRT, sel->r.top >> 1); } if (!ret) { + priv->rect.height += priv->rect.top - sel->r.top; priv->rect.top = sel->r.top; ret = ov6650_reg_write(client, REG_VSTOP, (sel->r.top + sel->r.height) >> 1); -- 2.20.1