From patchwork Tue Dec 22 18:09:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 7906261 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D2A1FBEEE5 for ; Tue, 22 Dec 2015 18:10:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 050CE20439 for ; Tue, 22 Dec 2015 18:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10F9A2047B for ; Tue, 22 Dec 2015 18:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755368AbbLVSKS (ORCPT ); Tue, 22 Dec 2015 13:10:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754130AbbLVSKR (ORCPT ); Tue, 22 Dec 2015 13:10:17 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 77141C0B7E02; Tue, 22 Dec 2015 18:10:17 +0000 (UTC) Received: from localhost.localdomain.com (vpn1-4-127.ams2.redhat.com [10.36.4.127]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBMIA5Y5024421; Tue, 22 Dec 2015 13:10:12 -0500 From: Hans de Goede To: "Rafael J. Wysocki" , Zhang Rui , Len Brown , Darren Hart Cc: Corentin Chary , Henrique de Moraes Holschuh , =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, ibm-acpi-devel@lists.sourceforge.net, Hans de Goede Subject: [PATCH 1/5] acpi-video: Add a acpi_video_handles_brightness_key_presses() helper Date: Tue, 22 Dec 2015 19:09:48 +0100 Message-Id: <1450807792-4980-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1450807792-4980-1-git-send-email-hdegoede@redhat.com> References: <1450807792-4980-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Several drivers want to know if the acpi-video is generating key-presses for brightness change hotkeys to avoid sending double key-events to userspace for these. Currently these driver use this construct for this: if (acpi_video_get_backlight_type() == acpi_backlight_vendor) report_brightness_key_event(); This indirect way of detecting if acpi-video is active does not make the code easier to understand, and in some cases it is wrong because just because the preferred type != vendor does not mean that acpi-video is actually listening for brightness events, e.g. there may be no acpi-video bus on the system at all. This commit adds a acpi_video_handles_brightness_key_presses() helper function, making the code needing this functionality both easier to read and more correct. Signed-off-by: Hans de Goede --- drivers/acpi/acpi_video.c | 12 ++++++++++++ include/acpi/video.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 3405f7a..2a649f3e 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -2072,6 +2072,18 @@ void acpi_video_unregister_backlight(void) mutex_unlock(®ister_count_mutex); } +bool acpi_video_handles_brightness_key_presses(void) +{ + bool have_video_busses; + + mutex_lock(&video_list_lock); + have_video_busses = !list_empty(&video_bus_head); + mutex_unlock(&video_list_lock); + + return have_video_busses; +} +EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses); + /* * This is kind of nasty. Hardware using Intel chipsets may require * the video opregion code to be run first in order to initialise diff --git a/include/acpi/video.h b/include/acpi/video.h index c62392d..f11d342 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h @@ -2,6 +2,7 @@ #define __ACPI_VIDEO_H #include /* for ENODEV */ +#include /* for bool */ struct acpi_device; @@ -31,6 +32,7 @@ extern int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, void **edid); extern enum acpi_backlight_type acpi_video_get_backlight_type(void); extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type); +extern bool acpi_video_handles_brightness_key_presses(void); #else static inline int acpi_video_register(void) { return 0; } static inline void acpi_video_unregister(void) { return; } @@ -46,6 +48,10 @@ static inline enum acpi_backlight_type acpi_video_get_backlight_type(void) static inline void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type) { } +static inline bool acpi_video_handles_brightness_key_presses(void) +{ + return false; +} #endif #endif