From patchwork Fri Jul 15 13:12:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 9234181 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 3511960756 for ; Mon, 18 Jul 2016 07:59:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 283D1212D9 for ; Mon, 18 Jul 2016 07:59:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D199254F7; Mon, 18 Jul 2016 07:59:09 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9C91212D9 for ; Mon, 18 Jul 2016 07:59:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 528B56E280; Mon, 18 Jul 2016 07:59:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.lekensteyn.nl (mail.lekensteyn.nl [IPv6:2a02:2308::360:1:25]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A14E6EA09; Fri, 15 Jul 2016 13:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lekensteyn.nl; s=s2048-2015-q1; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=c8aQR4pVNWeWbikpELbS2DoL2aUS8e5JgGHWn5i+2fY=; b=G8Go255Exlh7wevjrrI+uVygj7W9FnCtnAq8BBqCuShS00/ezKSNDDHn3mCtjMWyXJYrijjN/P17FRpOZRMxwrmPZj1hH0jgurYhRWKB7fwxyN08na7KeKbw+gxGich6JV7kHFrsYYX3hwqAUOL3febThRlpqxRUq901AOAfz0uzZGrF+kIdUYakluylva4CIgu4EwUboykndx5gBNRjyNChlmIaWehQOF4b1xxW21lYZKydWfAaLsQJdRxaRd9fABrJdEq4j6N5/BOB8nDn2bOSHuKgr+PW0X5aiRWAKFN/KPwP5JXbhYjZVQUelU7b9UlQRN6/7bLWSDCLCJhdVQ==; Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bO2vB-0002AX-PB; Fri, 15 Jul 2016 15:12:50 +0200 From: Peter Wu To: Dave Airlie Subject: [PATCH v3 2/4] drm/nouveau/acpi: return supported DSM functions Date: Fri, 15 Jul 2016 15:12:16 +0200 Message-Id: <20160715131218.2416-3-peter@lekensteyn.nl> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160715131218.2416-1-peter@lekensteyn.nl> References: <20160715131218.2416-1-peter@lekensteyn.nl> X-Mailman-Approved-At: Mon, 18 Jul 2016 07:54:40 +0000 Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Return the set of supported functions to the caller. No functional changes. Reviewed-by: Hans de Goede Signed-off-by: Peter Wu --- drivers/gpu/drm/nouveau/nouveau_acpi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index 886a67c..572ac30 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -107,7 +107,7 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t * * requirements on the fourth parameter, so a private implementation * instead of using acpi_check_dsm(). */ -static int nouveau_check_optimus_dsm(acpi_handle handle) +static int nouveau_dsm_get_optimus_functions(acpi_handle handle) { int result; @@ -122,7 +122,9 @@ static int nouveau_check_optimus_dsm(acpi_handle handle) * ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. * If the n-th bit is enabled, function n is supported */ - return result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS); + if (result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS)) + return result; + return 0; } static int nouveau_dsm(acpi_handle handle, int func, int arg) @@ -214,7 +216,7 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out { acpi_handle dhandle; bool supports_mux; - bool supports_opt; + int optimus_funcs; dhandle = ACPI_HANDLE(&pdev->dev); if (!dhandle) @@ -225,17 +227,17 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out supports_mux = acpi_check_dsm(dhandle, nouveau_dsm_muid, 0x00000102, 1 << NOUVEAU_DSM_POWER); - supports_opt = nouveau_check_optimus_dsm(dhandle); + optimus_funcs = nouveau_dsm_get_optimus_functions(dhandle); /* Does not look like a Nvidia device. */ - if (!supports_mux && !supports_opt) + if (!supports_mux && !optimus_funcs) return; *dhandle_out = dhandle; *has_mux = supports_mux; - *has_opt = supports_opt; + *has_opt = !!optimus_funcs; - if (supports_opt) { + if (optimus_funcs) { uint32_t result; nouveau_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0, &result);