Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1168166lqo; Sat, 11 May 2024 10:08:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFCaDOKjIXR0S+aufFelPeMNZClOM2JOqEJLfgEkC/CzzSpZg+y2tYtfIrRyxPkpXk28XOMVfO2Xu16tPwxNzIi9IAdXDmZF3eB+jM/w== X-Google-Smtp-Source: AGHT+IFuG/4EniQbW15ioUGbxg1gULnvdhc3x3/F7bE4trixi+w5lz4E9OLw8qfsd8xdwKFO+id2 X-Received: by 2002:ac8:5790:0:b0:43a:f697:667f with SMTP id d75a77b69052e-43dfdb68f5dmr62586231cf.48.1715447327528; Sat, 11 May 2024 10:08:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715447327; cv=pass; d=google.com; s=arc-20160816; b=yIdLOlXTqi4hQfWEyA+abueCtfL/yI68BXf7Ys+ouOvmGtRPFKcbxdDP7286iSnroE IkXPYVa3PJaN/YNokMFm9GRhNBnWdTHPBXG41ceWPQalJGH+ba6GkhiUFmJrxAz/dyYO f/13Vc8VgpLUCwdnS8JBLp1l9L22ZvijNrHWoQrRN6gs8QZjLBEegPIRYeJbftf0VuJ3 uVV9iPkGQkZZHRhvTBufgtMBdPMClvNYPgOmwRLY+r0ijDFkpbbNg7AfvThUZIw9zs7I 90KjxtGe2hIqS6te9b9/r11z9HPK6uSkCpCkfvYRLdCFeLXNz4qxxJx3aEwjZsQRruLH tMuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=timvJRGsOvaAJupM+NGf/T5JlzD1cz4vtYJRKUFZTHQ=; fh=/Gc+gxwmsD/aTozLPCW07DXG5l0jbc4TR9jwqPvJEcI=; b=wU0rLlwnDLlkdsduX3RZ9lqJy43jHhNj2tXPO85G50K8UEiRp1JjACoBHoiYm2ajiB V+5maXQcW2TwekE0f3MKZqsL6CB6W6Ozlmc/2Ii5Pr2iFAlm8QT5nkJD6hNsFRQR6PZ2 HivXYc0CxsnnfDHgjdMmRqfAtQwgzNKj6YEQ9MrfKW6K5lWSloxgEjhYCIwj1GiO5qeB duhze8VWk0HH8phKA3w8TommtEG9rN1cP7Q6+Qq/5UKHRgUqqvMAHVzPTI0R3eGE0/eq WXe3+v6cOh99Qk6UA2Fnfiv/y41KP4BXUhMWftT3vsC3rAWWHJ2y0lgB/EqrGZ3s80/z ZXhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=a4NzGwVH; 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-176651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df566f7d6si62935251cf.325.2024.05.11.10.08.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 10:08:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=a4NzGwVH; 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-176651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176651-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3CCDC1C20DB4 for ; Sat, 11 May 2024 17:08:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39DAC1BC4F; Sat, 11 May 2024 17:08:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="a4NzGwVH" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 6334E17C67; Sat, 11 May 2024 17:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715447317; cv=none; b=OLPEps2jfVUxKsRBXSkS0ku88skVuUyVawYbKolvhbxlGkm+55aYqcHx0asrA/qeaJ3yxueltCR566CECeNHAGJCrW/KjpFEE57Qu2zWbZPorw3/ctlL0pjLOsSnrYDh3mAxBtqxXjGb0irnh3VmPNloI5s2V/IdGXEeJcvxhc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715447317; c=relaxed/simple; bh=FbE3i+JnOatXNvvdNBizHy3Gz3h9MPYDLjzAbWPxrUA=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=mej4KUFRQ95zm+w6YGSQ3kYmn7yLI3nm3UcGMGpTAhiGp0TAHyLYJk8RhmlubBaZE5mDc6oQmO9I2UbsbaAe0oWUglyCM8dOuBBOAp5PRB76K7rtObmMDiPn9qNjbWpsM/e43DztsE101KuPO7Z9Ek+KzG7Cy8NP7vasK0pYDSM= 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=a4NzGwVH; arc=none smtp.client-ip=198.47.19.141 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 fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44BH8EGc019533; Sat, 11 May 2024 12:08:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715447294; bh=timvJRGsOvaAJupM+NGf/T5JlzD1cz4vtYJRKUFZTHQ=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=a4NzGwVH5nDzUxCmVpYQ+fMN5BN+GmueErg4d7loqutgIKrvCI6AUuihmGN2fCU+z frzOoL7mLBc7Bb/gZdaP6Fx42PRBuShiwO7HmwWjMpXC5/GuvRtBMmcN1+IwucbaRy PO5qs5SIFQPQMEYUvMDU3XpwzA+7HjUD16fNbLaE= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44BH8E2G040776 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 11 May 2024 12:08:14 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sat, 11 May 2024 12:08:14 -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; Sat, 11 May 2024 12:08:14 -0500 Received: from [10.249.130.181] ([10.249.130.181]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44BH852Q090626; Sat, 11 May 2024 12:08:05 -0500 Message-ID: <7e3ad816-6a2a-4e02-9b41-03a8562812ad@ti.com> Date: Sat, 11 May 2024 22:38:04 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 7/8] media: imagination: Round to closest multiple for cropping region To: Andy Shevchenko CC: , , , , , , , , , , , , , , , , , , , , , , , , , References: <20240509184001.4064820-1-devarsht@ti.com> Content-Language: en-US From: Devarsh Thakkar In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Hi Andy, Thanks for the quick review. On 10/05/24 20:40, Andy Shevchenko wrote: > On Fri, May 10, 2024 at 12:10:01AM +0530, Devarsh Thakkar wrote: >> 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 is arguable. How do we know that the bigger range is supported? > The safest side is to go smaller than bigger. > Yes and that's what the driver does when do when application passes V4L2_SEL_FLAG_LE while doing the selection. If application does not specify explicitly whether to round down or round up the cropping parameters requested by it (i.e app is neither passing V4L2_SEL_FLAG_LE nor V4L2_SEL_FLAG_GE flags), then it is preferred by driver to round the cropping parameters to nearest possible value by either rounding down or rounding up to align with hardware requirements. For e.g. If requested width for cropping region is 127 and HW requires width to be multiple of 64 then we would prefer to round it up to 128 rather than rounding down to a more distant value (i.e. 64), but if requested cropping width is 129 then we would prefer to instead round it down to 128. But if requested cropping width is 160 then there are two nearest possible values 160 - 32 = 128 and 160 + 32 = 192 and in which case we prefer the smaller value as you suggested and that's why the driver uses round_closest_down. For any reason, if still the cropping rectangle falls beyond the bound region, then driver will return out of range error (-ERANGE) to application. Regards Devarsh