Added TI patches, generated from commit 04f9d72 of the following tree:
[ubuntu-omap:gst-plugins-bad1-0.git] / debian / patches / 0071-PATCH-11-33-kmssink-share-the-drm-fd-with-other-elem.patch
1 From cdd3d051c95913e57b97e4a5e4402d05cfa2bdd0 Mon Sep 17 00:00:00 2001
2 From: Alessandro Decina <alessandro.decina@collabora.co.uk>
3 Date: Thu, 24 May 2012 07:11:07 +0000
4 Subject: [PATCH 071/100] [PATCH 11/33] kmssink: share the drm fd with other
5  elements in the pipeline
6
7 Implement the GstVideoContext interface to share the drm fd with
8 other elements (eg gst-ducati). This change removes the kmssink
9 dependency on libdce. libdce is still needed by the
10 sys/kms/gstducati*buffer code, but that will go away soon too.
11 ---
12  sys/kms/Makefile.am  |    8 ++---
13  sys/kms/gstkmssink.c |   94 +++++++++++++++++++++++++++++++++++++++-----------
14  2 files changed, 77 insertions(+), 25 deletions(-)
15
16 diff --git a/sys/kms/Makefile.am b/sys/kms/Makefile.am
17 index ab07641..08237e1 100644
18 --- a/sys/kms/Makefile.am
19 +++ b/sys/kms/Makefile.am
20 @@ -5,13 +5,13 @@ libgstkmssink_la_SOURCES =  gstkmssink.c gstdrmutils.c \
21                             gstducatibuffer.c \
22                             gstducatidrmbuffer.c \
23                             gstducatikmsbuffer.c
24 -libgstkmssink_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \
25 +libgstkmssink_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \
26                           $(DRM_CFLAGS) $(LIBDCE_CFLAGS)
27  libgstkmssink_la_LIBADD = \
28 -       $(GST_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
29 +       $(GST_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) -lgstbasevideo-$(GST_MAJORMINOR) \
30         $(GST_LIBS) \
31 -       $(DRM_LIBS) \
32 -       $(LIBDCE_LIBS)
33 +       $(LIBDCE_LIBS) \
34 +       $(DRM_LIBS)
35  
36  libgstkmssink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
37  libgstkmssink_la_LIBTOOLFLAGS = --tag=disable-static
38 diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
39 index 7aa508b..8c10e74 100644
40 --- a/sys/kms/gstkmssink.c
41 +++ b/sys/kms/gstkmssink.c
42 @@ -28,13 +28,19 @@
43  #include "config.h"
44  #endif
45  
46 +#include <gst/video/videocontext.h>
47  #include "gstkmssink.h"
48  #include "gstducatikmsbuffer.h"
49  
50  GST_DEBUG_CATEGORY_STATIC (gst_debug_kms_sink);
51  #define GST_CAT_DEFAULT gst_debug_kms_sink
52  
53 -G_DEFINE_TYPE (GstKMSSink, gst_kms_sink, GST_TYPE_VIDEO_SINK);
54 +static void
55 +gst_kms_sink_video_context_interface_init (GstVideoContextInterface * iface);
56 +
57 +G_DEFINE_TYPE_EXTENDED (GstKMSSink, gst_kms_sink, GST_TYPE_VIDEO_SINK, 0,
58 +    G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_CONTEXT,
59 +        gst_kms_sink_video_context_interface_init));
60  
61  static void gst_kms_sink_reset (GstKMSSink * sink);
62  
63 @@ -153,13 +159,6 @@ gst_kms_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
64    sink->plane = NULL;
65  
66    return TRUE;
67 -
68 -fail:
69 -  return FALSE;
70 -
71 -plane_not_found:
72 -  GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, (NULL), ("plane not found"));
73 -  goto fail;
74  }
75  
76  static void
77 @@ -183,6 +182,48 @@ gst_kms_sink_get_times (GstBaseSink * bsink, GstBuffer * buf,
78    }
79  }
80  
81 +static gboolean
82 +gst_kms_sink_query (GstBaseSink * basesink, GstQuery * query)
83 +{
84 +  gboolean res = FALSE;
85 +  GstKMSSink *sink = GST_KMS_SINK (basesink);
86 +
87 +  switch (GST_QUERY_TYPE (query)) {
88 +    case GST_QUERY_CUSTOM:
89 +    {
90 +      const gchar **types;
91 +      gint i;
92 +      GstStructure *structure;
93 +
94 +      structure = gst_query_get_structure (query);
95 +      if (strcmp (gst_structure_get_name (structure), "prepare-video-context"))
96 +        break;
97 +
98 +      types = gst_video_context_query_get_supported_types (query);
99 +      for (i = 0; types[i]; i++) {
100 +        if (strcmp (types[i], "drm-fd"))
101 +          continue;
102 +
103 +        if (sink->fd != -1) {
104 +          gst_structure_set (structure,
105 +              "video-context-type", G_TYPE_STRING, types[i],
106 +              "video-context", G_TYPE_INT, sink->fd, NULL);
107 +
108 +          res = TRUE;
109 +        }
110 +
111 +        break;
112 +      }
113 +
114 +      break;
115 +    }
116 +    default:
117 +      break;
118 +  }
119 +
120 +  return res;
121 +}
122 +
123  static GstFlowReturn
124  gst_kms_sink_show_frame (GstVideoSink * vsink, GstBuffer * inbuf)
125  {
126 @@ -197,7 +238,6 @@ gst_kms_sink_show_frame (GstVideoSink * vsink, GstBuffer * inbuf)
127    GST_INFO_OBJECT (sink, "enter");
128  
129    if (sink->conn.crtc == -1) {
130 -    GstVideoRectangle src = { 0 };
131      GstVideoRectangle dest = { 0 };
132  
133      if (!gst_drm_connector_find_mode_and_plane (sink->fd,
134 @@ -415,17 +455,12 @@ gst_kms_sink_reset (GstKMSSink * sink)
135    }
136  
137    if (sink->dev) {
138 -#if 0
139      omap_device_del (sink->dev);
140 -#endif
141 -    dce_deinit (sink->dev);
142      sink->dev = NULL;
143    }
144  
145    if (sink->fd != -1) {
146 -#if 0
147      close (sink->fd);
148 -#endif
149      sink->fd = -1;
150    }
151  
152 @@ -446,19 +481,20 @@ static gboolean
153  gst_kms_sink_start (GstBaseSink * bsink)
154  {
155    GstKMSSink *sink;
156 +  const gchar *context_types[] = { "drm-fd", NULL };
157  
158    sink = GST_KMS_SINK (bsink);
159 -#if 0
160 -  sink->fd = drmOpen ("omapdrm", NULL);
161 -  if (sink->fd < 0)
162 -    goto open_failed;
163 +
164 +  gst_video_context_prepare (GST_VIDEO_CONTEXT (sink), context_types);
165 +  if (sink->fd == -1) {
166 +    sink->fd = drmOpen ("omapdrm", NULL);
167 +    if (sink->fd < 0)
168 +      goto open_failed;
169 +  }
170  
171    sink->dev = omap_device_new (sink->fd);
172    if (sink->dev == NULL)
173      goto device_failed;
174 -#endif
175 -  sink->dev = dce_init ();
176 -  sink->fd = dce_get_fd ();
177  
178    sink->resources = drmModeGetResources (sink->fd);
179    if (sink->resources == NULL)
180 @@ -557,6 +593,21 @@ beach:
181  }
182  
183  static void
184 +gst_kms_sink_set_video_context (GstVideoContext * context,
185 +    const gchar * type, const GValue * value)
186 +{
187 +  GstKMSSink *sink = GST_KMS_SINK (context);
188 +
189 +  sink->fd = g_value_get_int (value);
190 +}
191 +
192 +static void
193 +gst_kms_sink_video_context_interface_init (GstVideoContextInterface * iface)
194 +{
195 +  iface->set_context = gst_kms_sink_set_video_context;
196 +}
197 +
198 +static void
199  gst_kms_sink_finalize (GObject * object)
200  {
201    GstKMSSink *sink;
202 @@ -620,6 +671,7 @@ gst_kms_sink_class_init (GstKMSSinkClass * klass)
203    gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_kms_sink_setcaps);
204    gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_kms_sink_get_times);
205    gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_kms_sink_event);
206 +  gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_kms_sink_query);
207    gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_kms_sink_start);
208    gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_kms_sink_stop);
209    gstbasesink_class->buffer_alloc =
210 -- 
211 1.7.9.5
212