From patchwork Mon Jan 30 12:45:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Woithe X-Patchwork-Id: 9545169 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 C208460417 for ; Mon, 30 Jan 2017 12:46:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7A2F25F31 for ; Mon, 30 Jan 2017 12:46:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C5BF2679B; Mon, 30 Jan 2017 12:46:38 +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 7EBF525F31 for ; Mon, 30 Jan 2017 12:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753177AbdA3Mqg (ORCPT ); Mon, 30 Jan 2017 07:46:36 -0500 Received: from server.atrad.com.au ([150.101.241.2]:51862 "EHLO server.atrad.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbdA3MqS (ORCPT ); Mon, 30 Jan 2017 07:46:18 -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 v0UCjFDv015534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jan 2017 23:15:17 +1030 Date: Mon, 30 Jan 2017 23:15:15 +1030 From: Jonathan Woithe To: kernel@kempniu.pl Cc: platform-driver-x86@vger.kernel.org Subject: [PATCH 3/4][RFC] fujitsu-laptop: autodetect lcd interface on unknown models Message-ID: <20170130124515.GF10561@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 (PROG_1 up to PROG_4) will be used as opposed to specific codes like KEY_HELP. Signed-off-by: Alan Jenkins Signed-off-by: Jonathan Woithe --- a/drivers/platform/x86/fujitsu-laptop.c 2017-01-30 22:41:22.976106164 +1030 +++ b/drivers/platform/x86/fujitsu-laptop.c 2017-01-30 22:41:04.736105860 +1030 @@ -161,6 +161,7 @@ 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 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_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_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 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 @@ 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 @@ 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);