2f86f0681f85769dd89ee81bc14aad1055550e23
[platform/upstream/gstreamer.git] / sys / dxr3 / dxr3videosink.c
1 /* GStreamer
2  * Copyright (C) 2003 Martin Soto <martinsoto@users.sourceforge.net>
3  *
4  * dxr3videosink.c: Video sink for em8300 based cards.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 #include <errno.h>
26 #include <string.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 #include <sys/ioctl.h>
30
31 #include <linux/em8300.h>
32
33 #include <gst/gst-i18n-plugin.h>
34 #include <gst/gst.h>
35
36 #include "dxr3videosink.h"
37 #include "dxr3marshal.h"
38
39 #include "dxr3common.h"
40
41 /* Dxr3VideoSink signals and args */
42 enum
43 {
44   SIGNAL_FLUSHED,
45   LAST_SIGNAL
46 };
47
48 enum
49 {
50   ARG_0,
51 };
52
53 /* Possible states for the MPEG start code scanner. */
54 enum
55 {
56   SCAN_STATE_WAITING,           /* Waiting for a code. */
57   SCAN_STATE_0,                 /* 0 seen. */
58   SCAN_STATE_00,                /* 00 seen. */
59   SCAN_STATE_001                /* 001 seen. */
60 };
61
62 /* Possible states for the MPEG sequence parser. */
63 enum
64 {
65   PARSE_STATE_WAITING,          /* Waiting for the start of a sequence. */
66   PARSE_STATE_START,            /* Start of sequence seen. */
67   PARSE_STATE_PICTURE           /* Picture start seen. */
68 };
69
70
71 /* Relevant mpeg start codes. */
72 #define START_CODE_PICTURE 0x00
73 #define START_CODE_SEQUENCE_HEADER 0xB3
74 #define START_CODE_SEQUENCE_END 0xB7
75
76 static GstStaticPadTemplate dxr3videosink_sink_factory =
77 GST_STATIC_PAD_TEMPLATE ("sink",
78     GST_PAD_SINK,
79     GST_PAD_ALWAYS,
80     GST_STATIC_CAPS ("video/mpeg, "
81         "mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE"
82         /* width/height/framerate omitted, we don't
83          * need a parsed stream */
84     )
85     );
86
87
88 static void dxr3videosink_class_init (Dxr3VideoSinkClass * klass);
89 static void dxr3videosink_base_init (Dxr3VideoSinkClass * klass);
90 static void dxr3videosink_init (Dxr3VideoSink * dxr3videosink);
91
92 static void dxr3videosink_set_property (GObject * object,
93     guint prop_id, const GValue * value, GParamSpec * pspec);
94 static void dxr3videosink_get_property (GObject * object,
95     guint prop_id, GValue * value, GParamSpec * pspec);
96
97 static gboolean dxr3videosink_open (Dxr3VideoSink * sink);
98 static void dxr3videosink_close (Dxr3VideoSink * sink);
99 static void dxr3videosink_set_clock (GstElement * element, GstClock * clock);
100
101 static void dxr3videosink_reset_parser (Dxr3VideoSink * sink);
102 static int dxr3videosink_next_start_code (Dxr3VideoSink * sink);
103 static void dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut);
104 static void dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut);
105 static void dxr3videosink_parse_data (Dxr3VideoSink * sink);
106
107 static gboolean dxr3videosink_handle_event (GstPad * pad, GstEvent * event);
108 static void dxr3videosink_chain (GstPad * pad, GstData * _data);
109
110 static GstStateChangeReturn dxr3videosink_change_state (GstElement * element,
111     GstStateChange transition);
112
113 /* static void  dxr3videosink_wait              (Dxr3VideoSink *sink, */
114 /*                                                  GstClockTime time); */
115 static int dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command);
116
117 static void dxr3videosink_flushed (Dxr3VideoSink * sink);
118
119 static GstElementClass *parent_class = NULL;
120 static guint dxr3videosink_signals[LAST_SIGNAL] = { 0 };
121
122
123 extern GType
124 dxr3videosink_get_type (void)
125 {
126   static GType dxr3videosink_type = 0;
127
128   if (!dxr3videosink_type) {
129     static const GTypeInfo dxr3videosink_info = {
130       sizeof (Dxr3VideoSinkClass),
131       (GBaseInitFunc) dxr3videosink_base_init,
132       NULL,
133       (GClassInitFunc) dxr3videosink_class_init,
134       NULL,
135       NULL,
136       sizeof (Dxr3VideoSink),
137       0,
138       (GInstanceInitFunc) dxr3videosink_init,
139     };
140
141     dxr3videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
142         "Dxr3VideoSink", &dxr3videosink_info, 0);
143   }
144
145   return dxr3videosink_type;
146 }
147
148
149 static void
150 dxr3videosink_base_init (Dxr3VideoSinkClass * klass)
151 {
152   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
153
154   gst_element_class_add_pad_template (element_class,
155       gst_static_pad_template_get (&dxr3videosink_sink_factory));
156   gst_element_class_set_details_simple (element_class,
157       "dxr3/Hollywood+ mpeg decoder board video element", "Sink/Video",
158       "Feeds MPEG2 video to Sigma Designs em8300 based boards",
159       "Martin Soto <martinsoto@users.sourceforge.net>");
160 }
161
162 static void
163 dxr3videosink_class_init (Dxr3VideoSinkClass * klass)
164 {
165   GObjectClass *gobject_class;
166   GstElementClass *gstelement_class;
167
168   gobject_class = (GObjectClass *) klass;
169   gstelement_class = (GstElementClass *) klass;
170
171   parent_class = g_type_class_peek_parent (klass);
172
173   dxr3videosink_signals[SIGNAL_FLUSHED] =
174       g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
175       G_SIGNAL_RUN_LAST,
176       G_STRUCT_OFFSET (Dxr3VideoSinkClass, flushed),
177       NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
178
179   klass->flushed = dxr3videosink_flushed;
180
181   gobject_class->set_property = dxr3videosink_set_property;
182   gobject_class->get_property = dxr3videosink_get_property;
183
184   gstelement_class->change_state = dxr3videosink_change_state;
185   gstelement_class->set_clock = dxr3videosink_set_clock;
186 }
187
188
189 static void
190 dxr3videosink_init (Dxr3VideoSink * sink)
191 {
192   GstPad *pad;
193
194   pad = gst_pad_new_from_static_template (&dxr3videosink_sink_factory, "sink");
195   gst_element_add_pad (GST_ELEMENT (sink), pad);
196   gst_pad_set_chain_function (pad, dxr3videosink_chain);
197
198   GST_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
199
200   sink->card_number = 0;
201
202   sink->video_filename = NULL;
203   sink->video_fd = -1;
204   sink->control_filename = NULL;
205   sink->control_fd = -1;
206
207   sink->clock = NULL;
208
209   sink->last_ts = GST_CLOCK_TIME_NONE;
210
211   sink->cur_buf = NULL;
212   dxr3videosink_reset_parser (sink);
213 }
214
215
216 static void
217 dxr3videosink_set_property (GObject * object, guint prop_id,
218     const GValue * value, GParamSpec * pspec)
219 {
220   Dxr3VideoSink *sink;
221
222   sink = DXR3VIDEOSINK (object);
223
224   switch (prop_id) {
225     default:
226       break;
227   }
228 }
229
230
231 static void
232 dxr3videosink_get_property (GObject * object, guint prop_id,
233     GValue * value, GParamSpec * pspec)
234 {
235   Dxr3VideoSink *sink;
236
237   g_return_if_fail (GST_IS_DXR3VIDEOSINK (object));
238
239   sink = DXR3VIDEOSINK (object);
240
241   switch (prop_id) {
242     default:
243       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
244       break;
245   }
246 }
247
248
249 static gboolean
250 dxr3videosink_open (Dxr3VideoSink * sink)
251 {
252   g_return_val_if_fail (!GST_OBJECT_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN),
253       FALSE);
254
255   /* Compute the name of the video device file. */
256   sink->video_filename = g_strdup_printf ("/dev/em8300_mv-%d",
257       sink->card_number);
258
259   sink->video_fd = open (sink->video_filename, O_WRONLY);
260   if (sink->video_fd < 0) {
261     GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
262         (_("Could not open video device \"%s\" for writing."),
263             sink->video_filename), GST_ERROR_SYSTEM);
264     return FALSE;
265   }
266
267   /* Open the control device. */
268   sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
269       sink->card_number);
270
271   sink->control_fd = open (sink->control_filename, O_WRONLY);
272   if (sink->control_fd < 0) {
273     GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
274         (_("Could not open control device \"%s\" for writing."),
275             sink->control_filename), GST_ERROR_SYSTEM);
276     return FALSE;
277   }
278
279   GST_OBJECT_FLAG_SET (sink, DXR3VIDEOSINK_OPEN);
280
281   return TRUE;
282 }
283
284
285 static void
286 dxr3videosink_close (Dxr3VideoSink * sink)
287 {
288   g_return_if_fail (GST_OBJECT_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN));
289
290   if (close (sink->video_fd) != 0) {
291     GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
292         (_("Could not close video device \"%s\"."), sink->video_filename),
293         GST_ERROR_SYSTEM);
294     return;
295   }
296
297   if (close (sink->control_fd) != 0) {
298     GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
299         (_("Could not close control device \"%s\"."), sink->control_filename),
300         GST_ERROR_SYSTEM);
301     return;
302   }
303
304   GST_OBJECT_FLAG_UNSET (sink, DXR3VIDEOSINK_OPEN);
305
306   free (sink->video_filename);
307   sink->video_filename = NULL;
308 }
309
310
311 static void
312 dxr3videosink_set_clock (GstElement * element, GstClock * clock)
313 {
314   Dxr3VideoSink *src = DXR3VIDEOSINK (element);
315
316   src->clock = clock;
317 }
318
319
320 static void
321 dxr3videosink_reset_parser (Dxr3VideoSink * sink)
322 {
323   if (sink->cur_buf != NULL) {
324     gst_buffer_unref (sink->cur_buf);
325     sink->cur_buf = NULL;
326   }
327   sink->cur_ts = GST_CLOCK_TIME_NONE;
328
329   sink->scan_state = SCAN_STATE_WAITING;
330   sink->scan_pos = 0;
331
332   sink->parse_state = PARSE_STATE_WAITING;
333 }
334
335
336 static int
337 dxr3videosink_next_start_code (Dxr3VideoSink * sink)
338 {
339   guchar c;
340
341   g_return_val_if_fail (sink->cur_buf != NULL, -1);
342
343   while (sink->scan_pos < GST_BUFFER_SIZE (sink->cur_buf)) {
344     c = (GST_BUFFER_DATA (sink->cur_buf))[sink->scan_pos];
345
346     switch (sink->scan_state) {
347       case SCAN_STATE_WAITING:
348         if (c == 0x00) {
349           sink->scan_state = SCAN_STATE_0;
350         }
351         break;
352       case SCAN_STATE_0:
353         if (c == 0x00) {
354           sink->scan_state = SCAN_STATE_00;
355         } else {
356           sink->scan_state = SCAN_STATE_WAITING;
357         }
358         break;
359       case SCAN_STATE_00:
360         if (c == 0x01) {
361           sink->scan_state = SCAN_STATE_001;
362         } else if (c != 0x00) {
363           sink->scan_state = SCAN_STATE_WAITING;
364         }
365         break;
366       case SCAN_STATE_001:
367         sink->scan_pos++;
368         sink->scan_state = SCAN_STATE_WAITING;
369         return c;
370     }
371
372     sink->scan_pos++;
373   }
374
375   return -1;
376 }
377
378
379 static void
380 dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut)
381 {
382   GstBuffer *sub;
383   guint size;
384
385   g_return_if_fail (sink->cur_buf != NULL);
386   g_assert (cut <= sink->scan_pos);
387
388   size = sink->scan_pos - cut;
389
390   g_return_if_fail (size <= GST_BUFFER_SIZE (sink->cur_buf));
391
392   if (GST_BUFFER_SIZE (sink->cur_buf) == size) {
393     gst_buffer_unref (sink->cur_buf);
394     sink->cur_buf = NULL;
395   } else {
396     sub = gst_buffer_create_sub (sink->cur_buf, size,
397         GST_BUFFER_SIZE (sink->cur_buf)
398         - size);
399     gst_buffer_unref (sink->cur_buf);
400     sink->cur_buf = sub;
401   }
402
403   sink->scan_state = SCAN_STATE_WAITING;
404   sink->scan_pos = cut;
405
406   sink->cur_ts = GST_CLOCK_TIME_NONE;
407 }
408
409
410 static void
411 dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut)
412 {
413   guint size, written;
414   guint8 *data;
415
416   g_return_if_fail (sink->cur_buf != NULL);
417
418   if (GST_OBJECT_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN)) {
419     if (sink->cur_ts != GST_CLOCK_TIME_NONE) {
420       guint pts;
421
422 /*       fprintf (stderr, "------ Video Time %.04f\n", */
423 /*                (double) sink->cur_ts / GST_SECOND); */
424
425       pts = (guint) GSTTIME_TO_MPEGTIME (sink->cur_ts);
426       ioctl (sink->video_fd, EM8300_IOCTL_VIDEO_SETPTS, &pts);
427       sink->cur_ts = GST_CLOCK_TIME_NONE;
428     }
429
430     data = GST_BUFFER_DATA (sink->cur_buf);
431     size = sink->scan_pos - cut;
432
433     g_assert (size <= GST_BUFFER_SIZE (sink->cur_buf));
434
435     /* We should always write data that corresponds to whole MPEG
436        video sintactical elements.  They should always start with an
437        MPEG start code. */
438     g_assert (size >= 4 && data[0] == 0 && data[1] == 0 && data[2] == 1);
439
440     while (size > 0) {
441       written = write (sink->video_fd, data, size);
442       if (written < 0) {
443         GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
444             (_("Could not write to device \"%s\"."), sink->video_filename),
445             GST_ERROR_SYSTEM);
446         break;
447       }
448       size = size - written;
449       data = data + written;
450     };
451   }
452
453   dxr3videosink_discard_data (sink, cut);
454 }
455
456
457 static void
458 dxr3videosink_parse_data (Dxr3VideoSink * sink)
459 {
460   int code;
461
462   /* Timestamp handling assumes that timestamps are associated to
463      sequence starts.  This seems to be the case, at least for
464      DVDs. */
465
466   code = dxr3videosink_next_start_code (sink);
467   while (code >= 0) {
468     switch (sink->parse_state) {
469
470       case PARSE_STATE_WAITING:
471         if (code == START_CODE_SEQUENCE_HEADER) {
472           dxr3videosink_discard_data (sink, 4);
473           sink->parse_state = PARSE_STATE_START;
474           sink->cur_ts = sink->last_ts;
475         }
476         break;
477
478       case PARSE_STATE_START:
479         switch (code) {
480           case START_CODE_SEQUENCE_HEADER:
481             dxr3videosink_discard_data (sink, 4);
482             sink->cur_ts = sink->last_ts;
483             break;
484           case START_CODE_SEQUENCE_END:
485             dxr3videosink_discard_data (sink, 0);
486             sink->parse_state = PARSE_STATE_WAITING;
487             break;
488           case START_CODE_PICTURE:
489             sink->parse_state = PARSE_STATE_PICTURE;
490             break;
491         }
492         break;
493
494       case PARSE_STATE_PICTURE:
495         switch (code) {
496           case START_CODE_SEQUENCE_HEADER:
497             dxr3videosink_write_data (sink, 4);
498             sink->parse_state = PARSE_STATE_START;
499             sink->cur_ts = sink->last_ts;
500             break;
501           case START_CODE_SEQUENCE_END:
502             dxr3videosink_write_data (sink, 0);
503             sink->parse_state = PARSE_STATE_WAITING;
504             break;
505           case START_CODE_PICTURE:
506             dxr3videosink_write_data (sink, 4);
507             break;
508         }
509         break;
510
511     }
512
513     code = dxr3videosink_next_start_code (sink);
514   }
515
516   if (sink->parse_state == PARSE_STATE_WAITING) {
517     dxr3videosink_discard_data (sink, 0);
518   }
519 }
520
521
522 static gboolean
523 dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
524 {
525   GstEventType type;
526   Dxr3VideoSink *sink;
527
528   sink = DXR3VIDEOSINK (gst_pad_get_parent (pad));
529
530   type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
531
532   switch (type) {
533     case GST_EVENT_EMPTY:
534       //fprintf (stderr, "++++++ Video empty event\n");
535     {
536       /* FIXME: Handle this with a discontinuity or something. */
537       /* Write an MPEG2 sequence end code, to ensure that the card
538          actually displays the last picture.  Apparently some DVDs are
539          encoded without proper sequence end codes. */
540       static guint8 sec[4] = { 0x00, 0x00, 0x01, 0xb7 };
541
542       if (sink->cur_buf != NULL) {
543         dxr3videosink_write_data (sink, 0);
544       }
545
546       write (sink->video_fd, &sec, 4);
547     }
548       break;
549
550     case GST_EVENT_DISCONTINUOUS:
551       //fprintf (stderr, "++++++ Video discont event\n");
552     {
553       gint64 time;
554       gboolean has_time;
555       unsigned cur_scr, mpeg_scr, diff;
556
557       has_time = gst_event_discont_get_value (event, GST_FORMAT_TIME, &time);
558       if (has_time) {
559 /*         fprintf (stderr, "^^^^^^ Discontinuous event has time %.4f\n", */
560 /*                  (double) time / GST_SECOND); */
561
562         /* If the SCR in the card is way off, fix it. */
563         ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr);
564         mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time));
565
566         diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr;
567         if (diff > 1800) {
568           unsigned zero = 0;
569
570 /*           fprintf (stderr, "====== Adjusting SCR from video\n"); */
571
572           ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero);
573           ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr);
574         }
575       } else {
576 /*         fprintf (stderr, "^^^^^^ Discontinuous event has no time\n"); */
577       }
578     }
579       break;
580
581     case GST_EVENT_FLUSH:
582       dxr3videosink_reset_parser (sink);
583       break;
584
585     default:
586       gst_pad_event_default (pad, event);
587       break;
588   }
589
590   return TRUE;
591 }
592
593
594 static void
595 dxr3videosink_chain (GstPad * pad, GstData * _data)
596 {
597   GstBuffer *buf = GST_BUFFER (_data);
598   Dxr3VideoSink *sink;
599   GstBuffer *merged;
600
601   g_return_if_fail (pad != NULL);
602   g_return_if_fail (GST_IS_PAD (pad));
603   g_return_if_fail (buf != NULL);
604
605   sink = DXR3VIDEOSINK (gst_pad_get_parent (pad));
606
607   if (GST_IS_EVENT (buf)) {
608     dxr3videosink_handle_event (pad, GST_EVENT (buf));
609     return;
610   }
611
612 /*   fprintf (stderr, "^^^^^^ Video block\n"); */
613
614   if (sink->cur_buf == NULL) {
615     sink->cur_buf = buf;
616   } else {
617     merged = gst_buffer_merge (sink->cur_buf, buf);
618     gst_buffer_unref (sink->cur_buf);
619     gst_buffer_unref (buf);
620     sink->cur_buf = merged;
621   }
622
623   sink->last_ts = GST_BUFFER_TIMESTAMP (buf);
624
625   dxr3videosink_parse_data (sink);
626 }
627
628
629 static GstStateChangeReturn
630 dxr3videosink_change_state (GstElement * element, GstStateChange transition)
631 {
632   g_return_val_if_fail (GST_IS_DXR3VIDEOSINK (element),
633       GST_STATE_CHANGE_FAILURE);
634
635   switch (transition) {
636     case GST_STATE_CHANGE_NULL_TO_READY:
637       if (!GST_OBJECT_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) {
638         if (!dxr3videosink_open (DXR3VIDEOSINK (element))) {
639           return GST_STATE_CHANGE_FAILURE;
640         }
641       }
642       break;
643     case GST_STATE_CHANGE_READY_TO_PAUSED:
644       dxr3videosink_mvcommand (DXR3VIDEOSINK (element), MVCOMMAND_PAUSE);
645       break;
646     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
647       dxr3videosink_mvcommand (DXR3VIDEOSINK (element), MVCOMMAND_START);
648       break;
649     case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
650       dxr3videosink_mvcommand (DXR3VIDEOSINK (element), MVCOMMAND_PAUSE);
651       break;
652     case GST_STATE_CHANGE_PAUSED_TO_READY:
653       dxr3videosink_mvcommand (DXR3VIDEOSINK (element), MVCOMMAND_STOP);
654       break;
655     case GST_STATE_CHANGE_READY_TO_NULL:
656       if (GST_OBJECT_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) {
657         dxr3videosink_close (DXR3VIDEOSINK (element));
658       }
659       break;
660   }
661
662   if (GST_ELEMENT_CLASS (parent_class)->change_state) {
663     return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
664   }
665
666   return GST_STATE_CHANGE_SUCCESS;
667 }
668
669 #if 0
670 /**
671  * dxr3videosink_wait:
672  *
673  * Make the sink wait the specified amount of time.
674  */
675 static void
676 dxr3videosink_wait (Dxr3VideoSink * sink, GstClockTime time)
677 {
678   GstClockID id;
679   GstClockTimeDiff jitter;
680   GstClockReturn ret;
681   GstClockTime current_time = gst_clock_get_time (sink->clock);
682
683   id = gst_clock_new_single_shot_id (sink->clock, current_time + time);
684   ret = gst_clock_id_wait (id, &jitter);
685   gst_clock_id_free (id);
686 }
687 #endif
688
689 /**
690  * dxr3videosink_mvcommand
691  *
692  * Send an MVCOMMAND to the card.
693  */
694 static int
695 dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command)
696 {
697   em8300_register_t regs;
698
699   regs.microcode_register = 1;
700   regs.reg = 0;
701   regs.val = command;
702
703   return ioctl (sink->control_fd, EM8300_IOCTL_WRITEREG, &regs);
704 }
705
706
707 /**
708  * dxr3videosink_flushed:
709  *
710  * Default do nothing implementation for the "flushed" signal.  The
711  * "flushed" signal will be fired right after flushing the hardware
712  * queues due to a received flush event 
713  */
714 static void
715 dxr3videosink_flushed (Dxr3VideoSink * sink)
716 {
717   /* Do nothing. */
718 }