3 * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * 2006 Edgard Lima <edgard.lima@indt.org.br>
6 * v4l2_calls.c - generic V4L2 calls handling
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include <sys/types.h>
31 #include <sys/ioctl.h>
37 /* Needed on older Solaris Nevada builds (72 at least) */
39 #include <sys/ioccom.h>
41 #include "v4l2_calls.h"
42 #include "gstv4l2tuner.h"
44 #include "gstv4l2xoverlay.h"
46 #include "gstv4l2colorbalance.h"
48 #include "gstv4l2src.h"
50 /* Those are ioctl calls */
51 #ifndef V4L2_CID_HCENTER
52 #define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
54 #ifndef V4L2_CID_VCENTER
55 #define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
58 GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
59 #define GST_CAT_DEFAULT v4l2_debug
61 /******************************************************
62 * gst_v4l2_get_capabilities():
63 * get the device's capturing capabilities
64 * return value: TRUE on success, FALSE on error
65 ******************************************************/
67 gst_v4l2_get_capabilities (GstV4l2Object * v4l2object)
71 e = v4l2object->element;
73 GST_DEBUG_OBJECT (e, "getting capabilities");
75 if (!GST_V4L2_IS_OPEN (v4l2object))
78 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_QUERYCAP, &v4l2object->vcap) < 0)
81 GST_LOG_OBJECT (e, "driver: '%s'", v4l2object->vcap.driver);
82 GST_LOG_OBJECT (e, "card: '%s'", v4l2object->vcap.card);
83 GST_LOG_OBJECT (e, "bus_info: '%s'", v4l2object->vcap.bus_info);
84 GST_LOG_OBJECT (e, "version: %08x", v4l2object->vcap.version);
85 GST_LOG_OBJECT (e, "capabilites: %08x", v4l2object->vcap.capabilities);
92 GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
93 (_("Error getting capabilities for device '%s': "
94 "It isn't a v4l2 driver. Check if it is a v4l1 driver."),
95 v4l2object->videodev), GST_ERROR_SYSTEM);
101 /******************************************************
102 * gst_v4l2_empty_lists() and gst_v4l2_fill_lists():
103 * fill/empty the lists of enumerations
104 * return value: TRUE on success, FALSE on error
105 ******************************************************/
107 gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
113 e = v4l2object->element;
115 GST_DEBUG_OBJECT (e, "getting enumerations");
116 GST_V4L2_CHECK_OPEN (v4l2object);
118 GST_DEBUG_OBJECT (e, " channels");
119 /* and now, the channels */
121 struct v4l2_input input = { 0, };
122 GstV4l2TunerChannel *v4l2channel;
124 GstTunerChannel *channel;
127 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
129 break; /* end of enumeration */
131 GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
132 (_("Failed to query attributes of input %d in device %s"),
133 n, v4l2object->videodev),
134 ("Failed to get %d in input enumeration for %s. (%d - %s)",
135 n, v4l2object->videodev, errno, strerror (errno)));
140 GST_LOG_OBJECT (e, " index: %d", input.index);
141 GST_LOG_OBJECT (e, " name: '%s'", input.name);
142 GST_LOG_OBJECT (e, " type: %08x", input.type);
143 GST_LOG_OBJECT (e, " audioset: %08x", input.audioset);
144 GST_LOG_OBJECT (e, " std: %016x", input.std);
145 GST_LOG_OBJECT (e, " status: %08x", input.status);
147 v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
148 channel = GST_TUNER_CHANNEL (v4l2channel);
149 channel->label = g_strdup ((const gchar *) input.name);
150 channel->flags = GST_TUNER_CHANNEL_INPUT;
151 v4l2channel->index = n;
153 if (input.type == V4L2_INPUT_TYPE_TUNER) {
154 struct v4l2_tuner vtun;
156 v4l2channel->tuner = input.tuner;
157 channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
159 vtun.index = input.tuner;
160 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
161 GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
162 (_("Failed to get setting of tuner %d on device '%s'."),
163 input.tuner, v4l2object->videodev), GST_ERROR_SYSTEM);
164 g_object_unref (G_OBJECT (channel));
168 channel->freq_multiplicator =
169 62.5 * ((vtun.capability & V4L2_TUNER_CAP_LOW) ? 1 : 1000);
170 channel->min_frequency = vtun.rangelow * channel->freq_multiplicator;
171 channel->max_frequency = vtun.rangehigh * channel->freq_multiplicator;
172 channel->min_signal = 0;
173 channel->max_signal = 0xffff;
175 if (input.audioset) {
176 /* we take the first. We don't care for
177 * the others for now */
178 while (!(input.audioset & (1 << v4l2channel->audio)))
179 v4l2channel->audio++;
180 channel->flags |= GST_TUNER_CHANNEL_AUDIO;
183 v4l2object->channels =
184 g_list_append (v4l2object->channels, (gpointer) channel);
187 GST_DEBUG_OBJECT (e, " norms");
190 struct v4l2_standard standard = { 0, };
191 GstV4l2TunerNorm *v4l2norm;
195 /* fill in defaults */
196 standard.frameperiod.numerator = 1;
197 standard.frameperiod.denominator = 0;
200 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
201 if (errno == EINVAL || errno == ENOTTY)
202 break; /* end of enumeration */
204 GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
205 (_("Failed to query norm on device '%s'."),
206 v4l2object->videodev),
207 ("Failed to get attributes for norm %d on devide '%s'. (%d - %s)",
208 n, v4l2object->videodev, errno, strerror (errno)));
213 GST_DEBUG_OBJECT (e, " '%s', fps: %d / %d",
214 standard.name, standard.frameperiod.denominator,
215 standard.frameperiod.numerator);
217 v4l2norm = g_object_new (GST_TYPE_V4L2_TUNER_NORM, NULL);
218 norm = GST_TUNER_NORM (v4l2norm);
219 norm->label = g_strdup ((const gchar *) standard.name);
220 gst_value_set_fraction (&norm->framerate,
221 standard.frameperiod.denominator, standard.frameperiod.numerator);
222 v4l2norm->index = standard.id;
224 v4l2object->norms = g_list_append (v4l2object->norms, (gpointer) norm);
227 GST_DEBUG_OBJECT (e, " controls+menus");
228 /* and lastly, controls+menus (if appropriate) */
229 for (n = V4L2_CID_BASE;; n++) {
230 struct v4l2_queryctrl control = { 0, };
231 GstV4l2ColorBalanceChannel *v4l2channel;
233 GstColorBalanceChannel *channel;
235 /* when we reached the last official CID, continue with private CIDs */
236 if (n == V4L2_CID_LASTP1) {
237 GST_DEBUG_OBJECT (e, "checking private CIDs");
238 n = V4L2_CID_PRIVATE_BASE;
239 /* FIXME: We are still not handling private controls. We need a new GstInterface
240 to export those controls */
245 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
246 if (errno == EINVAL) {
247 if (n < V4L2_CID_PRIVATE_BASE)
248 /* continue so that we also check private controls */
253 GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
254 (_("Failed getting controls attributes on device '%s'."),
255 v4l2object->videodev),
256 ("Failed querying control %d on device '%s'. (%d - %s)",
257 n, v4l2object->videodev, errno, strerror (errno)));
261 if (control.flags & V4L2_CTRL_FLAG_DISABLED)
265 case V4L2_CID_BRIGHTNESS:
266 case V4L2_CID_CONTRAST:
267 case V4L2_CID_SATURATION:
269 case V4L2_CID_BLACK_LEVEL:
270 case V4L2_CID_AUTO_WHITE_BALANCE:
271 case V4L2_CID_DO_WHITE_BALANCE:
272 case V4L2_CID_RED_BALANCE:
273 case V4L2_CID_BLUE_BALANCE:
275 case V4L2_CID_EXPOSURE:
276 case V4L2_CID_AUTOGAIN:
278 /* we only handle these for now (why?) */
282 case V4L2_CID_HCENTER:
283 case V4L2_CID_VCENTER:
284 #ifdef V4L2_CID_PAN_RESET
285 case V4L2_CID_PAN_RESET:
287 #ifdef V4L2_CID_TILT_RESET
288 case V4L2_CID_TILT_RESET:
290 /* not handled here, handled by VideoOrientation interface */
293 case V4L2_CID_AUDIO_VOLUME:
294 case V4L2_CID_AUDIO_BALANCE:
295 case V4L2_CID_AUDIO_BASS:
296 case V4L2_CID_AUDIO_TREBLE:
297 case V4L2_CID_AUDIO_MUTE:
298 case V4L2_CID_AUDIO_LOUDNESS:
299 /* FIXME: We should implement GstMixer interface */
303 "ControlID %s (%x) unhandled, FIXME", control.name, n);
310 GST_DEBUG_OBJECT (e, "Adding ControlID %s (%x)", control.name, n);
311 v4l2channel = g_object_new (GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL, NULL);
312 channel = GST_COLOR_BALANCE_CHANNEL (v4l2channel);
313 channel->label = g_strdup ((const gchar *) control.name);
317 /* FIXME: it will be need just when handling private controls
318 *(currently none of base controls are of this type) */
319 if (control.type == V4L2_CTRL_TYPE_MENU) {
320 struct v4l2_querymenu menu, *mptr;
327 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
329 break; /* end of enumeration */
331 GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
332 (_("Failed getting controls attributes on device '%s'."),
333 v4l2object->videodev),
334 ("Failed to get %d in menu enumeration for %s. (%d - %s)",
335 n, v4l2object->videodev, errno, strerror (errno)));
339 mptr = g_malloc (sizeof (menu));
340 memcpy (mptr, &menu, sizeof (menu));
341 menus = g_list_append (menus, mptr);
344 v4l2object->menus = g_list_append (v4l2object->menus, menus);
347 switch (control.type) {
348 case V4L2_CTRL_TYPE_INTEGER:
349 channel->min_value = control.minimum;
350 channel->max_value = control.maximum;
352 case V4L2_CTRL_TYPE_BOOLEAN:
353 channel->min_value = FALSE;
354 channel->max_value = TRUE;
357 /* FIXME we should find out how to handle V4L2_CTRL_TYPE_BUTTON.
358 BUTTON controls like V4L2_CID_DO_WHITE_BALANCE can just be set (1) or
359 unset (0), but can't be queried */
361 "Control with non supported type %s (%x), type=%d",
362 control.name, n, control.type);
363 channel->min_value = channel->max_value = 0;
367 v4l2object->colors = g_list_append (v4l2object->colors, (gpointer) channel);
370 GST_DEBUG_OBJECT (e, "done");
376 gst_v4l2_empty_lists (GstV4l2Object * v4l2object)
378 GST_DEBUG_OBJECT (v4l2object->element, "deleting enumerations");
380 g_list_foreach (v4l2object->channels, (GFunc) g_object_unref, NULL);
381 g_list_free (v4l2object->channels);
382 v4l2object->channels = NULL;
384 g_list_foreach (v4l2object->norms, (GFunc) g_object_unref, NULL);
385 g_list_free (v4l2object->norms);
386 v4l2object->norms = NULL;
388 g_list_foreach (v4l2object->colors, (GFunc) g_object_unref, NULL);
389 g_list_free (v4l2object->colors);
390 v4l2object->colors = NULL;
393 /******************************************************
395 * open the video device (v4l2object->videodev)
396 * return value: TRUE on success, FALSE on error
397 ******************************************************/
399 gst_v4l2_open (GstV4l2Object * v4l2object)
403 GstPollFD pollfd = GST_POLL_FD_INIT;
405 GST_DEBUG_OBJECT (v4l2object->element, "Trying to open device %s",
406 v4l2object->videodev);
408 GST_V4L2_CHECK_NOT_OPEN (v4l2object);
409 GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
411 /* be sure we have a device */
412 if (!v4l2object->videodev)
413 v4l2object->videodev = g_strdup ("/dev/video");
415 /* check if it is a device */
416 if (stat (v4l2object->videodev, &st) == -1)
419 if (!S_ISCHR (st.st_mode))
422 /* open the device */
423 v4l2object->video_fd =
424 open (v4l2object->videodev, O_RDWR /* | O_NONBLOCK */ );
426 if (!GST_V4L2_IS_OPEN (v4l2object))
429 libv4l2_fd = v4l2_fd_open (v4l2object->video_fd,
430 V4L2_ENABLE_ENUM_FMT_EMULATION);
431 /* Note the v4l2_xxx functions are designed so that if they get passed an
432 unknown fd, the will behave exactly as their regular xxx counterparts, so
433 if v4l2_fd_open fails, we continue as normal (missing the libv4l2 custom
434 cam format to normal formats conversion). Chances are big we will still
435 fail then though, as normally v4l2_fd_open only fails if the device is not
437 if (libv4l2_fd != -1)
438 v4l2object->video_fd = libv4l2_fd;
440 /* get capabilities, error will be posted */
441 if (!gst_v4l2_get_capabilities (v4l2object))
444 /* do we need to be a capture device? */
445 if (GST_IS_V4L2SRC (v4l2object) &&
446 !(v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
449 /* create enumerations, posts errors. */
450 if (!gst_v4l2_fill_lists (v4l2object))
453 GST_INFO_OBJECT (v4l2object->element,
454 "Opened device '%s' (%s) successfully",
455 v4l2object->vcap.card, v4l2object->videodev);
457 pollfd.fd = v4l2object->video_fd;
458 gst_poll_add_fd (v4l2object->poll, &pollfd);
459 gst_poll_fd_ctl_read (v4l2object->poll, &pollfd, TRUE);
466 GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
467 (_("Cannot identify device '%s'."), v4l2object->videodev),
473 GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
474 (_("This isn't a device '%s'."), v4l2object->videodev),
480 GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, OPEN_READ_WRITE,
481 (_("Could not open device '%s' for reading and writing."),
482 v4l2object->videodev), GST_ERROR_SYSTEM);
487 GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
488 (_("Device '%s' is not a capture device."),
489 v4l2object->videodev),
490 ("Capabilities: 0x%x", v4l2object->vcap.capabilities));
495 if (GST_V4L2_IS_OPEN (v4l2object)) {
497 v4l2_close (v4l2object->video_fd);
498 v4l2object->video_fd = -1;
501 gst_v4l2_empty_lists (v4l2object);
508 /******************************************************
510 * close the video device (v4l2object->video_fd)
511 * return value: TRUE on success, FALSE on error
512 ******************************************************/
514 gst_v4l2_close (GstV4l2Object * v4l2object)
516 GstPollFD pollfd = GST_POLL_FD_INIT;
517 GST_DEBUG_OBJECT (v4l2object->element, "Trying to close %s",
518 v4l2object->videodev);
520 GST_V4L2_CHECK_OPEN (v4l2object);
521 GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
524 v4l2_close (v4l2object->video_fd);
525 pollfd.fd = v4l2object->video_fd;
526 gst_poll_remove_fd (v4l2object->poll, &pollfd);
527 v4l2object->video_fd = -1;
530 gst_v4l2_empty_lists (v4l2object);
536 /******************************************************
537 * gst_v4l2_get_norm()
538 * Get the norm of the current device
539 * return value: TRUE on success, FALSE on error
540 ******************************************************/
542 gst_v4l2_get_norm (GstV4l2Object * v4l2object, v4l2_std_id * norm)
544 GST_DEBUG_OBJECT (v4l2object->element, "getting norm");
546 if (!GST_V4L2_IS_OPEN (v4l2object))
549 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_STD, norm) < 0)
557 GST_DEBUG ("Failed to get the current norm for device %s",
558 v4l2object->videodev);
564 /******************************************************
565 * gst_v4l2_set_norm()
566 * Set the norm of the current device
567 * return value: TRUE on success, FALSE on error
568 ******************************************************/
570 gst_v4l2_set_norm (GstV4l2Object * v4l2object, v4l2_std_id norm)
572 GST_DEBUG_OBJECT (v4l2object->element, "trying to set norm to %llx", norm);
574 if (!GST_V4L2_IS_OPEN (v4l2object))
577 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_S_STD, &norm) < 0)
585 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
586 (_("Failed to set norm for device '%s'."),
587 v4l2object->videodev), GST_ERROR_SYSTEM);
592 /******************************************************
593 * gst_v4l2_get_frequency():
594 * get the current frequency
595 * return value: TRUE on success, FALSE on error
596 ******************************************************/
598 gst_v4l2_get_frequency (GstV4l2Object * v4l2object,
599 gint tunernum, gulong * frequency)
601 struct v4l2_frequency freq;
603 GstTunerChannel *channel;
605 GST_DEBUG_OBJECT (v4l2object->element, "getting current tuner frequency");
607 if (!GST_V4L2_IS_OPEN (v4l2object))
610 channel = gst_tuner_get_channel (GST_TUNER (v4l2object->element));
612 freq.tuner = tunernum;
613 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0)
616 *frequency = freq.frequency * channel->freq_multiplicator;
623 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
624 (_("Failed to get current tuner frequency for device '%s'."),
625 v4l2object->videodev), GST_ERROR_SYSTEM);
631 /******************************************************
632 * gst_v4l2_set_frequency():
634 * return value: TRUE on success, FALSE on error
635 ******************************************************/
637 gst_v4l2_set_frequency (GstV4l2Object * v4l2object,
638 gint tunernum, gulong frequency)
640 struct v4l2_frequency freq;
642 GstTunerChannel *channel;
644 GST_DEBUG_OBJECT (v4l2object->element,
645 "setting current tuner frequency to %lu", frequency);
647 if (!GST_V4L2_IS_OPEN (v4l2object))
650 channel = gst_tuner_get_channel (GST_TUNER (v4l2object->element));
652 freq.tuner = tunernum;
653 /* fill in type - ignore error */
654 v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_FREQUENCY, &freq);
655 freq.frequency = frequency / channel->freq_multiplicator;
657 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0)
665 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
666 (_("Failed to set current tuner frequency for device '%s' to %lu Hz."),
667 v4l2object->videodev, frequency), GST_ERROR_SYSTEM);
672 /******************************************************
673 * gst_v4l2_signal_strength():
674 * get the strength of the signal on the current input
675 * return value: TRUE on success, FALSE on error
676 ******************************************************/
678 gst_v4l2_signal_strength (GstV4l2Object * v4l2object,
679 gint tunernum, gulong * signal_strength)
681 struct v4l2_tuner tuner;
683 GST_DEBUG_OBJECT (v4l2object->element, "trying to get signal strength");
685 if (!GST_V4L2_IS_OPEN (v4l2object))
688 tuner.index = tunernum;
689 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &tuner) < 0)
692 *signal_strength = tuner.signal;
699 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
700 (_("Failed to get signal strength for device '%s'."),
701 v4l2object->videodev), GST_ERROR_SYSTEM);
706 /******************************************************
707 * gst_v4l2_get_attribute():
708 * try to get the value of one specific attribute
709 * return value: TRUE on success, FALSE on error
710 ******************************************************/
712 gst_v4l2_get_attribute (GstV4l2Object * v4l2object,
713 int attribute_num, int *value)
715 struct v4l2_control control;
717 GST_DEBUG_OBJECT (v4l2object->element, "getting value of attribute %d",
720 if (!GST_V4L2_IS_OPEN (v4l2object))
723 control.id = attribute_num;
725 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_CTRL, &control) < 0)
728 *value = control.value;
735 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
736 (_("Failed to get value for control %d on device '%s'."),
737 attribute_num, v4l2object->videodev), GST_ERROR_SYSTEM);
743 /******************************************************
744 * gst_v4l2_set_attribute():
745 * try to set the value of one specific attribute
746 * return value: TRUE on success, FALSE on error
747 ******************************************************/
749 gst_v4l2_set_attribute (GstV4l2Object * v4l2object,
750 int attribute_num, const int value)
752 struct v4l2_control control;
754 GST_DEBUG_OBJECT (v4l2object->element, "setting value of attribute %d to %d",
755 attribute_num, value);
757 if (!GST_V4L2_IS_OPEN (v4l2object))
760 control.id = attribute_num;
761 control.value = value;
762 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_S_CTRL, &control) < 0)
770 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
771 (_("Failed to set value %d for control %d on device '%s'."),
772 value, attribute_num, v4l2object->videodev), GST_ERROR_SYSTEM);
778 gst_v4l2_get_input (GstV4l2Object * v4l2object, gint * input)
782 GST_DEBUG_OBJECT (v4l2object->element, "trying to get input");
784 if (!GST_V4L2_IS_OPEN (v4l2object))
787 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_INPUT, &n) < 0)
792 GST_DEBUG_OBJECT (v4l2object->element, "input: %d", n);
799 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
800 (_("Failed to get current input on device '%s'. May be it is a radio device"), v4l2object->videodev), GST_ERROR_SYSTEM);
806 gst_v4l2_set_input (GstV4l2Object * v4l2object, gint input)
808 GST_DEBUG_OBJECT (v4l2object->element, "trying to set input to %d", input);
810 if (!GST_V4L2_IS_OPEN (v4l2object))
813 if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_S_INPUT, &input) < 0)
821 GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
822 (_("Failed to set input %d on device %s."),
823 input, v4l2object->videodev), GST_ERROR_SYSTEM);