From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Aaron Lu <aaron.lwe@gmail.com>,
linux-acpi@vger.kernel.org,
Matthew Garrett <matthew.garrett@nebula.com>,
daniel.vetter@ffwll.ch, seth.forshee@canonical.com,
joeyli.kernel@gmail.com, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
lenb@kernel.org
Subject: Re: [Update][PATCH] ACPI / video / i915: Remove ACPI backlight if firmware expects Windows 8
Date: Tue, 16 Jul 2013 11:45:45 +0400 [thread overview]
Message-ID: <1373960745.1956.0.camel@ThinkPad-X230.localdomain> (raw)
In-Reply-To: <1519137.ZQha2P5GjU@vostro.rjw.lan>
On Tue, 2013-07-16 at 01:53 +0200, Rafael J. Wysocki wrote:
> On Monday, July 15, 2013 05:06:09 PM Igor Gnatenko wrote:
> > On Sat, 2013-07-13 at 02:46 +0200, Rafael J. Wysocki wrote:
>
> [...]
>
> >
> > I can't build it. Where did I go wrong?
>
> Probably nowhere, you tried to build the ACPI video driver as a module, that's
> all. And you need to apply https://patchwork.kernel.org/patch/2812951/
> before.
>
> Please try the appended version (on top of
> https://patchwork.kernel.org/patch/2812951/).
>
> Thanks,
> Rafael
>
Tested-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
>
> ---
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Subject: ACPI / video / i915: No ACPI backlight if firmware expects Windows 8
>
> According to Matthew Garrett, "Windows 8 leaves backlight control up
> to individual graphics drivers rather than making ACPI calls itself.
> There's plenty of evidence to suggest that the Intel driver for
> Windows [8] doesn't use the ACPI interface, including the fact that
> it's broken on a bunch of machines when the OS claims to support
> Windows 8. The simplest thing to do appears to be to disable the
> ACPI backlight interface on these systems".
>
> There's a problem with that approach, however, because simply
> avoiding to register the ACPI backlight interface if the firmware
> calls _OSI for Windows 8 may not work in the following situations:
> (1) The ACPI backlight interface actually works on the given system
> and the i915 driver is not loaded (e.g. another graphics driver
> is used).
> (2) The ACPI backlight interface doesn't work on the given system,
> but there is a vendor platform driver that will register its
> own, equally broken, backlight interface if not prevented from
> doing so by the ACPI subsystem.
> Therefore we need to allow the ACPI backlight interface to be
> registered until the i915 driver is loaded which then will unregister
> it if the firmware has called _OSI for Windows 8 (or will register
> the ACPI video driver without backlight support if not already
> present).
>
> For this reason, introduce an alternative function for registering
> ACPI video, acpi_video_register_with_quirks(), that will check
> whether or not the ACPI video driver has already been registered
> and whether or not the backlight Windows 8 quirk has to be applied.
> If the quirk has to be applied, it will block the ACPI backlight
> support and either unregister the backlight interface if the ACPI
> video driver has already been registered, or register the ACPI
> video driver without the backlight interface otherwise. Make
> the i915 driver use acpi_video_register_with_quirks() instead of
> acpi_video_register() in i915_driver_load().
>
> This change is based on earlier patches from Matthew Garrett,
> Chun-Yi Lee and Seth Forshee and Aaron Lu's comments.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/acpi/internal.h | 11 ++++++
> drivers/acpi/video.c | 65 ++++++++++++++++++++++++++++++++++++----
> drivers/acpi/video_detect.c | 21 ++++++++++++
> drivers/gpu/drm/i915/i915_dma.c | 2 -
> include/acpi/video.h | 11 ++++++
> include/linux/acpi.h | 1
> 6 files changed, 103 insertions(+), 8 deletions(-)
>
> Index: linux-pm/drivers/acpi/video.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/video.c
> +++ linux-pm/drivers/acpi/video.c
> @@ -44,6 +44,8 @@
> #include <linux/suspend.h>
> #include <acpi/video.h>
>
> +#include "internal.h"
> +
> #define PREFIX "ACPI: "
>
> #define ACPI_VIDEO_BUS_NAME "Video Bus"
> @@ -898,7 +900,7 @@ static void acpi_video_device_find_cap(s
> device->cap._DDC = 1;
> }
>
> - if (acpi_video_backlight_support()) {
> + if (acpi_video_verify_backlight_support()) {
> struct backlight_properties props;
> struct pci_dev *pdev;
> acpi_handle acpi_parent;
> @@ -1854,6 +1856,46 @@ static int acpi_video_bus_remove(struct
> return 0;
> }
>
> +static acpi_status video_unregister_backlight(acpi_handle handle, u32 lvl,
> + void *context, void **rv)
> +{
> + struct acpi_device *acpi_dev;
> + struct acpi_video_bus *video;
> + struct acpi_video_device *dev, *next;
> +
> + if (acpi_bus_get_device(handle, &acpi_dev))
> + return AE_OK;
> +
> + if (acpi_match_device_ids(acpi_dev, video_device_ids))
> + return AE_OK;
> +
> + video = acpi_driver_data(acpi_dev);
> + if (!video)
> + return AE_OK;
> +
> + acpi_video_bus_stop_devices(video);
> + mutex_lock(&video->device_list_lock);
> + list_for_each_entry_safe(dev, next, &video->video_device_list, entry) {
> + if (dev->backlight) {
> + backlight_device_unregister(dev->backlight);
> + dev->backlight = NULL;
> + kfree(dev->brightness->levels);
> + kfree(dev->brightness);
> + }
> + if (dev->cooling_dev) {
> + sysfs_remove_link(&dev->dev->dev.kobj,
> + "thermal_cooling");
> + sysfs_remove_link(&dev->cooling_dev->device.kobj,
> + "device");
> + thermal_cooling_device_unregister(dev->cooling_dev);
> + dev->cooling_dev = NULL;
> + }
> + }
> + mutex_unlock(&video->device_list_lock);
> + acpi_video_bus_start_devices(video);
> + return AE_OK;
> +}
> +
> static int __init is_i740(struct pci_dev *dev)
> {
> if (dev->device == 0x00D1)
> @@ -1885,14 +1927,25 @@ static int __init intel_opregion_present
> return opregion;
> }
>
> -int acpi_video_register(void)
> +int __acpi_video_register(bool backlight_quirks)
> {
> - int result = 0;
> + bool no_backlight;
> + int result;
> +
> + no_backlight = backlight_quirks ? acpi_video_backlight_quirks() : false;
> +
> if (register_count) {
> /*
> - * if the function of acpi_video_register is already called,
> - * don't register the acpi_vide_bus again and return no error.
> + * If acpi_video_register() has been called already, don't try
> + * to register acpi_video_bus, but unregister backlight devices
> + * if no backlight support is requested.
> */
> + if (no_backlight)
> + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
> + ACPI_UINT32_MAX,
> + video_unregister_backlight,
> + NULL, NULL, NULL);
> +
> return 0;
> }
>
> @@ -1908,7 +1961,7 @@ int acpi_video_register(void)
>
> return 0;
> }
> -EXPORT_SYMBOL(acpi_video_register);
> +EXPORT_SYMBOL(__acpi_video_register);
>
> void acpi_video_unregister(void)
> {
> Index: linux-pm/drivers/gpu/drm/i915/i915_dma.c
> ===================================================================
> --- linux-pm.orig/drivers/gpu/drm/i915/i915_dma.c
> +++ linux-pm/drivers/gpu/drm/i915/i915_dma.c
> @@ -1648,7 +1648,7 @@ int i915_driver_load(struct drm_device *
> if (INTEL_INFO(dev)->num_pipes) {
> /* Must be done after probing outputs */
> intel_opregion_init(dev);
> - acpi_video_register();
> + acpi_video_register_with_quirks();
> }
>
> if (IS_GEN5(dev))
> Index: linux-pm/include/acpi/video.h
> ===================================================================
> --- linux-pm.orig/include/acpi/video.h
> +++ linux-pm/include/acpi/video.h
> @@ -17,12 +17,21 @@ struct acpi_device;
> #define ACPI_VIDEO_DISPLAY_LEGACY_TV 0x0200
>
> #if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE)
> -extern int acpi_video_register(void);
> +extern int __acpi_video_register(bool backlight_quirks);
> +static inline int acpi_video_register(void)
> +{
> + return __acpi_video_register(false);
> +}
> +static inline int acpi_video_register_with_quirks(void)
> +{
> + return __acpi_video_register(true);
> +}
> extern void acpi_video_unregister(void);
> extern int acpi_video_get_edid(struct acpi_device *device, int type,
> int device_id, void **edid);
> #else
> static inline int acpi_video_register(void) { return 0; }
> +static inline int acpi_video_register_with_quirks(void) { return 0; }
> static inline void acpi_video_unregister(void) { return; }
> static inline int acpi_video_get_edid(struct acpi_device *device, int type,
> int device_id, void **edid)
> Index: linux-pm/drivers/acpi/video_detect.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/video_detect.c
> +++ linux-pm/drivers/acpi/video_detect.c
> @@ -38,6 +38,8 @@
> #include <linux/dmi.h>
> #include <linux/pci.h>
>
> +#include "internal.h"
> +
> #define PREFIX "ACPI: "
>
> ACPI_MODULE_NAME("video");
> @@ -234,6 +236,17 @@ static void acpi_video_caps_check(void)
> acpi_video_get_capabilities(NULL);
> }
>
> +bool acpi_video_backlight_quirks(void)
> +{
> + if (acpi_gbl_osi_data >= ACPI_OSI_WIN_8) {
> + acpi_video_caps_check();
> + acpi_video_support |= ACPI_VIDEO_SKIP_BACKLIGHT;
> + return true;
> + }
> + return false;
> +}
> +EXPORT_SYMBOL(acpi_video_backlight_quirks);
> +
> /* Promote the vendor interface instead of the generic video module.
> * This function allow DMI blacklists to be implemented by externals
> * platform drivers instead of putting a big blacklist in video_detect.c
> @@ -278,6 +291,14 @@ int acpi_video_backlight_support(void)
> }
> EXPORT_SYMBOL(acpi_video_backlight_support);
>
> +/* For the ACPI video driver use only. */
> +bool acpi_video_verify_backlight_support(void)
> +{
> + return (acpi_video_support & ACPI_VIDEO_SKIP_BACKLIGHT) ?
> + false : acpi_video_backlight_support();
> +}
> +EXPORT_SYMBOL(acpi_video_verify_backlight_support);
> +
> /*
> * Use acpi_backlight=vendor/video to force that backlight switching
> * is processed by vendor specific acpi drivers or video.ko driver.
> Index: linux-pm/include/linux/acpi.h
> ===================================================================
> --- linux-pm.orig/include/linux/acpi.h
> +++ linux-pm/include/linux/acpi.h
> @@ -191,6 +191,7 @@ extern bool wmi_has_guid(const char *gui
> #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200
> #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400
> #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800
> +#define ACPI_VIDEO_SKIP_BACKLIGHT 0x1000
>
> #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
>
> Index: linux-pm/drivers/acpi/internal.h
> ===================================================================
> --- linux-pm.orig/drivers/acpi/internal.h
> +++ linux-pm/drivers/acpi/internal.h
> @@ -164,4 +164,15 @@ struct platform_device;
> int acpi_create_platform_device(struct acpi_device *adev,
> const struct acpi_device_id *id);
>
> +/*--------------------------------------------------------------------------
> + Video
> + -------------------------------------------------------------------------- */
> +#if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
> +bool acpi_video_backlight_quirks(void);
> +bool acpi_video_verify_backlight_support(void);
> +#else
> +static inline bool acpi_video_backlight_quirks(void) { return false; }
> +static inline bool acpi_video_verify_backlight_support(void) { return false; }
> +#endif
> +
> #endif /* _ACPI_INTERNAL_H_ */
>
>
--
Igor Gnatenko
Fedora release 19 (Schrödinger’s Cat)
Linux 3.11.0-0.rc0.git7.1.fc20.x86_64
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-07-16 7:45 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 23:01 [PATCH 0/3] Fix backlight issues on some Windows 8 systems Matthew Garrett
2013-06-09 23:01 ` [PATCH 1/3] acpi: video: add function to support unregister backlight interface Matthew Garrett
2013-06-09 23:01 ` [PATCH 2/3] ACPICA: Add interface for getting latest OS version requested via _OSI Matthew Garrett
2013-06-17 22:31 ` Rafael J. Wysocki
2013-06-17 22:37 ` Matthew Garrett
2013-06-18 0:42 ` Rafael J. Wysocki
2013-06-25 23:23 ` Rafael J. Wysocki
2013-07-02 13:56 ` [PATCH 0/2] Expose OSI version Aaron Lu
2013-07-02 13:59 ` [PATCH 1/2] ACPICA: expose " Aaron Lu
2013-07-02 14:01 ` [PATCH 2/2] ACPI / OSL: add a wrapper function to return " Aaron Lu
2013-07-03 21:57 ` Rafael J. Wysocki
2013-07-04 1:24 ` Aaron Lu
2013-07-05 19:52 ` Rafael J. Wysocki
2013-06-09 23:01 ` [PATCH 3/3] i915: Don't provide ACPI backlight interface if firmware expects Windows 8 Matthew Garrett
2013-06-10 7:40 ` Daniel Vetter
2013-06-10 9:22 ` joeyli
2013-06-10 14:09 ` Alex Deucher
2013-06-14 6:47 ` Aaron Lu
2013-06-14 17:29 ` Matthew Garrett
2013-06-15 1:26 ` Aaron Lu
2013-06-15 1:38 ` Matthew Garrett
2013-06-15 4:14 ` Aaron Lu
2013-06-15 4:19 ` Matthew Garrett
2013-06-15 12:29 ` Aaron Lu
2013-06-15 15:16 ` Matthew Garrett
2013-06-15 18:29 ` Daniel Vetter
2013-06-15 18:44 ` Matthew Garrett
2013-06-15 20:27 ` Rafael J. Wysocki
2013-06-15 20:35 ` Daniel Vetter
2013-07-05 12:20 ` Rafael J. Wysocki
2013-07-05 20:00 ` Rafael J. Wysocki
2013-07-05 21:40 ` Rafael J. Wysocki
2013-07-05 22:23 ` Rafael J. Wysocki
2013-07-06 5:45 ` Aaron Lu
2013-07-06 13:33 ` Rafael J. Wysocki
2013-07-07 13:19 ` Rafael J. Wysocki
2013-07-08 8:00 ` Aaron Lu
2013-07-13 0:46 ` [Update][PATCH] ACPI / video / i915: Remove ACPI backlight " Rafael J. Wysocki
2013-07-15 2:36 ` Aaron Lu
2013-07-15 11:42 ` Rafael J. Wysocki
2013-07-16 3:24 ` Aaron Lu
2013-07-16 11:54 ` Rafael J. Wysocki
2013-07-15 13:06 ` Igor Gnatenko
2013-07-15 23:53 ` Rafael J. Wysocki
2013-07-16 7:45 ` Igor Gnatenko [this message]
2013-07-16 13:32 ` Igor Gnatenko
2013-07-16 17:08 ` Matthew Garrett
2013-07-16 22:01 ` Rafael J. Wysocki
2013-07-17 5:16 ` Igor Gnatenko
2013-07-17 11:38 ` Rafael J. Wysocki
2013-07-17 12:03 ` Igor Gnatenko
2013-06-10 11:59 ` [PATCH 0/3] Fix backlight issues on some Windows 8 systems Rafael J. Wysocki
2013-06-10 13:48 ` Matthew Garrett
2013-06-11 13:08 ` Seth Forshee
2013-06-22 21:46 ` Yves-Alexis Perez
2013-06-25 16:08 ` Matthew Garrett
2013-06-25 16:10 ` Daniel Vetter
2013-06-25 16:13 ` Matthew Garrett
2013-06-25 20:43 ` Yves-Alexis Perez
2013-06-25 20:54 ` Matthew Garrett
2013-06-25 21:10 ` Yves-Alexis Perez
2013-06-25 21:14 ` Matthew Garrett
2013-06-25 21:30 ` Yves-Alexis Perez
2013-06-25 21:33 ` Matthew Garrett
2013-06-25 21:46 ` Yves-Alexis Perez
2013-06-25 21:49 ` Matthew Garrett
2013-07-17 15:51 ` Felipe Contreras
2013-07-17 19:57 ` Yves-Alexis Perez
2013-07-18 0:16 ` [Update][PATCH " Rafael J. Wysocki
2013-07-18 0:20 ` [PATCH 1/3] ACPICA: expose OSI version Rafael J. Wysocki
2013-07-18 5:38 ` Igor Gnatenko
2013-07-18 0:21 ` [PATCH 2/3] ACPI / video: Always call acpi_video_init_brightness() on init Rafael J. Wysocki
2013-07-18 5:40 ` Igor Gnatenko
2013-07-18 0:22 ` [PATCH 3/3] ACPI / video / i915: No ACPI backlight if firmware expects Windows 8 Rafael J. Wysocki
2013-07-20 13:16 ` [Update][PATCH 0/3] Fix backlight issues on some Windows 8 systems Felipe Contreras
2013-07-31 0:01 ` Rafael J. Wysocki
2013-07-31 0:01 ` Matthew Garrett
2013-07-31 6:48 ` Igor Gnatenko
2013-07-31 9:08 ` Aaron Lu
2013-08-07 7:44 ` Backlight control only in the kernel? Borislav Petkov
2013-08-07 9:03 ` Aaron Lu
2013-08-07 10:34 ` Borislav Petkov
2013-08-07 10:36 ` Matthew Garrett
2013-08-07 11:04 ` Borislav Petkov
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=1373960745.1956.0.camel@ThinkPad-X230.localdomain \
--to=i.gnatenko.brain@gmail.com \
--cc=aaron.lwe@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=joeyli.kernel@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.garrett@nebula.com \
--cc=rjw@sisk.pl \
--cc=seth.forshee@canonical.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).