From patchwork Mon Apr 25 06:46:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12825324 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 C12C6C433FE for ; Mon, 25 Apr 2022 06:48:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCA6F1120A2; Mon, 25 Apr 2022 06:48:43 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8763310FF6B; Mon, 25 Apr 2022 06:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650869318; x=1682405318; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5ZULeZBk30F36WOKNvaXiUTU57I7g9fsai/DL3eQxUY=; b=IpYgyLEeV8SZXIzK7fAqWEdHBuDSyplRLoRoZOw1Nxbex3lDMsvk0lRS /d6IwJwZtegsOELr3cX9m/8p8kuhAS4Q6b2rprvhvCBacxS9Xa9Pe7Nv7 2UU9WdVs9O0zVCfnZscEj3PQfB0WgrdK+GFlYY5CY8CHHrvNyx4LaYBxS 7FZ10taKQoJbzutEbJf6sGC0TCgLfOynJnjS2Afq97C9Z6ecczZt0g9QL QVOWxdGbPD5pWqqYiaDcj9f7fJkExFc/PyNiKWg6Fv5MYv43Stv5RZkZU aGxp8vUCcv2b8ILGMv6ONyZ6tAwP1GjAy/UAiP8pFcBbVFSgC4fKOepQ9 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10327"; a="265325797" X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="265325797" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 23:48:38 -0700 X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="616385901" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 23:48:36 -0700 From: Bhanuprakash Modem To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ville.syrjala@linux.intel.com, manasi.d.navare@intel.com Subject: [RFC v2 1/2] drm/vrr: Attach vrr_enabled property to the drm crtc Date: Mon, 25 Apr 2022 12:16:11 +0530 Message-Id: <20220425064612.2993587-2-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220425064612.2993587-1-bhanuprakash.modem@intel.com> References: <20220425064612.2993587-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Kazlauskas , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Modern display hardware is capable of supporting variable refresh rates. This patch introduces helpers to attach and set "vrr_enabled" property on the crtc to allow userspace to query VRR enabled status on that crtc. Atomic drivers should attach this property to crtcs those are capable of driving variable refresh rates using drm_mode_crtc_attach_vrr_enabled_property(). The value should be updated based on driver and hardware capability by using drm_mode_crtc_set_vrr_enabled_property(). V2: Use property flag as atomic Cc: Ville Syrjälä Cc: Nicholas Kazlauskas Cc: Manasi Navare Cc: Harry Wentland Signed-off-by: Bhanuprakash Modem --- drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_mode_config.c | 2 +- include/drm/drm_crtc.h | 4 +++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 26a77a735905..95b4a0c7ecb3 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -883,3 +883,47 @@ int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc, return 0; } EXPORT_SYMBOL(drm_crtc_create_scaling_filter_property); + +/** + * drm_mode_crtc_attach_vrr_enabled_property - attaches the vrr_enabled property + * @crtc: drm CRTC to attach the vrr_enabled property on. + * + * This is used by atomic drivers to add support for querying + * VRR enabled status for a crtc. + */ +void drm_mode_crtc_attach_vrr_enabled_property(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct drm_mode_config *config = &dev->mode_config; + + if (!config->prop_vrr_enabled) + return; + + drm_object_attach_property(&crtc->base, + config->prop_vrr_enabled, + 0); +} +EXPORT_SYMBOL(drm_mode_crtc_attach_vrr_enabled_property); + +/** + * drm_mode_crtc_set_vrr_enabled_property - sets the vrr enabled property for + * a crtc. + * @crtc: drm CRTC + * @vrr_enabled: True to enable the VRR on CRTC + * + * Should be used by atomic drivers to update the VRR enabled status on a CRTC + */ +void drm_mode_crtc_set_vrr_enabled_property(struct drm_crtc *crtc, + bool vrr_enabled) +{ + struct drm_device *dev = crtc->dev; + struct drm_mode_config *config = &dev->mode_config; + + if (!config->prop_vrr_enabled) + return; + + drm_object_property_set_value(&crtc->base, + config->prop_vrr_enabled, + vrr_enabled); +} +EXPORT_SYMBOL(drm_mode_crtc_set_vrr_enabled_property); diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 37b4b9f0e468..b7cde73d5586 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -323,7 +323,7 @@ static int drm_mode_create_standard_properties(struct drm_device *dev) return -ENOMEM; dev->mode_config.prop_mode_id = prop; - prop = drm_property_create_bool(dev, 0, + prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC, "VRR_ENABLED"); if (!prop) return -ENOMEM; diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index a70baea0636c..bde657cb0f9e 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1333,4 +1333,8 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc, unsigned int supported_filters); +void drm_mode_crtc_attach_vrr_enabled_property(struct drm_crtc *crtc); +void drm_mode_crtc_set_vrr_enabled_property(struct drm_crtc *crtc, + bool vrr_enabled); + #endif /* __DRM_CRTC_H__ */ From patchwork Mon Apr 25 06:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12825325 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 56FEEC433EF for ; Mon, 25 Apr 2022 06:48:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 153D01122B0; Mon, 25 Apr 2022 06:48:44 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 987F510FF6B; Mon, 25 Apr 2022 06:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650869320; x=1682405320; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JyYi2/M8SAEwYhIYIJnEazvXfR+ni1R3cjWWjdBz8xE=; b=PGGTVhnBbmK4V6+uZ9vyx/JXEv/7OmkQNNFpwDGXDFGOPCkD6KJy9EuB Zx5PJg4lqDbzPOB0SQKVOJ70/uaDHGSIYc0iEAclRZ/3mUcygGjtTNUiP 7N07qEEBXzlgS8t+VSyMdWAKO1MCiWJ6fg65UIsbMPq6hgWLkFJ6cMv6P jMcwSnhnEeeFuBSGmf/QLE4AHSmQQPFAYKoRfiZh/abCYHn9SdgrtBBAf bquDkR/zo8AD59vHbSnavD1XRzly+/UKh+kSWRTO9Aht+8O/wxca7tHya qz/W0J/SMzQBx051aHKPZ4h9FZ90naKLWegHkn8LvuCTxKAPdv/9lwd2h g==; X-IronPort-AV: E=McAfee;i="6400,9594,10327"; a="265325807" X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="265325807" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 23:48:40 -0700 X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="616385910" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 23:48:38 -0700 From: Bhanuprakash Modem To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ville.syrjala@linux.intel.com, manasi.d.navare@intel.com Subject: [RFC v2 2/2] drm/i915/vrr: Attach and set drm crtc vrr_enabled property Date: Mon, 25 Apr 2022 12:16:12 +0530 Message-Id: <20220425064612.2993587-3-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220425064612.2993587-1-bhanuprakash.modem@intel.com> References: <20220425064612.2993587-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function attaches & sets the vrr_enabled property for crtc based on the platform support and the request from userspace. V2: Check for platform support before updating the prop. Cc: Ville Syrjälä Cc: Manasi Navare Signed-off-by: Bhanuprakash Modem --- drivers/gpu/drm/i915/display/intel_crtc.c | 3 +++ drivers/gpu/drm/i915/display/intel_vrr.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c index 4442aa355f86..36deaca9af66 100644 --- a/drivers/gpu/drm/i915/display/intel_crtc.c +++ b/drivers/gpu/drm/i915/display/intel_crtc.c @@ -366,6 +366,9 @@ int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe) BIT(DRM_SCALING_FILTER_DEFAULT) | BIT(DRM_SCALING_FILTER_NEAREST_NEIGHBOR)); + if (HAS_VRR(dev_priv)) + drm_mode_crtc_attach_vrr_enabled_property(&crtc->base); + intel_color_init(crtc); intel_crtc_drrs_init(crtc); diff --git a/drivers/gpu/drm/i915/display/intel_vrr.c b/drivers/gpu/drm/i915/display/intel_vrr.c index 396f2f994fa0..7263b35550de 100644 --- a/drivers/gpu/drm/i915/display/intel_vrr.c +++ b/drivers/gpu/drm/i915/display/intel_vrr.c @@ -160,6 +160,10 @@ void intel_vrr_enable(struct intel_encoder *encoder, enum transcoder cpu_transcoder = crtc_state->cpu_transcoder; u32 trans_vrr_ctl; + if (HAS_VRR(dev_priv)) + drm_mode_crtc_set_vrr_enabled_property(crtc_state->uapi.crtc, + crtc_state->vrr.enable); + if (!crtc_state->vrr.enable) return; @@ -211,6 +215,10 @@ void intel_vrr_disable(const struct intel_crtc_state *old_crtc_state) struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); enum transcoder cpu_transcoder = old_crtc_state->cpu_transcoder; + if (HAS_VRR(dev_priv)) + drm_mode_crtc_set_vrr_enabled_property(old_crtc_state->uapi.crtc, + false); + if (!old_crtc_state->vrr.enable) return;