From patchwork Thu Feb 22 19:58:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10236253 X-Patchwork-Delegate: dvhart@infradead.org 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 11AB1605CE for ; Thu, 22 Feb 2018 20:01:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0381728EA8 for ; Thu, 22 Feb 2018 20:01:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0179428F75; Thu, 22 Feb 2018 20:01:36 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 2C6C528EA8 for ; Thu, 22 Feb 2018 20:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbeBVT6w (ORCPT ); Thu, 22 Feb 2018 14:58:52 -0500 Received: from esa4.dell-outbound.iphmx.com ([68.232.149.214]:48154 "EHLO esa4.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbeBVT6v (ORCPT ); Thu, 22 Feb 2018 14:58:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1519329531; x=1550865531; h=from:to:cc:subject:date:message-id; bh=sMtwimO9Zy/vvKHGKlggucktPuIbl03uBSay3/Z3+2c=; b=zilCfitQHWkkuxG0tEr5tou6brR8Na74D4l23HlVgzapTOimLaqMkclt wPsGPtuESlSaAuTOYW1HbY1G3PAI0h3OE87DIushdG9upwmtGKlz6bCKC Pu4u8uUHV1P1jRggKFSSvnHzA+1kWe9B174f/k33lfznUb13dG1gdUn6O A=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2ErAwAoII9ah2Oa6ERcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYUlKH0DmwmDGIN2kliCFgo3hH2CMFYWAQIBAQEBAQECAQIQAQEBCgs?= =?us-ascii?q?JCCgvgjgkAYJ1Uk9vARKKI61MOoh3gkmFGYIngVeBZ4srgyIFinKIeJBVCYJOk?= =?us-ascii?q?0AClEACmCqBPCYCggJwgxKCBAFPEAyCJVmMaAEBAQ?= X-IPAS-Result: =?us-ascii?q?A2ErAwAoII9ah2Oa6ERcGgEBAQEBAgEBAQEIAQEBAYUlKH0?= =?us-ascii?q?DmwmDGIN2kliCFgo3hH2CMFYWAQIBAQEBAQECAQIQAQEBCgsJCCgvgjgkAYJ1U?= =?us-ascii?q?k9vARKKI61MOoh3gkmFGYIngVeBZ4srgyIFinKIeJBVCYJOk0AClEACmCqBPCY?= =?us-ascii?q?CggJwgxKCBAFPEAyCJVmMaAEBAQ?= Received: from esa6.dell-outbound2.iphmx.com ([68.232.154.99]) by esa4.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Feb 2018 13:58:51 -0600 Received: from ausxippc110.us.dell.com ([143.166.85.200]) by esa6.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2018 01:58:50 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.47,378,1515477600"; d="scan'208";a="621359774" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, Jeremy Cline , Alex Hung , Mario Limonciello Subject: [PATCH] platform/x86: Only activate tablet mode switch on 2-in-1's Date: Thu, 22 Feb 2018 13:58:42 -0600 Message-Id: <1519329522-16919-1-git-send-email-mario.limonciello@dell.com> X-Mailer: git-send-email 2.7.4 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 Some laptops such as the XPS 9360 support the intel-vbtn INT33D6 interface but don't initialize the bit that intel-vbtn uses to represent switching tablet mode. By running this only on real 2-in-1's it shouldn't cause false positives. Fixes: 30323fb6d5 ("Support tablet mode switch") Reported-by: Jeremy Cline Signed-off-by: Mario Limonciello Tested-by: Jeremy Cline --- Note: I also moved the code for detecting tablet into it's own function. To keep things under 80 lines with if statements was making the code very unreadable otherwise. drivers/platform/x86/intel-vbtn.c | 46 ++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index b703d6f..8173307 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -97,9 +98,35 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) dev_dbg(&device->dev, "unknown event index 0x%x\n", event); } -static int intel_vbtn_probe(struct platform_device *device) +static void detect_tablet_mode(struct platform_device *device) { + const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); + struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); + acpi_handle handle = ACPI_HANDLE(&device->dev); struct acpi_buffer vgbs_output = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + acpi_status status; + int m; + + if (!(chassis_type && strcmp(chassis_type, "31") == 0)) + goto out; + + status = acpi_evaluate_object(handle, "VGBS", NULL, &vgbs_output); + if (ACPI_FAILURE(status)) + goto out; + + obj = vgbs_output.pointer; + if (!(obj && obj->type == ACPI_TYPE_INTEGER)) + goto out; + + m = !(obj->integer.value & TABLET_MODE_FLAG); + input_report_switch(priv->input_dev, SW_TABLET_MODE, m); +out: + kfree(vgbs_output.pointer); +} + +static int intel_vbtn_probe(struct platform_device *device) +{ acpi_handle handle = ACPI_HANDLE(&device->dev); struct intel_vbtn_priv *priv; acpi_status status; @@ -122,22 +149,7 @@ static int intel_vbtn_probe(struct platform_device *device) return err; } - /* - * VGBS being present and returning something means we have - * a tablet mode switch. - */ - status = acpi_evaluate_object(handle, "VGBS", NULL, &vgbs_output); - if (ACPI_SUCCESS(status)) { - union acpi_object *obj = vgbs_output.pointer; - - if (obj && obj->type == ACPI_TYPE_INTEGER) { - int m = !(obj->integer.value & TABLET_MODE_FLAG); - - input_report_switch(priv->input_dev, SW_TABLET_MODE, m); - } - } - - kfree(vgbs_output.pointer); + detect_tablet_mode(device); status = acpi_install_notify_handler(handle, ACPI_DEVICE_NOTIFY,