From patchwork Thu Jul 7 23:38:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 9220047 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 20C8260574 for ; Fri, 8 Jul 2016 05:27:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12B6B2840D for ; Fri, 8 Jul 2016 05:27:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0780528412; Fri, 8 Jul 2016 05:27:03 +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 4F0DA2840D for ; Fri, 8 Jul 2016 05:27:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EE466E886; Fri, 8 Jul 2016 05:26:50 +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 E13E76E841; Fri, 8 Jul 2016 00:01:15 +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=Gi+D59OiNhHimzg4LrK5Z4ziXMyZT/GsYERU/v1YBZM=; b=mf4aqtmbQJjRXu8WGITOFv3W/GyvUyDgj6+tpKvCvxueK2nuGIzwe3sMc9Ka7AJZMEWbR+xrj15Oirk5Mzi8awtZKYK+5p5mcZ5U6hQTwhuxA31gic731v9AzStmTyTl+TmBcQx07eAFVi/vpyXZ8BZuFOjNcJ5mnrqS/k2UqdIshsIYAOYCrTEmSW925T0PEVHwjBIgCva3n/QBSlu5DGaXPtQJP/Fj9LD00UtJlPOG7VqZ1WppracOADCXLJ3bSwtnlb69sYjHPhctj8DB5opgeG4DVOP0pDS1rRPtZfJmikCRu5lo9ctIU82B++BUo5eNvoqyCOQZJfkRezk5pg==; Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bLIsh-0002VR-22; Fri, 08 Jul 2016 01:38:55 +0200 From: Peter Wu To: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/4] drm/nouveau/acpi: return supported DSM functions Date: Fri, 8 Jul 2016 01:38:25 +0200 Message-Id: <20160707233827.2100-3-peter@lekensteyn.nl> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160707233827.2100-1-peter@lekensteyn.nl> References: <20160707233827.2100-1-peter@lekensteyn.nl> X-Mailman-Approved-At: Fri, 08 Jul 2016 05:26:19 +0000 Cc: Dave Airlie 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. 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);