public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	John Nealy <jnealy3@yahoo.com>
Subject: [PATCH 5.10 2/6] media: uvcvideo: Support devices that report an OT as an entity source
Date: Fri,  9 Jul 2021 15:21:11 +0200	[thread overview]
Message-ID: <20210709131539.850852647@linuxfoundation.org> (raw)
In-Reply-To: <20210709131537.035851348@linuxfoundation.org>

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

commit 4ca052b4ea621d0002a5e5feace51f60ad5e6b23 upstream.

Some devices reference an output terminal as the source of extension
units. This is incorrect, as output terminals only have an input pin,
and thus can't be connected to any entity in the forward direction. The
resulting topology would cause issues when registering the media
controller graph. To avoid this problem, connect the extension unit to
the source of the output terminal instead.

While at it, and while no device has been reported to be affected by
this issue, also handle forward scans where two output terminals would
be connected together, and skip the terminals found through such an
invalid connection.

Reported-and-tested-by: John Nealy <jnealy3@yahoo.com>

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/media/usb/uvc/uvc_driver.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1588,6 +1588,31 @@ static int uvc_scan_chain_forward(struct
 				return -EINVAL;
 			}
 
+			/*
+			 * Some devices reference an output terminal as the
+			 * source of extension units. This is incorrect, as
+			 * output terminals only have an input pin, and thus
+			 * can't be connected to any entity in the forward
+			 * direction. The resulting topology would cause issues
+			 * when registering the media controller graph. To
+			 * avoid this problem, connect the extension unit to
+			 * the source of the output terminal instead.
+			 */
+			if (UVC_ENTITY_IS_OTERM(entity)) {
+				struct uvc_entity *source;
+
+				source = uvc_entity_by_id(chain->dev,
+							  entity->baSourceID[0]);
+				if (!source) {
+					uvc_trace(UVC_TRACE_DESCR,
+						"Can't connect extension unit %u in chain\n",
+						forward->id);
+					break;
+				}
+
+				forward->baSourceID[0] = source->id;
+			}
+
 			list_add_tail(&forward->chain, &chain->entities);
 			if (uvc_trace_param & UVC_TRACE_PROBE) {
 				if (!found)
@@ -1608,6 +1633,13 @@ static int uvc_scan_chain_forward(struct
 				return -EINVAL;
 			}
 
+			if (UVC_ENTITY_IS_OTERM(entity)) {
+				uvc_trace(UVC_TRACE_DESCR,
+					"Unsupported connection between output terminals %u and %u\n",
+					entity->id, forward->id);
+				break;
+			}
+
 			list_add_tail(&forward->chain, &chain->entities);
 			if (uvc_trace_param & UVC_TRACE_PROBE) {
 				if (!found)



  parent reply	other threads:[~2021-07-09 13:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 13:21 [PATCH 5.10 0/6] 5.10.49-rc1 review Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 1/6] KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path Greg Kroah-Hartman
2021-07-09 13:21 ` Greg Kroah-Hartman [this message]
2021-07-09 13:21 ` [PATCH 5.10 3/6] Hexagon: fix build errors Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 4/6] Hexagon: add target builtins to kernel Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 5/6] Hexagon: change jumps to must-extend in futex_atomic_* Greg Kroah-Hartman
2021-07-09 13:21 ` [PATCH 5.10 6/6] xen/events: reset active flag for lateeoi events later Greg Kroah-Hartman
2021-07-09 17:11 ` [PATCH 5.10 0/6] 5.10.49-rc1 review Jon Hunter
2021-07-09 20:00 ` Fox Chen
2021-07-09 21:40 ` Shuah Khan
2021-07-10  6:40 ` Samuel Zou
2021-07-10 10:21 ` Naresh Kamboju
2021-07-10 10:35 ` Sudip Mukherjee
2021-07-10 19:52 ` Guenter Roeck
2021-07-11  8:00 ` Pavel Machek
2021-07-11 22:15 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709131539.850852647@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jnealy3@yahoo.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox