From patchwork Thu Apr 3 19:16:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037538 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7C151FFC66 for ; Thu, 3 Apr 2025 19:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707790; cv=none; b=fFc/phCL5ZvAYcG9pjVUAgWG8tJik/wrWTJ/KrC7S2E9Z5e47CiAXEU8KKcx0P/6aBNyl2eH7ykA6+7e6QqdOct/+hpD1dFIVl32SxrEVXNO8Ow1SibfSXHWMwb2s9vEc7pb56Vc8skjwrS21aoNzc/XyLdI+Qi59zEaFCzH8tE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707790; c=relaxed/simple; bh=uYdW8UWkO7Lkj0/PLTSMCHmI2BhYM1Fy016gz/jcaNo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aOKVav3tSvLEIXe+P0ooMF0Is1axnZtq+cXVrVIMe+Dk6aLzkzBbpR00DY/2AKJY1XbSmDUrsk4Ly5svrg5BSlk5YVnbc3cUoU4fgzKBLcXoJfZtuy8mpGMMwGAV8Wf1B3KvVf89rYgLAjUl6vRu1RSnuqJOpwj4ic+pBH6KiKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=hsA8ykcF; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hsA8ykcF" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-54b0d638e86so1425226e87.1 for ; Thu, 03 Apr 2025 12:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707785; x=1744312585; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IFGb4OSmEELjX3L+UUTsl617UgttQGz/GrFW7lOnFds=; b=hsA8ykcFMc2t6vy9DIiQOxfpKQ+jowvmwUZKpp9Wx/5Nh/ejujC792sJeY/bUgMZRb ydQ/8xMVBA1Wpa49DoIJ+3RNSYbny+tjii1aklXIq2qDg+IKSBHYfTfTxG0IZYEv5D/K Cbjbw+Q9xFOLDRO0/Nrfm9IgaIaDgrZ7p9rRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707785; x=1744312585; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IFGb4OSmEELjX3L+UUTsl617UgttQGz/GrFW7lOnFds=; b=OY1OwvBp3f28P0s9rxURSrA5udYb2EZFO4dsYbIDw+J0L7Wjf8VDh6bvOsih4eLLSI Mmwa5fhCMFgoXUS7PwbGL45xCmQ4DWrL2JUHI9Y3apkqX9pQPPE5vDApoed21QBA0FdN pzy9PhMhvdlSN/J3kr0dPcwQ4wexT26EutBN0d6VniSimv55Mwee+a0plB/jJBS/C6lb jTfkmsbe05Rqz3KeA88cMSAa5b1d5aP0Ioi3KfnitNBFt6ZSyhfoPVUgdbGXtSdDrElD hfn+TxqU0Ve45Wlz8AtvzX6g90JCkxRxN7DaF4yDYLPPi1VtcOxbMQkz6bCNK1mb7cJb tQsA== X-Gm-Message-State: AOJu0YwZbocfSMY6LqIV9pCkryu30LUSeL0MIOSM67DAH4080tiUfzYT KaJInyhd8gAG9eB+pV6GDMQ1MBe42NW25x7gcX7vQGsO8n9kziMVaRLM7Oc/sQ== X-Gm-Gg: ASbGnctPGZMEoFfOYGkfS5wMeY/VZ0SMBU8/N7VADTdBHP4ljObQKOAX67MRHL/YiMH 8jcmENaIZJgcGZZf8b5puZEGQH/Nu2mMi2RiOJGl2QuLWcAm1I0rEOYJ8MAUQs7r5Nse1WdLgoC yTf21ly3Fy32/R6PcqjogxFzTG7sfcl9Z4X15x9GIXCRTUcHxEM2Pxu1w03b1jeEpUBpdOgSRZJ ksoqg3h74QMuye775A2KdW7ccWV+rwfJtyuZwmVRzDRuwYuTYve19Vw7nXQlJ0KkJpfp7JZw76X dC8QjaaT4FyWOZPI0/xHIKEBT0Ztj3MnmaRdXVcgxdHUJOwaUNtbetd5A/kDRZNLzTMZDqSNo/q yfBIihXPbPzZNpHTRofW1zzl4 X-Google-Smtp-Source: AGHT+IHlTjBkC/TNKA88/1+phuhgnK0El1kOI/FDaapJX6tSIZfWFhb6k+73fZ8xYXGiKrRLbFD6xg== X-Received: by 2002:a05:6512:15a8:b0:54b:117c:8ef3 with SMTP id 2adb3069b0e04-54c22800e8dmr78511e87.54.1743707784704; Thu, 03 Apr 2025 12:16:24 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:24 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:12 +0000 Subject: [PATCH 1/8] media: uvcvideo: Fix deferred probing error Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-1-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda , stable@vger.kernel.org, Douglas Anderson X-Mailer: b4 0.14.2 uvc_gpio_parse() can return -EPROBE_DEFER when the GPIOs it depends on have not yet been probed. This return code should be propagated to the caller of uvc_probe() to ensure that probing is retried when the required GPIOs become available. Currently, this error code is incorrectly converted to -ENODEV, causing some internal cameras to be ignored. This commit fixes this issue by propagating the -EPROBE_DEFER error. Cc: stable@vger.kernel.org Fixes: 2886477ff987 ("media: uvcvideo: Implement UVC_EXT_GPIO_UNIT") Reviewed-by: Douglas Anderson Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_driver.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 107e0fafd80f54ec98c9657e5d58d17a6ed8c02f..25e9aea81196e0eddba6de74951a46a97ae0bdb8 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2232,13 +2232,16 @@ static int uvc_probe(struct usb_interface *intf, #endif /* Parse the Video Class control descriptor. */ - if (uvc_parse_control(dev) < 0) { + ret = uvc_parse_control(dev); + if (ret < 0) { + ret = -ENODEV; uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n"); goto error; } /* Parse the associated GPIOs. */ - if (uvc_gpio_parse(dev) < 0) { + ret = uvc_gpio_parse(dev); + if (ret < 0) { uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n"); goto error; } @@ -2264,24 +2267,32 @@ static int uvc_probe(struct usb_interface *intf, } /* Register the V4L2 device. */ - if (v4l2_device_register(&intf->dev, &dev->vdev) < 0) + ret = v4l2_device_register(&intf->dev, &dev->vdev); + if (ret < 0) goto error; /* Scan the device for video chains. */ - if (uvc_scan_device(dev) < 0) + if (uvc_scan_device(dev) < 0) { + ret = -ENODEV; goto error; + } /* Initialize controls. */ - if (uvc_ctrl_init_device(dev) < 0) + if (uvc_ctrl_init_device(dev) < 0) { + ret = -ENODEV; goto error; + } /* Register video device nodes. */ - if (uvc_register_chains(dev) < 0) + if (uvc_register_chains(dev) < 0) { + ret = -ENODEV; goto error; + } #ifdef CONFIG_MEDIA_CONTROLLER /* Register the media device node */ - if (media_device_register(&dev->mdev) < 0) + ret = media_device_register(&dev->mdev); + if (ret < 0) goto error; #endif /* Save our data pointer in the interface data. */ @@ -2315,7 +2326,7 @@ static int uvc_probe(struct usb_interface *intf, error: uvc_unregister_video(dev); kref_put(&dev->ref, uvc_delete); - return -ENODEV; + return ret; } static void uvc_disconnect(struct usb_interface *intf) From patchwork Thu Apr 3 19:16:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037537 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 428711FFC74 for ; Thu, 3 Apr 2025 19:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707789; cv=none; b=CPW6AOeiy35cNf4p+XFZGsbIRrD4prC/JPFa8Uscj+3qCnLttFg3Th7nBZ0O03KR+TqOKoBmHkE1hMJz9CAyFxYyM6lqSUsnwOB2X9lzwchAJrKLeIPAZY5CFYYBdSCEJK8gTDLC5SjcH/01hLNbvl1UJpn/CPKNlguA49ZYy4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707789; c=relaxed/simple; bh=Wk0eWcuzWua/Qg5JYIHzxP7iyJmxxh8gGdGpfJV3+s8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KKzE2ZoVZuip6av6ru1ChAAxH4nrfZh1tu3f50SG9Jxkpt7yy5oUOABUOfXJwYJImpunbZpYfbf08P31vdBP+Dc0GdbohJJKoIekIeItpZfR0GXY3BFgUVN/Kh8j6yTFDONo9GHwA81NFCu1MwLkSrVVBvtgWJ/RF+OEmNTgiL8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=DWgwO9MS; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DWgwO9MS" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-549b159c84cso1514448e87.3 for ; Thu, 03 Apr 2025 12:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707785; x=1744312585; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uYoADrO9YZr1hNVt8FHHeiiSHUxZ6kaNBXaVFMruk+4=; b=DWgwO9MSWkKsNzZMC1zNRqXdDRAAWPff8lY2AmYm3PblwLKcMXt/NkDHDtHVm4x83n 2A8V8L1ZBAsC4gzccm/aotFQlP7sJJmD5BKMNUz60qx08wz8QJRy62Y/gKgNbjzN7yQ/ vmv10DmO5RqtS4diElpgm3KGnqAL2qIoFbVDI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707785; x=1744312585; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uYoADrO9YZr1hNVt8FHHeiiSHUxZ6kaNBXaVFMruk+4=; b=HyzEpl14HJIFLPY1v0mwKNottpsoiO28vFKXfZDPzpvSRvoMmSamHW3q8SD2H/azZI k/5xbOE0ChAz9Vmyew/XiLAxXNdv7f36PKQGA+MZuyJBKcCpqUNw0FJNQTkOJfY0OMVL dcvJj36q3zr3tvnO+VHKUi+8OOCrUeY1ZQcE2j0mcSd7z9ilCguA14f05HxnWU3FBJqW 3rSYkGGaNm8OCUI8ZM+HfVlcvN5qckd+h1szstsCxtPmzZLOdRGgq75TTvkPHYqrg/XC FE8vrAewIWbba7fC5b2T191huB/eIfp+im3g06/o8gAaUGer25rq6trxQgjf8b+lOD20 PiFg== X-Gm-Message-State: AOJu0Yy+7cGT6TJAEulQgHfChinSxgyUhw0FuMyWB0Yg46vbm3cf6S4y dC7BsL0K04NJy/pyfgPO0THPvGctC0qk/hNqLBoTx2SZa75C7iPEC8uyD1p9Dg== X-Gm-Gg: ASbGncv0wx0aMBARBCkU3j4iFCBUqAxJ30x14YsvHXgwkLvayEgReosEJqVtfETCFr/ /QZ7dM/EoP+aGAT669xr1kpHmWfKJiZWUl1Zv105zazrI16rFpkbDz6QZRV/gWjM5culetfVItl Wc582RLUMy8MrcBx/6djOy80Xy1XBpLl3QqtWcXX4O/rqw61E72/7+eLY7UyYcp6ghxFF3v7oSc 5qOaVY8UhmO4XIOidDa6sUDVyn0XrfqT+qkBLsIxh0sl2zyXMbAzV3RnAB3s7o8f4WeeBZFsc3x JYjWXAft3N3yRj1PWenxK5XQRTC6VsqpFEdV1TBikVULjrQTJW7tuSkOMx8k/P58a8oPE0rMCnk qhjF9g47A4Om91qwDFKuX2ohAJLWrEun+SU0= X-Google-Smtp-Source: AGHT+IEGoLkshPtfD44DKnSZEUYb7gfzSjncS4T82uGZM/B3/E2lVpGdvLMrx6Bl5sLRu/jazB7Lrg== X-Received: by 2002:a05:6512:3048:b0:542:213f:78fd with SMTP id 2adb3069b0e04-54c227f589amr79715e87.40.1743707785277; Thu, 03 Apr 2025 12:16:25 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:24 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:13 +0000 Subject: [PATCH 2/8] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-2-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda , Doug Anderson , Douglas Anderson X-Mailer: b4 0.14.2 Use the dev_err_probe() helper for devm_gpiod_get_optional(), like we do with gpiod_to_irq() That eventually calls device_set_deferred_probe_reason() which can be helpful for tracking down problems. Now that all the error paths in uvc_gpio_parse have dev_err_probe, we can remove the error message in uvc_probe. Suggested-by: Doug Anderson Reviewed-by: Douglas Anderson Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_driver.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 25e9aea81196e0eddba6de74951a46a97ae0bdb8..da24a655ab68cc0957762f2b67387677c22224d1 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1299,8 +1299,13 @@ static int uvc_gpio_parse(struct uvc_device *dev) gpio_privacy = devm_gpiod_get_optional(&dev->intf->dev, "privacy", GPIOD_IN); - if (IS_ERR_OR_NULL(gpio_privacy)) - return PTR_ERR_OR_ZERO(gpio_privacy); + if (!gpio_privacy) + return 0; + + if (IS_ERR(gpio_privacy)) + return dev_err_probe(&dev->intf->dev, + PTR_ERR(gpio_privacy), + "Can't get privacy GPIO\n"); irq = gpiod_to_irq(gpio_privacy); if (irq < 0) @@ -2241,10 +2246,8 @@ static int uvc_probe(struct usb_interface *intf, /* Parse the associated GPIOs. */ ret = uvc_gpio_parse(dev); - if (ret < 0) { - uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n"); + if (ret < 0) goto error; - } dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n", dev->uvc_version >> 8, dev->uvc_version & 0xff, From patchwork Thu Apr 3 19:16:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037539 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93368200138 for ; Thu, 3 Apr 2025 19:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707791; cv=none; b=MiofDgYMM8rX0yIn0cuAddLP4K+GBfV7wDa5TtO5i5EPqOAuFedjP1guSZd4dCQMWV3XSOZoJhWz3FLkQeCjL1YAKl+u9EWGArrRfUbB3tsNG1YyZVt/pflUD27K4xMJvq8MQJNLPGvo6I14t2x6k65zOB5g5RFGJat+kVKIJlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707791; c=relaxed/simple; bh=bGaAiPeWPDujMReJfDlyeCQH1PMh/OahseP2Qm+tEqI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BVeH3SFoprjRfQuibdyitjPwnkl65/9CIMOH8g7ogdnalYS47nsIt+IHoZyZggxnLu+P2x4xjTi9e88OjqjG5EOpLO8/UFL4CDIJ2IfoDRquAwt1zYSiKQ5xtsWohSER3KKVXYrLSmWZlOwDWeC1Xn65E0JP31siG8pFyYMCTcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=CkE1vVcq; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CkE1vVcq" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-54afb5fcebaso1415579e87.3 for ; Thu, 03 Apr 2025 12:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707786; x=1744312586; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yEqJQbM1Mf4t3pD37/T8xo0WrUZj8tqnA7nqQpopQiI=; b=CkE1vVcqmJ0VCZcMDdAuIgZ55E3XcNguuTEqB8SAxg3SuSdWoLcHrL4zjrsWbCPNnN 1BBOMSPCKJ9UItHXgbun4sj1cUVQaTnSnY7joVOQWFTtgs+XyFKZWrSRGFtDwVSBjkgY 2LujMk+EasSKezzcYqwIH5ZnlYiz5vehVx0qo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707786; x=1744312586; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yEqJQbM1Mf4t3pD37/T8xo0WrUZj8tqnA7nqQpopQiI=; b=B6VXPUSjL5o+m1djf7ehZXQTw9Gs/QxQlI7aDBFZN8dC1QoGFnpgbXQz7NLbLjZOG8 4LvGUsUjvkXqQG0soi9JT/3FHSIFHp5Qm865SalQCLizS1kAAmNKseb8JDSKR5LxLY8T PrKzLsezX9X5B4CYvZTfdtI8vsE5yZ2iiVCWaCfeOz/iuyYcBnnKoc66Ni4zMAgfi5nD LCdfRMLUB1QDnhvaFToCUQ2GfqhwZh/Qq2hrG22suRz+FQgvOwvQXGwGS2+iR+O4xV2a G2s9VYkFuhDIUoNo2aTTXuhg9ubm8tT8V3Vff7KXRxGQVabAenMWi19/kcGUUx9Q83zq /Gfw== X-Gm-Message-State: AOJu0YwIuGKF3/IBbn6IeCF+9GOCRo01DmRFyfrDwYSuEb49DoGaS4a4 +UA5Yi8r/jqiO5UoQ4aLIerRH8Swi0PLuqvA6hRWtZGRQgPy3ZxdPSIAbdeiWA== X-Gm-Gg: ASbGncvRevfKLefoflLBsWWNLGKNahMLgY8GJmoKAFi483nL7pGGhqb/gp1467OhCiy Km2ylJSy0NhmsVrTltgzxjcNjn7YL8oQfyUSqn+/FZxH9tODI2vmoZrs+rJD8M3XocOJ4kT/yIj bPskL1pEOO7klikBn/xyxyw/QKE29urHvWeEK5Mswy4OevBaeLfy/hc11BE57PbgWMpC2Wg11zR Z8R5iLjwNhqKUbA7MoMZuGeHNpqy/zBGkUzuLYCaJ8fCz0rEzuMYwnMsB2IyrUZ68rMmUWjCVac kF1bZ2rrCxgTnzJvgHorzQ36WWwFHDYM4GAbolcT8mE7jt4eazYri8UeBzk1Zv3qY82QYwVEcde NCCQJZDvkMzsM4JsFGWUglmdk X-Google-Smtp-Source: AGHT+IEtxSrTjJbJCoji6jyspDiVzgskf1D1Wes/27FHcNtXF4JkR2nUjJNmG5ErLGGAKBQY96uhEw== X-Received: by 2002:a05:6512:3c9c:b0:545:2c2c:5802 with SMTP id 2adb3069b0e04-54c227fec79mr118358e87.48.1743707785840; Thu, 03 Apr 2025 12:16:25 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:25 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:14 +0000 Subject: [PATCH 3/8] media: v4l: fwnode: Support acpi devices for v4l2_fwnode_device_parse Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-3-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.14.2 This patch modifies v4l2_fwnode_device_parse() to support ACPI devices. We initially add support only for orientation via the ACPI _PLD method. Signed-off-by: Ricardo Ribalda --- drivers/media/v4l2-core/v4l2-fwnode.c | 58 +++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index cb153ce42c45d69600a3ec4e59a5584d7e791a2a..81563c36b6436bb61e1c96f2a5ede3fa9d64dab3 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -15,6 +15,7 @@ * Author: Guennadi Liakhovetski */ #include +#include #include #include #include @@ -807,16 +808,47 @@ int v4l2_fwnode_connector_add_link(struct fwnode_handle *fwnode, } EXPORT_SYMBOL_GPL(v4l2_fwnode_connector_add_link); -int v4l2_fwnode_device_parse(struct device *dev, - struct v4l2_fwnode_device_properties *props) +static int v4l2_fwnode_device_parse_acpi(struct device *dev, + struct v4l2_fwnode_device_properties *props) +{ + struct acpi_pld_info *pld; + int ret = 0; + + if (!acpi_get_physical_device_location(ACPI_HANDLE(dev), &pld)) { + dev_dbg(dev, "acpi _PLD call failed\n"); + return 0; + } + + switch (pld->panel) { + case ACPI_PLD_PANEL_FRONT: + props->orientation = V4L2_FWNODE_ORIENTATION_FRONT; + break; + case ACPI_PLD_PANEL_BACK: + props->orientation = V4L2_FWNODE_ORIENTATION_BACK; + break; + case ACPI_PLD_PANEL_TOP: + case ACPI_PLD_PANEL_LEFT: + case ACPI_PLD_PANEL_RIGHT: + case ACPI_PLD_PANEL_UNKNOWN: + props->orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL; + break; + default: + dev_dbg(dev, "Unknown _PLD panel val %d\n", pld->panel); + ret = -EINVAL; + break; + } + + ACPI_FREE(pld); + return ret; +} + +static int v4l2_fwnode_device_parse_dt(struct device *dev, + struct v4l2_fwnode_device_properties *props) { struct fwnode_handle *fwnode = dev_fwnode(dev); u32 val; int ret; - memset(props, 0, sizeof(*props)); - - props->orientation = V4L2_FWNODE_PROPERTY_UNSET; ret = fwnode_property_read_u32(fwnode, "orientation", &val); if (!ret) { switch (val) { @@ -833,7 +865,6 @@ int v4l2_fwnode_device_parse(struct device *dev, dev_dbg(dev, "device orientation: %u\n", val); } - props->rotation = V4L2_FWNODE_PROPERTY_UNSET; ret = fwnode_property_read_u32(fwnode, "rotation", &val); if (!ret) { if (val >= 360) { @@ -847,6 +878,21 @@ int v4l2_fwnode_device_parse(struct device *dev, return 0; } + +int v4l2_fwnode_device_parse(struct device *dev, + struct v4l2_fwnode_device_properties *props) +{ + struct fwnode_handle *fwnode = dev_fwnode(dev); + + memset(props, 0, sizeof(*props)); + + props->orientation = V4L2_FWNODE_PROPERTY_UNSET; + props->rotation = V4L2_FWNODE_PROPERTY_UNSET; + + if (is_acpi_device_node(fwnode)) + return v4l2_fwnode_device_parse_acpi(dev, props); + return v4l2_fwnode_device_parse_dt(dev, props); +} EXPORT_SYMBOL_GPL(v4l2_fwnode_device_parse); /* From patchwork Thu Apr 3 19:16:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037540 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A69A7201006 for ; Thu, 3 Apr 2025 19:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707792; cv=none; b=qMApKlnVhyOwbSyRndZPDzZzGI39Fzeoir0tyIt1NN6Z39PnPRG3fgAQ/C+mmm0RUnRzItN8e3K+fqHUEf35oue6yogW94sxADHR8zGVOSCv/r4kVFkjtTbNbAvxm6D3nA6+AX+SN37XLRmDZaqCSutoTA1El6E2LdwwXTdWKt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707792; c=relaxed/simple; bh=FkbqQupMpzx0wszT8hmcVx+KkNGgx/ddD0tHr201vd4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=awrRFy6azGLmVGJFh7k6qklQP6SAp0l2hukKf9uXt0qwP6FrS8PBiahh1CoheZfSeD3Hu1Z3N3J+thhcJqKH8qv98ERPWv+cLNfvxMU1LQ2yRuhgEi0ghVn4lTpSHpRp/FC6KVdeWNN3O6MiurIXULloE8sxyq4/MyGXyHDPd00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=DUVN8BoL; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DUVN8BoL" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5493b5bc6e8so1515537e87.2 for ; Thu, 03 Apr 2025 12:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707787; x=1744312587; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3Ka+lvT2WWas4h5SU2dyS9iOFUZ7NSTxVoiGdeZqTAM=; b=DUVN8BoLDufoqp6l9PgZ5nVu3y253dfDUXL3m5TFpnDjZ3dSFN7nP4iUbleHFalBTX w80OnXcSo1FFVsDLrQyDbl3Y6f4h0474jHBY6XzRh0KXF6j0X5k8ZJFiX3qeTgf3IxeK +IrnGEhZH2B3yyG51KNx2kjMbPi8IodSCNHto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707787; x=1744312587; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Ka+lvT2WWas4h5SU2dyS9iOFUZ7NSTxVoiGdeZqTAM=; b=kgBrcT1kbjXLAhS8c9IKlG7UTPAEyb+1vJYtqFcREleKMHglcoc8k1AQ4a6FbLmS5u vvFA3N+ogX7Qgyaq8VjQkaJJuosvuNJG98trRJu12lAykH/f79hDU46x0p1HaAL/58H0 3I0iopqOopQFPxBgkGqzXNZ7lwNVsy3MbLsGYdydbZr/tKTuzEFD93HA0KarJp9bEQEz hmjmRR0W/uW33j7HelfQe2O+QY0awd5UpjFUq/olXBW9NSk2FplpW6gUcbAZxrTHSUMN zwcark3hspA/Ez8o67IykqcjnuVfDTGn1mlg5+Q85flKna/Jdxs98jaWzGTNQ5ldNQjD otfA== X-Gm-Message-State: AOJu0YwSUKo86OhEe4ach+STjEh81LC9nm3gORUx7kC8+zR9O9nG/qpF 6wLNtSnJ0dHP2EgDXdqTl98pW4yBOs8XImeeKYI6xFMqkf3DTAinFAz6FrO/Ew== X-Gm-Gg: ASbGnctmd8B0AabB3v/HV3dd9QVXyU1SIhlawDeTLbWHyrxGREfjLcleCzCwatPZCgd k+20++lnBSHt64AkSOvnMepCXQMT9UV+MFg1Jdayh/aDAhXBC6DU7Y9Daat2G6b5hLYXEJ44Kwu Vs94QtsaEKDVEH6M/PWU9jfeu9J3IwKGUeMIicirgKZu/EycyyNu0dEx195zDG8u1mmK2Zo34N+ opDs5kGP7O63eKAvCoMSAbfVpRTYfWaRkTbDhaQS3A0/Q1B3vMs2GRolCRVUmZhSYg8Ec3n0TjC c7n5JV2lp1mV4oUFPZlwKJe5gCj7cVdYESXgLbgPSTtVr7zQHvmeBYv7vP0xvjGmGqDeqeDwzse QwA6/rqWfBEebB5n74KuWBBmG X-Google-Smtp-Source: AGHT+IEoqeMaCo7VWkarYWDP+GRzyBsI/lGXquNjw+btFYnKJTWgwFNKTpnH5nMpaFghhD3kro9NkQ== X-Received: by 2002:a05:6512:3a87:b0:549:31e4:9ea with SMTP id 2adb3069b0e04-54c2282454fmr77746e87.52.1743707786957; Thu, 03 Apr 2025 12:16:26 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:26 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:15 +0000 Subject: [PATCH 4/8] media: ipu-bridge: Use v4l2_fwnode_device_parse helper Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-4-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.14.2 v4l2_fwnode_device_parse now supports acpi devices as well. Use the helper instead of re-implement the logic. Signed-off-by: Ricardo Ribalda --- drivers/media/pci/intel/ipu-bridge.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 1cb7458556004d2073688bb0d11defd01f2f61b7..79e6998d37dfde50bd4b44584c8864178527d951 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -251,36 +251,16 @@ static u32 ipu_bridge_parse_rotation(struct acpi_device *adev, static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_device *adev) { - enum v4l2_fwnode_orientation orientation; - struct acpi_pld_info *pld = NULL; + struct v4l2_fwnode_device_properties props; + int ret; - if (!acpi_get_physical_device_location(ACPI_PTR(adev->handle), &pld)) { - dev_warn(ADEV_DEV(adev), "_PLD call failed, using default orientation\n"); + ret = v4l2_fwnode_device_parse(ADEV_DEV(adev), &props); + if (!ret || props.rotation == V4L2_FWNODE_PROPERTY_UNSET) { + dev_warn(ADEV_DEV(adev), "Using default orientation\n"); return V4L2_FWNODE_ORIENTATION_EXTERNAL; } - switch (pld->panel) { - case ACPI_PLD_PANEL_FRONT: - orientation = V4L2_FWNODE_ORIENTATION_FRONT; - break; - case ACPI_PLD_PANEL_BACK: - orientation = V4L2_FWNODE_ORIENTATION_BACK; - break; - case ACPI_PLD_PANEL_TOP: - case ACPI_PLD_PANEL_LEFT: - case ACPI_PLD_PANEL_RIGHT: - case ACPI_PLD_PANEL_UNKNOWN: - orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL; - break; - default: - dev_warn(ADEV_DEV(adev), "Unknown _PLD panel val %d\n", - pld->panel); - orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL; - break; - } - - ACPI_FREE(pld); - return orientation; + return props.rotation; } int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor) From patchwork Thu Apr 3 19:16:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037541 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 490BF2010E3 for ; Thu, 3 Apr 2025 19:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707793; cv=none; b=s5D2aahFyQNAr70AeK+3w+MWc6L4wCvDRBTez/Lwp8kYjUKYgcl2OhHm8o2Qu+NKMMpWLVN+I/eL8RxIL4uckwhT0BcXz3FdrKsHSt7nkuXHt7/T2arQqTn+BOWqQAT87T4Twzknymxh4lZyTdLwiOGPG05KeLbw2erde6vQEdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707793; c=relaxed/simple; bh=rQ2v20Ddln+4BwZ1YiM0h0pDo1Qau2cCuH+bpTFZT9w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WxTi+ql8NmyIm3qMJbELhI4C976Lf9D64VpsT03uOjK2ZtuUN6zpOhqK+gpC8tINZ0lRMdnfeuDC06HNR9lCZAJFdG9To8EOtDWCNdLXQljKwnySnLIKeatCNQ7wcyDYsO5gfT9rBrEocf8rHL14utCsIhb/eH9o29RUV9AR8+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=dA+tqKgx; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dA+tqKgx" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5497590ffbbso1354864e87.1 for ; Thu, 03 Apr 2025 12:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707788; x=1744312588; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XTsIlDstX0o+Mbqya+IkMyfr6mBLbjzx0t4rQvZShfQ=; b=dA+tqKgxMEyaBrWTZ+T7TXv+rs/eoD44/x4t7aWao13O3Gd7wAUFM4j25zZwpfUHFu ZQXUUs0mPlvA5pz1LwM3Ua+rHXzFoZH4XJ2e1gHhsQ7izxa1P3QgR3MdVLokoebMRP0f vCvsIUMwhvQWEHM5tPZl/sRAGTwB51FeYmlvY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707788; x=1744312588; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XTsIlDstX0o+Mbqya+IkMyfr6mBLbjzx0t4rQvZShfQ=; b=n8C2eFh4VSEcsO1bzVH2+rkriuqUtnWS/bk+3ZxJFWp+UY1bhxiJEXyqgIQ1N4/HT1 YeHrfRfPqJYzRNNNhj6oJ49fBpaOnkvKuHWhDdJBGh3YM3tqXK86yq57Sejxb54yelwz 8EXcxJ+uCkRVGTOWB9AYYUapKHyQdYDTRyfmKLwCcW8CFt2gG1+hDen5c01ZjOXkhwz0 Piy+jdsTdXCU/k5a++7QsB72FHleXmqNe0m2K67TDof41ulqzNJQpE8nK6tfn2qDBemU jkIlcg6iwn02SsbVliOEFh32wxQOGgkbND6cde6PzHdsQiA+rFxJjiKtFHpKteuAirjQ bP1g== X-Gm-Message-State: AOJu0YzeV7xi9opibxtQe2F96n75jdmD3cnEHW5Oer9BYhMmXuzHVm4x yDfgx5FHVt9hdJ+rTLxJkoG/3JGTAi4UBdS1vvPiVYtz6bXFg8Ti9NjdLTD6Jg== X-Gm-Gg: ASbGncs3NLiLCoB3UsBecuSQrS7vt1BH6eMXLfz55isSZe5d9d8KlQrC00M3X49HvTC EQob6gz8WXcjwc1x0IOXmLteIqWY8nDc91goZ9l8pKvQQXA0eHGN+IDZxl4BdhsVulEKERv6McN L55DDKwP3ejv4nmvilEb8zLenqKKWorW2Ori8zrYA+M1ZJDdB5vaZNABH4Cv1mHUxftDThJRlVm 3CKB6BVFOxjbuPkekpH6H7608UE0687/sbT3/GKqvxNQKa/Pw8nyrL9i6UMrDIir7VKutgDlar9 W9k9AHG7i3jFN9GKErNoIsMCaiRrsLm2HTLVIML6QMj2ZgX5MmXAu7vLuABgx6XJT9o0zB6YcY+ qNYJZYolu7dQzxXfXFYRi/c9B X-Google-Smtp-Source: AGHT+IHCXI3V2p507FEESs4oxanJZZsNHxyB6fAQHEoPMaOLxvmQtP8ckbT8u/hI65VR8pFcvY0x2A== X-Received: by 2002:a05:6512:2253:b0:549:7c13:e88f with SMTP id 2adb3069b0e04-54c22795803mr113406e87.30.1743707787714; Thu, 03 Apr 2025 12:16:27 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:27 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:16 +0000 Subject: [PATCH 5/8] dt-bindings: usb: usb-device: Add orientation Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-5-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.14.2 For some devices, such as cameras, the OS needs to know where they are mounted. ACPI has a property for this purpose, which is parsed by acpi_get_physical_device_location(): https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#pld-physical-location-of-device In DT we have similar property for video-interface-devices called orientation: Documentation/devicetree/bindings/media/video-interface-devices.yaml Add a new property orientation for usb-devices that matches the already existing orientation property of video-interface-devices. Signed-off-by: Ricardo Ribalda --- Documentation/devicetree/bindings/usb/usb-device.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/usb-device.yaml b/Documentation/devicetree/bindings/usb/usb-device.yaml index da890ee60ce6e71a11910c565b6f805470782e4f..bbcda28ec7d5695307efa797f57180044afda77f 100644 --- a/Documentation/devicetree/bindings/usb/usb-device.yaml +++ b/Documentation/devicetree/bindings/usb/usb-device.yaml @@ -42,6 +42,10 @@ properties: port to which this device is attached. The range is 1-255. maxItems: 1 + orientation: + description: If present, specifies the orientation of the usb device. + $ref: /schemas/media/video-interface-devices.yaml#/properties/orientation + "#address-cells": description: should be 1 for hub nodes with device nodes, should be 2 for device nodes with interface nodes. @@ -101,6 +105,7 @@ examples: device@2 { compatible = "usb123,4567"; reg = <2>; + orientation = <0>; }; device@3 { From patchwork Thu Apr 3 19:16:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037542 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C25A20012B for ; Thu, 3 Apr 2025 19:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707794; cv=none; b=jVxgJpSvjG4/H1kQEUUjF0xop5AtUolwFFrWRusWMHFZprlNZQgMLrSrblnWgpDCgKa0msxSWcAVAb5D57teDFBHhxTV/sEGZ4h+GlDDziGnGsXmMIBKfBUA9NiahyGsMbADsyg6xU76u+eUgN2q3Oo6uX85+U5HX0MNlLoum38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707794; c=relaxed/simple; bh=noGsjNpbTJQGuzk0L9zxxVJfrWP8YJVEzJ14lhD15kg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Za18ezQCu/UoT91qiIYuIpmL8FloEgsNaLMWJxktPQDPHkpRFY96qM9wULnLpy2A1dSPFyIHo/2l5WcUwsM6ywssKPy3yr7LXZLAMNDsiPoF7hk5YG7JuhgRJqizQeqbHNaEV9RdmtDsUK0sCJ0HDyuvtW6QolTQN6uK4BCb/x8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=AyQdd6ro; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="AyQdd6ro" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-54993c68ba0so1326483e87.2 for ; Thu, 03 Apr 2025 12:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707788; x=1744312588; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eqeUSTXiNE7V9Doas/xI2vrhYng5skkX+gfjPxjj7HE=; b=AyQdd6roVYCDOCPgTqtwgu/LYNxPkPhJAZsmHL6lg/UKgtDHrX3KMVEzm0vJoxyToJ +ITS9sq07VvgbBkm3ketv+ReYDLajsui8X4sfOKtkF07jLDt8Jejz+TQOzJne4jonqSh pjJupBgX/EZHZkoejrXHXbo2uCmtYZVKadlXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707788; x=1744312588; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eqeUSTXiNE7V9Doas/xI2vrhYng5skkX+gfjPxjj7HE=; b=qSfADr1UlbRKm1z2E00DUlzNKmn9VzMns1vXFQhEB5chDSvv/ilgFr7FvZUdG/M5JX mbZUymtxrGJJrk6tKF8xqscha1XkynIyZKVmMmhy33OvXZIpfTBfpWOKag437Wz7Ljh1 Hceu+gMCbdvxhQmbXAFIPZDA5+e159ZnI75qf7grUOHznjGakBKMERGxTKTcFvREPo1U mom5CXWLS4kVUyNTwJgnFV8A/+WKqom3atN8aXxWz93dNnmE3kaLEvMVkTQm2HaAP7Xj YUkuo+YOyhr7uXGIOHsYNQI6+pKndKeV1OstNriew/lAWOfACOTuBI3T7YtQNAixnK/+ +w9A== X-Gm-Message-State: AOJu0YzDa9IkuuNPibGnNGbLJgCJJFJmUjwOw/P0XMrvzDiAWnpyhcvg aoYqFQJi2CS0VqSHqMW9BwiHZqs6MfCUO5kjfGCDusKUY5HKgDf1MGWAJDRDzw== X-Gm-Gg: ASbGncundYHsWleADPoAm9eDN15ZjV3w4nYNeQVqcewKz9EQOBp/mdMeR9xgoUUjyN/ dlPxE3EfAPBNhrhgmzjFBtFX6/l24hI0czEdOhpeJqQaLPEMlSrhaeeJHjtZJeu5oIS4CE33D55 rfLADDH3YvfwiOr5juDRytyhXVp8mkUTOAOBxVYRscpnard/cMrSbiwB1N+9eC5VFuA+Ec4rP/P 2fKeGyRAl2b9ymLjwjmFdVobqBKr0U9SJxbLLEj3IAayPKnDlmiuxcaIXB9gMOEz2u0ucfgNr70 HXKZzx+CDi+hxu040FlJJ4chCFC917KmOOeuYcEShM5UHZpfgp5CpiuyYckMSvRhm0/NMYKsDCn SnTcqOdvNeooM5zoYT2zR7kdWQewamKZHa6o= X-Google-Smtp-Source: AGHT+IEnp8VUB3M+G2jjQvzNOduVN4Gua0CvZ+Ge32/rY/9kjO4ZMwa0dgaHAma4urzs7NV5dGUWbw== X-Received: by 2002:a05:6512:108e:b0:549:91db:c14b with SMTP id 2adb3069b0e04-54c227708ecmr108305e87.8.1743707788502; Thu, 03 Apr 2025 12:16:28 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:27 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:17 +0000 Subject: [PATCH 6/8] media: uvcvideo: Factor out gpio functions to its own file Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-6-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.14.2 This is just a refactor patch, no new functionality is added. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/Makefile | 3 +- drivers/media/usb/uvc/uvc_driver.c | 121 +----------------------------------- drivers/media/usb/uvc/uvc_gpio.c | 123 +++++++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 6 ++ 4 files changed, 133 insertions(+), 120 deletions(-) diff --git a/drivers/media/usb/uvc/Makefile b/drivers/media/usb/uvc/Makefile index 4f9eee4f81ab6436a8b90324a688a149b2c3bcd1..85514b6e538fbb8284e574ca14700f2d749e1a2e 100644 --- a/drivers/media/usb/uvc/Makefile +++ b/drivers/media/usb/uvc/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ - uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o + uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o \ + uvc_gpio.o ifeq ($(CONFIG_MEDIA_CONTROLLER),y) uvcvideo-objs += uvc_entity.o endif diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index da24a655ab68cc0957762f2b67387677c22224d1..b52e1ff401e24f69b867b5e975cda4260463e760 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -792,8 +791,8 @@ static const u8 uvc_media_transport_input_guid[16] = UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; -static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, - unsigned int num_pads, unsigned int extra_size) +struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, unsigned int num_pads, + unsigned int extra_size) { struct uvc_entity *entity; unsigned int num_inputs; @@ -1242,122 +1241,6 @@ static int uvc_parse_control(struct uvc_device *dev) return 0; } -/* ----------------------------------------------------------------------------- - * Privacy GPIO - */ - -static void uvc_gpio_event(struct uvc_device *dev) -{ - struct uvc_entity *unit = dev->gpio_unit; - struct uvc_video_chain *chain; - u8 new_val; - - if (!unit) - return; - - new_val = gpiod_get_value_cansleep(unit->gpio.gpio_privacy); - - /* GPIO entities are always on the first chain. */ - chain = list_first_entry(&dev->chains, struct uvc_video_chain, list); - uvc_ctrl_status_event(chain, unit->controls, &new_val); -} - -static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity, - u8 cs, void *data, u16 size) -{ - if (cs != UVC_CT_PRIVACY_CONTROL || size < 1) - return -EINVAL; - - *(u8 *)data = gpiod_get_value_cansleep(entity->gpio.gpio_privacy); - - return 0; -} - -static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity, - u8 cs, u8 *caps) -{ - if (cs != UVC_CT_PRIVACY_CONTROL) - return -EINVAL; - - *caps = UVC_CONTROL_CAP_GET | UVC_CONTROL_CAP_AUTOUPDATE; - return 0; -} - -static irqreturn_t uvc_gpio_irq(int irq, void *data) -{ - struct uvc_device *dev = data; - - uvc_gpio_event(dev); - return IRQ_HANDLED; -} - -static int uvc_gpio_parse(struct uvc_device *dev) -{ - struct uvc_entity *unit; - struct gpio_desc *gpio_privacy; - int irq; - - gpio_privacy = devm_gpiod_get_optional(&dev->intf->dev, "privacy", - GPIOD_IN); - if (!gpio_privacy) - return 0; - - if (IS_ERR(gpio_privacy)) - return dev_err_probe(&dev->intf->dev, - PTR_ERR(gpio_privacy), - "Can't get privacy GPIO\n"); - - irq = gpiod_to_irq(gpio_privacy); - if (irq < 0) - return dev_err_probe(&dev->intf->dev, irq, - "No IRQ for privacy GPIO\n"); - - unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); - if (!unit) - return -ENOMEM; - - unit->gpio.gpio_privacy = gpio_privacy; - unit->gpio.irq = irq; - unit->gpio.bControlSize = 1; - unit->gpio.bmControls = (u8 *)unit + sizeof(*unit); - unit->gpio.bmControls[0] = 1; - unit->get_cur = uvc_gpio_get_cur; - unit->get_info = uvc_gpio_get_info; - strscpy(unit->name, "GPIO", sizeof(unit->name)); - - list_add_tail(&unit->list, &dev->entities); - - dev->gpio_unit = unit; - - return 0; -} - -static int uvc_gpio_init_irq(struct uvc_device *dev) -{ - struct uvc_entity *unit = dev->gpio_unit; - int ret; - - if (!unit || unit->gpio.irq < 0) - return 0; - - ret = request_threaded_irq(unit->gpio.irq, NULL, uvc_gpio_irq, - IRQF_ONESHOT | IRQF_TRIGGER_FALLING | - IRQF_TRIGGER_RISING, - "uvc_privacy_gpio", dev); - - unit->gpio.initialized = !ret; - - return ret; -} - -static void uvc_gpio_deinit(struct uvc_device *dev) -{ - if (!dev->gpio_unit || !dev->gpio_unit->gpio.initialized) - return; - - free_irq(dev->gpio_unit->gpio.irq, dev); -} - /* ------------------------------------------------------------------------ * UVC device scan */ diff --git a/drivers/media/usb/uvc/uvc_gpio.c b/drivers/media/usb/uvc/uvc_gpio.c new file mode 100644 index 0000000000000000000000000000000000000000..30e3e6dd22cbc9cfee420dde7f7f64dbdce499b9 --- /dev/null +++ b/drivers/media/usb/uvc/uvc_gpio.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * uvc_gpio.c -- USB Video Class driver + * + * Copyright 2025 Google LLC + */ + +#include +#include +#include "uvcvideo.h" + +static void uvc_gpio_event(struct uvc_device *dev) +{ + struct uvc_entity *unit = dev->gpio_unit; + struct uvc_video_chain *chain; + u8 new_val; + + if (!unit) + return; + + new_val = gpiod_get_value_cansleep(unit->gpio.gpio_privacy); + + /* GPIO entities are always on the first chain. */ + chain = list_first_entry(&dev->chains, struct uvc_video_chain, list); + uvc_ctrl_status_event(chain, unit->controls, &new_val); +} + +static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity, + u8 cs, void *data, u16 size) +{ + if (cs != UVC_CT_PRIVACY_CONTROL || size < 1) + return -EINVAL; + + *(u8 *)data = gpiod_get_value_cansleep(entity->gpio.gpio_privacy); + + return 0; +} + +static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity, + u8 cs, u8 *caps) +{ + if (cs != UVC_CT_PRIVACY_CONTROL) + return -EINVAL; + + *caps = UVC_CONTROL_CAP_GET | UVC_CONTROL_CAP_AUTOUPDATE; + return 0; +} + +static irqreturn_t uvc_gpio_irq(int irq, void *data) +{ + struct uvc_device *dev = data; + + uvc_gpio_event(dev); + return IRQ_HANDLED; +} + +int uvc_gpio_parse(struct uvc_device *dev) +{ + struct uvc_entity *unit; + struct gpio_desc *gpio_privacy; + int irq; + + gpio_privacy = devm_gpiod_get_optional(&dev->intf->dev, "privacy", + GPIOD_IN); + if (!gpio_privacy) + return 0; + + if (IS_ERR(gpio_privacy)) + return dev_err_probe(&dev->intf->dev, + PTR_ERR(gpio_privacy), + "Can't get privacy GPIO\n"); + + irq = gpiod_to_irq(gpio_privacy); + if (irq < 0) + return dev_err_probe(&dev->intf->dev, irq, + "No IRQ for privacy GPIO\n"); + + unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); + if (!unit) + return -ENOMEM; + + unit->gpio.gpio_privacy = gpio_privacy; + unit->gpio.irq = irq; + unit->gpio.bControlSize = 1; + unit->gpio.bmControls = (u8 *)unit + sizeof(*unit); + unit->gpio.bmControls[0] = 1; + unit->get_cur = uvc_gpio_get_cur; + unit->get_info = uvc_gpio_get_info; + strscpy(unit->name, "GPIO", sizeof(unit->name)); + + list_add_tail(&unit->list, &dev->entities); + + dev->gpio_unit = unit; + + return 0; +} + +int uvc_gpio_init_irq(struct uvc_device *dev) +{ + struct uvc_entity *unit = dev->gpio_unit; + int ret; + + if (!unit || unit->gpio.irq < 0) + return 0; + + ret = request_threaded_irq(unit->gpio.irq, NULL, uvc_gpio_irq, + IRQF_ONESHOT | IRQF_TRIGGER_FALLING | + IRQF_TRIGGER_RISING, + "uvc_privacy_gpio", dev); + + unit->gpio.initialized = !ret; + + return ret; +} + +void uvc_gpio_deinit(struct uvc_device *dev) +{ + if (!dev->gpio_unit || !dev->gpio_unit->gpio.initialized) + return; + + free_irq(dev->gpio_unit->gpio.irq, dev); +} + diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index b4ee701835fc016474d2cd2a0b67b2aa915c1c60..aef96b96499ce09ffa286c51793482afd9832097 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -683,6 +683,8 @@ do { \ */ struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id); +struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, unsigned int num_pads, + unsigned int extra_size); /* Video buffers queue management. */ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type); @@ -829,4 +831,8 @@ void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream); size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, size_t size); +/* gpio */ +int uvc_gpio_parse(struct uvc_device *dev); +int uvc_gpio_init_irq(struct uvc_device *dev); +void uvc_gpio_deinit(struct uvc_device *dev); #endif From patchwork Thu Apr 3 19:16:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037543 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01247202C24 for ; Thu, 3 Apr 2025 19:16:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707795; cv=none; b=duJdio6pMQCPO6yIeepuwMsNEhsIYk+Rw4mchz6vvyruZ+0GazTGNU7jixWoMfWfNIH7Tg1/o9lGBXQdHyPA1ZN095o7WzjgkwSbKLtVEuABbXm5yE6AlIyi5pYXQmB/BJ2XUIExFubxkRnP6D6jPu8W9dMbIfxsLBBb1syYO5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707795; c=relaxed/simple; bh=XJEMprlCEsKfWYhy5LoPnYnpm2JF0ywPCss0Gv2wgfw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y68FG1Dcvhh1b+NTTq1SlEjKFTdVh0CPKJT2M2LBcItEB+mahTqtRJvdOfJM3RNU88BlzNOK2iSOGzLfrUrfMNECMLtoAyOery76rZ+sW4MqyXJIqy2UZArYdjTJ+hNPAKYten3UfGiziij5CNJjoS8TXhn0wO6rjisILNScV8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Zec3XZj0; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Zec3XZj0" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-54b09cb06b0so1364584e87.1 for ; Thu, 03 Apr 2025 12:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707790; x=1744312590; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ktHQdoTvKewbftgZa2kS1uVSmUgEOG8hJ1cjDiKOz20=; b=Zec3XZj0EqGAttJQvFMhIroaiSKZImGGT1aFHzFWv6CpioaQom3O6gli82EvI9cUHm VqQ3G4Ss0VBw9TA2J8mLmKQf2iF7VKShIzFueOdz35utsXcCz86iG5uGAI595P/ryT9O /4+QlstkDtcntVVWbXb3dv+lypERJgvyuS2cY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707790; x=1744312590; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ktHQdoTvKewbftgZa2kS1uVSmUgEOG8hJ1cjDiKOz20=; b=JlkzbLuE6VpyiqkmiiZTc9moF5cVN/r98lYh4lSFgiwyzQvLtw3slB9xl+bBu+tzVO ofs23pg/5rt/52fUpPOAb6LXgPxcnsF/mtnTMF84LjZtZ544rvik+zp+5Ga77vbdz8De vS6puAV4P48tDDWMwb2LnqCVlVWw3lZad6DL8o2mCrF1HqCjabpKVA6dLw5jnW4McJhj KYEziZ508c9dc1k0mPa+WDNWv169xHBOKY+rLFEmCvE8u/96Ko1VJ8MaxfT+DL7sqHaS aa43gjBgz6/u3sRs6XFUS2O1h/G1Z6AXpMONWUQzi6FG0tEZrkI0TLbrWYgqLylpl4QT 4PUg== X-Gm-Message-State: AOJu0YwW37WajYar/PtHjQSLwUp667ACP09uja8N/Juk6IXoGeZw1FYG HaHvqXtKNP1+90Bd5fTmSs1Y/uCBB5t55TqmqSh0MWqua2lsYblP6rvPYP4yXQ== X-Gm-Gg: ASbGnctmribS2Ga01cGyTAmGo+VR+RIlJNGtePd+1yLmqM7+PT41dndbRhH+7/hnkqZ iwA18Jf3CJewF2iBbsVLWl8+i6JmoO2h2GZnb25a5oTdUXBIZ/oH1SJTIwYW2VtrDq7oNJmKeZY uhSAdMzSwckJkZnge3Z29Jt5CnsbgahkNEkB5hKLqNOBMx6SHmLJ5FJzu4T+rDA5TDWCmMnn/Wa MP97/q9uLznlsG2o/35AlFW+21Kksa7WCLPCT0GfM7l9XsCtmPes8hADtBMKlhU6+N3f4SKX0yL +lhJwaWrEYddjlx9acxI6nf5nmgIP0X/3gZuUhqxGCWfr3qy2pelVOUe0DghXDnyviWTuizQT8N xxn064xhEdRfiPEM36L/dkvmh5PmlRy1y0MU= X-Google-Smtp-Source: AGHT+IGVmGTZb50MVDuSzioZRE+RjuIhc164Y+aVsClKCW9Z3Yiby6JXeaNfKhHGp2ARsGmyfYIwxw== X-Received: by 2002:a05:6512:a94:b0:545:22ec:8b6c with SMTP id 2adb3069b0e04-54c2280a275mr116502e87.35.1743707789796; Thu, 03 Apr 2025 12:16:29 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:28 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:18 +0000 Subject: [PATCH 7/8] media: uvcvideo: Add support for V4L2_CID_CAMERA_ORIENTATION Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-7-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.14.2 Fetch the orientation from the fwnode and map it into a control. The uvc driver does not use the media controller, so we need to create a virtual entity, like we previously did with the external gpio. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/Makefile | 2 +- drivers/media/usb/uvc/uvc_ctrl.c | 21 +++++++++++ drivers/media/usb/uvc/uvc_driver.c | 14 ++++++-- drivers/media/usb/uvc/uvc_entity.c | 1 + drivers/media/usb/uvc/uvc_fwnode.c | 73 ++++++++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 15 ++++++++ include/linux/usb/uvc.h | 3 ++ 7 files changed, 125 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/uvc/Makefile b/drivers/media/usb/uvc/Makefile index 85514b6e538fbb8284e574ca14700f2d749e1a2e..2a5b76aab756c21011d966f3ce0410ff6b8e5b19 100644 --- a/drivers/media/usb/uvc/Makefile +++ b/drivers/media/usb/uvc/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o \ - uvc_gpio.o + uvc_gpio.o uvc_fwnode.o ifeq ($(CONFIG_MEDIA_CONTROLLER),y) uvcvideo-objs += uvc_entity.o endif diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index cbf19aa1d82374a08cf79b6a6787fa348b83523a..df84bf292dcab6b833fbd3c70eccbe9e567ee567 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -376,6 +376,13 @@ static const struct uvc_control_info uvc_ctrls[] = { | UVC_CTRL_FLAG_GET_DEF | UVC_CTRL_FLAG_AUTO_UPDATE, }, + { + .entity = UVC_GUID_FWNODE, + .selector = 0, + .index = 0, + .size = 1, + .flags = UVC_CTRL_FLAG_GET_CUR, + }, }; static const u32 uvc_control_classes[] = { @@ -975,6 +982,17 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .data_type = UVC_CTRL_DATA_TYPE_BITMASK, .name = "Region of Interest Auto Ctrls", }, + { + .id = V4L2_CID_CAMERA_ORIENTATION, + .entity = UVC_GUID_FWNODE, + .selector = 0, + .size = 8, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_MENU, + .data_type = UVC_CTRL_DATA_TYPE_ENUM, + .menu_mask = GENMASK(V4L2_CAMERA_ORIENTATION_EXTERNAL, + V4L2_CAMERA_ORIENTATION_FRONT), + }, }; /* ------------------------------------------------------------------------ @@ -3170,6 +3188,9 @@ static int uvc_ctrl_init_chain(struct uvc_video_chain *chain) } else if (UVC_ENTITY_TYPE(entity) == UVC_EXT_GPIO_UNIT) { bmControls = entity->gpio.bmControls; bControlSize = entity->gpio.bControlSize; + } else if (UVC_ENTITY_TYPE(entity) == UVC_FWNODE_UNIT) { + bmControls = entity->fwnode.bmControls; + bControlSize = entity->fwnode.bControlSize; } /* Remove bogus/blacklisted controls */ diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index b52e1ff401e24f69b867b5e975cda4260463e760..9a8e5d94b3eba09e1ee1be20bad5b016b6def915 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1752,11 +1752,15 @@ static int uvc_scan_device(struct uvc_device *dev) return -1; } - /* Add GPIO entity to the first chain. */ - if (dev->gpio_unit) { + /* Add virtual entities to the first chain. */ + if (dev->gpio_unit || dev->fwnode_unit) { chain = list_first_entry(&dev->chains, struct uvc_video_chain, list); - list_add_tail(&dev->gpio_unit->chain, &chain->entities); + if (dev->gpio_unit) + list_add_tail(&dev->gpio_unit->chain, &chain->entities); + if (dev->fwnode_unit) + list_add_tail(&dev->fwnode_unit->chain, + &chain->entities); } return 0; @@ -2132,6 +2136,10 @@ static int uvc_probe(struct usb_interface *intf, if (ret < 0) goto error; + ret = uvc_fwnode_parse(dev); + if (ret < 0) + goto error; + dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n", dev->uvc_version >> 8, dev->uvc_version & 0xff, udev->product ? udev->product : "", diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index cc68dd24eb42dce5b2846ca52a8dfa499c8aed96..01eeba2f049e9ebb25e091340a133656acbf28ca 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -106,6 +106,7 @@ static int uvc_mc_init_entity(struct uvc_video_chain *chain, case UVC_OTT_MEDIA_TRANSPORT_OUTPUT: case UVC_EXTERNAL_VENDOR_SPECIFIC: case UVC_EXT_GPIO_UNIT: + case UVC_FWNODE_UNIT: default: function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; break; diff --git a/drivers/media/usb/uvc/uvc_fwnode.c b/drivers/media/usb/uvc/uvc_fwnode.c new file mode 100644 index 0000000000000000000000000000000000000000..20f7b8847551acfd44cbf09bcbf653d89985561f --- /dev/null +++ b/drivers/media/usb/uvc/uvc_fwnode.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * uvc_fwnode.c -- USB Video Class driver + * + * Copyright 2025 Google LLC + */ + +#include +#include +#include +#include "uvcvideo.h" + +static int uvc_fwnode_get_cur(struct uvc_device *dev, struct uvc_entity *entity, + u8 cs, void *data, u16 size) +{ + if (size < 1) + return -EINVAL; + + switch (entity->fwnode.props.orientation) { + case V4L2_FWNODE_ORIENTATION_FRONT: + *(u8 *)data = V4L2_CAMERA_ORIENTATION_FRONT; + break; + case V4L2_FWNODE_ORIENTATION_BACK: + *(u8 *)data = V4L2_CAMERA_ORIENTATION_BACK; + break; + default: + *(u8 *)data = V4L2_CAMERA_ORIENTATION_EXTERNAL; + } + + return 0; +} + +static int uvc_fwnode_get_info(struct uvc_device *dev, + struct uvc_entity *entity, u8 cs, u8 *caps) +{ + *caps = UVC_CONTROL_CAP_GET; + return 0; +} + +int uvc_fwnode_parse(struct uvc_device *dev) +{ + static const u8 uvc_fwnode_guid[] = UVC_GUID_FWNODE; + struct v4l2_fwnode_device_properties props; + struct uvc_entity *unit; + int ret; + + ret = v4l2_fwnode_device_parse(&dev->udev->dev, &props); + if (ret) + return dev_err_probe(&dev->intf->dev, ret, + "Can't parse fwnode\n"); + + if (props.orientation == V4L2_FWNODE_PROPERTY_UNSET) + return 0; + + unit = uvc_alloc_entity(UVC_FWNODE_UNIT, UVC_FWNODE_UNIT_ID, 0, 1); + if (!unit) + return -ENOMEM; + + memcpy(unit->guid, uvc_fwnode_guid, sizeof(unit->guid)); + unit->fwnode.props = props; + unit->fwnode.bControlSize = 1; + unit->fwnode.bmControls = (u8 *)unit + sizeof(*unit); + unit->fwnode.bmControls[0] = 1; + unit->get_cur = uvc_fwnode_get_cur; + unit->get_info = uvc_fwnode_get_info; + strscpy(unit->name, "FWNODE", sizeof(unit->name)); + + list_add_tail(&unit->list, &dev->entities); + + dev->fwnode_unit = unit; + + return 0; +} diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index aef96b96499ce09ffa286c51793482afd9832097..c52ab99bf8d21ab37270d27ffc040fd115b3f5ba 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -19,6 +19,7 @@ #include #include #include +#include /* -------------------------------------------------------------------------- * UVC constants @@ -41,6 +42,9 @@ #define UVC_EXT_GPIO_UNIT 0x7ffe #define UVC_EXT_GPIO_UNIT_ID 0x100 +#define UVC_FWNODE_UNIT 0x7ffd +#define UVC_FWNODE_UNIT_ID 0x101 + /* ------------------------------------------------------------------------ * Driver specific constants. */ @@ -242,6 +246,12 @@ struct uvc_entity { int irq; bool initialized; } gpio; + + struct { + u8 bControlSize; + u8 *bmControls; + struct v4l2_fwnode_device_properties props; + } fwnode; }; u8 bNrInPins; @@ -617,6 +627,7 @@ struct uvc_device { } async_ctrl; struct uvc_entity *gpio_unit; + struct uvc_entity *fwnode_unit; }; enum uvc_handle_state { @@ -835,4 +846,8 @@ size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, int uvc_gpio_parse(struct uvc_device *dev); int uvc_gpio_init_irq(struct uvc_device *dev); void uvc_gpio_deinit(struct uvc_device *dev); + +/* fwnode */ +int uvc_fwnode_parse(struct uvc_device *dev); + #endif diff --git a/include/linux/usb/uvc.h b/include/linux/usb/uvc.h index bce95153e5a65613a710d7316fc17cf5462b5bce..d818839b0442988d94ab44935e1ce855b0adf4a1 100644 --- a/include/linux/usb/uvc.h +++ b/include/linux/usb/uvc.h @@ -29,6 +29,9 @@ #define UVC_GUID_EXT_GPIO_CONTROLLER \ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03} +#define UVC_GUID_FWNODE \ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04} #define UVC_GUID_FORMAT_MJPEG \ { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \ From patchwork Thu Apr 3 19:16:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 14037544 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35C791FFC74 for ; Thu, 3 Apr 2025 19:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707796; cv=none; b=Ksn66eB8JY41ssGixHMKp7iQtzQsWkxq3FJYyibB6SigOwwgdhottPYPcxfXDKKCRAc4NKn/HzmR9KGp/hpE7gUB+AMzGj784q1OeCizdwAcGM/GVhQl0X++lTz40DA9hWs6+edAj/Yb7+PVkFXFBamm3U8cdnudT16wX+QBSY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707796; c=relaxed/simple; bh=oIe/uWD/FQDzr1edh1CzgOk8NT19Av3Ax0Mu4QeYt0c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T+Iys5PbHmfR3cJbK0Lo9uS73IPZOxy81IOEEt4GV0gPmuq6HGWqda/v1kB2VKj7bcv1+p3N/idVrXQV5hqAk+mzI67GJbRmRgkTvqKEXnwobLaFt2ivHA4SsAQqqcGnLRqWb3caalcUYKrzcDH/dY65Mzo1Y1WGVCy2rM6z2R8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=KzcRrt6T; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KzcRrt6T" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-54c0fa6d455so1510578e87.1 for ; Thu, 03 Apr 2025 12:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1743707791; x=1744312591; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dorrjSo0orF//5lS6H31AEnatOUG0VehlrElNg21OPo=; b=KzcRrt6Tn4J4roTiElDsx6nBuxoqkw131eiq8KEj5G9YyO2hMWnVUXimaETLD+go38 8zmQjuyZ12i+Tow/1AKE/p/tPZLMpoTgwhacOV4EVTpyXKUGH/TLmrKD1uP866iZ9/xn nH+JVdVFOpZ849qslDl0pHcfyaASPW8VTQ7+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743707791; x=1744312591; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dorrjSo0orF//5lS6H31AEnatOUG0VehlrElNg21OPo=; b=jAwWkItPaOh0WMHNBXlmORn3nKafz0r4G+eVHwuAfiBZ6OSoKI58AIYTHZKN6fRB0D /I9Z1yTZMSVaK6ZT8e/WmWZWCj7MRhOPH/d1BplPMqUKp+SrDEMef5L12u9i0noicH9w m3NRVBvcwGQqTelABZbnoYhOQYi6ZPpS1fNSYQe0GvAPdmSHNb8ly3xmCOb2WbK616pB FTPDnNPoVEAavAzDC/WdvrLqRNhRKVpVdy2TXkHfegQDschVv5kkm2wqw3j9MwQ/TCIB Gm6NR6i9j9Lfko8t9QhzAd86TUTK/3Fzd4th6BqRPasRry1UnOtFdruGF6eKYlMwapHe z8ew== X-Gm-Message-State: AOJu0YxBIim1Sz8FNtvYlovzoBVCZcrCSzsI9ijp8QKIw7JjiSnt2Bk+ LcVQ8pM2Su63/D8cavBYBMluaHkzjV2aoyRiNNRT4x/GkJ/affBtN/cXZAqJ+Q== X-Gm-Gg: ASbGnctZ7IvdAYm14WkJJjev2Z6Jsq51I+Fq4CoLGq567wjPagw9tZwQQg4TDUB6GAF iMNVUx1J/BXWwiuHrPHgzQ3NFppDwABG62H6DUuqBc/FUklbwmj98OF5fzzS5WUJuCC1l7O6Yyh YRvYs47X+GGzXTlusbJ7PuADONpiSoQHAmUwV04+NXwI9ZbpJSJpvLbYRIVCnl7xlxVkq00fC5M 2Zkbur3WdhW6kPZ2Ob7FpAySmF7djOQYZbpE6W0ayIMFar65ujbHXUABMZsKFQux0675RRybIbq rFbyGjQ9JLlqpnseoI/6CgKQdeV+ZP+S2FmcBb04B7LV5XiWgex4VQs69bTPhUHRkkWl2fIKWVx FWZ2MOLYtLYp1l24eAyxfNRS+ X-Google-Smtp-Source: AGHT+IGVY3EFg5KnHKmHO2hTamBaTkRj2xwhuyk+NEFXhuefJ9O4PY6IbapG0I2fVQxVv80RmqRT3w== X-Received: by 2002:a05:6512:a91:b0:545:cd5:84d9 with SMTP id 2adb3069b0e04-54c2276e9b2mr115584e87.12.1743707790862; Thu, 03 Apr 2025 12:16:30 -0700 (PDT) Received: from ribalda.c.googlers.com (216.148.88.34.bc.googleusercontent.com. [34.88.148.216]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d6b1sm230142e87.194.2025.04.03.12.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 12:16:29 -0700 (PDT) From: Ricardo Ribalda Date: Thu, 03 Apr 2025 19:16:19 +0000 Subject: [PATCH 8/8] media: uvcvideo: Do not create MC entities for virtual entities Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250403-uvc-orientation-v1-8-1a0cc595a62d@chromium.org> References: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> In-Reply-To: <20250403-uvc-orientation-v1-0-1a0cc595a62d@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Bartosz Golaszewski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.14.2 Neither the GPIO nor the FWNODE entities form part of the device pipeline. We just create them to hold emulated uvc controls. When the device initializes, a warning is thrown by the v4l2 core: uvcvideo 1-1:1.0: Entity type for entity FWNODE was not initialized! There are no entity function that matches what we are doing here, and it does not make to much sense to create a function for entities that do not really exist. Do not create MC entities for them and pretend nothing happened here. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_entity.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 01eeba2f049e9ebb25e091340a133656acbf28ca..4a0a083b4f58f041023710207a73e8fede8526e0 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -72,6 +72,16 @@ static int uvc_mc_init_entity(struct uvc_video_chain *chain, { int ret; + /* + * Do not initialize virtual entities, they do not really exist + * and are not connected to any other entities. + */ + switch (UVC_ENTITY_TYPE(entity)) { + case UVC_EXT_GPIO_UNIT: + case UVC_FWNODE_UNIT: + return 0; + } + if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING) { u32 function;