summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2010-07-13 10:03:51 -0500
committerRob Clark <rob@ti.com>2010-12-29 11:46:41 -0600
commitbb07a39c6766bc925ebd15af9de8ea9bee923210 (patch)
tree75e5adc5d9f73ecae9d99bc8fd3a4da1dec16988
parentbf885474891ce13331a082b46bdc5127ea871b04 (diff)
v4l2: cleanup get/set input/output
output devices should use get/set output, and in either case we should not print a warning message if the ioctl fails but the device does not claim to support the tuner interface
-rw-r--r--sys/v4l2/gstv4l2sink.c2
-rw-r--r--sys/v4l2/v4l2_calls.c69
-rw-r--r--sys/v4l2/v4l2_calls.h2
3 files changed, 67 insertions, 6 deletions
diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c
index 3de98512e..421f639d8 100644
--- a/sys/v4l2/gstv4l2sink.c
+++ b/sys/v4l2/gstv4l2sink.c
@@ -286,7 +286,7 @@ gst_v4l2sink_init (GstV4l2Sink * v4l2sink, GstV4l2SinkClass * klass)
{
v4l2sink->v4l2object = gst_v4l2_object_new (GST_ELEMENT (v4l2sink),
V4L2_BUF_TYPE_VIDEO_OUTPUT, DEFAULT_PROP_DEVICE,
- gst_v4l2_get_input, gst_v4l2_set_input, NULL);
+ gst_v4l2_get_output, gst_v4l2_set_output, NULL);
/* same default value for video output device as is used for
* v4l2src/capture is no good.. so lets set a saner default
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index f2c2c081d..b4feef3eb 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -824,11 +824,14 @@ gst_v4l2_get_input (GstV4l2Object * v4l2object, gint * input)
/* ERRORS */
input_failed:
- {
+ if (v4l2object->vcap.capabilities & V4L2_CAP_TUNER) {
+ /* only give a warning message if driver actually claims to have tuner
+ * support
+ */
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
(_("Failed to get current input on device '%s'. May be it is a radio device"), v4l2object->videodev), GST_ERROR_SYSTEM);
- return FALSE;
}
+ return FALSE;
}
gboolean
@@ -846,10 +849,70 @@ gst_v4l2_set_input (GstV4l2Object * v4l2object, gint input)
/* ERRORS */
input_failed:
- {
+ if (v4l2object->vcap.capabilities & V4L2_CAP_TUNER) {
+ /* only give a warning message if driver actually claims to have tuner
+ * support
+ */
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
(_("Failed to set input %d on device %s."),
input, v4l2object->videodev), GST_ERROR_SYSTEM);
+ }
+ return FALSE;
+}
+
+gboolean
+gst_v4l2_get_output (GstV4l2Object * v4l2object, gint * output)
+{
+ gint n;
+
+ GST_DEBUG_OBJECT (v4l2object->element, "trying to get output");
+
+ if (!GST_V4L2_IS_OPEN (v4l2object))
+ return FALSE;
+
+ if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_OUTPUT, &n) < 0)
+ goto output_failed;
+
+ *output = n;
+
+ GST_DEBUG_OBJECT (v4l2object->element, "output: %d", n);
+
+ return TRUE;
+
+ /* ERRORS */
+output_failed:
+ if (v4l2object->vcap.capabilities & V4L2_CAP_TUNER) {
+ /* only give a warning message if driver actually claims to have tuner
+ * support
+ */
+ GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
+ (_("Failed to get current output on device '%s'. May be it is a radio device"), v4l2object->videodev), GST_ERROR_SYSTEM);
+ }
+ return FALSE;
+}
+
+gboolean
+gst_v4l2_set_output (GstV4l2Object * v4l2object, gint output)
+{
+ GST_DEBUG_OBJECT (v4l2object->element, "trying to set output to %d", output);
+
+ if (!GST_V4L2_IS_OPEN (v4l2object))
return FALSE;
+
+ if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_S_OUTPUT, &output) < 0)
+ goto output_failed;
+
+ return TRUE;
+
+ /* ERRORS */
+output_failed:
+ if (v4l2object->vcap.capabilities & V4L2_CAP_TUNER) {
+ /* only give a warning message if driver actually claims to have tuner
+ * support
+ */
+ GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
+ (_("Failed to set output %d on device %s."),
+ output, v4l2object->videodev), GST_ERROR_SYSTEM);
}
+ return FALSE;
}
diff --git a/sys/v4l2/v4l2_calls.h b/sys/v4l2/v4l2_calls.h
index c5c1808a4..a47872dd4 100644
--- a/sys/v4l2/v4l2_calls.h
+++ b/sys/v4l2/v4l2_calls.h
@@ -111,12 +111,10 @@ gboolean gst_v4l2_get_input (GstV4l2Object * v4l2object,
gint * input);
gboolean gst_v4l2_set_input (GstV4l2Object * v4l2object,
gint input);
-#if 0 /* output not handled by now */
gboolean gst_v4l2_get_output (GstV4l2Object *v4l2object,
gint *output);
gboolean gst_v4l2_set_output (GstV4l2Object *v4l2object,
gint output);
-#endif /* #if 0 - output not handled by now */
/* frequency control */
gboolean gst_v4l2_get_frequency (GstV4l2Object *v4l2object,