From f4852a2d8baabc2233915db4570039ddce5bbd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Van=C4=9Bk?= Date: Tue, 11 Jun 2024 19:03:21 +0000 Subject: [PATCH] v4l2src: Interpret V4L2 report of sync loss as video signal loss Certain V4L2 drivers can report that a video receiver is seeing some signal, but that it is unable to synchronize to it. IOW: the driver can sometimes report V4L2_IN_ST_NO_SYNC and not report V4L2_IN_ST_NO_SIGNAL. In particular, I've seen the tc358743 (HDMI-to-CSI2 converter) driver sometimes report this when deployed to a fleet of embedded Raspberry Pis. The relevant kernel code is in [1]. The video output is not practically usable when V4L2_IN_ST_NO_SYNC is reported (only visually corrupted frames, sometimes with random "snow", are received). I assume that this happens when either the HDMI cable is poorly plugged in or damaged or when a CSI2 FFC cable is used and is damaged. The change in this commit is useful for detecting this working-but-not-really condition in application code. Applications already listening for the "Signal lost" message will gain the ability to handle this condition. There seem to be more V4L2 error flags like this, see [2]. However, I do not have practical experience with them and adding only V4L2_IN_ST_NO_SYNC seems like a safer option. [1]: https://github.com/raspberrypi/linux/blob/be8498ee21aa/drivers/media/i2c/tc358743.c#L1534 [2]: https://www.kernel.org/doc/html/v6.6/userspace-api/media/v4l/vidioc-enuminput.html Part-of: --- subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c index beac542d95..3272480f76 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c @@ -687,7 +687,8 @@ gst_v4l2src_query_preferred_size (GstV4l2Src * v4l2src, GST_INFO_OBJECT (v4l2src, "Detect input %u as `%s`", in.index, in.name); /* Notify signal status using WARNING/INFO messages */ - if (in.status & (V4L2_IN_ST_NO_POWER | V4L2_IN_ST_NO_SIGNAL)) { + if (in.status & (V4L2_IN_ST_NO_POWER | V4L2_IN_ST_NO_SIGNAL | + V4L2_IN_ST_NO_SYNC)) { if (!v4l2src->no_signal) /* note: taken from decklinksrc element */ GST_ELEMENT_WARNING (v4l2src, RESOURCE, READ, ("Signal lost"),