Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2545865pxj; Mon, 10 May 2021 05:38:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXE9q+sqYNNl2kOnElVH1FyEIBE+BwNOwaA0Zu/hzwqqaFx600k5P2dZMFmgYIukTjQ30E X-Received: by 2002:a05:6402:350d:: with SMTP id b13mr29189204edd.21.1620650280469; Mon, 10 May 2021 05:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650280; cv=none; d=google.com; s=arc-20160816; b=JFQ2G/UqLK+YnyDzQ00fGSs7iwFGOTqfW78cUddYg/4B2n2xWst/MR9CStlKmB3Yxl MvJLCJAAf7UpXfm20tKhp+7Xp+cERUMVGwPnBn1cxVX35hX3ITIQMsq88kGkNmFb1Ffd 1+D36zkh00LkBXM4ZUvCIUbyPy1k2xcwfzcIvk+VD2066FHZ7ARYBLSrr/HBlCqnlL7D d7gBdGEcwAf82TJrtD5MfyLIJkrC7OQIk3Au50NyManh23S3eCgrViDQBWc3zqb9q+b9 BapXsiaDU36nItPtwJK0u833KmetrLw3stRV8fmOeAjl7BrPfypyuZdKbKpzAZXDstYp YvRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y0yLb4AjVpF5Va4cMBIugnqrR9w4jvnubWy9xRn9vPg=; b=Th9vJ1aRgV4ez7vISkMXJEF2ezJ6KPtFCsciFUnt/690cgFhWgAU9/XBuzZr9LyL3K /+5fTfbesDnbQyIMjuPaFxE8T41F/l+/bjJDIV+1rVvkKzuMi+oZ6A4/yTsl7gxPTLFy 4MZorD1B1uoFt7uSPRpyQiCO72FkbX7ubIcCzcmoLtmcndLUEELwkkjj6cDiGaPc/uVx TXKjR+SJW0B1ap1Z+t9sQQx3WgFYHksfQFtc5zE/0GPXVPTBMunbD/C5W8DbEGAid0M9 Up/w6vgLT68xKn68Kak/eT9iBVPndgLda7FIdjUmNML+NNOjKDFcOuQXiqTmxscqto7p LLwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TWTDU0Kn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si13105477ejj.140.2021.05.10.05.37.37; Mon, 10 May 2021 05:38:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TWTDU0Kn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344672AbhEJMY4 (ORCPT + 99 others); Mon, 10 May 2021 08:24:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:53778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237031AbhEJLLL (ORCPT ); Mon, 10 May 2021 07:11:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2DC861574; Mon, 10 May 2021 11:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644788; bh=E81XsKLIq3tXn1p9KGS0c/UKL92M806Q/8Ap/KlSHgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWTDU0KnU2milNiUrqbD0+ssNPEB28yqs7n7NG8sCeiMlwI8IB8L4hWEnKcOPsUbs pse7YUpKH6ys8OvTSZC5Lm2gX6Q74YZv6KRHZ329yrdefLVLs5P+BvryJl0Oox6QhU 0GIpuSag572XgBxC50xaOk6w7JmZQ5ROc5ovkw4Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Sasha Levin , John Nealy Subject: [PATCH 5.12 223/384] media: uvcvideo: Support devices that report an OT as an entity source Date: Mon, 10 May 2021 12:20:12 +0200 Message-Id: <20210510102022.256673879@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart [ Upstream commit 4ca052b4ea621d0002a5e5feace51f60ad5e6b23 ] 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 Signed-off-by: Laurent Pinchart Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/uvc/uvc_driver.c | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index e55cf02baad6..9a791d8ef200 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1716,6 +1716,31 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain, 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_dbg(chain->dev, 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 (!found) uvc_dbg_cont(PROBE, " (->"); @@ -1735,6 +1760,13 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain, return -EINVAL; } + if (UVC_ENTITY_IS_OTERM(entity)) { + uvc_dbg(chain->dev, DESCR, + "Unsupported connection between output terminals %u and %u\n", + entity->id, forward->id); + break; + } + list_add_tail(&forward->chain, &chain->entities); if (!found) uvc_dbg_cont(PROBE, " (->"); -- 2.30.2