From: Sakari Ailus <sakari.ailus@iki.fi>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH 3/8] media: v4l: fwnode: Support acpi devices for v4l2_fwnode_device_parse
Date: Tue, 22 Apr 2025 09:41:39 +0000 [thread overview]
Message-ID: <aAdkU65ruBfyRjss@valkosipuli.retiisi.eu> (raw)
In-Reply-To: <dd471b51-333b-4537-ac58-29ad2a10f1e2@redhat.com>
Hi Hans, Ricardo,
On Tue, Apr 22, 2025 at 10:44:41AM +0200, Hans de Goede wrote:
> Hi Ricardo,
>
> On 22-Apr-25 2:23 AM, Ricardo Ribalda wrote:
> > Hi Sakari
> >
> > On Sun, 13 Apr 2025 at 17:50, Sakari Ailus <sakari.ailus@iki.fi> wrote:
> >>
> >> Hi Ricardo,
> >>
> >> Thanks for the patch.
> >>
> >> On Thu, Apr 03, 2025 at 07:16:14PM +0000, Ricardo Ribalda wrote:
> >>> 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 <ribalda@chromium.org>
> >>> ---
> >>> 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 <g.liakhovetski@gmx.de>
> >>> */
> >>> #include <linux/acpi.h>
> >>> +#include <acpi/acpi_bus.h>
> >>> #include <linux/kernel.h>
> >>> #include <linux/mm.h>
> >>> #include <linux/module.h>
> >>> @@ -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;
> >>> + }
> >>
> >> You could have software nodes in an ACPI system as well as DT-aligned
> >> properties. They're not the primary means to convey this information still.
> >>
> >> How about returning e.g. -ENODATA here if _PLD doesn't exist for the device
> >> and then proceeding to parse properties as in DT?
> >
> > Do you mean that there can be devices with ACPI handles that can also
> > have DT properties?
>
> Yes it is possible to embed DT properties in ACPI, but I don't
> think that is really applicable here.
This is determined by
Documentation/firmware-guide/acpi/DSD-properties-rules.rst . So rotation
and orientation shouldn't come from _DSD properties on ACPI systems.
>
> But we also have secondary software-fwnodes which are used
> extensively on x86 to set device-properties on devices by
> platform code to deal with ACPI tables sometimes having
> incomplete information.
>
> For example atm _PLD is already being parsed in:
>
> drivers/media/pci/intel/ipu-bridge.c and that is then used to add
> a standard "orientation" device-property on the sensor device.
>
> This is actually something which I guess we can drop once your
> patches are in, since those should then do the same in a more
> generic manner.
DisCo for Imaging support currently also digs this information from _PDL
(see init_crs_csi2_swnodes() in drivers/acpi/mipi-disco-img.c), but this
is only done if a _CRS CSI-2 descriptor is present. It could also be done
for devices with the IPU Windows specific ACPI objects and it would be a
natural location for handing quirks -- there are some
unrelated Dell DSDT quirks already.
>
> > What shall we do if _PLD contradicts the DT property? What takes precedence?
>
> As for priorities, at east for rotation it seems that we are going
> to need some quirks, I already have a few Dell laptops where it seems
> that the sensor is upside down and parsing the rotation field in
> the IPU6 specific SSDB ACPI package does not yield a 180° rotation,
> so we are going to need some quirks.
>
> I expect these quirks to live in the bridge code, while your helper
> will be called from sensor drivers, so in order to allow quirks to
> override things, I think that first the "orientation" device-property
> should be checked (which the ACPI glue code we have can set before
> the sensor driver binds) and only then should _PLD be checked.
>
> IOW _PLD should be seen as the fallback, because ACPI tables are
> often a copy and paste job so it can very well contain wrong info
> copy-pasted from some example ACPI code or from another hw model.
Unfortunately that does happen. :-(
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2025-04-22 9:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 19:16 [PATCH 0/8] media: uvcvideo: Add support for V4L2_CID_CAMERA_SENSOR_ORIENTATION Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 1/8] media: uvcvideo: Fix deferred probing error Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 2/8] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 3/8] media: v4l: fwnode: Support acpi devices for v4l2_fwnode_device_parse Ricardo Ribalda
2025-04-13 9:50 ` Sakari Ailus
2025-04-22 0:23 ` Ricardo Ribalda
2025-04-22 8:44 ` Hans de Goede
2025-04-22 9:41 ` Sakari Ailus [this message]
2025-05-05 20:34 ` Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 4/8] media: ipu-bridge: Use v4l2_fwnode_device_parse helper Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 5/8] dt-bindings: usb: usb-device: Add orientation Ricardo Ribalda
2025-04-04 19:36 ` Rob Herring
2025-04-04 20:31 ` Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 6/8] media: uvcvideo: Factor out gpio functions to its own file Ricardo Ribalda
2025-04-22 21:28 ` Laurent Pinchart
2025-04-22 22:20 ` Ricardo Ribalda
2025-04-22 22:25 ` Laurent Pinchart
2025-04-22 22:35 ` Ricardo Ribalda
2025-04-22 22:48 ` Laurent Pinchart
2025-04-28 14:07 ` Hans de Goede
2025-04-28 15:32 ` Ricardo Ribalda
2025-04-03 19:16 ` [PATCH 7/8] media: uvcvideo: Add support for V4L2_CID_CAMERA_ORIENTATION Ricardo Ribalda
2025-04-22 21:32 ` Laurent Pinchart
2025-04-22 21:40 ` Laurent Pinchart
2025-04-03 19:16 ` [PATCH 8/8] media: uvcvideo: Do not create MC entities for virtual entities Ricardo Ribalda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aAdkU65ruBfyRjss@valkosipuli.retiisi.eu \
--to=sakari.ailus@iki.fi \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox