Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp34204lqo; Thu, 9 May 2024 11:44:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXducMRCmjPY6Shx8OL1+Ex57NxPWmonzj/7aYi+Xe95bZnbID3Tju//sltZ3jRXzbkMT7xqvIbM3H8dC2GXyykgGhxFgEeuO8M811k3g== X-Google-Smtp-Source: AGHT+IGHiqvrgqdtjGvAj2SRbKui4gTw/FLQDHOSBVGimpyRaTZ4Q3CjqQscb+gIfUmVp5ZBxECU X-Received: by 2002:a05:6a21:3392:b0:1ad:7e4d:2ea6 with SMTP id adf61e73a8af0-1afde0e694dmr767517637.20.1715280255958; Thu, 09 May 2024 11:44:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715280255; cv=pass; d=google.com; s=arc-20160816; b=N3qRjpHZu7ZXnWo3jmmMZH/PTIlzHXJ49hIrrXKQF9sykPXCqi5+ZZ65SVSVdHjbbM F3s/hkxhMHxPbeCNL3jGDQtw6R/FvWdCTirnnHVEfQfZjJoIXhaHaghUBLN3EaBS5+cu j42KR2bv2ILrohBrmmwa7AqsQUz+XONmcSfTQlZKL/VAvN6FJBw6gKoeGptcCoLl2p4U VbBDYgvVZ1DIngp1YNP6l4oMIml44Fci+vXARJDGP7C+nESUW8Kbwcg4TCdS7N4EG/Jd LCk2sB6YUrE4pOpOM+WW0nHH4HFPs+IhAqYgHR3qGbOgz1KrwLO5/f5jOEKck+USxqNq L7Fg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=6QVqq24uwbSeQ4NfbKqiY+EtSE8IhElBvO4qm2S3v2s=; fh=5DiuueyS1lAAqfho5bYx+Hd2/VuZEUnh7zjWzwl5vGk=; b=iMhu9X8MFUrsIK5ZA/S0i3g35TR2oJcBzFtbY8bS7a+tN8UEop3tLbe+G1KXR08+rQ wAiNdt7qwZT6COaOjkWpb/y6+IrxSYQSgo4gw34oAhQNmjGVqlyXwnK25AiZFASZZAEX YyBlh8zQwcja0zXQuepF4JF1jzhSRFKUUxN02QZ0LHEgHkCkZBHMq1IDnJlhV7bB2ZcN znbBbB4SS8p+Fv9CDkqZOvPJeUBOTHkF6TOv5UDShPEuRvv4x+RlmmWUFuyz3ECoa8P+ 4xc/do5IEXWc9xjvkCnBBovTDXLjHfEzY/tCWmSGFBEQLFdw2wfhDE6OOV0Y22SKC4Kx 4+4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="VamAP/m3"; 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-174783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b514d2si2112384b3a.386.2024.05.09.11.44.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 11:44:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="VamAP/m3"; 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-174783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174783-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 05A28B23103 for ; Thu, 9 May 2024 18:41:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07A6C824AE; Thu, 9 May 2024 18:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="VamAP/m3" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 8C5897F464; Thu, 9 May 2024 18:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715280018; cv=none; b=cMgKrVu0dKdPsvk+4KqiTf1yj6ShzN0xytusZKVlMEk7bIONg5Spid9s4JVkKTfCdwdZd3YW36OL+EH+ZUVHppmBm6Hu8PjVCvkI8chnWlhostYzn+dyp7AE0FklR0mWz9E3m+0SI8NHv1Xx0eQd9AqGfNfzm/lhl24E3JMtG3o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715280018; c=relaxed/simple; bh=LnGsKCLtG4HWV/QhMgM9/90EbCEjqHlXW0pCCjWpP/0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Q4PJUFsgmqRmiGGRReAMHuuSx4YVTsyd4fvKBxg8NLzG3ckbsMcLWpPqkUT7aZR64XMs1ysgLvgQqZQfBG18kOVqFsRXodlNxmMrSMT9GL+oPOZ3MpWP3gj2oTPdnGwOZLSLbO8H2ZG0ZivFlcTOmRxQEe6tw6pdl6GXlKiUmpM= 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=VamAP/m3; arc=none smtp.client-ip=198.47.23.248 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 lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 449Ie3XV081919; Thu, 9 May 2024 13:40:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715280003; bh=6QVqq24uwbSeQ4NfbKqiY+EtSE8IhElBvO4qm2S3v2s=; h=From:To:CC:Subject:Date; b=VamAP/m3qfOULlxA9+BkvBvgWoY5IKNwlRek948+HsRajaUeDwTZqXdkD4+ZSHmGJ SlQy3IJhPwo/qfrkYcVjgzWiMzPwVpZL/7fkKRe9M6kc5vbp80cxeL/jw3dW9katWv xXur6bWRkwAptAz6MuKvuSrZKXLutv7P2SBkuuQo= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 449Ie28x003457 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 May 2024 13:40:03 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 9 May 2024 13:40:02 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE113.ent.ti.com (10.64.6.34) 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; Thu, 9 May 2024 13:40:02 -0500 Received: from localhost (ti.dhcp.ti.com [172.24.227.95] (may be forged)) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 449Ie1qO097210; Thu, 9 May 2024 13:40:02 -0500 From: Devarsh Thakkar To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 7/8] media: imagination: Round to closest multiple for cropping region Date: Fri, 10 May 2024 00:10:01 +0530 Message-ID: <20240509184001.4064820-1-devarsht@ti.com> X-Mailer: git-send-email 2.39.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