Linux ACPI
 help / color / mirror / Atom feed
* [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720
@ 2009-04-24  5:29 Zhang Rui
  2009-04-24  6:15 ` Len Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Rui @ 2009-04-24  5:29 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Zhang, Rui, maximlevitsky


On Acer Aspire 5720, _BQC always returns a value 9 smaller than
the actual brightness level.
Add dmi quirk for this laptop.
http://bugzilla.kernel.org/show_bug.cgi?id=13121

Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/video.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -87,6 +87,8 @@ static const struct acpi_device_id video
 };
 MODULE_DEVICE_TABLE(acpi, video_device_ids);
 
+static int bqc_offset;
+
 static struct acpi_driver acpi_video_bus = {
 	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
@@ -556,7 +558,8 @@ acpi_video_device_lcd_get_level_current(
 								 - 3 - (*level);
 				*level = device->brightness->levels[*level + 2];
 
-			}
+			} else if (bqc_offset)
+				*level += bqc_offset;
 			device->brightness->curr = *level;
 			return 0;
 		} else {
@@ -698,6 +701,29 @@ acpi_video_bus_DOS(struct acpi_video_bus
 	return status;
 }
 
+static int video_bqc_offset(const struct dmi_system_id *d)
+{
+	bqc_offset = 9;
+	return 0;
+}
+
+static struct dmi_system_id video_dmi_table[] __initdata = {
+	/*
+	 * Acer Aspire 5720 _BQC method is broken,
+	 * it always returns a value smaller than the actual brightness level
+	 * http://bugzilla.kernel.org/show_bug.cgi?id=13121
+	 */
+	{
+	 .callback = video_bqc_offset,
+	 .ident = "Acer Aspire 5720",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
+		},
+	},
+	{}
+};
+
 /*
  * Simple comparison function used to sort backlight levels.
  */
@@ -2287,6 +2313,8 @@ EXPORT_SYMBOL(acpi_video_register);
 
 static int __init acpi_video_init(void)
 {
+	dmi_check_system(video_dmi_table);
+
 	if (intel_opregion_present())
 		return 0;
 



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

* Re: [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720
  2009-04-24  5:29 [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720 Zhang Rui
@ 2009-04-24  6:15 ` Len Brown
  2009-04-24  6:40   ` Zhang Rui
  0 siblings, 1 reply; 4+ messages in thread
From: Len Brown @ 2009-04-24  6:15 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, maximlevitsky


On Fri, 24 Apr 2009, Zhang Rui wrote:

> 
> On Acer Aspire 5720, _BQC always returns a value 9 smaller than
> the actual brightness level.
> Add dmi quirk for this laptop.
> http://bugzilla.kernel.org/show_bug.cgi?id=13121
> 
> Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/video.c |   30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6/drivers/acpi/video.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/video.c
> +++ linux-2.6/drivers/acpi/video.c
> @@ -87,6 +87,8 @@ static const struct acpi_device_id video
>  };
>  MODULE_DEVICE_TABLE(acpi, video_device_ids);
>  
> +static int bqc_offset;
> +

are there other machines with a similar bqc_offset AML bug?

If no, then I'd rather this simple workaround be simpler
rather than be ready for a general case that will never happen...

in any case, the code/comments should be clear that
this is a hideoous workaround rather than how things
are supposed to work.  eg call it bqc_offset_idiotic_aml_workaround or 
something..

thanks,
-Len Brown, Intel Open Source Technology Center

>  static struct acpi_driver acpi_video_bus = {
>  	.name = "video",
>  	.class = ACPI_VIDEO_CLASS,
> @@ -556,7 +558,8 @@ acpi_video_device_lcd_get_level_current(
>  								 - 3 - (*level);
>  				*level = device->brightness->levels[*level + 2];
>  
> -			}
> +			} else if (bqc_offset)
> +				*level += bqc_offset;
>  			device->brightness->curr = *level;
>  			return 0;
>  		} else {
> @@ -698,6 +701,29 @@ acpi_video_bus_DOS(struct acpi_video_bus
>  	return status;
>  }
>  
> +static int video_bqc_offset(const struct dmi_system_id *d)
> +{
> +	bqc_offset = 9;
> +	return 0;
> +}
> +
> +static struct dmi_system_id video_dmi_table[] __initdata = {
> +	/*
> +	 * Acer Aspire 5720 _BQC method is broken,
> +	 * it always returns a value smaller than the actual brightness level
> +	 * http://bugzilla.kernel.org/show_bug.cgi?id=13121
> +	 */
> +	{
> +	 .callback = video_bqc_offset,
> +	 .ident = "Acer Aspire 5720",
> +	 .matches = {
> +		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
> +		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
> +		},
> +	},
> +	{}
> +};
> +
>  /*
>   * Simple comparison function used to sort backlight levels.
>   */
> @@ -2287,6 +2313,8 @@ EXPORT_SYMBOL(acpi_video_register);
>  
>  static int __init acpi_video_init(void)
>  {
> +	dmi_check_system(video_dmi_table);
> +
>  	if (intel_opregion_present())
>  		return 0;
>  
> 
> 
> --
> 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
> 

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

* Re: [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720
  2009-04-24  6:15 ` Len Brown
@ 2009-04-24  6:40   ` Zhang Rui
  2009-04-24 16:17     ` Len Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Rui @ 2009-04-24  6:40 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, maximlevitsky@gmail.com

On Fri, 2009-04-24 at 14:15 +0800, Len Brown wrote:
> On Fri, 24 Apr 2009, Zhang Rui wrote:
> 
> > 
> > On Acer Aspire 5720, _BQC always returns a value 9 smaller than
> > the actual brightness level.
> > Add dmi quirk for this laptop.
> > http://bugzilla.kernel.org/show_bug.cgi?id=13121
> > 
> > Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/acpi/video.c |   30 +++++++++++++++++++++++++++++-
> >  1 file changed, 29 insertions(+), 1 deletion(-)
> > 
> > Index: linux-2.6/drivers/acpi/video.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/acpi/video.c
> > +++ linux-2.6/drivers/acpi/video.c
> > @@ -87,6 +87,8 @@ static const struct acpi_device_id video
> >  };
> >  MODULE_DEVICE_TABLE(acpi, video_device_ids);
> >  
> > +static int bqc_offset;
> > +
> 
> are there other machines with a similar bqc_offset AML bug?
> 
well, the answer is no for now.

> If no, then I'd rather this simple workaround be simpler
> rather than be ready for a general case that will never happen...

I don't think there is any place that we could make the code simpler.

> 
> in any case, the code/comments should be clear that
> this is a hideoous workaround rather than how things
> are supposed to work.
>   eg call it bqc_offset_idiotic_aml_workaround or 
> something..

agree. refreshed patch attached.


On Acer Aspire 5720, _BQC always returns a value 9 smaller than
the actual brightness level.
Add dmi quirk for this laptop.
http://bugzilla.kernel.org/show_bug.cgi?id=13121

Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/video.c |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -87,6 +87,12 @@ static const struct acpi_device_id video
 };
 MODULE_DEVICE_TABLE(acpi, video_device_ids);
 
+/*
+ * For some buggy _BQC methods, we need to add a constant value to
+ * the _BQC return value to get the actual current brightness level
+ */
+static int bqc_offset_idiotic_aml_workaround;
+
 static struct acpi_driver acpi_video_bus = {
 	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
@@ -556,7 +562,8 @@ acpi_video_device_lcd_get_level_current(
 								 - 3 - (*level);
 				*level = device->brightness->levels[*level + 2];
 
-			}
+			} else if (bqc_offset_idiotic_aml_workaround)
+				*level += bqc_offset_idiotic_aml_workaround;
 			device->brightness->curr = *level;
 			return 0;
 		} else {
@@ -698,6 +705,29 @@ acpi_video_bus_DOS(struct acpi_video_bus
 	return status;
 }
 
+static int video_set_bqc_offset(const struct dmi_system_id *d)
+{
+	bqc_offset_idiotic_aml_workaround = 9;
+	return 0;
+}
+
+static struct dmi_system_id video_dmi_table[] __initdata = {
+	/*
+	 * Acer Aspire 5720 _BQC method is broken,
+	 * it always returns a value smaller than the actual brightness level
+	 * http://bugzilla.kernel.org/show_bug.cgi?id=13121
+	 */
+	{
+	 .callback = video_set_bqc_offset,
+	 .ident = "Acer Aspire 5720",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
+		},
+	},
+	{}
+};
+
 /*
  * Simple comparison function used to sort backlight levels.
  */
@@ -2287,6 +2317,8 @@ EXPORT_SYMBOL(acpi_video_register);
 
 static int __init acpi_video_init(void)
 {
+	dmi_check_system(video_dmi_table);
+
 	if (intel_opregion_present())
 		return 0;
 





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

* Re: [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720
  2009-04-24  6:40   ` Zhang Rui
@ 2009-04-24 16:17     ` Len Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Len Brown @ 2009-04-24 16:17 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, maximlevitsky@gmail.com

From: Zhang Rui <rui.zhang@intel.com>
Subject: [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720

On Acer Aspire 5720, _BQC always returns a value 9 smaller than
the actual brightness level.  Add dmi quirk for this laptop.

http://bugzilla.kernel.org/show_bug.cgi?id=13121

Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
we can add __init to video_set_bqc_offset

we can delete the flag used to guard the add, and simply add 0 on
non-workaround machines.

we can move the use up with the definition, say, like this?

thanks,
-Len


 drivers/acpi/video.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index cd4fb75..7e8ee49 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -538,6 +538,33 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
 	return -EINVAL;
 }
 
+/*
+ * For some buggy _BQC methods, we need to add a constant value to
+ * the _BQC return value to get the actual current brightness level
+ */
+
+static int bqc_offset_aml_bug_workaround;
+static int __init video_set_bqc_offset(const struct dmi_system_id *d)
+{
+	bqc_offset_aml_bug_workaround = 9;
+	return 0;
+}
+
+static struct dmi_system_id video_dmi_table[] __initdata = {
+	/*
+	 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
+	 */
+	{
+	 .callback = video_set_bqc_offset,
+	 .ident = "Acer Aspire 5720",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
+		},
+	},
+	{}
+};
+
 static int
 acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 					unsigned long long *level)
@@ -557,6 +584,7 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 				*level = device->brightness->levels[*level + 2];
 
 			}
+			*level += bqc_offset_aml_bug_workaround;
 			device->brightness->curr = *level;
 			return 0;
 		} else {
@@ -2287,6 +2315,8 @@ EXPORT_SYMBOL(acpi_video_register);
 
 static int __init acpi_video_init(void)
 {
+	dmi_check_system(video_dmi_table);
+
 	if (intel_opregion_present())
 		return 0;
 
-- 
1.6.3.rc1.51.gea0b7



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

end of thread, other threads:[~2009-04-24 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-24  5:29 [PATCH] ACPI video: dmi check for broken _BQC on Acer Aspire 5720 Zhang Rui
2009-04-24  6:15 ` Len Brown
2009-04-24  6:40   ` Zhang Rui
2009-04-24 16:17     ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox