acpi: add a way to promote/demote vendor backlight drivers
Subsystems (4)
Corentin Chary
maintainerPATCH 1/2 acpi: add a way to promote/demote vendor backlight drivers
Instead of adding a big blacklist in video_detect.c to set ACPI_VIDEO_BACKLIGHT_DMI_VENDOR correctly, let external modules promote or demote themselves when they know the generic video module won't work.
Currently drivers where using acpi_video_unregister() directly but:
- That didn't respect any acpi_backlight=[video|vendor] parameter provided by the user.
- Any later call to acpi_video_register() would still re-load the generic video module (and some gpu drivers are doing that).
This patch fix those two issues.
--- drivers/acpi/video_detect.c | 31 +++++++++++++++++++++++++++++-- include/linux/acpi.h | 10 ++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)
drivers/acpi/video_detect.c +29 -2
@@ -182,8 +182,7 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle) }EXPORT_SYMBOL (acpi_video_get_capabilities); -/* Returns true if video.ko can do backlight switching */ -int acpi_video_backlight_support (void ) +static void acpi_video_caps_check (void ) {/* * We must check whether the ACPI graphics device is physically plugged
@@ -191,6 +190,34 @@ int acpi_video_backlight_support(void)*/ if (!acpi_video_caps_checked)acpi_video_get_capabilities (NULL ); +} + +/* 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 +* After calling this function you will probably want to call +* acpi_video_unregister() to make sure the video module is not loaded +*/ +void acpi_video_dmi_promote_vendor (void ) +{ +acpi_video_caps_check (); + acpi_video_support |=ACPI_VIDEO_BACKLIGHT_DMI_VENDOR ; +} +EXPORT_SYMBOL (acpi_video_dmi_promote_vendor); + +/* To be called when a driver who previously promoted the vendor +* interface */ +void acpi_video_dmi_demote_vendor (void ) +{ +acpi_video_caps_check (); + acpi_video_support &= ~ACPI_VIDEO_BACKLIGHT_DMI_VENDOR ; +} +EXPORT_SYMBOL (acpi_video_dmi_demote_vendor); + +/* Returns true if video.ko can do backlight switching */ +int acpi_video_backlight_support (void ) +{ +acpi_video_caps_check ();/* First check for boot param -> highest prio */ if (acpi_video_support &ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR )
include/linux/acpi.h +10 -0
@@ -190,6 +190,8 @@ extern bool wmi_has_guid(const char *guid);extern long acpi_video_get_capabilities (acpi_handle graphics_dev_handle);extern long acpi_is_video_device (struct acpi_device *device); +extern void acpi_video_dmi_promote_vendor (void ); +extern void acpi_video_dmi_demote_vendor (void );extern int acpi_video_backlight_support (void );extern int acpi_video_display_switch_support (void );
@@ -205,6 +207,14 @@ static inline long acpi_is_video_device(struct acpi_device *device)return 0 ; } +static inline void acpi_video_dmi_promote_vendor (void ) +{ +} + +static inline void acpi_video_dmi_demote_vendor (void ) +{ +} +static inline int acpi_video_backlight_support (void ) {return 0 ;
Signature · 1 line
1.7.9.5
Corentin Chary
maintainerPATCH 2/2 drivers-platform-x86: use acpi_video_dmi_promote_vendor()
Instead of using directly acpi_video_unregister(), use acpi_video_dmi_promote_vendor() (and make it call acpi_video_unregister() if needed)
--- drivers/platform/x86/acer-wmi.c | 11 ++++------- drivers/platform/x86/apple-gmux.c | 2 ++ drivers/platform/x86/samsung-laptop.c | 22 ++++++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-)
drivers/platform/x86/acer-wmi.c +4 -7
@@ -2036,14 +2036,11 @@ static int __init acer_wmi_init(void)set_quirks (); +if (dmi_check_system (video_vendor_dmi_table)) +acpi_video_dmi_promote_vendor ();if (acpi_video_backlight_support ()) { -if (dmi_check_system (video_vendor_dmi_table)) { -acpi_video_unregister (); - }else { - interface->capability &= ~ACER_CAP_BRIGHTNESS ; -pr_info ("Brightness must be controlled by " -"acpi video driver\n" ); - } + interface->capability &= ~ACER_CAP_BRIGHTNESS ; +pr_info ("Brightness must be controlled by acpi video driver\n" ); }if (wmi_has_guid (WMID_GUID3 )) {
drivers/platform/x86/apple-gmux.c +2 -0
@@ -193,6 +193,7 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,* backlight control and supports more levels than other options. * Disable the other backlight choices. */ +acpi_video_dmi_promote_vendor ();acpi_video_unregister ();apple_bl_unregister ();
@@ -213,6 +214,7 @@ static void __devexit gmux_remove(struct pnp_dev *pnp)release_region (gmux_data->iostart, gmux_data->iolen);kfree (gmux_data); +acpi_video_dmi_demote_vendor ();acpi_video_register ();apple_bl_register (); }
drivers/platform/x86/samsung-laptop.c +12 -10
@@ -26,7 +26,7 @@#include <linux/seq_file.h> #include <linux/debugfs.h> #include <linux/ctype.h> -#if (definedCONFIG_ACPI_VIDEO || definedCONFIG_ACPI_VIDEO_MODULE ) +#ifdef CONFIG_ACPI_VIDEO #include <acpi/video.h> #endif
@@ -1530,15 +1530,18 @@ static int __init samsung_init(void) samsung->quirks = quirks; -#if (definedCONFIG_ACPI_VIDEO || definedCONFIG_ACPI_VIDEO_MODULE ) +#ifdef CONFIG_ACPI +if (samsung->quirks->broken_acpi_video) +acpi_video_dmi_promote_vendor (); +/* Don't handle backlight here if the acpi video already handle it */ if (acpi_video_backlight_support ()) { -if (samsung->quirks->broken_acpi_video) { -pr_info ("Disabling ACPI video driver\n" ); -acpi_video_unregister (); - }else { - samsung->handle_backlight = false; - } + samsung->handle_backlight = false; + }else if (samsung->quirks->broken_acpi_video) { +pr_info ("Disabling ACPI video driver\n" ); +#ifdef CONFIG_ACPI_VIDEO +acpi_video_unregister (); +#endif }#endif
@@ -1552,8 +1555,7 @@ static int __init samsung_init(void)#ifdef CONFIG_ACPI /* Only log that if we are really on a sabi platform */ -if (acpi_video_backlight_support () && - !samsung->quirks->broken_acpi_video) +if (acpi_video_backlight_support ())pr_info ("Backlight controlled by ACPI video driver\n" );#endif
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] drivers-platform-x86: use acpi_video_dmi_promote_vendor()
於 一,2012-05-21 於 09:23 +0200,Corentin Chary 提到:
Quoted 24 lines
Instead of using directly
acpi_video_unregister(), useacpi_video_dmi_promote_vendor()(and make it callacpi_video_unregister()if needed)Signed-off-by Corentin Chary <[email protected]>--- drivers/platform/x86/acer-wmi.c | 11 ++++------- drivers/platform/x86/apple-gmux.c | 2 ++ drivers/platform/x86/samsung-laptop.c | 22 ++++++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-)drivers/platform/x86/acer-wmi.c +2
-2@@ -2036,14 +2036,11 @@ static int __init acer_wmi_init(void)set_quirks (); +if (dmi_check_system (video_vendor_dmi_table)) +acpi_video_dmi_promote_vendor ();if (acpi_video_backlight_support ()) { -if (dmi_check_system (video_vendor_dmi_table)) { -acpi_video_unregister ();
drivers/platform/x86/acer-wmi.c static int __init acer_wmi_init(void) · line 2046
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +2
-5- }else { - interface->capability &= ~ACER_CAP_BRIGHTNESS ; -pr_info ("Brightness must be controlled by " -"acpi video driver\n" ); - } + interface->capability &= ~ACER_CAP_BRIGHTNESS ; +pr_info ("Brightness must be controlled by acpi video driver\n" ); }if (wmi_has_guid (WMID_GUID3 )) {
Thanks a lot!
Joey Lee
Quoted 69 lines
drivers/platform/x86/apple-gmux.c +2
-0@@ -193,6 +193,7 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,* backlight control and supports more levels than other options. * Disable the other backlight choices. */ +acpi_video_dmi_promote_vendor ();acpi_video_unregister ();apple_bl_unregister ();@@ -213,6 +214,7 @@ static void __devexit gmux_remove(struct pnp_dev *pnp)release_region (gmux_data->iostart, gmux_data->iolen);kfree (gmux_data); +acpi_video_dmi_demote_vendor ();acpi_video_register ();apple_bl_register (); }drivers/platform/x86/samsung-laptop.c +12
-10@@ -26,7 +26,7 @@#include <linux/seq_file.h> #include <linux/debugfs.h> #include <linux/ctype.h> -#if (definedCONFIG_ACPI_VIDEO || definedCONFIG_ACPI_VIDEO_MODULE ) +#ifdef CONFIG_ACPI_VIDEO #include <acpi/video.h> #endif @@ -1530,15 +1530,18 @@ static int __init samsung_init(void) samsung->quirks = quirks; -#if (definedCONFIG_ACPI_VIDEO || definedCONFIG_ACPI_VIDEO_MODULE ) +#ifdef CONFIG_ACPI +if (samsung->quirks->broken_acpi_video) +acpi_video_dmi_promote_vendor (); +/* Don't handle backlight here if the acpi video already handle it */ if (acpi_video_backlight_support ()) { -if (samsung->quirks->broken_acpi_video) { -pr_info ("Disabling ACPI video driver\n" ); -acpi_video_unregister (); - }else { - samsung->handle_backlight = false; - } + samsung->handle_backlight = false; + }else if (samsung->quirks->broken_acpi_video) { +pr_info ("Disabling ACPI video driver\n" ); +#ifdef CONFIG_ACPI_VIDEO +acpi_video_unregister (); +#endif }#endif @@ -1552,8 +1555,7 @@ static int __init samsung_init(void)#ifdef CONFIG_ACPI /* Only log that if we are really on a sabi platform */ -if (acpi_video_backlight_support () && - !samsung->quirks->broken_acpi_video) +if (acpi_video_backlight_support ())pr_info ("Backlight controlled by ACPI video driver\n" );#endif