From patchwork Thu Jun 28 16:20:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10494419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AEDC603EE for ; Thu, 28 Jun 2018 16:21:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C1F92A4BA for ; Thu, 28 Jun 2018 16:21:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20B782A4BF; Thu, 28 Jun 2018 16:21:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD5682A4BC for ; Thu, 28 Jun 2018 16:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967339AbeF1QVy (ORCPT ); Thu, 28 Jun 2018 12:21:54 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:41955 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967336AbeF1QVx (ORCPT ); Thu, 28 Jun 2018 12:21:53 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYZfV-0004p3-Dh; Thu, 28 Jun 2018 18:21:13 +0200 Received: from mfe by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fYZfQ-0007FL-Jx; Thu, 28 Jun 2018 18:21:08 +0200 From: Marco Felsch To: mchehab@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: p.zabel@pengutronix.de, afshin.nasser@gmail.com, javierm@redhat.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 05/22] [media] v4l2-rect.h: add position and equal helpers Date: Thu, 28 Jun 2018 18:20:37 +0200 Message-Id: <20180628162054.25613-6-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180628162054.25613-1-m.felsch@pengutronix.de> References: <20180628162054.25613-1-m.felsch@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add two helper functions to check if two rectangles have the same position (top/left) and if two rectangles equals (same size and same position). Signed-off-by: Marco Felsch Acked-by: Sakari Ailus --- include/media/v4l2-rect.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h index 595c3ba05f23..1ae25f599a6f 100644 --- a/include/media/v4l2-rect.h +++ b/include/media/v4l2-rect.h @@ -82,6 +82,33 @@ static inline bool v4l2_rect_same_size(const struct v4l2_rect *r1, return r1->width == r2->width && r1->height == r2->height; } +/** + * v4l2_rect_same_position() - return true if r1 has the same position as r2 + * @r1: rectangle. + * @r2: rectangle. + * + * Return true if both rectangles have the same position + */ +static inline bool v4l2_rect_same_position(const struct v4l2_rect *r1, + const struct v4l2_rect *r2) +{ + return r1->top == r2->top && r1->left == r2->left; + +} + +/** + * v4l2_rect_equal() - return true if r1 equals r2 + * @r1: rectangle. + * @r2: rectangle. + * + * Return true if both rectangles have the same size and position. + */ +static inline bool v4l2_rect_equal(const struct v4l2_rect *r1, + const struct v4l2_rect *r2) +{ + return v4l2_rect_same_size(r1, r2) && v4l2_rect_same_position(r1, r2); +} + /** * v4l2_rect_intersect() - calculate the intersection of two rects. * @r: intersection of @r1 and @r2.