From patchwork Tue Jan 31 13:09:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Woithe X-Patchwork-Id: 9547185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D734F60425 for ; Tue, 31 Jan 2017 13:09:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8D4F28334 for ; Tue, 31 Jan 2017 13:09:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC92C2838E; Tue, 31 Jan 2017 13:09:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5083C28334 for ; Tue, 31 Jan 2017 13:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752043AbdAaNJn (ORCPT ); Tue, 31 Jan 2017 08:09:43 -0500 Received: from server.atrad.com.au ([150.101.241.2]:52688 "EHLO server.atrad.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752119AbdAaNJk (ORCPT ); Tue, 31 Jan 2017 08:09:40 -0500 Received: from marvin.atrad.com.au (IDENT:1008@marvin.atrad.com.au [192.168.0.2]) by server.atrad.com.au (8.14.9/8.14.9) with ESMTP id v0VD9WuJ029246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 31 Jan 2017 23:39:33 +1030 Date: Tue, 31 Jan 2017 23:39:32 +1030 From: Jonathan Woithe To: kernel@kempniu.pl Cc: platform-driver-x86@vger.kernel.org Subject: [PATCH 3/4][RFC v2] fujitsu-laptop: fujitsu-laptop: autodetect lcd interface on unknown models Message-ID: <20170131130932.GD6218@marvin.atrad.com.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-MIMEDefang-action: accept X-Scanned-By: MIMEDefang 2.78 on 192.168.0.1 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do lcd autodetection for all models - not just the ones we have DMI matches for. Also, if we're running on an unknown model, inform the user that generic keycodes (KEY5_CODE up to KEY1_CODE) will be used as opposed to specific codes like KEY_HELP. Signed-off-by: Alan Jenkins Signed-off-by: Jonathan Woithe --- drivers/platform/x86/fujitsu-laptop.c | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index c410047..7167223 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -161,6 +161,7 @@ struct fujitsu_laptop { struct acpi_device *dev; struct input_dev *input; char phys[32]; + const char *dmi_ident; struct platform_device *pf_device; struct kfifo fifo; spinlock_t fifo_lock; @@ -615,23 +616,9 @@ static struct platform_driver fujitsu_pf_driver = { } }; -static void __init dmi_check_cb_common(const struct dmi_system_id *id) -{ - pr_info("Identified laptop model '%s'\n", id->ident); - if (use_alt_lcd_levels == -1) { - if (acpi_has_method(NULL, - "\\_SB.PCI0.LPCB.FJEX.SBL2")) - use_alt_lcd_levels = 1; - else - use_alt_lcd_levels = 0; - vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as " - "%i\n", use_alt_lcd_levels); - } -} - static int __init dmi_check_cb_s6410(const struct dmi_system_id *id) { - dmi_check_cb_common(id); + fujitsu_laptop->dmi_ident = id->ident; fujitsu_laptop->keycode1 = KEY_SCREENLOCK; /* "Lock" */ fujitsu_laptop->keycode2 = KEY_HELP; /* "Mobility Center" */ return 1; @@ -639,7 +626,7 @@ static int __init dmi_check_cb_s6410(const struct dmi_system_id *id) static int __init dmi_check_cb_s6420(const struct dmi_system_id *id) { - dmi_check_cb_common(id); + fujitsu_laptop->dmi_ident = id->ident; fujitsu_laptop->keycode1 = KEY_SCREENLOCK; /* "Lock" */ fujitsu_laptop->keycode2 = KEY_HELP; /* "Mobility Center" */ return 1; @@ -647,7 +634,7 @@ static int __init dmi_check_cb_s6420(const struct dmi_system_id *id) static int __init dmi_check_cb_p8010(const struct dmi_system_id *id) { - dmi_check_cb_common(id); + fujitsu_laptop->dmi_ident = id->ident; fujitsu_laptop->keycode1 = KEY_HELP; /* "Support" */ fujitsu_laptop->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */ fujitsu_laptop->keycode4 = KEY_WWW; /* "Internet" */ @@ -683,8 +670,8 @@ static const struct dmi_system_id fujitsu_laptop_dmi_table[] __initconst = { static int acpi_fujitsu_bl_add(struct acpi_device *device) { - int result = 0; int state = 0; + int result = 0; struct input_dev *input; int error; @@ -742,6 +729,16 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device) pr_err("_INI Method failed\n"); } + if (use_alt_lcd_levels == -1) { + if (acpi_has_method(NULL, + "\\_SB.PCI0.LPCB.FJEX.SBL2")) + use_alt_lcd_levels = 1; + else + use_alt_lcd_levels = 0; + vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as " + "%i\n", use_alt_lcd_levels); + } + /* do config (detect defaults) */ use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; @@ -877,11 +874,18 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); device->driver_data = fujitsu_laptop; - fujitsu_laptop->keycode1 = KEY_PROG1; - fujitsu_laptop->keycode2 = KEY_PROG2; - fujitsu_laptop->keycode3 = KEY_PROG3; - fujitsu_laptop->keycode4 = KEY_PROG4; - dmi_check_system(fujitsu_laptop_dmi_table); + if (dmi_check_system(fujitsu_laptop_dmi_table)) { + pr_info("Identified laptop model '%s'\n", + fujitsu_laptop->dmi_ident); + } else { + pr_info("fujitsu-laptop: Unknown laptop model" + " - using generic keycodes.\n"); + fujitsu_laptop->keycode1 = KEY1_CODE; + fujitsu_laptop->keycode2 = KEY2_CODE; + fujitsu_laptop->keycode3 = KEY3_CODE; + fujitsu_laptop->keycode4 = KEY4_CODE; + fujitsu_laptop->keycode5 = KEY5_CODE; + } /* kfifo */ spin_lock_init(&fujitsu_laptop->fifo_lock);