Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1102163lqo; Fri, 17 May 2024 10:39:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVf8UDEbgPddz5mG2vyV97fbNLPwPWfSf1rgPBOCvuFWxtfhPd0L5JXRYYBZbrtTkJTPGsJCX0vPfDmLXyx63m3wYyh8ro5wPjIf0E8xg== X-Google-Smtp-Source: AGHT+IE9xB0McMDnRPi8frDDO4L0sPxfPZoSoRgoG1mXiMLg6NzpB74e5CVF0I3AnxI3zDxfYBOn X-Received: by 2002:a17:906:29cf:b0:a59:ab57:7413 with SMTP id a640c23a62f3a-a5a2d680d65mr1391167866b.73.1715967557437; Fri, 17 May 2024 10:39:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715967557; cv=pass; d=google.com; s=arc-20160816; b=ILQFwUibP31qb+1vpKaXWxadLBA2NUdOLb3jbCggXFLlnfSkRlWsVSbYFLtpJa+c1c NoSTHuXRsu2sAJfvY3LcxKDIySfmx74ivSnJUBt2Dpr79/ZAguzrgVP8kskuPrqu0X1D SVmdOulAsadywOKMeb58S0wVQ3QtAql5mRJ1Yh6Do4XIY6tjr4/gpUCTdsj0nNzMJAga DOWaOWmYohVyh/+UGsUV7QJu0Jhdj6QZQqs6WLa/VU3awGPisxXqxPh58/yLsrg90d/l 1EVu59ZJwBb6+s99+WlFSSkPFOs24mpowFL0Irsa663fp89xE3xXssasgjQ7foUXqULj er5A== 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=FNQ9SYEb9xcVs7Kzu/f1bAQjuhNomrYufflu1dSgjug=; fh=5DiuueyS1lAAqfho5bYx+Hd2/VuZEUnh7zjWzwl5vGk=; b=vdVsLEOPl0TGosBInZ8p5kLYlaBh3wuS2ILPj56+zv2UoNs5SowYwz8x2c2CUHyc/F J0JwBsgUBaNYNTxMQIX/ZQEs1CZfTQK3EzyghUqsj8Lu4ewymRO+c4OLn7fC7BVXSK8H 3mHAQkUYBM4SyeA6W6SwuZHmnHIoupoAIgBGXQTyvbMC+TjmwpgnF75GaLvDydlsx4cc kHxNuNE3xql7UhErzmLiRbfjVDQ2r2tN0zlg9cGH7PQ6AShbUStpHqbQyvoUIqiKFyg3 ZcmhmLW3SU/8Ffjpjx6M4eD8FnnKn8haXIWiiPUXyWohD6Lyq9QrIr01PAXlI2XS6JA1 jMQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=M8FakSIW; 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-182431-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182431-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1794625fsi1029798066b.115.2024.05.17.10.39.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182431-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=M8FakSIW; 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-182431-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182431-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2FECA1F2175B for ; Fri, 17 May 2024 17:39:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60D8B13E3E5; Fri, 17 May 2024 17:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="M8FakSIW" 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 D7E6213DDB7; Fri, 17 May 2024 17:38:51 +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=1715967533; cv=none; b=PdeuyNfeb1Tp/0llTG6GSYthJXst//01EZTVZ7F1jW4U48OZ4Lzw7UbA4IC6/2CKUJP4q9vtX392aEa4YidRHIRNxti2fa+Pb9aKiAO4ZZodVUclL5p9owJWoAeazpOXFUmqEBFfuKL6Zy68IG9bRNANduatedbI7zZyFmhok2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967533; c=relaxed/simple; bh=sK6BdYWdVcnr1feBf78EOTZrmEawiJ3PSYPuWNm2RUs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eezofbzXlxOYeryTZPfHJC4l15t1nt1R5IrgmH9ADH6Adi4o7Sh2ZSH8VV1IhIdZ5G8ovjOcdnbIAc68hMcT3varEc0iwBll+wD/17EClysA23KDM1TOuGK+g+Ryn/n0mdk6obqSukE1u6LFuEgOvrz+g5kz7+6CQ+BjwJ68N58= 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=M8FakSIW; 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44HHcbbZ078619; Fri, 17 May 2024 12:38:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715967517; bh=FNQ9SYEb9xcVs7Kzu/f1bAQjuhNomrYufflu1dSgjug=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=M8FakSIW7riPC6PgRlgGS9GFUIeWqtfiaY5hFTvPlxqnI0BVG6mn9QXk2lUlgrGE9 reWCQnSujfKN6iM5gGl4zf4wyLl6Arj5oS9BYdf7QD9JonTs+kFfnc8D40ik0UC9BP RtCT0lblE+SvmpHD4hKmGlVDR5YY4PDrx7y2siE4= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44HHcbKG046865 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 May 2024 12:38:37 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 17 May 2024 12:38:37 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE104.ent.ti.com (10.64.6.25) 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, 17 May 2024 12:38:37 -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 44HHcaQY008911; Fri, 17 May 2024 12:38:36 -0500 From: Devarsh Thakkar To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 09/10] media: imagination: Round to closest multiple for cropping region Date: Fri, 17 May 2024 23:08:36 +0530 Message-ID: <20240517173836.806498-1-devarsht@ti.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240517171532.748684-1-devarsht@ti.com> References: <20240517171532.748684-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 --- 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 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