Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2461204ybe; Tue, 3 Sep 2019 13:14:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwctr5B/yDofJoVc441IEy9iQsCRpNelPGRiMblv0pf0YsdngW7KHdJ+O2Z8XmeFhg+nSZu X-Received: by 2002:a17:902:748a:: with SMTP id h10mr33870522pll.31.1567541675206; Tue, 03 Sep 2019 13:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567541675; cv=none; d=google.com; s=arc-20160816; b=FmOA/ii3xALL1jDLZ4oUa6fa36o5ui38FFAeTd+x6iBo0OAyHUv1O3zbNpGWjQMktG jlBd+7M5Gru5JjDg72Jcx0qNxmbbtxb8cJUxwVf9I18oMkWnlCblCvi9UXwcC9jjekPl pp/liT+YrC7yC4GOLbMza8MVQZ0XvnIxU5UJcaS0zl+9S5DD3Dhw4fOlFxp9EHiMxFuX XkU16lxSgEc72xUFuUp8jwqcbLp83ms1sEGXfL6pExXiCmTSTWtzygCTRorPbaSuDc1S 1hcC2JML1ScPQztr//2zXq6yu924FyTyyfSGayFjWE8Hxlpm+q91noLqPeDQRHKSzOoZ HQ2A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qhHCXko5D/FCS0uQslLsv5tvuSiKAItzGjWfdeWXw6I=; b=bXK4nRCM0E9UMbsxBWMFGbOH0nlpwJuHD7VdHawAZuAbFhdC2DTi9J4rdf7khDTj0T VAsLJWZcpitfLRJTWN6W25/YzFClopYWpYvbbWiMdN5w7PPanLnIj7RIOOqdZeoSzacJ NaYccQBw1mDU6/gb3C6lKlp0Tw/y7HWPJK536n1uvJtUHzStRoH5zAjdcLmAfntuIIER MB06nW1HKFuIaZOwmhmm90W7zG/oCDP7iB1nm3XsJZ/YNhhEGp0ZeEKELxjG2QWhlvoR d03K5Vt1nVmVMSn5033fJGSkXvE2z/anjTme5fom5LMG5U3TlrOrVKmAtMJFYsxsSuFe kj3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EvNJLpof; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si6386685pfc.257.2019.09.03.13.14.19; Tue, 03 Sep 2019 13:14:35 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=EvNJLpof; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727195AbfICUNN (ORCPT + 99 others); Tue, 3 Sep 2019 16:13:13 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33009 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727096AbfICUNM (ORCPT ); Tue, 3 Sep 2019 16:13:12 -0400 Received: by mail-lj1-f196.google.com with SMTP id a22so205297ljd.0; Tue, 03 Sep 2019 13:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qhHCXko5D/FCS0uQslLsv5tvuSiKAItzGjWfdeWXw6I=; b=EvNJLpofgvO4m6y+PySnbZ+7SQyxmQymiVN8fJ6z3LTeKYG16oA/P7fiYNwDAu0Y3Q Jqs4YfI3FqRyBD/nkNoPtWguZnon9RKzIFh1g1qQBS4FlFllb41SmSf8sKObVFqpQJ4D qQh+GAQM7IpVzEsxPl8ze3rAilGUKOaLQlCYYrNlRo7KCsUR6PWwHdK+diGr5qjaY6IY xF3wenpSHNzEwXRfZ7NxZ7KuTtoyQMcmt37fycyP9LpqS2jezn2TaN1naPjY8gTQO5KU 76oeYndpIsV0dLBOMbn84M4WcU7PWhcD6Rdc7b5CfiWBB8KjCWa1tDNEpIZd08YW0djW WEQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qhHCXko5D/FCS0uQslLsv5tvuSiKAItzGjWfdeWXw6I=; b=jqqChJbT1POgMLmzhoKDsQQRf3SDC9nDE6fkB63elPpuCZKpQqOREI83omTPjndwHk nF308gRZhjTyZRFdRX1zHhDHL8x07d7iV+3kpnVNQJctLUC7OGx/juTvTExLU2ClEj6Y 6vfo8rrA3byCkcu1HSDFu5hslUbj+l1hKWmUJZepinOnrE+lf63VY1obkEP/U/hss8ht 9BbUaRVtk7ChQz5Q08M/+Ka0xWcCFNuEZTft/2hmTeTLlR0BhzrxCCCtQ74SCKRlnsMf 0xtEQdd2h8JpKgyRYvwWbGSNVkq3TjeDGUKUM3Z+6aei7fa6QB0ooy/08hXgOHnfX1o7 qrpg== X-Gm-Message-State: APjAAAVKtd0dWBm2pX2oo4kicpzYWJ8XCcNEF0Uy8Ma2AIUTiut8Cu86 H7gK5vV7B6vCpKG8rYUK2Og= X-Received: by 2002:a2e:9c03:: with SMTP id s3mr12966228lji.109.1567541590101; Tue, 03 Sep 2019 13:13:10 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.13.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:09 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 9/9] media: ov6650: Fix stored crop rectangle not in sync with hardware Date: Tue, 3 Sep 2019 22:11:44 +0200 Message-Id: <20190903201144.13219-10-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 126a662be301..16887049f0cd 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -491,6 +491,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); @@ -500,6 +501,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.21.0