From 85518e7cca555fd534b4c71d49c4c60d0a3381f3 Mon Sep 17 00:00:00 2001 From: fryshorts Date: Wed, 22 Apr 2015 20:07:35 +0200 Subject: [PATCH 1/2] linux-v4l2: Fix build when missing CAP_DEVICE_CAPS Improve compatibility with older versions of the api by not requiring V4L2_CAP_DEVICE_CAPS. If we don't have this, we fall back to using the capabilities member for the whole device instead of the device_caps member for the currently selected subdevice. Just like we would do if the device would not support this. The new device_caps field was introduced with Linux 3.3. --- plugins/linux-v4l2/v4l2-input.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index 06237bf6d..962ea3882 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -298,9 +298,14 @@ static void v4l2_device_list(obs_property_t *prop, obs_data_t *settings) continue; } +#ifndef V4L2_CAP_DEVICE_CAPS + caps = video_cap.capabilities; +#else + /* ... since Linux 3.3 */ caps = (video_cap.capabilities & V4L2_CAP_DEVICE_CAPS) ? video_cap.device_caps : video_cap.capabilities; +#endif if (!(caps & V4L2_CAP_VIDEO_CAPTURE)) { blog(LOG_INFO, "%s seems to not support video capture", @@ -924,6 +929,11 @@ static void *v4l2_create(obs_data_t *settings, obs_source_t *source) data->dev = -1; data->source = source; + /* Bitch about build problems ... */ +#ifndef V4L2_CAP_DEVICE_CAPS + blog(LOG_WARNING, "Plugin built without device caps support!"); +#endif + v4l2_update(data, settings); #if HAVE_UDEV From 34c3be43d1710b4c042e5826f9f10bb69c679006 Mon Sep 17 00:00:00 2001 From: fryshorts Date: Wed, 22 Apr 2015 20:09:18 +0200 Subject: [PATCH 2/2] linux-v4l2: Fix build when missing ENUM_DV_TIMINGS Add compatibility with older versions of the api by not failing to build when the VIDIOC_ENUM_DV_TIMINGS is missing. In older versions of the api there was a different system to get dv-timing presets, which was replaced by the current enumeration system with Linux 3.4. This will allow for the plugin to be built against older versions of the api by disabling the enumeration support, thus reducing the functionality for some devices. --- plugins/linux-v4l2/v4l2-helpers.c | 7 +++++++ plugins/linux-v4l2/v4l2-input.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/plugins/linux-v4l2/v4l2-helpers.c b/plugins/linux-v4l2/v4l2-helpers.c index 5bed14c7c..d468b9011 100644 --- a/plugins/linux-v4l2/v4l2-helpers.c +++ b/plugins/linux-v4l2/v4l2-helpers.c @@ -240,6 +240,12 @@ int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard) int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt, int index) { +#ifndef VIDIOC_ENUM_DV_TIMINGS + UNUSED_PARAMETER(dev); + UNUSED_PARAMETER(dvt); + UNUSED_PARAMETER(index); + return -1; +#else if (!dev || !dvt) return -1; @@ -253,6 +259,7 @@ int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt, memcpy(dvt, &iter.timings, sizeof(struct v4l2_dv_timings)); return 0; +#endif } int_fast32_t v4l2_set_dv_timing(int_fast32_t dev, int *timing) diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index 962ea3882..f9e3d8d06 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -41,6 +41,12 @@ along with this program. If not, see . #include "v4l2-udev.h" #endif +/* The new dv timing api was introduced in Linux 3.4 + * Currently we simply disable dv timings when this is not defined */ +#ifndef VIDIOC_ENUM_DV_TIMINGS +#define V4L2_IN_CAP_DV_TIMINGS 0 +#endif + #define V4L2_DATA(voidptr) struct v4l2_data *data = voidptr; #define timeval2ns(tv) \ @@ -933,6 +939,9 @@ static void *v4l2_create(obs_data_t *settings, obs_source_t *source) #ifndef V4L2_CAP_DEVICE_CAPS blog(LOG_WARNING, "Plugin built without device caps support!"); #endif +#ifndef VIDIOC_ENUM_DV_TIMINGS + blog(LOG_WARNING, "Plugin built without dv-timing support!"); +#endif v4l2_update(data, settings);