From patchwork Tue Sep 26 17:15:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13399421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2D707E7E656 for ; Tue, 26 Sep 2023 17:16:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 85F5E10E407; Tue, 26 Sep 2023 17:16:04 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F61F10E41A for ; Tue, 26 Sep 2023 17:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695748563; x=1727284563; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pJoa+1qQ6yRE8YaxmdNh8e+yQhpksPntX86DgSljQ00=; b=FDhEQEdRREidms0m2KIZjq7bSHYEm1fIez6WZL5hwuhwd4wWT/d3I2m/ BYGBc4iB1A+6AtruItOwGq91bj+a1Src9quzI5MsRJjGQ/FXyFXSXyBLX YSGBIXa9keOLcJsMf4aiUHsuQTXnPFKnyGn/WBYOWnWzWQ94yM1kJGCUU cuwD2U2swWAA+aRlOGCnKQVMsbjONv92uXQrMaQ9Q8+1IDlqm/tKvcJ4X yAUia4ecZTacgK7szzSoNXYZ3ggK0Ag5arq9SILQAkBK+Ng8gV2QVZkRQ 8TW9DPvFq9VJvCsYNAnnFcRKaJhkeMvdR03OiGpLTa5ps/Kt/FtnsgkxT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="385469018" X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="385469018" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 10:15:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="232788" Received: from wagnert-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.52.202]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 10:15:23 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Sep 2023 20:15:41 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [RFC 1/3] drm/i915: rough ideas for further separating display code from the rest X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, matthew.d.roper@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Long term goal: Separate display code from struct drm_i915_private and i915_drv.h, and everything in them. First step, draft some ideas how we could use struct intel_display as the main device structure for display, while struct drm_device remains in struct drm_i915_private (or, in the case of xe, in struct xe_device). To get at struct drm_device * given a struct intel_display *, simply store a backpointer. To get at struct intel_display * given a struct drm_device *, require storing a struct intel_display * right after struct drm_device in memory. It's slightly hackish, but devm_drm_dev_alloc() facilitates defining the enclosing struct as we wish. Signed-off-by: Jani Nikula --- .../gpu/drm/i915/display/intel_display_core.h | 16 ++++++++++++++++ .../gpu/drm/i915/display/intel_display_device.c | 13 +++++++++++++ drivers/gpu/drm/i915/i915_drv.h | 11 ++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h index 53e5c33e08c3..a5463a9b5f54 100644 --- a/drivers/gpu/drm/i915/display/intel_display_core.h +++ b/drivers/gpu/drm/i915/display/intel_display_core.h @@ -14,6 +14,7 @@ #include #include +#include #include #include "intel_cdclk.h" @@ -267,6 +268,9 @@ struct intel_wm { }; struct intel_display { + /* drm device backpointer */ + struct drm_device *drm; + /* Display functions */ struct { /* Top level crtc-ish functions */ @@ -521,4 +525,16 @@ struct intel_display { struct intel_wm wm; }; +/* FIXME: could be placed somewhere else to avoid drm/drm_device.h include */ +static inline struct intel_display *to_intel_display(const struct drm_device *drm) +{ + /* + * Assume there's a pointer to struct intel_display in memory right + * after struct drm_device. + */ + struct intel_display **p = (struct intel_display **)(drm + 1); + + return *p; +} + #endif /* __INTEL_DISPLAY_CORE_H__ */ diff --git a/drivers/gpu/drm/i915/display/intel_display_device.c b/drivers/gpu/drm/i915/display/intel_display_device.c index a6a18eae7ae8..b90da136ac65 100644 --- a/drivers/gpu/drm/i915/display/intel_display_device.c +++ b/drivers/gpu/drm/i915/display/intel_display_device.c @@ -921,6 +921,19 @@ void intel_display_device_probe(struct drm_i915_private *i915) const struct intel_display_device_info *info; u16 ver, rel, step; + /* + * These are here for now to do them as early as possible. i915 has just + * been allocated, drm isn't even initialized yet, but we have the + * pointer. + * + * Later on, the display probe would allocate struct intel_display + * itself, and return the pointer to the caller, for whom struct + * intel_display would be an opaque type, a cookie to be passed on to + * display functions. + */ + i915->__intel_display_private = &i915->display; + i915->display.drm = &i915->drm; + if (HAS_GMD_ID(i915)) info = probe_gmdid_display(i915, &ver, &rel, &step); else diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 511eba3bbdba..10770fb5f429 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -193,7 +193,16 @@ struct i915_selftest_stash { }; struct drm_i915_private { - struct drm_device drm; + struct { + struct drm_device drm; + + /* + * Display private data. Do *not* access directly. Must be + * placed right after drm_device to facilitate getting to it + * given a drm device pointer. + */ + struct intel_display *__intel_display_private; + } __packed; struct intel_display display; From patchwork Tue Sep 26 17:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13399422 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9703BE7E656 for ; Tue, 26 Sep 2023 17:16:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2470E10E40B; Tue, 26 Sep 2023 17:16:09 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30B7710E411 for ; Tue, 26 Sep 2023 17:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695748566; x=1727284566; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8Z7cf++iAUW/Xs+/qbBgoAw6A+taNlFxwXYdlH7c4qY=; b=jr9O8PujaF+OwGKTNfrUZ08ZrY0hzW/D9msB4MQ+Jzspz5i8R+XMbHWk xiRM7N8bBTGGPAAJk/L5xiKISbA9mxmpRT8A2pVhclKsDxfq718dY+HCv V9WG7K8Z4CoFxCN9H2h2coOsXEapICfv6lW/cffeZySjiNR4wf4HBacLR fQbzXq7wusTOwDIPNnBkqHrPqpqCGc7vWZJ6jERHZERzf6FRQINr/5M3I v1ULVOESmsmVoXxOO/2sCU3fVOEkarBx8pTKjZwd0/l09VwTAe79ziKzf 26ZiDAuOSoUCK5DsK+6PEiU/vWv/+F6PXu4SKVQyFtfvRkAOtwv1BKd1F Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="378899715" X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="378899715" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 10:16:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="778207937" X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="778207937" Received: from wagnert-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.52.202]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 10:15:58 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Sep 2023 20:15:42 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [RFC 2/3] drm/i915/hdmi: drafting what struct intel_display usage would look like X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, matthew.d.roper@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_hdmi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index af4102e91769..f06d57b386c0 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -64,6 +64,11 @@ inline struct drm_i915_private *intel_hdmi_to_i915(struct intel_hdmi *intel_hdmi return to_i915(hdmi_to_dig_port(intel_hdmi)->base.base.dev); } +static inline struct intel_display *intel_hdmi_to_display(struct intel_hdmi *intel_hdmi) +{ + return to_intel_display(hdmi_to_dig_port(intel_hdmi)->base.base.dev); +} + static void assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) { @@ -1239,16 +1244,16 @@ static void hsw_set_infoframes(struct intel_encoder *encoder, void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable) { - struct drm_i915_private *dev_priv = intel_hdmi_to_i915(hdmi); + struct intel_display *display = intel_hdmi_to_display(hdmi); struct i2c_adapter *ddc = hdmi->attached_connector->base.ddc; if (hdmi->dp_dual_mode.type < DRM_DP_DUAL_MODE_TYPE2_DVI) return; - drm_dbg_kms(&dev_priv->drm, "%s DP dual mode adaptor TMDS output\n", + drm_dbg_kms(display->drm, "%s DP dual mode adaptor TMDS output\n", enable ? "Enabling" : "Disabling"); - drm_dp_dual_mode_set_tmds_output(&dev_priv->drm, + drm_dp_dual_mode_set_tmds_output(display->drm, hdmi->dp_dual_mode.type, ddc, enable); } From patchwork Tue Sep 26 17:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13399423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 87A45E7E65B for ; Tue, 26 Sep 2023 17:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 093A110E411; Tue, 26 Sep 2023 17:16:12 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7990A10E40B for ; Tue, 26 Sep 2023 17:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695748567; x=1727284567; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g2RRfU0sW4otM5Q7TbKfEduyzIfOYegrhHwREJUfmM4=; b=nmyHp1wPnQ+0VUe7oVIUttHjT2PyRRkBaZFrwPd/QSI3O+oHleWEB6hE w0qlSfGe2jTV7TnZV+Ypz7hSN7VzlHV8C2tr4Y+p2WwjRTO9d8pZP6Pki WqsxmnYeq/d/R+/ySJHBFXs4YdQf43B3heByKl2SUc7UNkK5oEgjysisZ bANbpHt25YbwgvC+vHfTKhGzD4x9U588ZL04WFge+8AU6i8tt09ABjrTy 4iTM96jJNKo8u6JTdNbjxOZrTfJg4Dl3hf+492TBfxBj4pO3/7+92Zm/+ mfdvWOHJxbV+hOV49r3blBgw0IDNAWSrSYQMBIZAi0xmR4kplaJrPMjXo w==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="378899732" X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="378899732" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 10:16:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="778207985" X-IronPort-AV: E=Sophos;i="6.03,178,1694761200"; d="scan'208";a="778207985" Received: from wagnert-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.52.202]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 10:16:04 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Sep 2023 20:15:43 +0300 Message-Id: <10dccccf2afa8910049ea5a761f0e8e9ea58fbaf.1695747484.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [RFC 3/3] drm/i915: draft what feature test macros would look like X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, matthew.d.roper@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Obviously they'd be without underscore prefix. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_display_device.h | 4 ++++ drivers/gpu/drm/i915/display/intel_hdmi.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_device.h b/drivers/gpu/drm/i915/display/intel_display_device.h index 44733c9d5812..4738d7c59703 100644 --- a/drivers/gpu/drm/i915/display/intel_display_device.h +++ b/drivers/gpu/drm/i915/display/intel_display_device.h @@ -32,6 +32,10 @@ struct drm_printer; func(overlay_needs_physical); \ func(supports_tv); +#define _DISPLAY_INFO(display) ((display)->info.__device_info) +#define _DISPLAY_RUNTIME_INFO(display) (&(display)->info.__runtime_info) +#define _HAS_DDI(display) (_DISPLAY_INFO(display)->has_ddi) + #define HAS_4TILE(i915) (IS_DG2(i915) || DISPLAY_VER(i915) >= 14) #define HAS_ASYNC_FLIPS(i915) (DISPLAY_VER(i915) >= 5) #define HAS_CDCLK_CRAWL(i915) (DISPLAY_INFO(i915)->has_cdclk_crawl) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index f06d57b386c0..efc398ad1b67 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -2583,9 +2583,9 @@ static const struct drm_connector_funcs intel_hdmi_connector_funcs = { static int intel_hdmi_connector_atomic_check(struct drm_connector *connector, struct drm_atomic_state *state) { - struct drm_i915_private *i915 = to_i915(state->dev); + struct intel_display *display = to_intel_display(state->dev); - if (HAS_DDI(i915)) + if (_HAS_DDI(display)) return intel_digital_connector_atomic_check(connector, state); else return g4x_hdmi_connector_atomic_check(connector, state);