linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] acpi: add a way to promote/demote vendor backlight drivers
@ 2012-05-21  7:23 Corentin Chary
  2012-05-21  7:23 ` [PATCH 2/2] drivers-platform-x86: use acpi_video_dmi_promote_vendor() Corentin Chary
  0 siblings, 1 reply; 3+ messages in thread
From: Corentin Chary @ 2012-05-21  7:23 UTC (permalink / raw)
  To: Len Brown
  Cc: Richard Purdie, platform-driver-x86, linux-acpi, Zhang Rui,
	Corentin Chary, linux-kernel

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.

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
---
 drivers/acpi/video_detect.c |   31 +++++++++++++++++++++++++++++--
 include/linux/acpi.h        |   10 ++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 45d8097..942fa2a 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -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)
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index f421dd8..27ab201 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] drivers-platform-x86: use acpi_video_dmi_promote_vendor()
  2012-05-21  7:23 [PATCH 1/2] acpi: add a way to promote/demote vendor backlight drivers Corentin Chary
@ 2012-05-21  7:23 ` Corentin Chary
  2012-05-21 15:17   ` joeyli
  0 siblings, 1 reply; 3+ messages in thread
From: Corentin Chary @ 2012-05-21  7:23 UTC (permalink / raw)
  To: Len Brown
  Cc: Richard Purdie, platform-driver-x86, linux-acpi, Zhang Rui,
	Corentin Chary, Joey Lee, Matthew Garrett, Corentin Chary,
	linux-kernel

Instead of using directly acpi_video_unregister(), use
acpi_video_dmi_promote_vendor() (and make it call
acpi_video_unregister() if needed)

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
---
 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(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index c1a3fd8..a3f2f1b 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -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)) {
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index 6dcef4f..39e047d 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -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();
 }
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index e2a34b4..2cbccc1 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -26,7 +26,7 @@
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
 #include <linux/ctype.h>
-#if (defined CONFIG_ACPI_VIDEO || defined CONFIG_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 (defined CONFIG_ACPI_VIDEO || defined CONFIG_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
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] drivers-platform-x86: use acpi_video_dmi_promote_vendor()
  2012-05-21  7:23 ` [PATCH 2/2] drivers-platform-x86: use acpi_video_dmi_promote_vendor() Corentin Chary
@ 2012-05-21 15:17   ` joeyli
  0 siblings, 0 replies; 3+ messages in thread
From: joeyli @ 2012-05-21 15:17 UTC (permalink / raw)
  To: Corentin Chary
  Cc: Len Brown, Richard Purdie, platform-driver-x86, linux-acpi,
	Zhang Rui, Joey Lee, Matthew Garrett, Corentin Chary,
	linux-kernel

於 一,2012-05-21 於 09:23 +0200,Corentin Chary 提到:
> Instead of using directly acpi_video_unregister(), use
> acpi_video_dmi_promote_vendor() (and make it call
> acpi_video_unregister() if needed)
> 
> Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
> ---
>  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(-)
> 
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index c1a3fd8..a3f2f1b 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -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)) {


Acked-by: Lee, Chun-Yi <jlee@suse.com>


Thanks a lot!
Joey Lee

> diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
> index 6dcef4f..39e047d 100644
> --- a/drivers/platform/x86/apple-gmux.c
> +++ b/drivers/platform/x86/apple-gmux.c
> @@ -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();
>  }
> diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
> index e2a34b4..2cbccc1 100644
> --- a/drivers/platform/x86/samsung-laptop.c
> +++ b/drivers/platform/x86/samsung-laptop.c
> @@ -26,7 +26,7 @@
>  #include <linux/seq_file.h>
>  #include <linux/debugfs.h>
>  #include <linux/ctype.h>
> -#if (defined CONFIG_ACPI_VIDEO || defined CONFIG_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 (defined CONFIG_ACPI_VIDEO || defined CONFIG_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
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-21 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-21  7:23 [PATCH 1/2] acpi: add a way to promote/demote vendor backlight drivers Corentin Chary
2012-05-21  7:23 ` [PATCH 2/2] drivers-platform-x86: use acpi_video_dmi_promote_vendor() Corentin Chary
2012-05-21 15:17   ` joeyli

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).