From patchwork Fri Aug 10 11:21:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 1305661 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 333D6DF266 for ; Fri, 10 Aug 2012 13:55:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18BB8A0B01 for ; Fri, 10 Aug 2012 06:55:16 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from ams-iport-2.cisco.com (ams-iport-2.cisco.com [144.254.224.141]) by gabe.freedesktop.org (Postfix) with ESMTP id 30B6B9EBCD for ; Fri, 10 Aug 2012 04:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=hans.verkuil@cisco.com; l=2576; q=dns/txt; s=iport; t=1344598277; x=1345807877; h=from:to:cc:subject:date:message-id; bh=+OkfVhcrN+I14KFP5996g+E/Yk4I8zKqgGAG88cfCsY=; b=hmcEH2/OTSdYPj3SIPWL4Ufq/zVgz5pO/7WPSCqoZ8fwGDsvraJg+OFI TNmxyMDwRxcKYB/r9YYrt67Ye3XvcKI5nP+uToNER7Q5n9UGwVKDMqVzJ d1MBw8KO+VJSx2jFmsKOBSXOEhsx2onB4DYZGN59IJBY2CEdnCpbK8wlj Y=; X-IronPort-AV: E=Sophos;i="4.77,745,1336348800"; d="scan'208";a="75910698" Received: from ams-core-1.cisco.com ([144.254.72.81]) by ams-iport-2.cisco.com with ESMTP; 10 Aug 2012 11:21:33 +0000 Received: from cobaltpc1.cisco.com (dhcp-10-54-92-107.cisco.com [10.54.92.107]) by ams-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id q7ABLUxY020363; Fri, 10 Aug 2012 11:21:32 GMT From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [RFCv3 PATCH 5/8] v4l2-common: add v4l_match_dv_timings. Date: Fri, 10 Aug 2012 13:21:21 +0200 Message-Id: <2e7ff1685d7f232a97f551be4ab897b21e252c1e.1344592468.git.hans.verkuil@cisco.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1344597684-8413-1-git-send-email-hans.verkuil@cisco.com> References: <1344597684-8413-1-git-send-email-hans.verkuil@cisco.com> In-Reply-To: References: X-Mailman-Approved-At: Fri, 10 Aug 2012 06:49:47 -0700 Cc: Tomasz Stanislawski , Scott Jiang , Mauro Carvalho Chehab , mats.randgaard@cisco.com, dri-devel@lists.freedesktop.org, Soby Mathew , marbugge@cisco.com, manjunath.hadli@ti.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Add the v4l_match_dv_timings function that can be used to compare two v4l2_dv_timings structs. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-common.c | 33 +++++++++++++++++++++++++++++++++ include/media/v4l2-common.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 1baec83..38da47c 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -597,6 +597,39 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) } EXPORT_SYMBOL_GPL(v4l_fill_dv_preset_info); +/** + * v4l_match_dv_timings - check if two timings match + * @t1 - compare this v4l2_dv_timings struct... + * @t2 - with this struct. + * @pclock_delta - the allowed pixelclock deviation. + * + * Compare t1 with t2 with a given margin of error for the pixelclock. + */ +bool v4l_match_dv_timings(const struct v4l2_dv_timings *t1, + const struct v4l2_dv_timings *t2, + unsigned pclock_delta) +{ + if (t1->type != t2->type || t1->type != V4L2_DV_BT_656_1120) + return false; + if (t1->bt.width == t2->bt.width && + t1->bt.height == t2->bt.height && + t1->bt.interlaced == t2->bt.interlaced && + t1->bt.polarities == t2->bt.polarities && + t1->bt.pixelclock >= t2->bt.pixelclock - pclock_delta && + t1->bt.pixelclock <= t2->bt.pixelclock + pclock_delta && + t1->bt.hfrontporch == t2->bt.hfrontporch && + t1->bt.vfrontporch == t2->bt.vfrontporch && + t1->bt.vsync == t2->bt.vsync && + t1->bt.vbackporch == t2->bt.vbackporch && + (!t1->bt.interlaced || + (t1->bt.il_vfrontporch == t2->bt.il_vfrontporch && + t1->bt.il_vsync == t2->bt.il_vsync && + t1->bt.il_vbackporch == t2->bt.il_vbackporch))) + return true; + return false; +} +EXPORT_SYMBOL_GPL(v4l_match_dv_timings); + const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( const struct v4l2_discrete_probe *probe, s32 width, s32 height) diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index a298ec4..b43b968 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -212,4 +212,8 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( const struct v4l2_discrete_probe *probe, s32 width, s32 height); +bool v4l_match_dv_timings(const struct v4l2_dv_timings *t1, + const struct v4l2_dv_timings *t2, + unsigned pclock_delta); + #endif /* V4L2_COMMON_H_ */