Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3258764yba; Mon, 8 Apr 2019 14:47:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxw/fHj3H6gSMy1g4RjkY3ooqhYWfguFerZSV/sLaj5a683I661BIA1e7vPiapqUjqb0VK3 X-Received: by 2002:a17:902:2965:: with SMTP id g92mr15365150plb.267.1554760030211; Mon, 08 Apr 2019 14:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554760030; cv=none; d=google.com; s=arc-20160816; b=vu/W+UyP+iNPTMDvtLIfmala/c/ofswEen0kH3LLxCnhWYV/y+m3aNRAtLjxVIfjIT DEuD26baQw3j1rZhwpz4mvqyOlp8pQ+ornx4lQkG8XhTH1fqYiHjfEaOIcDx1kS2+OFF wrQeBDHJAKi2otP7YQAYZFZeygNv/Pk14VG6EadzPDf7f88Z53PK8ZOq6rEvOLpqrO24 mGH3alo9eX7+cChipy18aPsHwUtd4H9l8DVambkb2Cjydr2e8B4sfS/FI5b5AuITC13V JyF0S0Gk3hoWkhRAojEZUf6A6Conzy0mmBM804emBDbGdtThGAutt7LC9QQUAzDuZfjq Vsqg== 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=TDPWX+c9T8wtLVwEqZLlhf3dHuEObpXGSnaRZkfVeqo=; b=pFbGnhy2gYpcE/oxlSbM/a8UPkp+5PftiuPXXTMl5RGlPCMhqZL2AmruXqBv+X+Ful CavwrM5Im6K5LAGannueL8iYiR+37++FT92lr9w1+5J0gNhDPoPuJ28GueYjG4W+jcSZ KK+WXyO7GYtdN6vgZaMds+qaDZ9Ldwor1ykKHltd/XqmATU/m7KanC8BTi6Pp3UTse/L FeGE7LE+VuvpPnh9MarjzhOAcLSirIT8fgeiCJQaJ9jqvWNaHOoJkP91wc0M/yNLkK07 D40z2ftK92IstQYYSuFuTPNLbHq57krgoTqB3PSTxM5KaBu8t2yX6GPtOWJb6z4HZoC4 SHyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZTWZdhB/"; 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 f131si28580857pfc.92.2019.04.08.14.46.55; Mon, 08 Apr 2019 14:47:10 -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="ZTWZdhB/"; 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 S1728725AbfDHVoL (ORCPT + 99 others); Mon, 8 Apr 2019 17:44:11 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44654 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfDHVnT (ORCPT ); Mon, 8 Apr 2019 17:43:19 -0400 Received: by mail-lj1-f194.google.com with SMTP id h16so12592510ljg.11; Mon, 08 Apr 2019 14:43:17 -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=TDPWX+c9T8wtLVwEqZLlhf3dHuEObpXGSnaRZkfVeqo=; b=ZTWZdhB/OFzD9rVvGhiW8mkmgo5pEDqG3JYgsUK7mzudPv5RFiwjuaF//snIOzR4Cm WTV3mvQPERZcfbhRcbL3SIojFa2j6lbCl3xN4WelY3qwb2B3tMqZ8Q5ki+QxMwWTd38O a5n9hbTFw9pL1cOKjHFgzTch82Qm7VeTli0niIukU7WBgpuPMIMACpShltGfNEReKHHL 1ky6VlyIHhuEO+HvU8xLAh/fReOGdtut5Xn3zAmjGsVck/BeRJVQ32y72A7jq8ZeUSHi 3bCJ3eVW0H1JGWNzTCjqrxjg2UvGH8xvVQWUPoFuXksCOchByJn3cn5qqbEMDlrZSsIx tGQQ== 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=TDPWX+c9T8wtLVwEqZLlhf3dHuEObpXGSnaRZkfVeqo=; b=ifUDjKipSb07lNkt1+LKymhWgkII4etPy3F3+iV1eXhn+UTAQlKrUc78XEPdJI2iE3 3lm0OQQ9LrU2tu1plNnSqlgBLIe2oUT/wyOFKJnnPy6Y+4T6uiKpgxWIgfOX5m97kxSn Fbyn145saaSfm4StCjgoz0HyG4tgIVG/DkdBD5BmwvW9x3k2y2IN3So7doLnI6XtuqJI Xs48ZKP+lhq5j7DJNTB78tjH8kVhSSPD3QKZv/NAygyRbDenewJnPTr2CDCZV/JroK2V vM7hzCnO0NTWHE8ok/wS4QPpPhUz6jx9bIi5AlcGqvX0fvKw+wUCHn3J/yZs3RedrtNB SYdw== X-Gm-Message-State: APjAAAXcOMAL6KToCOu4ESuTjQFBfxSf5TBNJRo13/KuFSD1AP1TMxZe bpEoUjt5c0hvpXD7cONcHyo= X-Received: by 2002:a2e:808e:: with SMTP id i14mr18167106ljg.103.1554759796391; Mon, 08 Apr 2019 14:43:16 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:15 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik , staable@vger.kernel.org Subject: [PATCH 08/14] media: ov6650: Fix crop rectangle alignment not passed back Date: Mon, 8 Apr 2019 23:42:36 +0200 Message-Id: <20190408214242.9603-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 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 operaion 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 Cc: staable@vger.kernel.org --- 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 1daef0c7ad91..07d7a0708cca 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -471,7 +471,6 @@ 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->pad) @@ -481,31 +480,31 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, 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.21.0