From: Ricardo Ribalda <ribalda@chromium.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans de Goede <hdegoede@redhat.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
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>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH v2 02/12] media: v4l: fwnode: Support ACPI's _PLD for v4l2_fwnode_device_parse
Date: Tue, 1 Jul 2025 11:04:25 +0200 [thread overview]
Message-ID: <CANiDSCuRLVtT54ZxxAh6031OLg422VApsocvOTCOnavQgifTaA@mail.gmail.com> (raw)
In-Reply-To: <1ac49bd3-1b65-4611-8c90-92fb2c2ffd4a@linux.intel.com>
Hi Sakari
Thanks for your review!
On Mon, 30 Jun 2025 at 09:06, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
>
> Hi Ricardo,
>
> Thanks for the update.
>
> On 6/5/25 20:52, Ricardo Ribalda wrote:
> > Currently v4l2_fwnode_device_parse() obtains the orientation and
> > rotation via fwnode properties.
> >
> > Extend the function to support as well ACPI devices with _PLD info.
> >
> > We give a higher priority to fwnode, because it might contain quirks
> > injected via swnodes.
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> > drivers/media/v4l2-core/v4l2-fwnode.c | 85 ++++++++++++++++++++++++++++++++---
> > 1 file changed, 79 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> > index cb153ce42c45d69600a3ec4e59a5584d7e791a2a..379290ab3cfde74c8f663d61837a9a95011b5ae0 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,65 @@ 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 (!is_acpi_device_node(dev_fwnode(dev)))
> > + return 0;
> > +
> > + if (!acpi_get_physical_device_location(ACPI_HANDLE(dev), &pld)) {
> > + dev_dbg(dev, "acpi _PLD call failed\n");
>
> I'd do:
>
> acpi_handle_debug(ACPI_HANDLE(dev), "cannot obtain _PLD\n");
ack
>
> > + return 0;
> > + }
> > +
> > + if (props->orientation != V4L2_FWNODE_PROPERTY_UNSET) {
> > + 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);
>
> Similarly:
>
> acpi_handle_debug(ACPI_HANDLE(dev), "invalid panel %u in _PLD\n",
> pld->panel);
>
> > + ret = -EINVAL;
>
> Should this be an error or should we simply ignore it here (and maybe
> use acpi_handle_warn())?
v4l2_fwnode_device_parse_of() returns -EINVAL for a similar situation,
so I think it is better to be consistent and return -EINVAL here.
But I agree that acpi_handle_warn() better suits here than _dbg.
>
> > + goto done;
> > + }
> > + }
> > +
> > + if (props->rotation != V4L2_FWNODE_PROPERTY_UNSET) {
> > + switch (pld->rotation) {
> > + case 0 ... 7:
> > + props->rotation = pld->rotation * 45;
> > + break;
> > + default:
> > + dev_dbg(dev, "Unknown _PLD rotation val %d\n", pld->panel);
>
> acpi_handle_debug(ACPI_HANDLE(dev), "invalid rotation %u in _PLD\n",
> pld->rotation);
>
> > + ret = -EINVAL;
> > + goto done;
> > + }
> > + }
> > +
> > +done:
> > + ACPI_FREE(pld);
> > + return ret;
> > +}
> > +
> > +static int v4l2_fwnode_device_parse_dt(struct device *dev,
>
> I'd call this v4l2_fwnode_device_parse_of() as we're parsing OF nodes
> and properties here.
ack
>
> > + 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 +883,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 +896,30 @@ int v4l2_fwnode_device_parse(struct device *dev,
> >
> > return 0;
> > }
> > +
> > +int v4l2_fwnode_device_parse(struct device *dev,
> > + struct v4l2_fwnode_device_properties *props)
> > +{
> > + int ret;
> > +
> > + memset(props, 0, sizeof(*props));
> > +
> > + props->orientation = V4L2_FWNODE_PROPERTY_UNSET;
> > + props->rotation = V4L2_FWNODE_PROPERTY_UNSET;
> > +
> > + /* Start by looking into swnodes and dt. */
> > + ret = v4l2_fwnode_device_parse_dt(dev, props);
> > + if (ret)
> > + return ret;
> > +
> > + /* Orientation and rotation found!, we are ready. */
> > + if (props->orientation != V4L2_FWNODE_PROPERTY_UNSET &&
> > + props->rotation != V4L2_FWNODE_PROPERTY_UNSET)
> > + return 0;
>
> I think you can remove this check without affecting the functionality.
I want to avoid calling an acpi method unless it is strictly
necessary. The check is not that ugly... if it is ok with you i'd
rather keep it.
>
> > +
> > + /* Let's check the acpi table. */
> > + return v4l2_fwnode_device_parse_acpi(dev, props);
> > +}
> > EXPORT_SYMBOL_GPL(v4l2_fwnode_device_parse);
> >
> > /*
> >
>
> --
> Regards,
>
> Sakari Ailus
Thanks!
--
Ricardo Ribalda
next prev parent reply other threads:[~2025-07-01 9:04 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 17:52 [PATCH v2 00/12] media: uvcvideo: Add support for orientation and rotation Ricardo Ribalda
2025-06-05 17:52 ` [PATCH v2 01/12] media: uvcvideo: Always set default_value Ricardo Ribalda
2025-06-29 17:39 ` Laurent Pinchart
2025-07-14 13:00 ` Hans de Goede
2025-06-05 17:52 ` [PATCH v2 02/12] media: v4l: fwnode: Support ACPI's _PLD for v4l2_fwnode_device_parse Ricardo Ribalda
2025-06-29 9:21 ` Sakari Ailus
2025-07-01 9:04 ` Ricardo Ribalda [this message]
2025-07-07 21:01 ` Sakari Ailus
2025-07-14 13:03 ` Hans de Goede
2025-07-14 14:14 ` Ricardo Ribalda
2025-06-05 17:52 ` [PATCH v2 03/12] ACPI: mipi-disco-img: Do not duplicate rotation info into swnodes Ricardo Ribalda
2025-06-29 9:24 ` Sakari Ailus
2025-07-07 21:05 ` Sakari Ailus
2025-07-14 13:08 ` Hans de Goede
2025-06-05 17:52 ` [PATCH v2 04/12] media: ipu-bridge: Use v4l2_fwnode_device_parse helper Ricardo Ribalda
2025-06-06 4:27 ` kernel test robot
2025-07-14 13:11 ` Hans de Goede
2025-06-05 17:52 ` [PATCH v2 05/12] media: ipu-bridge: Use v4l2_fwnode for unknown rotations Ricardo Ribalda
2025-07-07 21:44 ` Sakari Ailus
2025-07-08 9:16 ` Ricardo Ribalda
2025-07-08 9:22 ` Sakari Ailus
2025-07-08 12:09 ` Ricardo Ribalda
2025-07-08 12:20 ` Sakari Ailus
2025-07-08 14:58 ` Ricardo Ribalda
2025-07-08 23:46 ` Sakari Ailus
2025-07-14 13:11 ` Hans de Goede
2025-06-05 17:52 ` [PATCH v2 06/12] dt-bindings: usb: usb-device: Add orientation and rotation Ricardo Ribalda
2025-06-25 18:56 ` Rob Herring
2025-06-05 17:53 ` [PATCH v2 07/12] media: uvcvideo: Make uvc_alloc_entity non static Ricardo Ribalda
2025-06-29 17:43 ` Laurent Pinchart
2025-07-14 13:31 ` Hans de Goede
2025-06-05 17:53 ` [PATCH v2 08/12] media: uvcvideo: Add support for V4L2_CID_CAMERA_ORIENTATION Ricardo Ribalda
2025-06-29 17:50 ` Laurent Pinchart
2025-07-01 9:22 ` Ricardo Ribalda
2025-07-14 14:15 ` Hans de Goede
2025-07-14 14:23 ` Laurent Pinchart
2025-07-14 14:36 ` Hans de Goede
2025-06-05 17:53 ` [PATCH v2 09/12] media: uvcvideo: Add uvc_ctrl_query_entity helper Ricardo Ribalda
2025-06-29 18:01 ` Laurent Pinchart
2025-07-14 14:24 ` Hans de Goede
2025-07-14 15:51 ` Ricardo Ribalda
2025-06-05 17:53 ` [PATCH v2 10/12] media: uvcvideo: Add get_* functions to uvc_entity Ricardo Ribalda
2025-06-29 18:12 ` Laurent Pinchart
2025-07-01 11:13 ` Ricardo Ribalda
2025-07-14 14:28 ` Hans de Goede
2025-07-14 14:29 ` Laurent Pinchart
2025-07-14 15:46 ` Ricardo Ribalda
2025-07-15 19:35 ` Laurent Pinchart
2025-07-16 10:32 ` Ricardo Ribalda
2025-08-07 7:35 ` Ricardo Ribalda
2025-06-05 17:53 ` [PATCH v2 11/12] media: uvcvideo: Add support for V4L2_CID_CAMERA_ROTATION Ricardo Ribalda
2025-06-29 18:14 ` Laurent Pinchart
2025-07-01 11:26 ` Ricardo Ribalda
2025-07-14 14:31 ` Laurent Pinchart
2025-07-14 15:59 ` Ricardo Ribalda
2025-06-05 17:53 ` [PATCH v2 12/12] media: uvcvideo: Do not create MC entities for virtual entities Ricardo Ribalda
2025-06-29 18:05 ` Laurent Pinchart
2025-07-01 11:20 ` Ricardo Ribalda
2025-07-08 6:28 ` Ricardo Ribalda
2025-07-14 14:36 ` Laurent Pinchart
2025-07-14 16:04 ` Ricardo Ribalda
2025-07-14 16:30 ` Laurent Pinchart
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=CANiDSCuRLVtT54ZxxAh6031OLg422VApsocvOTCOnavQgifTaA@mail.gmail.com \
--to=ribalda@chromium.org \
--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=lenb@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.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=rafael@kernel.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;
as well as URLs for NNTP newsgroup(s).