Received: by 2002:ab2:7853:0:b0:1fa:5c73:8e2d with SMTP id m19csp8798lqp; Thu, 30 May 2024 10:20:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV958XyUMobxfoVGTgTSJEeLRwXE+hW8uVUQaQ1xZy20HkyQSyfe9i8WyqoSQWUfd8UCHBqOeMdE6iu6Qr5pPHFQtzCoZPMxQGQjtK1Cw== X-Google-Smtp-Source: AGHT+IE+qlS9WOTq+fD+0/jYOV5qQQhSYywXt8+XFknW++AkERTcpwW3K6Tx34ef8EvRJyOwDKzN X-Received: by 2002:a05:6a20:2455:b0:1af:96e8:7b9c with SMTP id adf61e73a8af0-1b264645ba3mr3120085637.47.1717089601198; Thu, 30 May 2024 10:20:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717089601; cv=pass; d=google.com; s=arc-20160816; b=P2HHtAS5g0SyvtlX3S3CrsNeJJgcdBbBay1il3VNQTlsf2FUA/DnYH+nywqU6hc4RF /clzRrXe6RWcQVjtFbUVzuIfzat32AiL2mzi034VIOw/t6tQLdXAhb31qsHma1cAlnEd rPxu2t32FYSv6g06m5ZQFUX4Sq57NiRjKBf6Ooym/ryx+8eohpZZYc2aAmw1i38k1bxy j+vHeAxg2K/DT+lsdGA4B4AP7UKAQCny+W0mnXNuNXafXP1ah/JAQryE7YWFsMWrI7mI CQHWsn6SRS9aZhjoq6ZUkYKED8U7BDLVPdjlzqe/Iqyfe+sTDYKNRUEiIhUeYYRbEfXP u1FQ== 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=L6UE0uHq7+Hth/Fy/fnGsGgkL3Q0yEzciP8ACtQuH7s=; fh=5DiuueyS1lAAqfho5bYx+Hd2/VuZEUnh7zjWzwl5vGk=; b=WfFrA2Ah6QZBhgfV5BnxIcKF32wTmDs0VVbaJHEtJ/csZSZFaxlUTWkSque8qDsQCt Sp6QrFA0GaecEC6lg3QscjpKkpxjKUSUIENCXSp7LZ6LZNNU6kmTKb15FeeXzwKIbe/J PZOMizHpEkS9nXFpXBKF6L5asJ0GsvGeyB/jPYc+akRSft1YVwn0AFVlQ10we/9duQAG D+qqgODuSn1dIDjjz1ZaDp7XU02hq0MYu7vPVoq0EZSPHgB7S18DXQSZMx34wB3y80sE dBQMKLJJL+XjT6e00HdyaVSmAJliO2HoqvQiaebDlv94xlxPHeOha0ms1LKd3FENmw0A 4vuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="Kd/4pm1t"; 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-195726-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195726-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-6c35d973c24si5018a12.872.2024.05.30.10.20.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 10:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195726-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="Kd/4pm1t"; 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-195726-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195726-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 D5D19283F82 for ; Thu, 30 May 2024 17:20:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A76B45C16; Thu, 30 May 2024 17:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Kd/4pm1t" 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 9719A2D05D; Thu, 30 May 2024 17:19:47 +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=1717089589; cv=none; b=Bd088AxoybB+ujhOfReQcN8+4oMnoKUjjPQOhdFVgXi2oit9OdnPSSHyVzanCJ1vjGXcUrl6gVOy+ZZi74evo9xLXWGkyLIHf8nNdE+FXVZTAiT4CDMrQjsUnOUXPri1nfMVRI+MCHcAZhL++uRHp3Q7aVBHtkMQodqmqnTq2Vw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717089589; c=relaxed/simple; bh=I3PbgC0t9h53S5n4YgwQ1uZ07WUBHyczBKFjiGU1lgI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GWRF3MM5FP3cvXLxeAL05wnAKGUcZoZF1C7HvzizwP8WvTQLmL37LK6p7z8qQA8YUhzeqx9Dfp3YJ2W5qYnUPRa2woBUNu4N/8TJRdPdvDXptJ9PFfCUdZW5GDrvcLNUaNSiDzqqIRbFqCnY2JS/76N3LEXADglz3z2s7T+axbg= 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=Kd/4pm1t; 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44UHJWGg069115; Thu, 30 May 2024 12:19:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717089572; bh=L6UE0uHq7+Hth/Fy/fnGsGgkL3Q0yEzciP8ACtQuH7s=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Kd/4pm1tgI+e+sJUuHRKuRleQ6ezbj40f5SeBokefcJxOmuEkMDIFySDod4NFi7Id DtqzIinSGJaYgtPSYJypxV3o5KLN/p4KjuQfxfOmgqX4Iol7GVisCnPVS3QBltaYoH nIveJb4KMcA8OSBuVTgGqXTjHFlqUzXhwVp5CDVo= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44UHJW42023415 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 May 2024 12:19:32 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 30 May 2024 12:19:31 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE104.ent.ti.com (157.170.170.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, 30 May 2024 12:19:31 -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 44UHJVmZ021926; Thu, 30 May 2024 12:19:31 -0500 From: Devarsh Thakkar To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 10/11] media: imagination: Round to closest multiple for cropping region Date: Thu, 30 May 2024 22:49:30 +0530 Message-ID: <20240530171930.2768174-1-devarsht@ti.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240530165925.2715837-1-devarsht@ti.com> References: <20240530165925.2715837-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 --- 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