From patchwork Sun Feb 26 20:58:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 9592373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C87F76042B for ; Sun, 26 Feb 2017 21:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5F2228305 for ; Sun, 26 Feb 2017 21:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7F4228408; Sun, 26 Feb 2017 21:06:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA0E128305 for ; Sun, 26 Feb 2017 21:06:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751291AbdBZVGw (ORCPT ); Sun, 26 Feb 2017 16:06:52 -0500 Received: from mout.gmx.net ([212.227.15.19]:59369 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbdBZVGw (ORCPT ); Sun, 26 Feb 2017 16:06:52 -0500 Received: from axis700.grange ([81.173.166.100]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Mfn40-1cwLUn1Wmy-00NCeZ; Sun, 26 Feb 2017 21:58:21 +0100 Received: by axis700.grange (Postfix, from userid 1000) id 1315B8B111; Sun, 26 Feb 2017 21:58:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 0B9308B110; Sun, 26 Feb 2017 21:58:17 +0100 (CET) Date: Sun, 26 Feb 2017 21:58:16 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List cc: Koji Matsuoka , Yoshihiro Kaneko , Simon Horman , Laurent Pinchart Subject: [PATCH] soc-camera: fix rectangle adjustment in cropping Message-ID: MIME-Version: 1.0 X-Provags-ID: V03:K0:1kpVVdITu+7sVBeQP7oMim+eXjb5JnIWEjtgl6LumJirX1v2YLw EVMMNM/sBOHwN39lB7bFMYNg9fPNI04Be05lKxo75OpF4K71sM4tdZo8cp4Lu+o/iR6TbE+ Umd48k4q65t7hl/3mYI8X6h0dbVKIFSTW4kX1m8LRRoYNsMJCZtszkzCTj0N/zrY9tuZ+M0 fnr5hKOVNluoIRsqAO4Rw== X-UI-Out-Filterresults: notjunk:1; V01:K0:N2wvjXFM6lM=:J0bitk8SwKfQubKmpvo192 yVTORy4o/k4IgG38Tk7+zQDneb/UG20C2MIcE946wBr27XTVkJtJ/Tsy+e3xGgDev4L2OErkx NLBRMy3V3d/7dnQwW6n4rtLGZQOQoQy1MxSDQIHzbjMzhZzrREPWBGjMJAeykMV6+ALaQGKN2 XM4Ip10TYgQJkqob9fUqLNAV6hzXgxU6Ah6wJaMr1sygMUxR2/36lTiyuELxvPEQ2lyEZIGAj Ez42EMxgrklECnETXjRqybYwlR/nA95qqgABQ5ky8yo8upktIGG84ASCb2CThlPXNKQ+HwFrJ H8lw1YBrYYzysUh4+6mDpye5+/QtUWkzhdC6m6oGukOtuYPJcJK6MqDiCQkpQwF777GaSjkcm oaLmd/P68KkgMZH7uuZFgh9R5gx0MhX8o38rBezeXpox/DafZiowz5pHoXlavjV3XPV8E18AH AIBGGqI2nsaaiH4vC8aQDD4iBj1Pa3jPZi1mpeL/Wv6lW7IFPIELeH0tVLKPMpcwekQyKmkOC tPxmTAxNGkUkB1Rohc7VEBYJjhiozjEcSlnMVsfbArfF/i0cKG4dmT42dPLOqcSigTVEiIuDX krwphpn4yDuyEVyfeVXjJjiL0mQdAWupxeurRl0vl0rAJbJ0YDFHi3Vadc3+XevCzpYscqwch Kn8SqpcSAegtnBGy3C4qvH82gPIWzuQoP2vn4iehK7hyalJMHUsJJAHS0Ix+8VENnjBksyyPj REWwlZSYimJx4+VRpGn59u3XWI+w2Xbdz7/OWSa+VzVqv6+JVcTHbjiMgNz1KBjRT7F5G8xnu TLNIUeL Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Koji Matsuoka update_subrect() adjusts the sub-rectangle to be inside a base area. It checks width and height to not exceed those of the area, then it checks the low border (left or top) to lie within the area, then the high border (right or bottom) to lie there too. This latter check has a bug, which is fixed by this patch. Signed-off-by: Koji Matsuoka Signed-off-by: Yoshihiro Kaneko [g.liakhovetski@gmx.de: dropped supposedly wrong hunks] Signed-off-by: Guennadi Liakhovetski --- This is a part of the https://patchwork.linuxtv.org/patch/26441/ submitted almost 2.5 years ago. Back then I commented to the patch but never got a reply or an update. I preserved original authorship and Sob tags, although this version only uses a small portion of the original patch. This version is of course completely untested, any testing (at least regression) would be highly appreciated! This code is only used by the SH CEU driver and only in cropping / zooming scenarios. drivers/media/platform/soc_camera/soc_scale_crop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c index f77252d..4bfc1bf 100644 --- a/drivers/media/platform/soc_camera/soc_scale_crop.c +++ b/drivers/media/platform/soc_camera/soc_scale_crop.c @@ -70,14 +70,14 @@ static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect) if (rect->height < subrect->height) subrect->height = rect->height; - if (rect->left > subrect->left) + if (rect->left < subrect->left) subrect->left = rect->left; else if (rect->left + rect->width > subrect->left + subrect->width) subrect->left = rect->left + rect->width - subrect->width; - if (rect->top > subrect->top) + if (rect->top < subrect->top) subrect->top = rect->top; else if (rect->top + rect->height > subrect->top + subrect->height)