From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>, Kate Hsuan <hpa@redhat.com>,
Tsuchiya Yuto <kitakar@gmail.com>,
Yury Luneff <yury.lunev@gmail.com>,
Nable <nable.maininbox@googlemail.com>,
andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH 1/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper function
Date: Thu, 18 May 2023 18:57:09 +0200 [thread overview]
Message-ID: <9375a528-8e39-304e-9b60-99ea43e16ec0@redhat.com> (raw)
In-Reply-To: <CAHp75Vf6t302XpVKKgm1uyHQ5LsuqSEE+B3AGc1-ODoev77ENA@mail.gmail.com>
Hi,
On 5/18/23 18:36, Andy Shevchenko wrote:
> On Thu, May 18, 2023 at 6:32 PM Hans de Goede <hdegoede@redhat.com> 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.
>
> than
>
> (not the first time I see the same typo in your commit messages :-)
>
>
>> 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().
>>
>> There also is a no-op stub provided for non ACPI platforms so that
>> no #ifdef-s are necessary in the driver.
>>
>> Note v4l2_acpi_parse_sensor_gpios() is basically a copy of
>> the atomisp2 v4l2_get_acpi_sensor_info() helper from:
>> drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
>> minus logging the sensor module-name using a second _DSM.
>
>> v4l2_get_acpi_sensor_info() was already reviewed by Andy,
>> see the Link tag below.
>>
>> (this code duplication is removed in the next patch in this series)
>
> I believe the above is not needed to be in the commit message, but
> rather in the comments below (after the '---' cutter line).
>
> ...
<snip>
>> + * Note this code uses the same DSM GUID as the INT3472 discrete.c code
>> + * and there is some overlap, but there are enough differences that it is
>> + * difficult to share the code.
>
> Can you add the name of the variable in that file, so likely the
> source code indexing tool might add a link?
You mean change the comment something like this:
* Note this code uses the same DSM GUID as the int3472_gpio_guid in
* the INT3472 discrete.c code and there is some overlap, but there are
* enough differences that it is difficult to share the code.
I guess, where int3472_gpio_guid comes from:
drivers/platform/x86/intel/int3472/discrete.c:
static const guid_t int3472_gpio_guid =
GUID_INIT(0x79234640, 0x9e10, 0x4fea,
0xa5, 0xc1, 0xb5, 0xaa, 0x8b, 0x19, 0x75, 0x6f);
?
>> + devm_acpi_dev_add_driver_gpios(dev, data.map->mapping);
>
> Won't we print a warning here as well in case of error?
The only way this can fail is with -ENOMEM (we already know dev
has an ACPI companion) and generally speaking the rule is to
not log errors for ENOMEM since when we hit that the kernel
already complains loudly before returning from the alloc call.
> ...
>
>> +#ifdef CONFIG_ACPI
>
>> +struct device;
>
> This should be outside of previous ifdeffery as it's used in a stub.
>
>> +/**
>> + * v4l2_acpi_parse_sensor_gpios - Parse ACPI info describing sensor GPIOs.
>> + *
>
> Dunno the style of v4l2, but this line is redundant.
>
>> + * @dev: Device to parse the ACPI info for
>> + *
>> + * On x86/ACPI platforms the GPIO resources do not provide information
>> + * about which resource maps to which connection-id.
>> + *
>> + * Sensor drivers can call this function to use platform specific methods
>> + * (e.g. the Intel 79234640-9e10-4fea-a5c1-b5aa8b19756f _DSM) to get
>> + * information about the pins and add GPIO mappings to make standard gpiod_get()
>> + * calls work.
>> + *
>> + * The registered mappings use devm managed memory and are automatically free-ed
>> + * on remove() and on probe() failure.
>> + */
>
> Usually the kernel doc is attached to the function implementation
Thank you for the review!
I agree with all your other points and I'll address them
in the next version.
The kernel doc being here is modeled after newer (less old)
v4l2 APIs like include/media/v4l2-fwnode.h and
include/media/v4l2-async.h which all also have this in the header.
So unless the v4l2 folks want me to change this I'm going to keep
the kernel docs in the header.
(more in general I have seen both header and next to the body
placements for these kernel docs in various places in the kernel)
Regards,
Hans
>> +void v4l2_acpi_parse_sensor_gpios(struct device *dev);
>> +
>> +#else /* ifdef CONFIG_ACPI */
>> +static inline void v4l2_acpi_parse_sensor_gpios(struct device *dev) { return 0; }
>> +#endif /* ifdef CONFIG_ACPI */
>
next prev parent reply other threads:[~2023-05-18 16:57 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-18 15:32 [PATCH 0/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper + gc0310 sensor driver Hans de Goede
2023-05-18 15:32 ` [PATCH 1/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper function Hans de Goede
2023-05-18 16:36 ` Andy Shevchenko
2023-05-18 16:57 ` Hans de Goede [this message]
2023-05-19 10:19 ` Andy Shevchenko
2023-05-18 19:48 ` kernel test robot
2023-05-19 7:31 ` Sakari Ailus
2023-05-19 8:55 ` Hans de Goede
2023-05-19 10:21 ` Andy Shevchenko
2023-05-19 10:58 ` Sakari Ailus
2023-05-19 11:55 ` Hans de Goede
2023-05-19 12:16 ` Sakari Ailus
2023-05-19 13:08 ` Hans de Goede
2023-05-19 14:01 ` Sakari Ailus
2023-05-19 14:39 ` Hans de Goede
2023-05-24 12:16 ` Sakari Ailus
2023-05-18 15:32 ` [PATCH 2/9] media: atomisp: Switch to v4l2_acpi_parse_sensor_gpios() Hans de Goede
2023-05-18 15:32 ` [PATCH 3/9] media: atomisp: gc0310: Turn into standard v4l2 sensor driver Hans de Goede
2023-05-18 15:32 ` [PATCH 4/9] media: atomisp: gc0310: Drop XXGC0310 ACPI hardware-id Hans de Goede
2023-05-19 10:24 ` Andy Shevchenko
2023-05-18 15:32 ` [PATCH 5/9] media: atomisp: gc0310: Fix double free in gc0310_remove() Hans de Goede
2023-05-18 15:32 ` [PATCH 6/9] media: atomisp: gc0310: Cleanup includes Hans de Goede
2023-05-18 15:32 ` [PATCH 7/9] media: atomisp: gc0310: Remove gc0310_s_config() function Hans de Goede
2023-05-19 10:32 ` Andy Shevchenko
2023-05-19 10:35 ` Hans de Goede
2023-05-18 15:32 ` [PATCH 8/9] media: atomisp: gc0310: Remove gc0310.h Hans de Goede
2023-05-18 15:32 ` [PATCH 9/9] media: Move gc0310 sensor drivers to drivers/media/i2c/ Hans de Goede
2023-05-21 1:13 ` kernel test robot
2023-05-18 16:02 ` [PATCH 0/9] media: v4l: Add v4l2_acpi_parse_sensor_gpios() helper + gc0310 sensor driver Andy Shevchenko
2023-05-18 16:49 ` Hans de Goede
2023-05-19 12:14 ` Andy Shevchenko
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=9375a528-8e39-304e-9b60-99ea43e16ec0@redhat.com \
--to=hdegoede@redhat.com \
--cc=andrey.i.trufanov@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=fabioaiuto83@gmail.com \
--cc=hpa@redhat.com \
--cc=kitakar@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=nable.maininbox@googlemail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=yury.lunev@gmail.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