diff --git a/plugins/linux-v4l2/v4l2-helpers.c b/plugins/linux-v4l2/v4l2-helpers.c index 2c824e55c..080a83fb1 100644 --- a/plugins/linux-v4l2/v4l2-helpers.c +++ b/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; +} diff --git a/plugins/linux-v4l2/v4l2-helpers.h b/plugins/linux-v4l2/v4l2-helpers.h index 5ee28fd4a..390fac669 100644 --- a/plugins/linux-v4l2/v4l2-helpers.h +++ b/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