aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2016-07-21 15:38:38 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2016-11-03 15:43:10 +0100
commitaf130511285045bf773e5fc5bf577de26fc6f5a3 (patch)
treec28d249c0c31fff8a3ba0d3cc94c8078f766ac4e
parent27529c670742336a118c40859713dc775cced1d7 (diff)
v4l2-dv-timings: add v4l2_dv_timings_cea861_aspect_ratiovic
This new function determines the picture aspect ratio from the DV timings and returns it in CEA-861 AVI InfoFrame format. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c18
-rw-r--r--include/media/v4l2-dv-timings.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 337ca237a84c..cc87ff1cebb3 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -23,6 +23,7 @@
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/rational.h>
+#include <linux/hdmi.h>
#include <linux/videodev2.h>
#include <linux/v4l2-dv-timings.h>
#include <media/v4l2-dv-timings.h>
@@ -384,6 +385,23 @@ struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t)
}
EXPORT_SYMBOL_GPL(v4l2_dv_timings_aspect_ratio);
+u8 v4l2_dv_timings_cea861_aspect_ratio(const struct v4l2_dv_timings *t)
+{
+ unsigned int w = t->bt.width;
+ unsigned int h = t->bt.height;
+
+ if (t->bt.flags & V4L2_DV_FL_HAS_PICTURE_ASPECT) {
+ w = t->bt.picture_aspect.numerator;
+ h = t->bt.picture_aspect.denominator;
+ }
+ if (w * 3 == h * 4)
+ return HDMI_PICTURE_ASPECT_4_3;
+ if (w * 9 == h * 16)
+ return HDMI_PICTURE_ASPECT_16_9;
+ return HDMI_PICTURE_ASPECT_NONE;
+}
+EXPORT_SYMBOL_GPL(v4l2_dv_timings_cea861_aspect_ratio);
+
/*
* CVT defines
* Based on Coordinated Video Timings Standard
diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h
index 3722ce8eac76..efae7b1b153e 100644
--- a/include/media/v4l2-dv-timings.h
+++ b/include/media/v4l2-dv-timings.h
@@ -203,6 +203,14 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
*/
struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t);
+/**
+ * v4l2_dv_timings_cea861_aspect_ratio() - return CEA-861 picture aspect ratio
+ * @t: the timings data.
+ *
+ * Returns the CEA-861 picture aspect ratio value (AVI InfoFrame bits M0+M1)
+ */
+u8 v4l2_dv_timings_cea861_aspect_ratio(const struct v4l2_dv_timings *t);
+
/*
* reduce_fps - check if conditions for reduced fps are true.
* bt - v4l2 timing structure

Privacy Policy