Przeglądaj źródła

linux-v4l2: Add helper function to get dv timings

Add a helper function to get a dv timing by index for the input.
fryshorts 10 lat temu
rodzic
commit
0a6cf208f1

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

@@ -236,3 +236,21 @@ int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard)
 
 	return 0;
 }
+
+int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt,
+		int index)
+{
+	if (!dev || !dvt)
+		return -1;
+
+	struct v4l2_enum_dv_timings iter;
+	memset(&iter, 0, sizeof(iter));
+	iter.index   = index;
+
+	if (v4l2_ioctl(dev, VIDIOC_ENUM_DV_TIMINGS, &iter) < 0)
+		return -1;
+
+	memcpy(dvt, &iter.timings, sizeof(struct v4l2_dv_timings));
+
+	return 0;
+}

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

@@ -270,6 +270,18 @@ int_fast32_t v4l2_set_framerate(int_fast32_t dev, int *framerate);
  */
 int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard);
 
+/**
+ * Get the dv timing for an input with a specified index
+ *
+ * @param dev handle to the v4l2 device
+ * @param timing pointer to the timing structure to fill
+ * @param index index of the dv timing to fetch
+ *
+ * @return negative on failure
+ */
+int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt,
+		int index);
+
 #ifdef __cplusplus
 }
 #endif