Re: [PATCH 1/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper function

Sakari Ailus
2023-05-19T07:32:05Z

Hi Hans,

On Thu, May 18, 2023 at 05:32:06PM +0200, Hans de Goede wrote:
> On x86/ACPI platforms the GPIO resources do not provide information
> about which GPIO resource maps to which connection-id. So e.g.
> gpiod_get(devg, "reset") does not work.
>
> On devices with an Intel IPU3 or newer ISP there is a special ACPI
> INT3472 device describing the GPIOs and instantiating of the i2c_client
> for a sensor is deferred until the INT3472 driver has been bound based
> on the sensor ACPI device having a _DEP on the INT3472 ACPI device.
>
> This allows the INT3472 driver to add the necessary GPIO lookups
> without needing any special ACPI handling in the sensor driver.
>
> Unfortunately this does not work on devices with an atomisp2 ISP,
> there the _DSM describing the GPIOs is part of the sensor ACPI device
> itself, rather then being part of a separate ACPI device.
>
> IOW there is no separate firmware-node to which we can bind to register
> the GPIO lookups (and also no way to defer creating the sensor i2c_client).
>
> This unfortunately means that all sensor drivers which may be used on
> BYT or CHT hw need some code to deal with ACPI integration.
>
> This patch adds a new v4l2_acpi_parse_sensor_gpios() helper function
> for this, which does all the necessary work. This minimizes the
> (unavoidable) change to sensor drivers for ACPI integration to just
> adding a single line calling this void function to probe().

I'd rather avoid making changes to sensor drivers due to this hack. At the
very least it must be labelled so: this has no more to do with ACPI
standard than that this information happens to be located in an ACPI table.

Although if the number of those drivers would be small, this could be just
undesirable but still somehow acceptable. And I wouldn't expect new sensors
to be paired with the IPU2 anymore. How many drivers there would be
roughly? I think I've seen ten-ish sensor drivers with the atomisp driver.

Isn't it possible to create a device for this purpose and use software
nodes for the GPIOs? I guess that would be a hack as well and you'd somehow
have to initialise this via other route than driver probe.

--
Kind regards,

Sakari Ailus