From patchwork Mon Nov 4 19:41:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11228359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E191139A for ; Tue, 5 Nov 2019 17:53:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75FDD217F5 for ; Tue, 5 Nov 2019 17:53:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75FDD217F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E56CF6EB36; Tue, 5 Nov 2019 17:53:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B430896AF for ; Mon, 4 Nov 2019 19:41:53 +0000 (UTC) Received: by mail-pl1-x649.google.com with SMTP id v2so11212670plp.14 for ; Mon, 04 Nov 2019 11:41:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3VArYdzuhYZ5F7lzuhgwCdAuyaphVwUyvDoIU6FlqsQ=; b=V7EDxPWwPOVtjse+3JC+60miATGbj10tjn/FWCFRxrky8epm0lIra4a1b+lPZnt6IV gHk2BaqmmhC0oA5ezlxhauwwspUfSU3F73jeIBkypR29g8iJhfnD8IbpzBmqGmdgvLZz Uec/ioHTyeKkvKAs5GPb8GqYAoPhVzANNzIlenKcB/B9fWO/tChrke8OI6Ybm1geWnj8 3gvaOeYfgxoOs4fR+UeNeWW2nG631/1kdHMiKPoQ7Xs4Svvx/XEJhchnznGeCM/2JVBA 8W8Fh8oK+YZtkXp+iyJJHdt0YLOL0sW3TVQZg2h9228SUGDC0UyMAdnmAYohMYgsghoZ ifag== X-Gm-Message-State: APjAAAVCy/xx6zcUSjJImvecve2vzHe+Mmt+vpJsp1Zuq6T6WdpbjvHf Ry7Gka+kK2kA9WB+Hj4kTjmCBW0EclLK X-Google-Smtp-Source: APXvYqzgyJKX/aMK/PCesa/JZEFUnHC+1EnTiVopo5JDa033eb7ODBNtkyHZnqytRQQWMtuqBDosgK+6/LRl X-Received: by 2002:a63:1c10:: with SMTP id c16mr30979864pgc.183.1572896512467; Mon, 04 Nov 2019 11:41:52 -0800 (PST) Date: Mon, 4 Nov 2019 11:41:45 -0800 In-Reply-To: <20191023001206.15741-1-rajatja@google.com> Message-Id: <20191104194147.185642-1-rajatja@google.com> Mime-Version: 1.0 References: <20191023001206.15741-1-rajatja@google.com> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog From: Rajat Jain To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , " =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= " , Chris Wilson , Imre Deak , " =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= " , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org, mathewk@google.com, Daniel Thompson , Jonathan Corbet , Pavel Machek , seanpaul@google.com, Duncan Laurie , jsbarnes@google.com, Thierry Reding X-Mailman-Approved-At: Tue, 05 Nov 2019 17:53:45 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3VArYdzuhYZ5F7lzuhgwCdAuyaphVwUyvDoIU6FlqsQ=; b=T5uKi/m7kOXDbQheqvsINWaygZIAlT7klsFKc8D9sd2E5YTaoR+mABMHRMkacGBYQk TEeJ3xc2lNA7+zQEWB2APhBk67PDsVThT/qB5bti/4GmYGPYBlYQgQ/YgSXT7FGeJ6jT zCIABfGkVqhvJXDyO9dHfXcqQj5qMqYgGshJ3CWrdRfFaRNrWgSwBaut6SaVN8hubDUC 6DQzIiA5sBYokHALDfa7gOnf+8hxTpdT1pqiueGDmIp5rA1AS5VB5k00iSFnsfFCE8gX MoKY+znZF0NNfaAqA2D9JReZ/spsiGyR0hBuXAPTegztfQT6fUAjlvfQf4E9ORdtoN8y rzmg== Subject: [Intel-gfx] [PATCH v2 1/3] drm/i915: Move the code to populate ACPI device ID into intel_acpi X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rajat Jain , rajatxjain@gmail.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move the code that populates the ACPI device ID for devices, into more appripriate intel_acpi.c. This is done in preparation for more users of this code (in next patch). Signed-off-by: Rajat Jain Change-Id: Ifb3bd458734985c2a78ba682e6f0a2e63e0626ca --- v2: v1 doesn't exist. Found existing code in i915 driver to assign the ACPI ID which is what I plan to re-use. drivers/gpu/drm/i915/display/intel_acpi.c | 87 +++++++++++++++++++ drivers/gpu/drm/i915/display/intel_acpi.h | 6 ++ drivers/gpu/drm/i915/display/intel_opregion.c | 80 +---------------- 3 files changed, 97 insertions(+), 76 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c index 3456d33feb46..748d9b3125dd 100644 --- a/drivers/gpu/drm/i915/display/intel_acpi.c +++ b/drivers/gpu/drm/i915/display/intel_acpi.c @@ -156,3 +156,90 @@ void intel_register_dsm_handler(void) void intel_unregister_dsm_handler(void) { } + +/* + * ACPI Specification, Revision 5.0, Appendix B.3.2 _DOD (Enumerate All Devices + * Attached to the Display Adapter). + */ +#define ACPI_DISPLAY_INDEX_SHIFT 0 +#define ACPI_DISPLAY_INDEX_MASK (0xf << 0) +#define ACPI_DISPLAY_PORT_ATTACHMENT_SHIFT 4 +#define ACPI_DISPLAY_PORT_ATTACHMENT_MASK (0xf << 4) +#define ACPI_DISPLAY_TYPE_SHIFT 8 +#define ACPI_DISPLAY_TYPE_MASK (0xf << 8) +#define ACPI_DISPLAY_TYPE_OTHER (0 << 8) +#define ACPI_DISPLAY_TYPE_VGA (1 << 8) +#define ACPI_DISPLAY_TYPE_TV (2 << 8) +#define ACPI_DISPLAY_TYPE_EXTERNAL_DIGITAL (3 << 8) +#define ACPI_DISPLAY_TYPE_INTERNAL_DIGITAL (4 << 8) +#define ACPI_VENDOR_SPECIFIC_SHIFT 12 +#define ACPI_VENDOR_SPECIFIC_MASK (0xf << 12) +#define ACPI_BIOS_CAN_DETECT (1 << 16) +#define ACPI_DEPENDS_ON_VGA (1 << 17) +#define ACPI_PIPE_ID_SHIFT 18 +#define ACPI_PIPE_ID_MASK (7 << 18) +#define ACPI_DEVICE_ID_SCHEME (1ULL << 31) + +static u32 acpi_display_type(struct intel_connector *connector) +{ + u32 display_type; + + switch (connector->base.connector_type) { + case DRM_MODE_CONNECTOR_VGA: + case DRM_MODE_CONNECTOR_DVIA: + display_type = ACPI_DISPLAY_TYPE_VGA; + break; + case DRM_MODE_CONNECTOR_Composite: + case DRM_MODE_CONNECTOR_SVIDEO: + case DRM_MODE_CONNECTOR_Component: + case DRM_MODE_CONNECTOR_9PinDIN: + case DRM_MODE_CONNECTOR_TV: + display_type = ACPI_DISPLAY_TYPE_TV; + break; + case DRM_MODE_CONNECTOR_DVII: + case DRM_MODE_CONNECTOR_DVID: + case DRM_MODE_CONNECTOR_DisplayPort: + case DRM_MODE_CONNECTOR_HDMIA: + case DRM_MODE_CONNECTOR_HDMIB: + display_type = ACPI_DISPLAY_TYPE_EXTERNAL_DIGITAL; + break; + case DRM_MODE_CONNECTOR_LVDS: + case DRM_MODE_CONNECTOR_eDP: + case DRM_MODE_CONNECTOR_DSI: + display_type = ACPI_DISPLAY_TYPE_INTERNAL_DIGITAL; + break; + case DRM_MODE_CONNECTOR_Unknown: + case DRM_MODE_CONNECTOR_VIRTUAL: + display_type = ACPI_DISPLAY_TYPE_OTHER; + break; + default: + MISSING_CASE(connector->base.connector_type); + display_type = ACPI_DISPLAY_TYPE_OTHER; + break; + } + + return display_type; +} + +void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) +{ + struct intel_connector *connector; + struct drm_connector_list_iter conn_iter; + u8 display_index[16] = {}; + u32 device_id, type; + + /* Populate the ACPI IDs for all connectors for a given drm_device */ + drm_connector_list_iter_begin(drm_dev, &conn_iter); + for_each_intel_connector_iter(connector, &conn_iter) { + + device_id = acpi_display_type(connector); + + /* Use display type specific display index. */ + type = (device_id & ACPI_DISPLAY_TYPE_MASK) + >> ACPI_DISPLAY_TYPE_SHIFT; + device_id |= display_index[type]++ << ACPI_DISPLAY_INDEX_SHIFT; + + connector->acpi_device_id = device_id; + } + drm_connector_list_iter_end(&conn_iter); +} diff --git a/drivers/gpu/drm/i915/display/intel_acpi.h b/drivers/gpu/drm/i915/display/intel_acpi.h index 1c576b3fb712..8f6d850df6fa 100644 --- a/drivers/gpu/drm/i915/display/intel_acpi.h +++ b/drivers/gpu/drm/i915/display/intel_acpi.h @@ -6,12 +6,18 @@ #ifndef __INTEL_ACPI_H__ #define __INTEL_ACPI_H__ +#include "intel_display_types.h" + #ifdef CONFIG_ACPI void intel_register_dsm_handler(void); void intel_unregister_dsm_handler(void); +void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev); #else static inline void intel_register_dsm_handler(void) { return; } static inline void intel_unregister_dsm_handler(void) { return; } +static inline void +static inline void +intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) { } #endif /* CONFIG_ACPI */ #endif /* __INTEL_ACPI_H__ */ diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index 969ade623691..f5976a6ab3c4 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -35,6 +35,7 @@ #include "display/intel_panel.h" #include "i915_drv.h" +#include "intel_acpi.h" #include "intel_display_types.h" #include "intel_opregion.h" @@ -242,29 +243,6 @@ struct opregion_asle_ext { #define SWSCI_SBCB_POST_VBE_PM SWSCI_FUNCTION_CODE(SWSCI_SBCB, 19) #define SWSCI_SBCB_ENABLE_DISABLE_AUDIO SWSCI_FUNCTION_CODE(SWSCI_SBCB, 21) -/* - * ACPI Specification, Revision 5.0, Appendix B.3.2 _DOD (Enumerate All Devices - * Attached to the Display Adapter). - */ -#define ACPI_DISPLAY_INDEX_SHIFT 0 -#define ACPI_DISPLAY_INDEX_MASK (0xf << 0) -#define ACPI_DISPLAY_PORT_ATTACHMENT_SHIFT 4 -#define ACPI_DISPLAY_PORT_ATTACHMENT_MASK (0xf << 4) -#define ACPI_DISPLAY_TYPE_SHIFT 8 -#define ACPI_DISPLAY_TYPE_MASK (0xf << 8) -#define ACPI_DISPLAY_TYPE_OTHER (0 << 8) -#define ACPI_DISPLAY_TYPE_VGA (1 << 8) -#define ACPI_DISPLAY_TYPE_TV (2 << 8) -#define ACPI_DISPLAY_TYPE_EXTERNAL_DIGITAL (3 << 8) -#define ACPI_DISPLAY_TYPE_INTERNAL_DIGITAL (4 << 8) -#define ACPI_VENDOR_SPECIFIC_SHIFT 12 -#define ACPI_VENDOR_SPECIFIC_MASK (0xf << 12) -#define ACPI_BIOS_CAN_DETECT (1 << 16) -#define ACPI_DEPENDS_ON_VGA (1 << 17) -#define ACPI_PIPE_ID_SHIFT 18 -#define ACPI_PIPE_ID_MASK (7 << 18) -#define ACPI_DEVICE_ID_SCHEME (1 << 31) - #define MAX_DSLP 1500 static int swsci(struct drm_i915_private *dev_priv, @@ -662,54 +640,12 @@ static void set_did(struct intel_opregion *opregion, int i, u32 val) } } -static u32 acpi_display_type(struct intel_connector *connector) -{ - u32 display_type; - - switch (connector->base.connector_type) { - case DRM_MODE_CONNECTOR_VGA: - case DRM_MODE_CONNECTOR_DVIA: - display_type = ACPI_DISPLAY_TYPE_VGA; - break; - case DRM_MODE_CONNECTOR_Composite: - case DRM_MODE_CONNECTOR_SVIDEO: - case DRM_MODE_CONNECTOR_Component: - case DRM_MODE_CONNECTOR_9PinDIN: - case DRM_MODE_CONNECTOR_TV: - display_type = ACPI_DISPLAY_TYPE_TV; - break; - case DRM_MODE_CONNECTOR_DVII: - case DRM_MODE_CONNECTOR_DVID: - case DRM_MODE_CONNECTOR_DisplayPort: - case DRM_MODE_CONNECTOR_HDMIA: - case DRM_MODE_CONNECTOR_HDMIB: - display_type = ACPI_DISPLAY_TYPE_EXTERNAL_DIGITAL; - break; - case DRM_MODE_CONNECTOR_LVDS: - case DRM_MODE_CONNECTOR_eDP: - case DRM_MODE_CONNECTOR_DSI: - display_type = ACPI_DISPLAY_TYPE_INTERNAL_DIGITAL; - break; - case DRM_MODE_CONNECTOR_Unknown: - case DRM_MODE_CONNECTOR_VIRTUAL: - display_type = ACPI_DISPLAY_TYPE_OTHER; - break; - default: - MISSING_CASE(connector->base.connector_type); - display_type = ACPI_DISPLAY_TYPE_OTHER; - break; - } - - return display_type; -} - static void intel_didl_outputs(struct drm_i915_private *dev_priv) { struct intel_opregion *opregion = &dev_priv->opregion; struct intel_connector *connector; struct drm_connector_list_iter conn_iter; int i = 0, max_outputs; - int display_index[16] = {}; /* * In theory, did2, the extended didl, gets added at opregion version @@ -721,20 +657,12 @@ static void intel_didl_outputs(struct drm_i915_private *dev_priv) max_outputs = ARRAY_SIZE(opregion->acpi->didl) + ARRAY_SIZE(opregion->acpi->did2); + intel_populate_acpi_ids_for_all_connectors(&dev_priv->drm); + drm_connector_list_iter_begin(&dev_priv->drm, &conn_iter); for_each_intel_connector_iter(connector, &conn_iter) { - u32 device_id, type; - - device_id = acpi_display_type(connector); - - /* Use display type specific display index. */ - type = (device_id & ACPI_DISPLAY_TYPE_MASK) - >> ACPI_DISPLAY_TYPE_SHIFT; - device_id |= display_index[type]++ << ACPI_DISPLAY_INDEX_SHIFT; - - connector->acpi_device_id = device_id; if (i < max_outputs) - set_did(opregion, i, device_id); + set_did(opregion, i, connector->acpi_device_id); i++; } drm_connector_list_iter_end(&conn_iter); From patchwork Mon Nov 4 19:41:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11228361 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5113A1390 for ; Tue, 5 Nov 2019 17:53:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38E97217F5 for ; Tue, 5 Nov 2019 17:53:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38E97217F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 438836EB38; Tue, 5 Nov 2019 17:53:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-vk1-xa4a.google.com (mail-vk1-xa4a.google.com [IPv6:2607:f8b0:4864:20::a4a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8026F89BB0 for ; Mon, 4 Nov 2019 19:41:56 +0000 (UTC) Received: by mail-vk1-xa4a.google.com with SMTP id o144so8297453vko.13 for ; Mon, 04 Nov 2019 11:41:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Hw2kwOv7aHvONVhhCWMO8y6YePHkYT17+TPLWVMLRSU=; b=n9MDZh1+QtNujP/48TU58jjdxGDRk1+xfgrTVG+oLG+xeLTS5TbYHCUBcUv5SSlw76 uAY0NhTUc5FUJu3HvvYbCCWXLMv86pqgrmnGjUbFkbKLjdzvwZnnxi5dTbc5CIzbrLi2 DfBfRVrZg4IIDlZzpnI9hTlyvwPvQ2ql2bE3mqoUP9StZpCgqqyaPWbCrfCnNJJj7biP FkNNif9B09ch++m0RYQfjfN08s9yEXT56nH/OAY3yMW0eZktl7OJJToTXZ0rKWhzCLfP 94kVr7MZI8vySDrdP695fxKnV7caXA9GR2ViLe8nMoPUet7XkeXfn1UWDtNRKRZ5bxaZ areg== X-Gm-Message-State: APjAAAXfg8mmCN0kDkbXW3zzo4B5tDuPSEbEK1cVibM8KDRaTM2cOJam 5dT5uZus72/axZXTe+zRPNCFDjgbhOOm X-Google-Smtp-Source: APXvYqwb6j34OVjZAiDyjhBEmZpq85fuYsMFGZ6t/xrnw1a7t9N7/et8lPSVl8i0rq89wRb09CV6muZzyUlz X-Received: by 2002:a1f:accb:: with SMTP id v194mr12398929vke.24.1572896515242; Mon, 04 Nov 2019 11:41:55 -0800 (PST) Date: Mon, 4 Nov 2019 11:41:46 -0800 In-Reply-To: <20191104194147.185642-1-rajatja@google.com> Message-Id: <20191104194147.185642-2-rajatja@google.com> Mime-Version: 1.0 References: <20191023001206.15741-1-rajatja@google.com> <20191104194147.185642-1-rajatja@google.com> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog From: Rajat Jain To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , " =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= " , Chris Wilson , Imre Deak , " =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= " , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org, mathewk@google.com, Daniel Thompson , Jonathan Corbet , Pavel Machek , seanpaul@google.com, Duncan Laurie , jsbarnes@google.com, Thierry Reding X-Mailman-Approved-At: Tue, 05 Nov 2019 17:53:45 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Hw2kwOv7aHvONVhhCWMO8y6YePHkYT17+TPLWVMLRSU=; b=RsgJREjB0mlFsau8SHnepZumZUcVdUKubJ1bNzsWBi+9P2bPsQpu3xr7xsCEvCoqRQ 36Q65eYrYtvRFamazrB6URSmqgrn+LooJpHOXrYLGxQ1m9gl2oqkbtITwPAchypEDGSD RGDMaxeKlpiNfsjI7VLXJTn426oaMj7lP+7/TdyWPC3jmd6WHydcWRn3mrNuiiIdyqTV hjPMI3VdfrI8VkoGlHs5AJB+BDUMQIV2lajUz1bQNyjEdA4TsT5cdmRm6YpDXO8T8q/n VT5ge8M6qgX7Rd78Hxo6y4AX7g2BIqIbX3xAGz8ixGOVlUBE5+4hAjHHZVQLC1mQlGlJ gg4Q== Subject: [Intel-gfx] [PATCH v2 2/3] drm/i915: Lookup and attach ACPI device node for connectors X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rajat Jain , rajatxjain@gmail.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Lookup and attach ACPI nodes for intel connectors. The lookup is done in compliance with ACPI Spec 6.3 https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf (Ref: Pages 1119 - 1123). This can be useful for any connector specific platform properties. (This will be used for privacy screen in next patch). Signed-off-by: Rajat Jain Change-Id: I798e70714a4402554c8cd2a8e58268353f75814f --- v2: formed by splitting the original patch into ACPI lookup, and privacy screen property. Also move it into i915 now that I found existing code in i915 that can be re-used. drivers/gpu/drm/i915/display/intel_acpi.c | 50 +++++++++++++++++++ drivers/gpu/drm/i915/display/intel_acpi.h | 4 +- .../drm/i915/display/intel_display_types.h | 3 ++ drivers/gpu/drm/i915/display/intel_dp.c | 4 ++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c index 748d9b3125dd..0c10516430b1 100644 --- a/drivers/gpu/drm/i915/display/intel_acpi.c +++ b/drivers/gpu/drm/i915/display/intel_acpi.c @@ -243,3 +243,53 @@ void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) } drm_connector_list_iter_end(&conn_iter); } + +/* + * Ref: ACPI Spec 6.3 + * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf + * Pages 1119 - 1123 describe, what I believe, a standard way of + * identifying / addressing "display panels" in the ACPI. It provides + * a way for the ACPI to define devices for the display panels attached + * to the system. It thus provides a way for the BIOS to export any panel + * specific properties to the system via ACPI (like device trees). + * + * The following functions looks up the ACPI node for a connector and returns + * it. Technically it is independent from the i915 code, and + * ideally may be called for all connectors. It is generally a good idea to + * be able to attach an ACPI node to describe anything if needed. (This can + * help in future for other panel specific features maybe). However, it + * needs an acpi device ID which is build using an index within a particular + * type of port (Ref to the pages of spec mentioned above, and to code in + * intel_populate_acpi_ids_for_all_connectors()). This device index + * unfortunately is not available in DRM code, so currently its call is + * originated from i915 driver. If in future this is useful for other drivers + * and we can find a generic way of getting a device index, we should move this + * function to drm code, maybe. + */ +void intel_connector_lookup_acpi_node(struct intel_connector *intel_connector) +{ + struct drm_device *drm_dev = intel_connector->base.dev; + struct device *dev = &drm_dev->pdev->dev; + struct acpi_device *conn_dev; + u64 conn_addr; + + /* + * Repopulate ACPI IDs for all connectors is needed because the display + * index may have changed as a result of hotplugging and unplugging + * connectors + */ + intel_populate_acpi_ids_for_all_connectors(drm_dev); + + /* Build the _ADR to look for */ + conn_addr = intel_connector->acpi_device_id; + conn_addr |= ACPI_DEVICE_ID_SCHEME; + conn_addr |= ACPI_BIOS_CAN_DETECT; + + DRM_DEV_INFO(dev, "Looking for connector ACPI node at _ADR=%llX\n", + conn_addr); + + /* Look up the connector device, under the PCI device */ + conn_dev = acpi_find_child_device(ACPI_COMPANION(dev), conn_addr, + false); + intel_connector->acpi_handle = conn_dev ? conn_dev->handle : NULL; +} diff --git a/drivers/gpu/drm/i915/display/intel_acpi.h b/drivers/gpu/drm/i915/display/intel_acpi.h index 8f6d850df6fa..61a4392fac4a 100644 --- a/drivers/gpu/drm/i915/display/intel_acpi.h +++ b/drivers/gpu/drm/i915/display/intel_acpi.h @@ -9,14 +9,16 @@ #include "intel_display_types.h" #ifdef CONFIG_ACPI +void intel_connector_lookup_acpi_node(struct intel_connector *connector); void intel_register_dsm_handler(void); void intel_unregister_dsm_handler(void); void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev); #else +static inline void +intel_connector_lookup_acpi_node(struct intel_connector *connector) { return; } static inline void intel_register_dsm_handler(void) { return; } static inline void intel_unregister_dsm_handler(void) { return; } static inline void -static inline void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) { } #endif /* CONFIG_ACPI */ diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 449abaea619f..c2706afc069b 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -400,6 +400,9 @@ struct intel_connector { /* ACPI device id for ACPI and driver cooperation */ u32 acpi_device_id; + /* ACPI handle corresponding to this connector display, if found */ + void *acpi_handle; + /* Reads out the current hw, returning true if the connector is enabled * and active (i.e. dpms ON state). */ bool (*get_hw_state)(struct intel_connector *); diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index f865615172a5..4fac408a4299 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -45,6 +45,7 @@ #include "i915_debugfs.h" #include "i915_drv.h" #include "i915_trace.h" +#include "intel_acpi.h" #include "intel_atomic.h" #include "intel_audio.h" #include "intel_connector.h" @@ -6333,6 +6334,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect { struct drm_i915_private *dev_priv = to_i915(connector->dev); enum port port = dp_to_dig_port(intel_dp)->base.port; + struct intel_connector *intel_connector = to_intel_connector(connector); if (!IS_G4X(dev_priv) && port != PORT_A) intel_attach_force_audio_property(connector); @@ -6354,6 +6356,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT; + /* Lookup the ACPI node corresponding to the connector */ + intel_connector_lookup_acpi_node(intel_connector); } }