summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-ti/recipes-arago/gstreamer/gstreamer1.0-plugins-bad/0003-kmssink-add-YUYV-support.patch
blob: a57a0bbfa412e511c4174c79bf6e8655eff2d13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From 11a3ff4b9451f12374006f853ef5736f5d098932 Mon Sep 17 00:00:00 2001
From: Eric Ruei <e-ruei1@ti.com>
Date: Tue, 14 Mar 2017 17:24:07 -0400
Subject: [PATCH 3/3] kmssink: add YUYV support

Signed-off-by: Eric Ruei <e-ruei1@ti.com>
---
 sys/kms/gstkmsbufferpriv.c | 32 +++++++++++++++++++++++++++-----
 sys/kms/gstkmssink.c       |  2 +-
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/sys/kms/gstkmsbufferpriv.c b/sys/kms/gstkmsbufferpriv.c
index 172a4c3..57c01f8 100644
--- a/sys/kms/gstkmsbufferpriv.c
+++ b/sys/kms/gstkmsbufferpriv.c
@@ -41,22 +41,44 @@
 static int
 create_fb (GstKMSBufferPriv * priv, GstKMSSink * sink)
 {
+
   /* TODO get format, etc from caps.. and query device for
    * supported formats, and make this all more flexible to
    * cope with various formats:
    */
-  uint32_t fourcc = GST_MAKE_FOURCC ('N', 'V', '1', '2');
-
+  GstVideoFormat format = sink->format;
+  uint32_t fourcc;
   uint32_t handles[4] = {
-    omap_bo_handle (priv->bo), omap_bo_handle (priv->bo),
+    omap_bo_handle (priv->bo),
   };
   uint32_t pitches[4] = {
-    GST_ROUND_UP_4 (sink->input_width), GST_ROUND_UP_4 (sink->input_width),
+    GST_ROUND_UP_4 (sink->input_width),
   };
   uint32_t offsets[4] = {
-    0, pitches[0] * sink->input_height
+    0,
   };
 
+  /**
+   * Only two formats are supported:
+   * AM3/4: YUYV
+   * AM5: NV12, YUYV
+   */
+  if(format == GST_VIDEO_FORMAT_YUY2)
+  {
+    /* YUYV */
+    fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', 'V');
+    pitches[0] = GST_ROUND_UP_4 (sink->input_width*2);
+  }
+  else
+  {
+    /* NV12 */
+    fourcc = GST_MAKE_FOURCC ('N', 'V', '1', '2');
+    handles[1] = omap_bo_handle (priv->bo);
+    pitches[1] = GST_ROUND_UP_4 (sink->input_width);
+    offsets[1] = pitches[0] * sink->input_height;
+  }
+
+
   return drmModeAddFB2 (priv->fd, sink->input_width, sink->input_height,
       fourcc, handles, pitches, offsets, &priv->fb_id, 0);
 }
diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
index 9795bdf..b36d88f 100644
--- a/sys/kms/gstkmssink.c
+++ b/sys/kms/gstkmssink.c
@@ -50,7 +50,7 @@ static GstStaticPadTemplate gst_kms_sink_template_factory =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE("NV12"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE("{NV12,YUY2}"))
     );
 
 enum
-- 
1.9.1