Received: by 10.223.185.116 with SMTP id b49csp6078592wrg; Thu, 8 Mar 2018 01:12:03 -0800 (PST) X-Google-Smtp-Source: AG47ELvWy6QY+1tD3hDEWvNe1sgvfzRPCuOS5KZ7kw48Pq3bDHx+PT7KsXsN2wgH3HhRba77eFvU X-Received: by 10.99.166.10 with SMTP id t10mr20509228pge.198.1520500323628; Thu, 08 Mar 2018 01:12:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520500323; cv=none; d=google.com; s=arc-20160816; b=l82JN8SP2ZwN/qXXSLElYqKRGcxePrPVnKOpLo1kT0vAI5/n6U7o7BP7hq1AITgSPq M76odP/DunGL2DcVZYkQkh5fVbrvpGApGc7DdEt7nV+6XJGz091ijIKYH9xi0mrX9Wlz rKbwBcb6JPuOAJbO3W/wAGHVWvkE6m+XrQ62WdlktU+obsOuxLe27ooknYJJPZBwal17 aLIqZJZArzf/vvX3VRyBpP865CRzvTxtyXprFliah6r+UbRg4TRrMf3QwygKotFWeTeD rRoNr+uDoB4r2AfcpjRc01KV6SXs6mQsEQ+Y0CHwP+bR8smUgTe5COF/NOiL/X7QnKWF /zVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=bQ7V4VidW6HiXaqegk/OlG3yXU8VWivnrsV55xntGsk=; b=DQWe1uRv8XiEHAeamEaoRlCFXWy27SeiZ0hI81Zxf6x7m0j955M8UfBZ6W14JVV5z3 y9+cwkGPQeKz/hvkiPCJxnK5kX/6B2iM6P0wf+6F9B1f28gEltf/X5a/ifc4DuJCSzVw Y+/+poipoK6F/GL2STAI4k/pRLLp7YWjJslNxb02gGPPHO1cm1jZdaHck7u6IFNlFHk3 /k5AN6au0L8Hlv4RMDr7NieDKuQKro0aIkOc/fR48Ygw9Y1/DN/h2Y/Fd/3uj0uUwdlN me7VnpQLAcatpw9/7vw+v15GO7vJPHZHAzC3Ddgh8okeAr58DrYrwxJiRHAlNh8PwWaP 1J9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c200si15289899pfb.373.2018.03.08.01.11.49; Thu, 08 Mar 2018 01:12:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935040AbeCHJKl (ORCPT + 99 others); Thu, 8 Mar 2018 04:10:41 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:46094 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755461AbeCHJKi (ORCPT ); Thu, 8 Mar 2018 04:10:38 -0500 Received: from [175.41.48.77] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1etrZG-0003jY-PG; Thu, 08 Mar 2018 09:10:31 +0000 From: Kai-Heng Feng To: mjg59@srcf.ucam.org, pali.rohar@gmail.com, dvhart@infradead.org, andy@infradead.org, mario.limonciello@dell.com, tiwai@suse.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Kai-Heng Feng Subject: [PATCH v2 2/3] platform/x86: dell-*: Add interface for switchable graphics status query Date: Thu, 8 Mar 2018 17:10:22 +0800 Message-Id: <20180308091023.9061-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180308091023.9061-1-kai.heng.feng@canonical.com> References: <20180308091023.9061-1-kai.heng.feng@canonical.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some Dell platforms, there's a BIOS option "Enable Switchable Graphics". This information is useful if we want to do different things based on this value, e.g. disable unused audio controller that comes with the discrete graphics. Signed-off-by: Kai-Heng Feng --- v2: Mario suggested to squash the HDA part into the same series. Forgot to put dell_switchable_gfx_enabled() into header, so put it here. drivers/platform/x86/dell-laptop.c | 23 +++++++++++++++++++++++ drivers/platform/x86/dell-smbios.c | 2 ++ drivers/platform/x86/dell-smbios.h | 2 ++ include/linux/dell-common.h | 1 + 4 files changed, 28 insertions(+) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 8ba820e6c3d0..3f6fc07b8cf2 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -2116,6 +2116,29 @@ int dell_micmute_led_set(int state) } EXPORT_SYMBOL_GPL(dell_micmute_led_set); +int dell_switchable_gfx_enabled(bool *enabled) +{ + struct calling_interface_buffer buffer; + struct calling_interface_token *token; + int ret; + + *enabled = false; + + token = dell_smbios_find_token(SWITCHABLE_GRAPHICS_ENABLE); + if (!token) + return -ENODEV; + + dell_fill_request(&buffer, token->location, 0, 0, 0); + ret = dell_send_request(&buffer, CLASS_TOKEN_READ, SELECT_TOKEN_STD); + if (ret) + return ret; + + *enabled = !!buffer.output[1]; + + return 0; +} +EXPORT_SYMBOL_GPL(dell_switchable_gfx_enabled); + static int __init dell_init(void) { struct calling_interface_token *token; diff --git a/drivers/platform/x86/dell-smbios.c b/drivers/platform/x86/dell-smbios.c index 8541cde4cb7d..ca38b9d9dcf4 100644 --- a/drivers/platform/x86/dell-smbios.c +++ b/drivers/platform/x86/dell-smbios.c @@ -86,6 +86,8 @@ struct token_range { static struct token_range token_whitelist[] = { /* used by userspace: fwupdate */ {CAP_SYS_ADMIN, CAPSULE_EN_TOKEN, CAPSULE_DIS_TOKEN}, + /* can indicate to userspace Switchable Graphics enable status */ + {CAP_SYS_ADMIN, SWITCHABLE_GRAPHICS_ENABLE, SWITCHABLE_GRAPHICS_DISABLE}, /* can indicate to userspace that WMI is needed */ {0x0000, WSMT_EN_TOKEN, WSMT_DIS_TOKEN} }; diff --git a/drivers/platform/x86/dell-smbios.h b/drivers/platform/x86/dell-smbios.h index 138d478d9adc..b012d4abd239 100644 --- a/drivers/platform/x86/dell-smbios.h +++ b/drivers/platform/x86/dell-smbios.h @@ -37,6 +37,8 @@ #define KBD_LED_AUTO_100_TOKEN 0x02F6 #define GLOBAL_MIC_MUTE_ENABLE 0x0364 #define GLOBAL_MIC_MUTE_DISABLE 0x0365 +#define SWITCHABLE_GRAPHICS_ENABLE 0x037A +#define SWITCHABLE_GRAPHICS_DISABLE 0x037B struct notifier_block; diff --git a/include/linux/dell-common.h b/include/linux/dell-common.h index 37e4b614dd74..4435c5717388 100644 --- a/include/linux/dell-common.h +++ b/include/linux/dell-common.h @@ -3,5 +3,6 @@ #define __DELL_COMMON_H__ int dell_micmute_led_set(int on); +int dell_switchable_gfx_enabled(bool *enabled); #endif -- 2.15.1