Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13342470ybl; Sun, 29 Dec 2019 09:42:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyu2MD/fT2CkHZRP2/zm48GDVjtvwMxjqpp87s4TqLQphAXg5R5BbwbTy0Z/XoWZKtKI/Zu X-Received: by 2002:a9d:730e:: with SMTP id e14mr65849976otk.62.1577641331845; Sun, 29 Dec 2019 09:42:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577641331; cv=none; d=google.com; s=arc-20160816; b=jbPq6mre49NVwNPOsrXm0I7MnhpivBApxcCwYb5xehuzGM//KmI4S5xO7pvuwGZy6g g41ntL53iLNbW2E+awbdu6YfGqzgAsIpYISfCBC+I8T4zMYxf7y7Cg1H4mldXXuQffvF qM6DFBTxpKyA7iAAySKXTCBmtz5fNGokQn7svwHcvkG+Kwt7MAi3n4CpxWfM7apjm678 qJyF+M7oi6CluQyQRkaPlr/sBkbrr7OBI9bukCCbxzXI9voiWgZhntOgd+WHZt4Ws8tl zEkmKh1n7f67+2VFdf3lArilmuSnL7F24LIvELeq1PTnC+ELeU+EDKYEf7FP1/+3M/xE JVLw== 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=sYZGcokoX7GkaDaHwyInEP+bteH7NzYSAHnhJ9uq4n0=; b=O9b2EAasfa5tIjLRmAKYAM9vYISag4jS0CXxIHT7Pm69o6k4dwqnkG3ce1UcIcjFfS dcryG+4uTKck2VuLSJNkmtOeUBentlUUzgYDo/neEDf3uvJcHLyDl/yzdES9nalpuoSk fitvz6sYIjyaj43xsqQw+tj4WUPRvuaTvfjQ5VQpbK+NJC0EbbtAPD9DQPTYcp5E6bYy zxdm7t1nK71GvUirxXWJW8kocuQ8+hNAR1D5ONEAkkbmh8zeOuucboE5aGv06/QdOUT3 hHsn25h2TcPISnQ/fH6XvtYJrYRFSPkb2TAV+JpAC2NjmoZFwu/MxiIuz0WyAYj5BCmx xt5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rxVPIBVr; 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 m7si10719258oih.7.2019.12.29.09.42.00; Sun, 29 Dec 2019 09:42:11 -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=rxVPIBVr; 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 S1730167AbfL2Rkq (ORCPT + 99 others); Sun, 29 Dec 2019 12:40:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:58368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728832AbfL2RbS (ORCPT ); Sun, 29 Dec 2019 12:31:18 -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 E9886207FF; Sun, 29 Dec 2019 17:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640677; bh=IKl3Z/XjmJ//7QNafY/cu/s4LPpoLCIhNTMq43rmXKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxVPIBVruLS2k7AV/HbIs/oVuOFrGhAmh3qHbbuEus3+ai7muSLLBAxszRQXYESt6 zUjPK2RTF4CV/b56gGNFF9FCOZ0NqXiBI/5ghe/m1Y01Nn3z/8OK6WS7L/mWyyG3uh q7cLtRFXquRgaG0RF3kQLTwYZS+DUVV+j/Dp5/B8= 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.19 044/219] media: ov6650: Fix stored crop rectangle not in sync with hardware Date: Sun, 29 Dec 2019 18:17:26 +0100 Message-Id: <20191229162514.606664845@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@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 60109442a072..c5aadd8dd23f 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