diff options
author | Rob Clark <rob@ti.com> | 2010-07-13 10:03:51 -0500 |
---|---|---|
committer | Rob Clark <rob@ti.com> | 2010-12-29 11:46:41 -0600 |
commit | bb07a39c6766bc925ebd15af9de8ea9bee923210 (patch) | |
tree | 75e5adc5d9f73ecae9d99bc8fd3a4da1dec16988 /sys/v4l2/v4l2_calls.c | |
parent | bf885474891ce13331a082b46bdc5127ea871b04 (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
Diffstat (limited to 'sys/v4l2/v4l2_calls.c')
-rw-r--r-- | sys/v4l2/v4l2_calls.c | 69 |
1 files changed, 66 insertions, 3 deletions
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; } |