aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-08-10 05:09:26 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-13 15:08:22 -0400
commitc2a667fa2b40ccb7d21a99ffae53610699a3102c (patch)
treee21c4f2141654ee0b9bd6c291db7e1bd49460f6f /drivers/media/v4l2-core
parent977ebec754cce0ab0c7d62d54ac6cd95833504f2 (diff)
[media] v4l2-common: add v4l_match_dv_timings
Add the v4l_match_dv_timings function that can be used to compare two v4l2_dv_timings structs. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-common.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 105f88cdb9d6..028133ba4c6b 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -597,6 +597,39 @@ int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info)
597} 597}
598EXPORT_SYMBOL_GPL(v4l_fill_dv_preset_info); 598EXPORT_SYMBOL_GPL(v4l_fill_dv_preset_info);
599 599
600/**
601 * v4l_match_dv_timings - check if two timings match
602 * @t1 - compare this v4l2_dv_timings struct...
603 * @t2 - with this struct.
604 * @pclock_delta - the allowed pixelclock deviation.
605 *
606 * Compare t1 with t2 with a given margin of error for the pixelclock.
607 */
608bool v4l_match_dv_timings(const struct v4l2_dv_timings *t1,
609 const struct v4l2_dv_timings *t2,
610 unsigned pclock_delta)
611{
612 if (t1->type != t2->type || t1->type != V4L2_DV_BT_656_1120)
613 return false;
614 if (t1->bt.width == t2->bt.width &&
615 t1->bt.height == t2->bt.height &&
616 t1->bt.interlaced == t2->bt.interlaced &&
617 t1->bt.polarities == t2->bt.polarities &&
618 t1->bt.pixelclock >= t2->bt.pixelclock - pclock_delta &&
619 t1->bt.pixelclock <= t2->bt.pixelclock + pclock_delta &&
620 t1->bt.hfrontporch == t2->bt.hfrontporch &&
621 t1->bt.vfrontporch == t2->bt.vfrontporch &&
622 t1->bt.vsync == t2->bt.vsync &&
623 t1->bt.vbackporch == t2->bt.vbackporch &&
624 (!t1->bt.interlaced ||
625 (t1->bt.il_vfrontporch == t2->bt.il_vfrontporch &&
626 t1->bt.il_vsync == t2->bt.il_vsync &&
627 t1->bt.il_vbackporch == t2->bt.il_vbackporch)))
628 return true;
629 return false;
630}
631EXPORT_SYMBOL_GPL(v4l_match_dv_timings);
632
600const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( 633const struct v4l2_frmsize_discrete *v4l2_find_nearest_format(
601 const struct v4l2_discrete_probe *probe, 634 const struct v4l2_discrete_probe *probe,
602 s32 width, s32 height) 635 s32 width, s32 height)