From: Jani Nikula <jani.nikula@linux.intel.com> To: Hans de Goede <hdegoede@redhat.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, Rajat Jain <rajatja@google.com>, Lyude <lyude@redhat.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Mark Gross <mgross@linux.intel.com>, Andy Shevchenko <andy@infradead.org> Cc: Hans de Goede <hdegoede@redhat.com>, Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>, Pekka Paalanen <pekka.paalanen@collabora.com>, Mario Limonciello <mario.limonciello@outlook.com>, Mark Pearson <markpearson@lenovo.com>, Sebastien Bacher <seb128@ubuntu.com>, Marco Trevisan <marco.trevisan@canonical.com>, Emil Velikov <emil.l.velikov@gmail.com>, intel-gfx <intel-gfx@lists.freedesktop.org>, dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org Subject: Re: [PATCH 3/9] drm/privacy-screen: Add X86 specific arch init code Date: Thu, 16 Sep 2021 11:51:08 +0300 [thread overview] Message-ID: <87v930x5s3.fsf@intel.com> (raw) In-Reply-To: <20210906073519.4615-4-hdegoede@redhat.com> On Mon, 06 Sep 2021, Hans de Goede <hdegoede@redhat.com> wrote: > Add X86 specific arch init code, which fills the privacy-screen lookup > table by checking for various vendor specific ACPI interfaces for > controlling the privacy-screen. > > This initial version only checks for the Lenovo Thinkpad specific ACPI > methods for privacy-screen control. > > Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > drivers/gpu/drm/Makefile | 2 +- > drivers/gpu/drm/drm_privacy_screen_x86.c | 86 ++++++++++++++++++++++++ > include/drm/drm_privacy_screen_machine.h | 5 ++ > 3 files changed, 92 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/drm_privacy_screen_x86.c > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index 788fc37096f6..12997ca5670d 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -32,7 +32,7 @@ drm-$(CONFIG_OF) += drm_of.o > drm-$(CONFIG_PCI) += drm_pci.o > drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o > drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o > -drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o > +drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o drm_privacy_screen_x86.o Would be nice to avoid building drm_privacy_screen_x86.o altogether for CONFIG_X86=n, and avoid... > > obj-$(CONFIG_DRM_DP_AUX_BUS) += drm_dp_aux_bus.o > > diff --git a/drivers/gpu/drm/drm_privacy_screen_x86.c b/drivers/gpu/drm/drm_privacy_screen_x86.c > new file mode 100644 > index 000000000000..a2cafb294ca6 > --- /dev/null > +++ b/drivers/gpu/drm/drm_privacy_screen_x86.c > @@ -0,0 +1,86 @@ > +// SPDX-License-Identifier: MIT > +/* > + * Copyright (C) 2020 Red Hat, Inc. > + * > + * Authors: > + * Hans de Goede <hdegoede@redhat.com> > + */ > + > +#include <linux/acpi.h> > +#include <drm/drm_privacy_screen_machine.h> > + > +#ifdef CONFIG_X86 ...ifdefs that cover the entire file. This can be a future improvement, though. > +static struct drm_privacy_screen_lookup arch_lookup; > + > +struct arch_init_data { > + struct drm_privacy_screen_lookup lookup; > + bool (*detect)(void); > +}; > + > +#if IS_ENABLED(CONFIG_THINKPAD_ACPI) > +static acpi_status __init acpi_set_handle(acpi_handle handle, u32 level, > + void *context, void **return_value) > +{ > + *(acpi_handle *)return_value = handle; > + return AE_CTRL_TERMINATE; > +} > + > +static bool __init detect_thinkpad_privacy_screen(void) > +{ > + union acpi_object obj = { .type = ACPI_TYPE_INTEGER }; > + struct acpi_object_list args = { .count = 1, .pointer = &obj, }; > + acpi_handle ec_handle = NULL; > + unsigned long long output; > + acpi_status status; > + > + /* Get embedded-controller handle */ > + status = acpi_get_devices("PNP0C09", acpi_set_handle, NULL, &ec_handle); > + if (ACPI_FAILURE(status) || !ec_handle) > + return false; > + > + /* And call the privacy-screen get-status method */ > + status = acpi_evaluate_integer(ec_handle, "HKEY.GSSS", &args, &output); > + if (ACPI_FAILURE(status)) > + return false; > + > + return (output & 0x10000) ? true : false; > +} > +#endif > + > +static const struct arch_init_data arch_init_data[] __initconst = { > +#if IS_ENABLED(CONFIG_THINKPAD_ACPI) > + { > + .lookup = { > + .dev_id = NULL, > + .con_id = NULL, > + .provider = "privacy_screen-thinkpad_acpi", > + }, > + .detect = detect_thinkpad_privacy_screen, > + }, > +#endif > +}; > + > +void __init drm_privacy_screen_lookup_init(void) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(arch_init_data); i++) { > + if (!arch_init_data[i].detect()) > + continue; > + > + pr_info("Found '%s' privacy-screen provider\n", > + arch_init_data[i].lookup.provider); > + > + /* Make a copy because arch_init_data is __initconst */ > + arch_lookup = arch_init_data[i].lookup; > + drm_privacy_screen_lookup_add(&arch_lookup); > + break; > + } > +} > + > +void drm_privacy_screen_lookup_exit(void) > +{ > + if (arch_lookup.provider) > + drm_privacy_screen_lookup_remove(&arch_lookup); > +} > +#endif /* ifdef CONFIG_X86 */ > diff --git a/include/drm/drm_privacy_screen_machine.h b/include/drm/drm_privacy_screen_machine.h > index aaa0d38cce92..02e5371904d3 100644 > --- a/include/drm/drm_privacy_screen_machine.h > +++ b/include/drm/drm_privacy_screen_machine.h > @@ -31,11 +31,16 @@ struct drm_privacy_screen_lookup { > void drm_privacy_screen_lookup_add(struct drm_privacy_screen_lookup *lookup); > void drm_privacy_screen_lookup_remove(struct drm_privacy_screen_lookup *lookup); > > +#if IS_ENABLED(CONFIG_DRM_PRIVACY_SCREEN) && IS_ENABLED(CONFIG_X86) > +void drm_privacy_screen_lookup_init(void); > +void drm_privacy_screen_lookup_exit(void); > +#else > static inline void drm_privacy_screen_lookup_init(void) > { > } > static inline void drm_privacy_screen_lookup_exit(void) > { > } > +#endif > > #endif -- Jani Nikula, Intel Open Source Graphics Center
WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com> To: Hans de Goede <hdegoede@redhat.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, Rajat Jain <rajatja@google.com>, Lyude <lyude@redhat.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Mark Gross <mgross@linux.intel.com>, Andy Shevchenko <andy@infradead.org> Cc: Hans de Goede <hdegoede@redhat.com>, Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>, Pekka Paalanen <pekka.paalanen@collabora.com>, Mario Limonciello <mario.limonciello@outlook.com>, Mark Pearson <markpearson@lenovo.com>, Sebastien Bacher <seb128@ubuntu.com>, Marco Trevisan <marco.trevisan@canonical.com>, Emil Velikov <emil.l.velikov@gmail.com>, intel-gfx <intel-gfx@lists.freedesktop.org>, dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org Subject: Re: [Intel-gfx] [PATCH 3/9] drm/privacy-screen: Add X86 specific arch init code Date: Thu, 16 Sep 2021 11:51:08 +0300 [thread overview] Message-ID: <87v930x5s3.fsf@intel.com> (raw) In-Reply-To: <20210906073519.4615-4-hdegoede@redhat.com> On Mon, 06 Sep 2021, Hans de Goede <hdegoede@redhat.com> wrote: > Add X86 specific arch init code, which fills the privacy-screen lookup > table by checking for various vendor specific ACPI interfaces for > controlling the privacy-screen. > > This initial version only checks for the Lenovo Thinkpad specific ACPI > methods for privacy-screen control. > > Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > drivers/gpu/drm/Makefile | 2 +- > drivers/gpu/drm/drm_privacy_screen_x86.c | 86 ++++++++++++++++++++++++ > include/drm/drm_privacy_screen_machine.h | 5 ++ > 3 files changed, 92 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/drm_privacy_screen_x86.c > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index 788fc37096f6..12997ca5670d 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -32,7 +32,7 @@ drm-$(CONFIG_OF) += drm_of.o > drm-$(CONFIG_PCI) += drm_pci.o > drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o > drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o > -drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o > +drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o drm_privacy_screen_x86.o Would be nice to avoid building drm_privacy_screen_x86.o altogether for CONFIG_X86=n, and avoid... > > obj-$(CONFIG_DRM_DP_AUX_BUS) += drm_dp_aux_bus.o > > diff --git a/drivers/gpu/drm/drm_privacy_screen_x86.c b/drivers/gpu/drm/drm_privacy_screen_x86.c > new file mode 100644 > index 000000000000..a2cafb294ca6 > --- /dev/null > +++ b/drivers/gpu/drm/drm_privacy_screen_x86.c > @@ -0,0 +1,86 @@ > +// SPDX-License-Identifier: MIT > +/* > + * Copyright (C) 2020 Red Hat, Inc. > + * > + * Authors: > + * Hans de Goede <hdegoede@redhat.com> > + */ > + > +#include <linux/acpi.h> > +#include <drm/drm_privacy_screen_machine.h> > + > +#ifdef CONFIG_X86 ...ifdefs that cover the entire file. This can be a future improvement, though. > +static struct drm_privacy_screen_lookup arch_lookup; > + > +struct arch_init_data { > + struct drm_privacy_screen_lookup lookup; > + bool (*detect)(void); > +}; > + > +#if IS_ENABLED(CONFIG_THINKPAD_ACPI) > +static acpi_status __init acpi_set_handle(acpi_handle handle, u32 level, > + void *context, void **return_value) > +{ > + *(acpi_handle *)return_value = handle; > + return AE_CTRL_TERMINATE; > +} > + > +static bool __init detect_thinkpad_privacy_screen(void) > +{ > + union acpi_object obj = { .type = ACPI_TYPE_INTEGER }; > + struct acpi_object_list args = { .count = 1, .pointer = &obj, }; > + acpi_handle ec_handle = NULL; > + unsigned long long output; > + acpi_status status; > + > + /* Get embedded-controller handle */ > + status = acpi_get_devices("PNP0C09", acpi_set_handle, NULL, &ec_handle); > + if (ACPI_FAILURE(status) || !ec_handle) > + return false; > + > + /* And call the privacy-screen get-status method */ > + status = acpi_evaluate_integer(ec_handle, "HKEY.GSSS", &args, &output); > + if (ACPI_FAILURE(status)) > + return false; > + > + return (output & 0x10000) ? true : false; > +} > +#endif > + > +static const struct arch_init_data arch_init_data[] __initconst = { > +#if IS_ENABLED(CONFIG_THINKPAD_ACPI) > + { > + .lookup = { > + .dev_id = NULL, > + .con_id = NULL, > + .provider = "privacy_screen-thinkpad_acpi", > + }, > + .detect = detect_thinkpad_privacy_screen, > + }, > +#endif > +}; > + > +void __init drm_privacy_screen_lookup_init(void) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(arch_init_data); i++) { > + if (!arch_init_data[i].detect()) > + continue; > + > + pr_info("Found '%s' privacy-screen provider\n", > + arch_init_data[i].lookup.provider); > + > + /* Make a copy because arch_init_data is __initconst */ > + arch_lookup = arch_init_data[i].lookup; > + drm_privacy_screen_lookup_add(&arch_lookup); > + break; > + } > +} > + > +void drm_privacy_screen_lookup_exit(void) > +{ > + if (arch_lookup.provider) > + drm_privacy_screen_lookup_remove(&arch_lookup); > +} > +#endif /* ifdef CONFIG_X86 */ > diff --git a/include/drm/drm_privacy_screen_machine.h b/include/drm/drm_privacy_screen_machine.h > index aaa0d38cce92..02e5371904d3 100644 > --- a/include/drm/drm_privacy_screen_machine.h > +++ b/include/drm/drm_privacy_screen_machine.h > @@ -31,11 +31,16 @@ struct drm_privacy_screen_lookup { > void drm_privacy_screen_lookup_add(struct drm_privacy_screen_lookup *lookup); > void drm_privacy_screen_lookup_remove(struct drm_privacy_screen_lookup *lookup); > > +#if IS_ENABLED(CONFIG_DRM_PRIVACY_SCREEN) && IS_ENABLED(CONFIG_X86) > +void drm_privacy_screen_lookup_init(void); > +void drm_privacy_screen_lookup_exit(void); > +#else > static inline void drm_privacy_screen_lookup_init(void) > { > } > static inline void drm_privacy_screen_lookup_exit(void) > { > } > +#endif > > #endif -- Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2021-09-16 8:51 UTC|newest] Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-06 7:35 [PATCH 0/9] drm: Add privacy-screen class and connector properties Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [PATCH 1/9] drm/connector: Add support for privacy-screen properties (v4) Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-15 19:48 ` Lyude Paul 2021-09-15 19:48 ` [Intel-gfx] " Lyude Paul 2021-09-15 19:48 ` Lyude Paul 2021-09-16 8:26 ` Jani Nikula 2021-09-16 8:26 ` [Intel-gfx] " Jani Nikula 2021-09-06 7:35 ` [PATCH 2/9] drm: Add privacy-screen class (v3) Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-15 20:01 ` Lyude Paul 2021-09-15 20:01 ` [Intel-gfx] " Lyude Paul 2021-09-15 20:01 ` Lyude Paul 2021-09-16 8:49 ` Hans de Goede 2021-09-16 8:49 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [PATCH 3/9] drm/privacy-screen: Add X86 specific arch init code Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-16 8:51 ` Jani Nikula [this message] 2021-09-16 8:51 ` Jani Nikula 2021-09-16 9:18 ` Hans de Goede 2021-09-16 9:18 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] [PATCH 4/9] drm/privacy-screen: Add notifier support Hans de Goede 2021-09-06 7:35 ` Hans de Goede 2021-09-15 20:26 ` Lyude Paul 2021-09-15 20:26 ` Lyude Paul 2021-09-15 20:26 ` [Intel-gfx] " Lyude Paul 2021-09-16 9:06 ` Hans de Goede 2021-09-16 9:06 ` [Intel-gfx] " Hans de Goede 2021-09-16 16:50 ` Lyude Paul 2021-09-16 16:50 ` Lyude Paul 2021-09-16 16:50 ` [Intel-gfx] " Lyude Paul 2021-09-06 7:35 ` [PATCH 5/9] drm/connector: Add a drm_connector privacy-screen helper functions Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [PATCH 6/9] platform/x86: thinkpad_acpi: Add hotkey_notify_extended_hotkey() helper Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [PATCH 7/9] platform/x86: thinkpad_acpi: Get privacy-screen / lcdshadow ACPI handles only once Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [PATCH 8/9] platform/x86: thinkpad_acpi: Register a privacy-screen device Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-15 20:55 ` Lyude Paul 2021-09-15 20:55 ` [Intel-gfx] " Lyude Paul 2021-09-15 20:55 ` Lyude Paul 2021-09-16 9:09 ` Hans de Goede 2021-09-16 9:09 ` [Intel-gfx] " Hans de Goede 2021-09-06 7:35 ` [PATCH 9/9] drm/i915: Add privacy-screen support Hans de Goede 2021-09-06 7:35 ` [Intel-gfx] " Hans de Goede 2021-09-15 21:11 ` Lyude Paul 2021-09-15 21:11 ` [Intel-gfx] " Lyude Paul 2021-09-15 21:11 ` Lyude Paul 2021-09-16 9:12 ` Hans de Goede 2021-09-16 9:12 ` [Intel-gfx] " Hans de Goede 2021-09-16 9:40 ` Jani Nikula 2021-09-16 9:40 ` [Intel-gfx] " Jani Nikula 2021-09-16 10:32 ` Hans de Goede 2021-09-16 10:32 ` [Intel-gfx] " Hans de Goede 2021-09-20 21:06 ` Lyude Paul 2021-09-20 21:06 ` Lyude Paul 2021-09-20 21:06 ` [Intel-gfx] " Lyude Paul 2021-09-16 14:04 ` Ville Syrjälä 2021-09-16 14:04 ` [Intel-gfx] " Ville Syrjälä 2021-09-17 14:23 ` Hans de Goede 2021-09-17 14:23 ` [Intel-gfx] " Hans de Goede 2021-09-16 13:45 ` Ville Syrjälä 2021-09-16 13:45 ` [Intel-gfx] " Ville Syrjälä 2021-09-17 14:37 ` Hans de Goede 2021-09-17 14:37 ` [Intel-gfx] " Hans de Goede 2021-09-17 16:25 ` Ville Syrjälä 2021-09-17 16:25 ` [Intel-gfx] " Ville Syrjälä 2021-09-17 16:42 ` Hans de Goede 2021-09-17 16:42 ` [Intel-gfx] " Hans de Goede 2021-09-17 17:04 ` Ville Syrjälä 2021-09-17 17:04 ` [Intel-gfx] " Ville Syrjälä 2021-09-06 8:46 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm: Add privacy-screen class and connector properties (rev4) Patchwork 2021-09-06 8:49 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork 2021-09-06 9:17 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork 2021-09-06 11:16 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork 2021-09-15 21:12 ` [PATCH 0/9] drm: Add privacy-screen class and connector properties Lyude Paul 2021-09-15 21:12 ` [Intel-gfx] " Lyude Paul 2021-09-15 21:12 ` Lyude Paul 2021-09-16 9:30 ` Hans de Goede 2021-09-16 9:30 ` [Intel-gfx] " Hans de Goede 2021-09-16 10:14 ` Jani Nikula 2021-09-16 10:14 ` [Intel-gfx] " Jani Nikula
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=87v930x5s3.fsf@intel.com \ --to=jani.nikula@linux.intel.com \ --cc=airlied@linux.ie \ --cc=andy@infradead.org \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=emil.l.velikov@gmail.com \ --cc=hdegoede@redhat.com \ --cc=intel-gfx@lists.freedesktop.org \ --cc=joonas.lahtinen@linux.intel.com \ --cc=lyude@redhat.com \ --cc=maarten.lankhorst@linux.intel.com \ --cc=marco.trevisan@canonical.com \ --cc=mario.limonciello@outlook.com \ --cc=markpearson@lenovo.com \ --cc=mgross@linux.intel.com \ --cc=mripard@kernel.org \ --cc=pekka.paalanen@collabora.com \ --cc=platform-driver-x86@vger.kernel.org \ --cc=rajatja@google.com \ --cc=rodrigo.vivi@intel.com \ --cc=seb128@ubuntu.com \ --cc=tzimmermann@suse.de \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.