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: 878154 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 DFD1520011B for ; Thu, 3 Apr 2025 19:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707791; cv=none; b=qDuE4zO4mTrqH4UlP+R8n4Ce1Hk4/CX+GQT53v1bEwIVUxrIP2mss1fQrHTQQXm8/DZr8TnKPB4B5PNn1ZVnkKGtNWjvRjR6paKZD0rZCB3NCF5cV9xXTYvCngKExyzWL2PxTnObcoyQAvRBj9nD5KC0+m5d5PNxUZnFQC8AAQc= 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.42 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-f42.google.com with SMTP id 2adb3069b0e04-54ac9b3ddf6so1168968e87.1 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=uhPJoRFw25u7C5rzrP8quXRANCM+VXQmM37k4idgOSZBYUX9XNhzbBi8FUKCWwWlLJ Sry49djAQJ+Dq5Q989dw51dT+97ejuzdw7olUVNoI3Dq0YAtrHkKWxkL/ps9bvkFr+yq V18nARJkHDlNBpuRgwu2BWzfXQb+g0yUkjuLd+urOZE6fETRy+A36kkZTjoTEATW414w 7XrcJIM1kC4wbhUJdQlH2YC0bIT77nGLhn+Cblge1XhVEXlKO4H6qVl4m98HIVQ7wbfL 4y8cnnsYbvyouVGqV7xH0TuI7NkJsSLggnb4tsqDp14TtAbqI3Q+uf5soUx4bKBmZouM V/bQ== X-Forwarded-Encrypted: i=1; AJvYcCUeVfroUPZlTgnRhtSuN0ZyDJIJV72z4C2idQnzY/+zllUgqAzxjqE4UNP1O0/Kp7NOuyOITOKaUiI=@vger.kernel.org X-Gm-Message-State: AOJu0YyncG0JOVlsk06LuOLJFwQdBp4GdJdC+3d4BlMMeg8Sq/DAZEg3 nCZScC0HCVeWQKe7OaJdmSZXgMY459/EjjiqO2K1wnMoEXtFjalZX4h8sr7zhg== X-Gm-Gg: ASbGnctGDIe55GAh04BuItheQ0JdN0NgaPHfsoAeCfgCOnn/9UH3eELznSzamEM/YxK koqEvRb5R4njJfHbqcubf1OkFPu+UirTJd3m0WEz3Bkv5UIvcSqszXO7NhXClR5xH3VbVFQ5HpB xXw1ffumJYcYw4bd5NeNZDs4RG8oNH8/bJ+84sGeHsIC8aMQZ6vBTGAdv+/v7p7OA/E7UYhUNwX qycOhzPhov9VTnRpnVdayvUpREdBEr/T4tH5P9dpWMc75qA7z9q8hxW5eQnjkRHSpnnQtDtGnCy 0xm213i+uMcgK5qDCGl4Pa6TFcHIvWWjahIFFub/WV9dd7ORTd6/ik01eL4Cf8IRiXW9gAlq8kO /kWZdCk06n0loXa7DZN8FVVPG 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-usb@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: 878153 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 25066200B9F for ; Thu, 3 Apr 2025 19:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707791; cv=none; b=i5Qb9ejL5zwI5+S5hgb5YlprIRmcK/4Jh6/AMjnU8Q1rQIa/caQZhLasJvwvgBcdy7I7Vu/0EUkxvGmLN8CS8uMutx9Pi2rzn4+cTuFHpqgWPBneP2wKeMPc22RjV0NdjkkvHHPl3RAhl6XGxhwlJ7IBquEYvATf5DIEahnXkXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707791; c=relaxed/simple; bh=FkbqQupMpzx0wszT8hmcVx+KkNGgx/ddD0tHr201vd4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MQJ0H628V98Owiavd8w4Y2ktHYCUkJYvsBoYRGlSrd3pumk+PreQn2MVOdbeHJ43owjo6Lxgh+Le5sHBq80NHLK2b5f0UjMDb5+JTR2ZiAzaqSLZ7QPgDK8YY54SRtmfZ6SPeccFUVb4EO3TMG54hyx7DCadA73f3b/tZgnQWe4= 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.50 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-f50.google.com with SMTP id 2adb3069b0e04-549967c72bcso1445912e87.3 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=gnGT/blggpAWmpLJk5h8mAyjX5RppHjAdyJfsQuAnKJMY9Wyx+U2mBYyvqrgt1zSgR vC3jDvyB0WyZnGJDwsR2KLQNOM2G6sRun7+7pPrz6YiSHm7e8l9xoMRsG7BVvCZHqpZr s1HjIbginUoqzFqUqOlPWmExECY09oq6ndptTctZ8ORkcuvhPG7rS+VvIDWJ/b2t2uo1 Ol8pgC9y0QMxA/BShL4hZHV2L9aSWrQrcbvIh7ckRpbBeTHr9H6RUaSdVbyXSKHlGuZV sExj5HwyqHG2UigylbwtW+QlTkOmTGuvI6w08HLTyyVqgAXqJkNXzWQ7lo/MtPeoXwtz 1/ZQ== X-Forwarded-Encrypted: i=1; AJvYcCWJTuckAZQvebOrhcLbQZE6XaqQfmXPNNhSB7MWO+rZSAlzmJ2NfnBa8je8AlT9AwtHeRype3Oom3A=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0Fs52jOWxirjrsrG7fjADQY8xEIZ8Vv4WllLVCET6Sv3OHjdE E3ZDegG+HaZdf9CscJfbYvsuN/IxSeOwCIJSZgpkqt4fiLNkMcj371VrIT2VOw== X-Gm-Gg: ASbGnct4OQ8CA2SMZu6hKnR8muHFjVeaaoRYH4nWKeEJyIPrIft+LYIWAYg14ndY/6K LyBJrKsElANOWHdwpF7QuCOq3oci3z0wFh6gVyNf8v7+xD8NSYOJNvpQyG7P9Ske1E//j/+w54h 8ai8IajeNcIjVDFzH4Nh4sysvQOhNP04ehbuY6oZyFEciH+53a/hn0IidOybUMKwqBc9FrMMCs0 b3b6+sIfqEobHjStinpLFjaWoxya+xqr4GFAJP6HTZwHvEdfUh3KVyqSZ7TrMR1DmTnA0LOP5U4 sUQHV+BP6wPIu49CV9zEEMEAWbt7Z98UEGa9TrNlYcrq2uYGQQMRinBKVFI32Yv9aEHHtiDvFKf JN/LyLnpW80Uqd5x5Qmg63w32 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-usb@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: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: 878152 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 F158720125B for ; Thu, 3 Apr 2025 19:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707794; cv=none; b=YeNV/efzaYqVclrzNHG/CsaznuOlHYjAoPmrOvDWOYEPY21ogLwQYgfuBl1uXLe2IcbeIXeUMIFShlNfCHdZEtw6LHdrdoCo+o6cJyPV7+JjSwJSW9WC6PuaS/Hkotm/2LMvIqK7KGBNtjcSyUlwE7oaS7ikdk/CFQMqfgr1A9g= 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.50 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-f50.google.com with SMTP id 2adb3069b0e04-54b1095625dso1445537e87.0 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=C58rx8+NS529EbG5fdYe+ndbkOqW+8h5XamwC291w41/Ij85KhDkYELpZy05iULX2m S8afbY1zsHoYMfud/fJQoHJskVUbe/aVdFiwyftS9xF00TReFTwWRh333sGmIrc6RzS1 ddCsjrUEnIevof4q//yYBQDshirZCMdljicuWLbrhrk/mbqMuQ0qZeltcRgaJQ3HoqRl fmgomXGnzA10vrtDm13/chRDLZqxcZHwElHHrIVw22saPVa9Eq1vPpuuXmeBDy5kXclF clFKO4stKGKXvGlKR9AtO9Nk6TfNUlLJRT3Lgb41F+EteH3RegjrAxHm8X8E0ch+9Nu/ OS2w== X-Forwarded-Encrypted: i=1; AJvYcCULDwMNmo9FOVoaxJtJB5LSqK/lKz+4iMPcW0ByTfM3vKzAnSjhZCbQ8r3iLrd/uUrCkpQQpOsrX6w=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1qmCAZN1VjjvQzaAn30hCX9oEF3EOPPQOkm2j0mbKgqNq7OjO Z0JPcthAW3d8adzZV98DfKhMwR643mRW59/a7A80jREI+yfpfVpgilXh7tRxMw== X-Gm-Gg: ASbGnct/81v9iiqkt3aLP93hNHofA6vB+S18xyJyc5bGMdzZUhY96wfhwefx1ENArwu kt0d32BFY4bPzJpW6htrPMXuZXC9E1dPiX2uGNBynYRzixm2mO37Y2ev1FqqP4Edw4w/Y2RXQsC U66UKJEsnZ98V74/8WGRFJ9ICB3z3xz2HI5JlsPnnOKfvNsQwhU9BapIIWjKg8R4+lDSOg6+PEX o55o260Ewn2BbDczpMukyYLWmS1WZ28s2jCoMzhdRNnyWo4DwVaYUOZ//Ww1J3QMWAUS35VVDyg QJEWS6JByVf+bkkfumcZetwLUURWJrF/t+TN4SozHQeDp9ZHQJyO2M2E8/rMCzQSgGIcjA7gkUf DlvCDpcZnLzhhw8kzkgWTrFMvnp7mWVjQ4M8= 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-usb@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: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: 878151 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 0FBDB204595 for ; Thu, 3 Apr 2025 19:16:32 +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=uh6A0ByGTQgWfw8fKxsVY5w0p6rvsKOiZnCQZLojZ1X82qD2Ez/KSEEQ+O8x6QLcvz5Rtbrn2CTTUW+OTRMFNXtVD7P84b0fMMNNpMflTLWohIJ3ThxehorcECojHLz3gRauTguOQT9RMqyxJxQAad7BEh2b5YF6I793UixKM1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743707795; c=relaxed/simple; bh=oIe/uWD/FQDzr1edh1CzgOk8NT19Av3Ax0Mu4QeYt0c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WhfXIpPx3Ve6EHRwyrAAZ9KHeUQJoj9FCzGpbMsssYFLzzJ5CAlWNXo/LETILnwSywXWaFKK29p3U+hDbwgufpMOZ6NzrT1Tq2SGABuPF+wcrFr9VDe5o/smPlD1fWasW5WaqiqurOvMR+FMW62EWZmGFFgGzmc5rZjDzaSQmeU= 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.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="KzcRrt6T" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5499659e669so1342449e87.3 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=lI0NVjCaNJgjIJXOm7j69Zqp+kvfYHPUZHIuRtv/aVwmOESZkcmfVDLW0+t7Z4H7B0 ksnLekknRhECN/XFiAXn2f9LRcwCjOqoba4+bWzQxY0t5rBBU/35z1WVmdaKoxnY3OBi CpUNBwp0oUEdvRGLfgHIeKK6Po6lqFvAsXB3HtaChew+tSgzDKwJEl4toG3mfaqxHsYx 8hvGPrCFNI+5DUtz9WH1lNEc5pIa05PPSCJJ0tm2OBSNOjcQdKzB+ZUhU9TbJIQSZaBV opcFzvi1T9GWW3WEZDvT8+j/JbJy200DM1UfZHs4aQiEQNSDj0/RLHciIbffB5ZrHb0W W7tQ== X-Forwarded-Encrypted: i=1; AJvYcCV33oCpEJH7NxNCOclNQAezOWlpOyUPQvoJIpK0xvC1tu21GdJzqQua8oQHZHYsjm49XNofb4apW3k=@vger.kernel.org X-Gm-Message-State: AOJu0YyAQSRBDUYyXhRgqGKeB2D84Y29lbigspunD3WTd/0jT2KBVcg3 GUemDX99chDEHokFzPpCYnWZHk2tj7e03r3z9an0kIYgjn6ZqqE6ENvamH5V2Q== X-Gm-Gg: ASbGncvkXvr3Z3EOsFmrk5gQpkgh8OCgO7sFJiZNN3m6ako8qyjBKOVeI1rvlsCY/J9 yN3xSGqJxgjFgQLFRtgIObgRtJeJfK7h/oMb/H6km0VszIFQrIIjI7r/qmja91clwGhjACAiW9J QbCTRCE28p6k7u5ptXAuMici8QZCtJnv0iYCYU1dbHKijH3oNikAPYtfL//pq5lAbi1hGKJzlju dAgH23jj2+AmJ9xsVwWfj7KZTQhT+grsxovZLkqz/fgnHxc7fJH2qvDhoTiREq4Zp0P5LAM4Cs7 7k4RDQFJhtTnSHIc77GIqCnl8bAPmTBzvPMGDty9i8f/PwXM3lvzNXD6+tufHFTMDKQg5Jwf+MZ EcCrtDpuJIn6NrfoXOXgQ8jlq 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-usb@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;