Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp351688lqo; Fri, 10 May 2024 01:38:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5fUO2Y+ZfhIqbB4jrYoePebXyTbYZ45+U01AX/hY1ZkSPcDQcZotIS93HREgkkjYMwzCcZa3ULNnZ2SXgjxja0tyhaVj+g8y3gDJ2kw== X-Google-Smtp-Source: AGHT+IGK974wf7Kwxk0zzOqjLFzoLgQx+Bp8HaACeF+BZUmyJBLCNPHL5WzffhNPL6CnSOGyUysj X-Received: by 2002:a05:6808:7c3:b0:3c9:6594:8e31 with SMTP id 5614622812f47-3c997081ce7mr2015832b6e.35.1715330286664; Fri, 10 May 2024 01:38:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715330286; cv=pass; d=google.com; s=arc-20160816; b=MOPv9LuvOwIfZW76FmV0snyF4wuWs/ZOjsL7Xe8jJornglpH5SE8nN0Y+/4q6b4LT5 SGfmJpIzYYNFxgkBqh2sJ/p98bKUvI/mvizdAB6jb4B96okR1MAHmOo4xaJQKMXFmZHd +hBDFB49xgJjekHr0zv6tz8pLX9KJsDaF+TJFCa9L5OY7QXUdcklkYsiGSIH0JxoGh9m xdqYlXrYYiUfrqvM9eqDyA8eAWE6q/IK9V0NzJR631IUooHa6dYybBjMWNTaCdYHRnfB nvvqo3pATqsURTIMFcYfimuIli2DPTOcff/LoPs+zSNp+IdlWQQ5YQJGJL4kFW1Im45I lzMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6QVqq24uwbSeQ4NfbKqiY+EtSE8IhElBvO4qm2S3v2s=; fh=5DiuueyS1lAAqfho5bYx+Hd2/VuZEUnh7zjWzwl5vGk=; b=0Au/DMbSeCKb6CsYjs3L/52MTDTSCJFPWRNnLEnuOHJDyknFe5gXbWiROb6eFa78a+ R/4MvHJq9ekyUYQG+wxdwfsxPB5cfGoDit8x1eXzaWmsjXDpDUpQCz+c4WSQmo79oCz9 O4GvNFVlE5BlijWMZc/i0YXAiHWBqcoiRAmQjcN9n9DwXiD4AY9sJcDqoQtL7w9j60Z3 Btk9vSPn4+eD9BF81cs8vJZnwZk6l3FyT3EUdLDoIo3lrQ1V3EGDUEZBdoTeVYfnQxHR N61KThSX6XXB+9EtyKYxOFtTjL+7MrPPgB0qTxmRXVXl4XFtPEEMYtCo7RcRyPi/erpe vIRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=g+QSTavH; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-175449-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175449-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412f13f28si3216131a12.785.2024.05.10.01.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 01:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175449-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=g+QSTavH; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-175449-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175449-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4A075281451 for ; Fri, 10 May 2024 08:38:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19CC1152790; Fri, 10 May 2024 08:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="g+QSTavH" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5A5410A3E; Fri, 10 May 2024 08:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715330277; cv=none; b=W+yBCc6a5tH6oPEA6nOMsA7HOP4VAYR17/1l6mHQZ/DXUmz1KiWcE/kc8LNVLxJ13WKmAI6cSVerGznWSoKrMqkIOez4lPJGQ+baKR3OfRQhnwQwlcAzoL4wo9C9DYx8+/U/hG2oZmVA/8nn1jxk9R9W6GPZAo/9IWnBVUNJipI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715330277; c=relaxed/simple; bh=LnGsKCLtG4HWV/QhMgM9/90EbCEjqHlXW0pCCjWpP/0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o6Kn4g6JZThKGTbKt7AtKaTgm1RHGBy6VXSYPtKnHdSwC3bjnIwgoQzTMSG8Y/1/nXXxhk84jUhypcbaQA9RMn+AkKccPgdYDcEbn5xoM8zlzARsBmATVQttdN38eI8jSZfUpvbdzoCdjTBVdkQQc5s31dqoePUilTWwJE1gnLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=g+QSTavH; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44A8bg35050651; Fri, 10 May 2024 03:37:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715330262; bh=6QVqq24uwbSeQ4NfbKqiY+EtSE8IhElBvO4qm2S3v2s=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=g+QSTavHcWEIH6fPtcwj3svXG47fIMkykQVpNTX6EohCRy81FvklQvn8OD8IDZZ/Z BR1Y0NQXuUVMn5NihvdMatxLe7gGB2UTnW8dDjvWj/dKihf7zS2UtxrkO84UH6M3eC Rfg4zbvKsGhWk8J10tf4McF0CqXT7tyEiURmwfgE= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44A8bgA5019755 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 May 2024 03:37:42 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 10 May 2024 03:37:42 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 10 May 2024 03:37:42 -0500 Received: from localhost (ti.dhcp.ti.com [172.24.227.95] (may be forged)) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44A8bf0o107288; Fri, 10 May 2024 03:37:42 -0500 From: Devarsh Thakkar To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RESEND v7 7/8] media: imagination: Round to closest multiple for cropping region Date: Fri, 10 May 2024 14:07:41 +0530 Message-ID: <20240510083741.1282823-1-devarsht@ti.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240510082603.1263256-1> References: <20240510082603.1263256-1> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up (V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest multiple of requested value while updating the crop rectangle coordinates. Use the rounding macro which gives preference to rounding down in case two nearest values (high and low) are possible to raise the probability of cropping rectangle falling inside the bound region. Signed-off-by: Devarsh Thakkar --- V1->V6 (No change, patch introduced in V7) --- drivers/media/platform/imagination/e5010-jpeg-enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c index 189e2a99c43d..abd66bc9b96c 100644 --- a/drivers/media/platform/imagination/e5010-jpeg-enc.c +++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c @@ -517,10 +517,10 @@ static int e5010_s_selection(struct file *file, void *fh, struct v4l2_selection switch (s->flags) { case 0: - s->r.width = round_down(s->r.width, queue->fmt->frmsize.step_width); - s->r.height = round_down(s->r.height, queue->fmt->frmsize.step_height); - s->r.left = round_down(s->r.left, queue->fmt->frmsize.step_width); - s->r.top = round_down(s->r.top, 2); + s->r.width = round_closest_down(s->r.width, queue->fmt->frmsize.step_width); + s->r.height = round_closest_down(s->r.height, queue->fmt->frmsize.step_height); + s->r.left = round_closest_down(s->r.left, queue->fmt->frmsize.step_width); + s->r.top = round_closest_down(s->r.top, 2); if (s->r.left + s->r.width > queue->width) s->r.width = round_down(s->r.width + s->r.left - queue->width, -- 2.39.1