Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3095721lqo; Tue, 14 May 2024 22:09:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUC/vPjQ3G2uTVO2fYGidBCz9c8CIdiz9SuzcgNJm3vlkDJY0HFOf6Rpt/sVp++9HNbAOjfuFY/lAlc4a9ja1J0yjZOKZODmu2+3nBxuQ== X-Google-Smtp-Source: AGHT+IFUuHr18iBFd7+PTUxyUy937QrfR9OdIQKMeFYEfksetm8P8wfQ1c3275Fg0CaabnDUOTRH X-Received: by 2002:a25:b2a1:0:b0:de5:5b4c:e70b with SMTP id 3f1490d57ef6-dee4f2f6d72mr12705704276.2.1715749762403; Tue, 14 May 2024 22:09:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715749762; cv=pass; d=google.com; s=arc-20160816; b=S/eZFZvluZlShyZXiriIk5jX5ssyX/l+QM+Ls+3Dcd2RcY3KlfEaYO66V2io8n6eWt r9mxXHj71qYR0by6guYUaSkqTbQtk8ic0XrZq8dhDkeNA4oAp/1U92wa/dxMZKb+XFVW O05d/v+/+cn16jQRkwJXy6uaemYC6aZLPkrbCEwDWu4j99M8Ts4AV+I8nyvFJL6K5jq6 Er+Koj2Yrr4C50yKyrNnSVnGrm9vogHyw24KSI/wlpY/+c3yffDvm+xQpsye3PWLI/BR z5apAMATHqcebld4xkeHdsYHayq7xk54ccBGRbpt1SZvceivcVoIDspcxr6oKNN73svh OPCA== 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=lr7ZZX9mxqPIcMui9i6bdbeAkLlgyW616D+DtDq0tQ8=; fh=sYzZMXDP/9sDJ/w5qjbnyGPXBDSinWv12D2a8daB9u8=; b=jUui2wb5iPXDupjvpHDFh5zyQQrOV1OmvtC4nWDbG/v88tLsG7gGVGtqQ/NSfjB4T6 Iwx0QZf5NbHja3cxzG0vBCv+l7Em6usw9eHhWXwTwZeeaMXyno6bDBZDRHdpiIiq1zJx wVYZiYOlBD8l/7ueEDetANIs3q6BKP9c/MCCM5ZGWkI3vARSlYp9Fe1ZmGN7A4CU4BvW N9eyb4CM/wkhn6XDJJzWTcKDWBfNU5HZJOeQ5gxV7Pbp1V1cUMfagrepTpRFng2PqnXh ehJg2HNF0voAqMNoykAh88Ir6He2B24gCVjK8RBhH7prYeIY+hLiyZn9w4FiHfC1n6Xw M3qw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BwNgg371; 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-179447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179447-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 af79cd13be357-792bf381e90si1291286585a.688.2024.05.14.22.09.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179447-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=BwNgg371; 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-179447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179447-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 33AD11C22575 for ; Wed, 15 May 2024 05:07:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEFC23B2A6; Wed, 15 May 2024 05:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BwNgg371" 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 1AB7339FE9; Wed, 15 May 2024 05:07:13 +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=1715749635; cv=none; b=K5IFtjqDa9DHL7ymreO3RUL03e6nTBbfyimW1Ez8RBQr7hgBGGF3Okz0WuZ+El5fmHZgCK8Hos7jY0CtqgCj8SETS5SHfjFvDamtDovwrsqCsYopqxMmgYGHJ0Eap2kyA6Z5ebmp6zYQ4SKRaIENqauXBPfKsl+z5Rl4ANnKf2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715749635; c=relaxed/simple; bh=B+ujLyhk9VYMb8Rvy3uR2OszmyIefiZFEh2clSlhLO8=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=F/+J4HOCTAnxoCd42XR6kcy8mJCBjt+JD6oLODsnpDg2J6252ipQSBNhLgFN3s2ePbg6sryDLR1phTpdh19LEoWznuyf2Dz4lTH/MS1249T+AFhO9MP0g8oZTae6ZZE2NL5cO5pyvRZ/TBucZW4NcbbCPUazE8yeFP1Wvhv9bhc= 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=BwNgg371; 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 44F56qja124834; Wed, 15 May 2024 00:06:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715749613; bh=lr7ZZX9mxqPIcMui9i6bdbeAkLlgyW616D+DtDq0tQ8=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=BwNgg371V+3EN4fDtVfg0pehr5vy/SAAa99UL634VYHudr7nMcX8e/2xkUL+AiE+7 jH8SX99G7N8n3+CBJcpS+xoeOcjx/wgzaIADMH86ulty0kp9NAsg/kwBDUTDL9Kk0v xFp1f4YL1nm8ipvRDzLVJYupmTTSNhjifSf5CxUY= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44F56q9K084315 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 15 May 2024 00:06:52 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 15 May 2024 00:06:52 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) 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; Wed, 15 May 2024 00:06:52 -0500 Received: from [172.24.227.193] (devarsht.dhcp.ti.com [172.24.227.193] (may be forged)) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44F56ijO048285; Wed, 15 May 2024 00:06:45 -0500 Message-ID: Date: Wed, 15 May 2024 10:36:44 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v7 7/8] media: imagination: Round to closest multiple for cropping region To: Nicolas Dufresne , Andy Shevchenko CC: , , , , , , , , , , , , , , , , , , , , , , , , References: <20240509184001.4064820-1-devarsht@ti.com> <7e3ad816-6a2a-4e02-9b41-03a8562812ad@ti.com> <432f336e6d4b0666cfbb431591624d0e1fefd773.camel@ndufresne.ca> Content-Language: en-US From: Devarsh Thakkar In-Reply-To: <432f336e6d4b0666cfbb431591624d0e1fefd773.camel@ndufresne.ca> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Hi Nicolas, Thanks for the review. On 15/05/24 01:52, Nicolas Dufresne wrote: > Le samedi 11 mai 2024 à 22:38 +0530, Devarsh Thakkar a écrit : >> 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 >> 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. > > I would appreciate if this change was based on specification text, meaning > improving the next if that behaviour is undefined. We might not be able to fix > it everywhere, but we can recommend something. > Yes, this change is based on specification text. This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl description as documented in v4l uapi [1] which means 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." If the user-space has specific requirement to either round down, round up or honor exact values, it should pass V4L2_SEL_FLAG_LE, V4L2_SEL_FLAG_GE or V4L2_SEL_FLAG_LE | V4L2_SEL_FLAG_GE flags respectively. [1] https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst#:~:text=compose%20rectangle%20as-,close,-as%20possible%20to Regards Devarsh