Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp599414lqh; Fri, 31 May 2024 10:19:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUju/3th+m3RXc9gU4eCFBrnIOj2LFaIHaC5fGqYFBuFdWXzZYpoTpuZnrcJDFb/vhAJtPr7zwoTNKNQR9s+N+DfLE43Vn9E5H0tf4Aw== X-Google-Smtp-Source: AGHT+IH0JC5iuyIFz+YDctyrMt8J1tGqFIhfyG3BRjDBlo+3hFM5hJgQibxiVqhrqoYTIvEbrLVF X-Received: by 2002:a05:6a00:130c:b0:6ea:bdbc:6a4 with SMTP id d2e1a72fcca58-702478043admr2425082b3a.13.1717175998650; Fri, 31 May 2024 10:19:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717175998; cv=pass; d=google.com; s=arc-20160816; b=MN85Ix0zlRLkE2yu6ckWrGtd5Y7KFj1N02nYyaN45H7Dw+JybiQRmWZVCr7130AzVI LEUKenWcquExKINgSniL5tIOhA5VWtDhNwcPLfmSzcCJrjN5YjTXpec2EBcvbd2nb71c MI0ncUo8g2IdVDh7anTCtsgS9xiRMO/Gqt1KInvnihX83hc/ats7c3bry0ga7zfou4mF 0Y3gmzNc8UsbqBW0SoyT7oy+1CtfU8lzBsohAYtEi5QckJ2M97FE1ScX+lj+1AL/lYOR 26MlWI2o82zXYVICm2bm+Ss8N4xMPkiN8OcTNBhyDXx2mpKBUyl8hUPIMpzzyCECB6uy Ps7A== 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=Un12nQNSmZAEW86dzSpgGrIq+plSTAlSnQhQo3l8dic=; fh=5DiuueyS1lAAqfho5bYx+Hd2/VuZEUnh7zjWzwl5vGk=; b=ZaiBvnBZMDwvL2OZZC6BgVGVRcmfNV2gCR8jFBP2IpNwLy+XLhLw5bk3CAoj+DdKi0 gWiYETfcy+JJYrKRkCzgRXjZu/nBnaIoGAkzi3BQ6dYIukOSrDJc0tNjBQ253Gapn95N T8KpT615KjwvobVRKLVfN8smTj7IV+9SwRYWa6BfM8TLysLhgZCT9C1PGMJU0ssLCTrU 85B2ApHAMVr371jLUWm0nHGMZSpP75H8nZqX+cin/ajGnRfVc3HwKS+BYkfSrkNaT05/ 2WleoVtNs60dJmjjcVkx6VSv27MyZ9TK/dBUZZ9+Yp9deWASVyzpVfxu4GpQ6go3/g1u tcbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CtUrBG91; 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-197245-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197245-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 d2e1a72fcca58-7024c1fbf68si1200390b3a.99.2024.05.31.10.19.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 10:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197245-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=CtUrBG91; 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-197245-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197245-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 6953E28A99B for ; Fri, 31 May 2024 17:18:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3CB617C23B; Fri, 31 May 2024 17:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="CtUrBG91" 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 7F52F176AA4; Fri, 31 May 2024 17:18:36 +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=1717175919; cv=none; b=mMO0qq+prDT5wxz+oxg+BA/maHck+pcr6gKIu4Zhn0GOMQQqAV78GAADZLdf1xxVP8z5dODLXZZxFh5NXs/+Cj/Vg5nd07y/oCwNABL2JMz2JHSghRjujHOnVa+GQhKrwk4kfjFiePVN+BSoqzTO/+qGgYsyTYkzhtP486dUwG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717175919; c=relaxed/simple; bh=ZWVknI2+x5Un3S/Nn4fzUhrGkzdDgoJ0JlONO0r4wDg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B8uA8nQ/le/J2BcYqiCuoD6Vw6Vai77gnspIkZIfJlc/aGbwipyDuSk+NXssVswV5sgAIJtSeRMKFu6G1WohB/7mxdKwZh47xf6pfVYf8zElOwXMzWQPz7ZazTy08Trrr4BNT3oFx9w0NTKJoRYQFXlK9lGRg6fW/8uyybzf0yQ= 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=CtUrBG91; 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 44VHIL35063534; Fri, 31 May 2024 12:18:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717175902; bh=Un12nQNSmZAEW86dzSpgGrIq+plSTAlSnQhQo3l8dic=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CtUrBG91nwREiDkdVkgO4x36gm/1+n0w9UZZ/pChQDsupnjJePb4Q3c1i3nG0NTjv f1k/7Jq+RQozu6UqSN6tGHv232fnp6BVFb5kvq0djkyRdlvpgPqc1HZDGT9Gnj/Cvg H4LiqRMe7hD1ke3D5eE+4UlS7UgjSoG2VQlAxMYs= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44VHILOm028388 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 31 May 2024 12:18:21 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 31 May 2024 12:18:21 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE102.ent.ti.com (10.64.6.23) 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, 31 May 2024 12:18:21 -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 44VHIKH4061281; Fri, 31 May 2024 12:18:21 -0500 From: Devarsh Thakkar To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v11 10/11] media: imagination: Round to closest multiple for cropping region Date: Fri, 31 May 2024 22:48:20 +0530 Message-ID: <20240531171820.1311037-1-devarsht@ti.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240531170229.1270828-1-devarsht@ti.com> References: <20240531170229.1270828-1-devarsht@ti.com> 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. This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl description as documented in v4l uapi [1] which specifies that driver should choose crop rectangle as close as possible if no flags are passed by user-space, as quoted below : "``0`` - The driver can adjust the rectangle size freely and shall choose a crop/compose rectangle as close as possible to the requested one." [1] : https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst Signed-off-by: Devarsh Thakkar --- V11: No change V10: No change V9: No change V8: Update commit message with specification reference V1->V7 (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 e701d573a26a..d65646f0c38c 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