Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp428358ybm; Thu, 28 May 2020 06:29:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGrZrv1mzKZQA0Nk13D5mKNiqcaJxXxOVn+5fyPFhmYThv40ToSQ3MViBR1vl/JSrnqnxc X-Received: by 2002:a17:906:7855:: with SMTP id p21mr3048946ejm.257.1590672571827; Thu, 28 May 2020 06:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590672571; cv=none; d=google.com; s=arc-20160816; b=aR3iWs26nPeYuCrv1PLqihkTYWC54znkFXlzDMf1yM+TYyLtqxwa279ZQleYcZ6t0N F0PMOGW2+suCg3253nMe0o9v6I7VpPzKtdnslBbO6LShfN677XU/npZ7oi4S3eQ85k1J Ki9k4XbtpqJjj8WW8MGhbXlxLIDjHvsAiFTzxyjV1xxZatOMvxErNoVNsSF8qfQPadwr qvkTtZU24Djw8ACOJZ4UcbBjbo4fB7UiL8kowPlXcCgoHdcFOWO4os0x5lpCAHGaZ7q2 HtvJTMbxUxbzzgqJbG4s78J+WBt74ucFNmgvCcdMfju/XWrb8DVr2MZk1Zn0fOWp3F51 rJhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=L/yiPOBagfz8wPQbjlNHBugPa8Jb7cZfiONvNDsbqvw=; b=jzLg+BVzk8HLtfFv3bPYotlW3sEn18FNjetCmqdzMpoIvLrBDmmLQSz4BpBPrOVy8q mVrS9JIzmKGxbWIvdFsPx6CM7wy4BgrmVhRG9QqkNAbVRvHj29VNsvTHBZMwiX7gfI2r TOb5g3mDQzLrCbOHjyHmifGY/FUO/Kl/pR9ZfvNX201in42eyWVQDOtj010ZUE9BkWb3 46GRggMhm6+oNnuxzZZ3B3KhVa3AhrzOyTPjHp5yhaJ68NxzrU2vpDjxNy6ld8Zm8g4Q GYq0M1O7lmDELJ5aDD8a385/jQ/wLpIQ5z5V99fV38XWmoaLJcezjAYl6Apfm3Ql4qYp TCNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lqmne1OS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si3367450ejr.529.2020.05.28.06.29.07; Thu, 28 May 2020 06:29:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lqmne1OS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390330AbgE1N1G (ORCPT + 99 others); Thu, 28 May 2020 09:27:06 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:47464 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390283AbgE1N0o (ORCPT ); Thu, 28 May 2020 09:26:44 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04SDQcqv044454; Thu, 28 May 2020 08:26:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1590672398; bh=L/yiPOBagfz8wPQbjlNHBugPa8Jb7cZfiONvNDsbqvw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lqmne1OSKRg6NIJqjVCMYfJeGQ0X3EsOKHXCNbwGFECDRpqq19I56h8jBP9FtG+1O ybHUAzbBroa1AK6ShTMQH4zzppZYmHjz82J33Fa62U46JPhVFe0JMG0m8ZeaBjxQ2S EE2LzBu2HUWkz1jnZDx4l9QpX1qLREc8vVlC2cPY= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 04SDQbHg071464 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 May 2020 08:26:38 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 28 May 2020 08:26:37 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 28 May 2020 08:26:37 -0500 Received: from ula0869644.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04SDQWxS130696; Thu, 28 May 2020 08:26:37 -0500 From: Benoit Parrot To: Hans Verkuil , Prabhakar Lad , Kyungmin Park , Kukjin Kim , Sylwester Nawrocki , Krzysztof Kozlowski , Andrzej Pietrasiewicz , Jacek Anaszewski CC: , , Benoit Parrot Subject: [Patch 1/2] media: v4l2-rect.h: add enclosed rectangle helper Date: Thu, 28 May 2020 08:26:04 -0500 Message-ID: <20200528132605.18339-2-bparrot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528132605.18339-1-bparrot@ti.com> References: <20200528132605.18339-1-bparrot@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper function to check if one rectangle is enclosed inside another. Signed-off-by: Benoit Parrot --- include/media/v4l2-rect.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h index 8800a640c224..bd587d0c0dc3 100644 --- a/include/media/v4l2-rect.h +++ b/include/media/v4l2-rect.h @@ -184,4 +184,24 @@ static inline bool v4l2_rect_overlap(const struct v4l2_rect *r1, return true; } +/** + * v4l2_rect_enclosed() - is r1 enclosed in r2? + * @r1: rectangle. + * @r2: rectangle. + * + * Returns true if @r1 is enclosed in @r2. + */ +static inline bool v4l2_rect_enclosed(struct v4l2_rect *r1, + struct v4l2_rect *r2) +{ + if (r1->left < r2->left || r1->top < r2->top) + return false; + if (r1->left + r1->width > r2->left + r2->width) + return false; + if (r1->top + r1->height > r2->top + r2->height) + return false; + + return true; +} + #endif -- 2.17.1