linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods
@ 2007-09-03 12:29 Alexey Starikovskiy
  2007-09-03 12:30 ` [PATCH 2/2] ACPI: VIDEO: Adjust current level to closest available one Alexey Starikovskiy
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Alexey Starikovskiy @ 2007-09-03 12:29 UTC (permalink / raw)
  To: Thomas Tuttle, linux-acpi, lenb

Signed-off-by: Ryan May <rmay@ou.edu>
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---

 drivers/acpi/video.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 3c9bb85..83aa41c 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
 static int
 acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
 {
-	int status;
+	int status = AE_OK;
 	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
 	struct acpi_object_list args = { 1, &arg0 };
 
 
 	arg0.integer.value = level;
-	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
-
+	if (device->cap._BCM)
+		status = acpi_evaluate_object(device->dev->handle, "_BCM",
+					      &args, NULL);
+	device->brightness->curr = level;
 	printk(KERN_DEBUG "set_level status: %x\n", status);
 	return status;
 }
@@ -425,11 +427,11 @@ static int
 acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 					unsigned long *level)
 {
-	int status;
-
-	status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
-
-	return status;
+	if (device->cap._BQC)
+		return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
+					     level);
+	*level = device->brightness->curr;
+	return AE_OK;
 }
 
 static int


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

* [PATCH 2/2] ACPI: VIDEO: Adjust current level to closest available one.
  2007-09-03 12:29 [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Alexey Starikovskiy
@ 2007-09-03 12:30 ` Alexey Starikovskiy
  2007-09-03 14:49 ` [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Len Brown
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Alexey Starikovskiy @ 2007-09-03 12:30 UTC (permalink / raw)
  To: Thomas Tuttle, linux-acpi, lenb

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---

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

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 83aa41c..8a60a3d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1636,9 +1636,20 @@ static int
 acpi_video_get_next_level(struct acpi_video_device *device,
 			  u32 level_current, u32 event)
 {
-	int min, max, min_above, max_below, i, l;
+	int min, max, min_above, max_below, i, l, delta = 255;
 	max = max_below = 0;
 	min = min_above = 255;
+	/* Find closest level to level_current */
+	for (i = 0; i < device->brightness->count; i++) {
+		l = device->brightness->levels[i];
+		if (abs(l - level_current) < abs(delta)) {
+			delta = l - level_current;
+			if (!delta)
+				break;
+		}
+	}
+	/* Ajust level_current to closest available level */
+	level_current += delta;
 	for (i = 0; i < device->brightness->count; i++) {
 		l = device->brightness->levels[i];
 		if (l < min)


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

* Re: [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods
  2007-09-03 12:29 [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Alexey Starikovskiy
  2007-09-03 12:30 ` [PATCH 2/2] ACPI: VIDEO: Adjust current level to closest available one Alexey Starikovskiy
@ 2007-09-03 14:49 ` Len Brown
  2007-09-03 15:15   ` Alexey Starikovskiy
  2007-09-14 14:01 ` Ryan May
  2007-10-02 13:22 ` Ryan May
  3 siblings, 1 reply; 7+ messages in thread
From: Len Brown @ 2007-09-03 14:49 UTC (permalink / raw)
  To: Alexey Starikovskiy; +Cc: Thomas Tuttle, linux-acpi

Is it a good idea to return AE_OK when no operation was actually performed?

-Len

On Monday 03 September 2007 08:29, Alexey Starikovskiy wrote:
> Signed-off-by: Ryan May <rmay@ou.edu>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
> 
>  drivers/acpi/video.c |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
> index 3c9bb85..83aa41c 100644
> --- a/drivers/acpi/video.c
> +++ b/drivers/acpi/video.c
> @@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
>  static int
>  acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
>  {
> -	int status;
> +	int status = AE_OK;
>  	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
>  	struct acpi_object_list args = { 1, &arg0 };
>  
>  
>  	arg0.integer.value = level;
> -	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
> -
> +	if (device->cap._BCM)
> +		status = acpi_evaluate_object(device->dev->handle, "_BCM",
> +					      &args, NULL);
> +	device->brightness->curr = level;
>  	printk(KERN_DEBUG "set_level status: %x\n", status);
>  	return status;
>  }
> @@ -425,11 +427,11 @@ static int
>  acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
>  					unsigned long *level)
>  {
> -	int status;
> -
> -	status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
> -
> -	return status;
> +	if (device->cap._BQC)
> +		return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
> +					     level);
> +	*level = device->brightness->curr;
> +	return AE_OK;
>  }
>  
>  static int
> 
> -
> 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] 7+ messages in thread

* Re: [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods
  2007-09-03 14:49 ` [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Len Brown
@ 2007-09-03 15:15   ` Alexey Starikovskiy
  0 siblings, 0 replies; 7+ messages in thread
From: Alexey Starikovskiy @ 2007-09-03 15:15 UTC (permalink / raw)
  To: Len Brown; +Cc: Alexey Starikovskiy, Thomas Tuttle, linux-acpi

Len Brown wrote:
> Is it a good idea to return AE_OK when no operation was actually performed?
There is a write into device->brightness->curr, so _some_ operation was performed.
Do you suggest any other error code?

Alex
> 
> -Len
> 
> On Monday 03 September 2007 08:29, Alexey Starikovskiy wrote:
>> Signed-off-by: Ryan May <rmay@ou.edu>
>> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
>> ---
>>
>>  drivers/acpi/video.c |   18 ++++++++++--------
>>  1 files changed, 10 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
>> index 3c9bb85..83aa41c 100644
>> --- a/drivers/acpi/video.c
>> +++ b/drivers/acpi/video.c
>> @@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
>>  static int
>>  acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
>>  {
>> -	int status;
>> +	int status = AE_OK;
>>  	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
>>  	struct acpi_object_list args = { 1, &arg0 };
>>  
>>  
>>  	arg0.integer.value = level;
>> -	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
>> -
>> +	if (device->cap._BCM)
>> +		status = acpi_evaluate_object(device->dev->handle, "_BCM",
>> +					      &args, NULL);
>> +	device->brightness->curr = level;
>>  	printk(KERN_DEBUG "set_level status: %x\n", status);
>>  	return status;
>>  }
>> @@ -425,11 +427,11 @@ static int
>>  acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
>>  					unsigned long *level)
>>  {
>> -	int status;
>> -
>> -	status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
>> -
>> -	return status;
>> +	if (device->cap._BQC)
>> +		return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
>> +					     level);
>> +	*level = device->brightness->curr;
>> +	return AE_OK;
>>  }
>>  
>>  static int
>>
>> -
>> 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
>>
> -
> 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] 7+ messages in thread

* Re: [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods
  2007-09-03 12:29 [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Alexey Starikovskiy
  2007-09-03 12:30 ` [PATCH 2/2] ACPI: VIDEO: Adjust current level to closest available one Alexey Starikovskiy
  2007-09-03 14:49 ` [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Len Brown
@ 2007-09-14 14:01 ` Ryan May
  2007-10-02 13:22 ` Ryan May
  3 siblings, 0 replies; 7+ messages in thread
From: Ryan May @ 2007-09-14 14:01 UTC (permalink / raw)
  To: linux-acpi

What's the status of this particular patch?

Ryan

Alexey Starikovskiy wrote:
> Signed-off-by: Ryan May <rmay@ou.edu>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
> 
>  drivers/acpi/video.c |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
> index 3c9bb85..83aa41c 100644
> --- a/drivers/acpi/video.c
> +++ b/drivers/acpi/video.c
> @@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
>  static int
>  acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
>  {
> -	int status;
> +	int status = AE_OK;
>  	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
>  	struct acpi_object_list args = { 1, &arg0 };
>  
>  
>  	arg0.integer.value = level;
> -	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
> -
> +	if (device->cap._BCM)
> +		status = acpi_evaluate_object(device->dev->handle, "_BCM",
> +					      &args, NULL);
> +	device->brightness->curr = level;
>  	printk(KERN_DEBUG "set_level status: %x\n", status);
>  	return status;
>  }
> @@ -425,11 +427,11 @@ static int
>  acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
>  					unsigned long *level)
>  {
> -	int status;
> -
> -	status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
> -
> -	return status;
> +	if (device->cap._BQC)
> +		return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
> +					     level);
> +	*level = device->brightness->curr;
> +	return AE_OK;
>  }
>  
>  static int
> 
> -
> 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
> 
> 


-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

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

* Re: [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods
  2007-09-03 12:29 [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Alexey Starikovskiy
                   ` (2 preceding siblings ...)
  2007-09-14 14:01 ` Ryan May
@ 2007-10-02 13:22 ` Ryan May
  2007-10-02 15:52   ` Alexey Starikovskiy
  3 siblings, 1 reply; 7+ messages in thread
From: Ryan May @ 2007-10-02 13:22 UTC (permalink / raw)
  To: Alexey Starikovskiy; +Cc: Thomas Tuttle, linux-acpi, lenb

Hi,

What's the status of this patch?  AFAICT, it hasn't been applied
upstream anywhere.  This fixes the problems on my HP dv2125nr with the
new BIOS, so I'd really like to see it merged.

Thanks,

Ryan

Alexey Starikovskiy wrote:
> Signed-off-by: Ryan May <rmay@ou.edu>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
> 
>  drivers/acpi/video.c |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
> index 3c9bb85..83aa41c 100644
> --- a/drivers/acpi/video.c
> +++ b/drivers/acpi/video.c
> @@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
>  static int
>  acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
>  {
> -	int status;
> +	int status = AE_OK;
>  	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
>  	struct acpi_object_list args = { 1, &arg0 };
>  
>  
>  	arg0.integer.value = level;
> -	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
> -
> +	if (device->cap._BCM)
> +		status = acpi_evaluate_object(device->dev->handle, "_BCM",
> +					      &args, NULL);
> +	device->brightness->curr = level;
>  	printk(KERN_DEBUG "set_level status: %x\n", status);
>  	return status;
>  }
> @@ -425,11 +427,11 @@ static int
>  acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
>  					unsigned long *level)
>  {
> -	int status;
> -
> -	status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
> -
> -	return status;
> +	if (device->cap._BQC)
> +		return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
> +					     level);
> +	*level = device->brightness->curr;
> +	return AE_OK;
>  }
>  
>  static int
> 
> -
> 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
> 
> 


-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

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

* Re: [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods
  2007-10-02 13:22 ` Ryan May
@ 2007-10-02 15:52   ` Alexey Starikovskiy
  0 siblings, 0 replies; 7+ messages in thread
From: Alexey Starikovskiy @ 2007-10-02 15:52 UTC (permalink / raw)
  To: Ryan May; +Cc: Alexey Starikovskiy, Thomas Tuttle, linux-acpi, lenb

Ryan,
It is in queue for 2.6.24... Too late for .23

Regards,
Alex.
Ryan May wrote:
> Hi,
> 
> What's the status of this patch?  AFAICT, it hasn't been applied
> upstream anywhere.  This fixes the problems on my HP dv2125nr with the
> new BIOS, so I'd really like to see it merged.
> 
> Thanks,
> 
> Ryan
> 
> Alexey Starikovskiy wrote:
>> Signed-off-by: Ryan May <rmay@ou.edu>
>> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
>> ---
>>
>>  drivers/acpi/video.c |   18 ++++++++++--------
>>  1 files changed, 10 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
>> index 3c9bb85..83aa41c 100644
>> --- a/drivers/acpi/video.c
>> +++ b/drivers/acpi/video.c
>> @@ -409,14 +409,16 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
>>  static int
>>  acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
>>  {
>> -	int status;
>> +	int status = AE_OK;
>>  	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
>>  	struct acpi_object_list args = { 1, &arg0 };
>>  
>>  
>>  	arg0.integer.value = level;
>> -	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
>> -
>> +	if (device->cap._BCM)
>> +		status = acpi_evaluate_object(device->dev->handle, "_BCM",
>> +					      &args, NULL);
>> +	device->brightness->curr = level;
>>  	printk(KERN_DEBUG "set_level status: %x\n", status);
>>  	return status;
>>  }
>> @@ -425,11 +427,11 @@ static int
>>  acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
>>  					unsigned long *level)
>>  {
>> -	int status;
>> -
>> -	status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
>> -
>> -	return status;
>> +	if (device->cap._BQC)
>> +		return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
>> +					     level);
>> +	*level = device->brightness->curr;
>> +	return AE_OK;
>>  }
>>  
>>  static int
>>
>> -
>> 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] 7+ messages in thread

end of thread, other threads:[~2007-10-02 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-03 12:29 [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Alexey Starikovskiy
2007-09-03 12:30 ` [PATCH 2/2] ACPI: VIDEO: Adjust current level to closest available one Alexey Starikovskiy
2007-09-03 14:49 ` [PATCH 1/2] [PATCH] ACPI: video: Don't call absent methods Len Brown
2007-09-03 15:15   ` Alexey Starikovskiy
2007-09-14 14:01 ` Ryan May
2007-10-02 13:22 ` Ryan May
2007-10-02 15:52   ` Alexey Starikovskiy

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