Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13422734ybl; Sun, 29 Dec 2019 11:31:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxo7ClGhhRo4E6+RiiuI5rL8PvEgxYIrz4+aPyhDvba4jb9H41a8IS/bWqETMKruoEBKhqG X-Received: by 2002:a9d:222f:: with SMTP id o44mr56975509ota.51.1577647864205; Sun, 29 Dec 2019 11:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577647864; cv=none; d=google.com; s=arc-20160816; b=KOcq5AlqUDN9RAXNcH2z20RyE1pceC/ibbclAahbT/JyA0hwlNcqoDpE5GeNd9GxP8 tNKdL+k0EhB9dethm12/IgeLhIf1qSUvKaLgyDPQZJ7fFGca+Of+813Cc/qcE5NL1t+F hn1VuFFT8Pjb1aFJfUmwjyi/2wIVi/0GaRgTbana8WeoyiZ9jtqyWvcvDLz9CUWeV3ZH Js8nQTzoHmIzDKJdBZYCuVWTYij8PuL051XuBIGn9egPqKZUCfMsC2HgftX7mExRjufn 1KP9MJgkm+HFcN9H7Zs9vl2S295+8f12Qsnl13EYS7bL258QPt27t+3YZb1tre4kNwpq ZGtQ== 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=h2i/9zq9/fzuEIJuL0FkfziZb+yhbaZcbth+j9OyMCk=; b=KtW9w+pDXJ5zLpx8BDMeGMtyQtZfQrc+8aYcYTGnvtKp0W8BaQioBA4ZgerPyCZixg oF1xD2C1BY52mq59Eh9uhy/G08WJA+rr7El4aDo4Qjbssjssq1kqlqGxo0Bk0BGghNm8 BvGQ5r5jzho8/udm3r4BbM5andaCVENSM4BNgM0JYnqk1BDolCxgSHe7WN8o/iLc9UtR vLOVyGikmuVzkJTEiGKaurvtDTd7l+Op2LM9G5eihTL2SucM2Yo2KTvej7068Ufoyn/L 8KiriMBJq12BG/BP9rWZn+I0GUocejSfVY2bZNSn07DmKM6RB9PfU37emReUt09exJ32 jJIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JdTrQAUG; 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 e192si20835711oib.82.2019.12.29.11.30.53; Sun, 29 Dec 2019 11:31:04 -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=JdTrQAUG; 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 S1728755AbfL2R3S (ORCPT + 99 others); Sun, 29 Dec 2019 12:29:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:53590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728730AbfL2R3P (ORCPT ); Sun, 29 Dec 2019 12:29:15 -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 EA7F920409; Sun, 29 Dec 2019 17:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640554; bh=tYaqDIPhdpG95zKqwXM1lmQaU5drgjlP4IT0TXuAVHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JdTrQAUGoXw/Nwjdk8WqOutWz+TeDsYtkWg84X53CHM1l9qFjQ7oCjCTC6EYSuJfW ePwqygx3PCdXpUM7rhZbwbMzFvUnALSoRZa0bVsXEnBZ0a9J93iFp2aUrIPCbctB4k m0uXZ2f9PdAlt01KPII7IUtXclgoLE1GlZn7+1MQ= 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 041/219] media: ov6650: Fix crop rectangle alignment not passed back Date: Sun, 29 Dec 2019 18:17:23 +0100 Message-Id: <20191229162514.382737411@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 7b188d6ba27a131e7934a51a14ece331c0491f18 ] Commit 4f996594ceaf ("[media] v4l2: make vidioc_s_crop const") introduced a writable copy of constified user requested crop rectangle in order to be able to perform hardware alignments on it. Later on, commit 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") replaced s_crop() video operation using that const argument with set_selection() pad operation which had a corresponding argument not constified, however the original behavior of the driver was not restored. Since that time, any hardware alignment applied on a user requested crop rectangle is not passed back to the user calling .set_selection() as it should be. Fix the issue by dropping the copy and replacing all references to it with references to the crop rectangle embedded in the user argument. Fixes: 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") 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 | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index edded869d792..e3433a4fc473 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -469,38 +469,37 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov6650 *priv = to_ov6650(client); - struct v4l2_rect rect = sel->r; int ret; if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE || sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - v4l_bound_align_image(&rect.width, 2, W_CIF, 1, - &rect.height, 2, H_CIF, 1, 0); - v4l_bound_align_image(&rect.left, DEF_HSTRT << 1, - (DEF_HSTRT << 1) + W_CIF - (__s32)rect.width, 1, - &rect.top, DEF_VSTRT << 1, - (DEF_VSTRT << 1) + H_CIF - (__s32)rect.height, 1, - 0); + v4l_bound_align_image(&sel->r.width, 2, W_CIF, 1, + &sel->r.height, 2, H_CIF, 1, 0); + v4l_bound_align_image(&sel->r.left, DEF_HSTRT << 1, + (DEF_HSTRT << 1) + W_CIF - (__s32)sel->r.width, 1, + &sel->r.top, DEF_VSTRT << 1, + (DEF_VSTRT << 1) + H_CIF - (__s32)sel->r.height, + 1, 0); - ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1); + ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1); if (!ret) { - priv->rect.left = rect.left; + priv->rect.left = sel->r.left; ret = ov6650_reg_write(client, REG_HSTOP, - (rect.left + rect.width) >> 1); + (sel->r.left + sel->r.width) >> 1); } if (!ret) { - priv->rect.width = rect.width; - ret = ov6650_reg_write(client, REG_VSTRT, rect.top >> 1); + priv->rect.width = sel->r.width; + ret = ov6650_reg_write(client, REG_VSTRT, sel->r.top >> 1); } if (!ret) { - priv->rect.top = rect.top; + priv->rect.top = sel->r.top; ret = ov6650_reg_write(client, REG_VSTOP, - (rect.top + rect.height) >> 1); + (sel->r.top + sel->r.height) >> 1); } if (!ret) - priv->rect.height = rect.height; + priv->rect.height = sel->r.height; return ret; } -- 2.20.1