From patchwork Fri May 23 12:50:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 4232211 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8B27A9F32B for ; Fri, 23 May 2014 12:51:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77BAC20108 for ; Fri, 23 May 2014 12:51:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DBDC203A9 for ; Fri, 23 May 2014 12:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752178AbaEWMux (ORCPT ); Fri, 23 May 2014 08:50:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24796 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751790AbaEWMuw (ORCPT ); Fri, 23 May 2014 08:50:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4NComIS017530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 May 2014 08:50:48 -0400 Received: from shalem.localdomain (vpn1-4-213.ams2.redhat.com [10.36.4.213]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4NCokom028792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 23 May 2014 08:50:47 -0400 Message-ID: <537F4425.70205@redhat.com> Date: Fri, 23 May 2014 14:50:45 +0200 From: Hans de Goede User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Lewis Toohey , Aaron Lu CC: linux-acpi@vger.kernel.org Subject: Re: Bug Report - [Acer Aspire V5-122P] Unable to adjust screen brightness References: <537BFF89.9010806@intel.com> <537C9DC5.5040408@intel.com> <537EA5B7.9050509@intel.com> In-Reply-To: X-Enigmail-Version: 1.6 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Lewis et all, On 05/23/2014 02:07 PM, Lewis Toohey wrote: > On 23 May 2014 02:34, Aaron Lu wrote: >> On 05/21/2014 09:02 PM, Lewis Toohey wrote: >>> Hi Aaron >>> >>> I followed your instructions and can report some limited success. I >>> have two interfaces listed in /sys/class/backlight namely: >>> acpi_video0 radeon_bl0 >>> >>> max_brightness for acpi_video0 is 11. Echo-ing new values to >>> brightness appears to have no effect. >>> >>> max_brightness for radeon_bl0 is 255. Echo-ing new values to >>> brightness does adjust the screen brightness as you would expect. >>> >>> Results are the same on both battery and powered. >>> >>> I hope that is useful. >> >> I think Hans' patchset should solve your problem, can you please give it >> a try? You will need to pass the video.use_native_backlight=1 to kernel >> cmdline when testing, thanks. >> >> [PATCH resend 0/4] Make video.use_native_backlight=1 work properly with nouveau >> http://www.spinics.net/lists/dri-devel/msg59941.html >> >> -Aaron > > Aaron > > Thank you for this. Unfortunately I am going to have to ask you for a > bit of help here as I am now, officially, "out of my depth". I > appreciate this is a pain as you will have to take time explaining it > to me and I apologise for that. > > I have figured out how to pass the kernel command line argument, this > is not an issue. > > I have located the patch you refer to here: > https://bugzilla.redhat.com/attachment.cgi?id=894577 > (which I believe is correct) but I cannot figure out how to apply it. That is not the right patch, you need a set of 2 patches. I've attached them to this mail. Note please ignore the numbering starting at 6, these are the 2 patches you need. You will need to build a Linux kernel with these 2 patches applied, see your distributions documentation on how to build a kernel from source. I don't know which distro you are using, I've a Fedora kernel with this patches included available here: http://people.fedoraproject.org/~jwrdegoede/rhbz1093171/ Regards, Hans From b865e1e6ef6e0abcc5b4084d854418ebf7cd7772 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 15 May 2014 15:50:20 +0200 Subject: [PATCH 7/8] acpi-video: Unregister the backlight device if a raw one shows up later When video.use_native_backlight=1 and non intel gfx are in use, the raw backlight device of the gfx driver will show up after acpi-video has done its acpi_video_verify_backlight_support() check. This causes video.use_native_backlight=1 to not have the desired result. This patch fixes this by adding a backlight notifier and when a raw backlight is registered or unregistered re-doing the acpi_video_verify_backlight_support() check. Signed-off-by: Hans de Goede --- drivers/acpi/video.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index aee85c4..123f919 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -151,6 +151,7 @@ struct acpi_video_enumerated_device { struct acpi_video_bus { struct acpi_device *device; bool backlight_registered; + bool backlight_notifier_registered; u8 dos_setting; struct acpi_video_enumerated_device *attached_array; u8 attached_count; @@ -162,6 +163,7 @@ struct acpi_video_bus { struct input_dev *input; char phys[32]; /* for input device */ struct notifier_block pm_nb; + struct notifier_block backlight_nb; }; struct acpi_video_device_flags { @@ -1836,6 +1838,9 @@ static int acpi_video_bus_register_backlight(struct acpi_video_bus *video) { struct acpi_video_device *dev; + if (video->backlight_registered) + return 0; + if (!acpi_video_verify_backlight_support()) return 0; @@ -1980,6 +1985,56 @@ static void acpi_video_bus_remove_notify_handler(struct acpi_video_bus *video) video->input = NULL; } +static int acpi_video_backlight_notify(struct notifier_block *nb, + unsigned long val, void *bd) +{ + struct backlight_device *backlight = bd; + struct acpi_video_bus *video; + + /* acpi_video_verify_backlight_support only cares about raw devices */ + if (backlight->props.type != BACKLIGHT_RAW) + return NOTIFY_DONE; + + video = container_of(nb, struct acpi_video_bus, backlight_nb); + + switch (val) { + case BACKLIGHT_REGISTERED: + if (!acpi_video_verify_backlight_support()) + acpi_video_bus_unregister_backlight(video); + break; + case BACKLIGHT_UNREGISTERED: + acpi_video_bus_register_backlight(video); + break; + } + + return NOTIFY_OK; +} + +static int acpi_video_bus_add_backlight_notify_handler( + struct acpi_video_bus *video) +{ + int error; + + video->backlight_nb.notifier_call = acpi_video_backlight_notify; + video->backlight_nb.priority = 0; + error = backlight_register_notifier(&video->backlight_nb); + if (error == 0) + video->backlight_notifier_registered = true; + + return error; +} + +static int acpi_video_bus_remove_backlight_notify_handler( + struct acpi_video_bus *video) +{ + if (!video->backlight_notifier_registered) + return 0; + + video->backlight_notifier_registered = false; + + return backlight_unregister_notifier(&video->backlight_nb); +} + static int acpi_video_bus_put_devices(struct acpi_video_bus *video) { struct acpi_video_device *dev, *next; @@ -2061,6 +2116,7 @@ static int acpi_video_bus_add(struct acpi_device *device) acpi_video_bus_register_backlight(video); acpi_video_bus_add_notify_handler(video); + acpi_video_bus_add_backlight_notify_handler(video); return 0; @@ -2084,6 +2140,7 @@ static int acpi_video_bus_remove(struct acpi_device *device) video = acpi_driver_data(device); + acpi_video_bus_remove_backlight_notify_handler(video); acpi_video_bus_remove_notify_handler(video); acpi_video_bus_unregister_backlight(video); acpi_video_bus_put_devices(video); -- 1.9.0