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: 1305131 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3C59CDF215 for ; Fri, 10 Aug 2012 11:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752782Ab2HJLVm (ORCPT ); Fri, 10 Aug 2012 07:21:42 -0400 Received: from ams-iport-2.cisco.com ([144.254.224.141]:44946 "EHLO ams-iport-2.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046Ab2HJLVe (ORCPT ); Fri, 10 Aug 2012 07:21:34 -0400 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=1344597694; x=1345807294; h=from:to:cc:subject:date:message-id; bh=+OkfVhcrN+I14KFP5996g+E/Yk4I8zKqgGAG88cfCsY=; b=duMO0+lCrCCohCNlsQJNKOtlQDXOIp+gZokrf/mXktwIzNuRhPZlBb1K EXQa7NwSsZfafMYfMHa1DjQhPEiWirhdkJ3XBuBzot2+rNXiImAH4FY46 TZVmKVrqThkAn/4Oi1wANZvGXNAXjAOc0fHy26IYTXcHfPpR9RaFU+bMO w=; 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 Cc: marbugge@cisco.com, Soby Mathew , mats.randgaard@cisco.com, manjunath.hadli@ti.com, Tomasz Stanislawski , Mauro Carvalho Chehab , Scott Jiang , dri-devel@lists.freedesktop.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: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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_ */