Browse Source

linux-v4l2: Add helper function for video standard

Add a helper function to get/set the video standard for the input.
fryshorts 10 years ago
parent
commit
7dc9069c1b
2 changed files with 28 additions and 0 deletions
  1. 16 0
      plugins/linux-v4l2/v4l2-helpers.c
  2. 12 0
      plugins/linux-v4l2/v4l2-helpers.h

+ 16 - 0
plugins/linux-v4l2/v4l2-helpers.c

@@ -220,3 +220,19 @@ int_fast32_t v4l2_set_framerate(int_fast32_t dev, int *framerate)
 			par.parm.capture.timeperframe.denominator);
 	return 0;
 }
+
+int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard)
+{
+	if (!dev || !standard)
+		return -1;
+
+	if (*standard == -1) {
+		if (v4l2_ioctl(dev, VIDIOC_G_STD, standard) < 0)
+			return -1;
+	} else {
+		if (v4l2_ioctl(dev, VIDIOC_S_STD, standard) < 0)
+			return -1;
+	}
+
+	return 0;
+}

+ 12 - 0
plugins/linux-v4l2/v4l2-helpers.h

@@ -258,6 +258,18 @@ int_fast32_t v4l2_set_format(int_fast32_t dev, int *resolution,
  */
 int_fast32_t v4l2_set_framerate(int_fast32_t dev, int *framerate);
 
+/**
+ * Set a video standard on the device.
+ *
+ * If the action succeeds standard is set to the used video standard id.
+ *
+ * @param dev handle to the v4l2 device
+ * @param standard id of the standard to use or -1 to leave as is
+ *
+ * @return negative on failure
+ */
+int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard);
+
 #ifdef __cplusplus
 }
 #endif