From bf27d4c1cb9a9fab115f1e20bb7327e89f6c573b Mon Sep 17 00:00:00 2001 From: fryshorts Date: Tue, 24 Feb 2015 21:32:09 +0100 Subject: [PATCH] linux-v4l2: Add function to list dv timings Add a helper function to enumerate dv timings supported by the selected input and add them to a property. --- plugins/linux-v4l2/v4l2-input.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index cf0bfebd3..8e7ddf900 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -399,6 +399,43 @@ static void v4l2_standard_list(int dev, obs_property_t *prop) } } +/* + * List dv timings for the device + */ +static void v4l2_dv_timing_list(int dev, obs_property_t *prop) +{ + struct v4l2_dv_timings dvt; + struct dstr buf; + int index = 0; + dstr_init(&buf); + + obs_property_list_clear(prop); + + obs_property_list_add_int(prop, obs_module_text("LeaveUnchanged"), -1); + + while (v4l2_enum_dv_timing(dev, &dvt, index) == 0) { + /* i do not pretend to understand, this is from qv4l2 ... */ + double h = (double) dvt.bt.height + dvt.bt.vfrontporch + + dvt.bt.vsync + dvt.bt.vbackporch + + dvt.bt.il_vfrontporch + dvt.bt.il_vsync + + dvt.bt.il_vbackporch; + double w = (double) dvt.bt.width + dvt.bt.hfrontporch + + dvt.bt.hsync + dvt.bt.hbackporch; + double i = (dvt.bt.interlaced) ? 2.0f : 1.0f; + double rate = (double) dvt.bt.pixelclock / (w * (h / i)); + + dstr_printf(&buf, "%ux%u%c %.2f", + dvt.bt.width, dvt.bt.height, + (dvt.bt.interlaced) ? 'i' : 'p', rate); + + obs_property_list_add_int(prop, buf.array, index); + + index++; + } + + dstr_free(&buf); +} + /* * List resolutions for device and format */