From patchwork Wed Oct 25 10:27:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Garg, Nemesa" X-Patchwork-Id: 13435963 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 6C11AC0032E for ; Wed, 25 Oct 2023 10:37:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA7E210E62F; Wed, 25 Oct 2023 10:37:08 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9F2F910E63E for ; Wed, 25 Oct 2023 10:37: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=1698230227; x=1729766227; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DimPZXg2G4GISaJVd4Qi1QgyumwHeV2hVK1FKhIFQ1c=; b=UgK1z7pGXFtIxIs7ch8LboO+4owxXzYKA8p4QEZTByPPQDV/t2PjKiWz 0t18ud7+ChbrbHvTsGVMSqNgz74KdAtA23Wg8hIlpeh+Y4ZkL9ph54Z+u wPE09IstdeYkHEHJ0g40emj+qPi/WpiZMTsOpTOUo8qkzXx2eUgGgom1+ oQNW3WVoOHKo+RQ6DcuVTl1IqSD2We6J65plHvhsj9sL3FzrYwZ1wAl3N qoq/zbxDnBKvHtAkb+Mgj3FfxZvZB02Zlh6rV+5vDSOcggdZH8flygSwf MPWLlgiEjiQl/WZkeWlsPwZnU02dHq/k704px6RaAyHe0Ftp0aOiqZxnb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="43851" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="43851" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 03:30:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="882409878" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="882409878" Received: from nemesa.iind.intel.com ([10.190.239.22]) by orsmga004.jf.intel.com with ESMTP; 25 Oct 2023 03:29:58 -0700 From: Nemesa Garg To: intel-gfx@lists.freedesktop.org Date: Wed, 25 Oct 2023 15:57:33 +0530 Message-Id: <20231025102734.2783492-2-nemesa.garg@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231025102734.2783492-1-nemesa.garg@intel.com> References: <20231025102734.2783492-1-nemesa.garg@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] drm/i915: Add Darkscreen registers and timer handler. 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add new registers for Darkscreen The logic checks for any black screen at pipe level and upon such detection prints error. Darkscreen compares the pixels with the compare value(0x00 - black) for the detection purpose. This feature can be enable/disable through debugfs. Signed-off-by: Nemesa Garg --- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 69 +++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 40 +++++++++++ .../drm/i915/display/intel_display_types.h | 3 + drivers/gpu/drm/i915/i915_reg.h | 9 +++ 5 files changed, 122 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 88b2bb005014..538d5a42f9e3 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -254,6 +254,7 @@ i915-y += \ display/intel_crtc.o \ display/intel_crtc_state_dump.o \ display/intel_cursor.o \ + display/intel_darkscreen.o \ display/intel_display.o \ display/intel_display_driver.o \ display/intel_display_irq.o \ diff --git a/drivers/gpu/drm/i915/display/intel_darkscreen.c b/drivers/gpu/drm/i915/display/intel_darkscreen.c new file mode 100644 index 000000000000..ef68dbc7a296 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_darkscreen.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2018 Intel Corporation + * + * Author: Nemesa Garg + */ +#include "i915_reg.h" +#include "intel_display_types.h" +#include "intel_de.h" + +/* + * Dark screen detection check if all pixels + * in a frame are less than or equal to compare + * value.Check the color format and compute the + * compare value based on bpc. + */ +void dark_screen_enable(struct intel_crtc_state *crtc_state) +{ + u32 comparevalue; + enum transcoder cpu_transcoder = crtc_state->cpu_transcoder; + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); + struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); + + if (!crtc->dark_screen.enable) + return; + + if (crtc_state->output_format != INTEL_OUTPUT_FORMAT_RGB) + return; + drm_err(&dev_priv->drm, + "RGB format is not present%c\n", + pipe_name(crtc->pipe)); + + switch (crtc_state->pipe_bpp / 3) { + case DD_COLOR_DEPTH_6BPC: + comparevalue = DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_6_BPC; + break; + case DD_COLOR_DEPTH_8BPC: + comparevalue = DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_8_BPC; + break; + case DD_COLOR_DEPTH_10BPC: + comparevalue = DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_10_BPC; + break; + case DD_COLOR_DEPTH_12BPC: + comparevalue = DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_12_BPC; + break; + default: + break; + } + + comparevalue = comparevalue << + (DARKSCREEN_PROGRAMMED_COMPARE_VALUE_CALCULATION_FACTOR - crtc->dark_screen.bpc); + + intel_de_write(dev_priv, DARK_SCREEN(cpu_transcoder), + DARK_SCREEN_ENABLE | DARK_SCREEN_DETECT | + DARK_SCREEN_DONE | DARK_SCREEN_COMPARE_VAL(comparevalue)); + + intel_de_wait_for_set(dev_priv, + DARK_SCREEN(crtc->config->cpu_transcoder), DARK_SCREEN_DONE, 1); + + if (intel_de_read(dev_priv, DARK_SCREEN(crtc->config->cpu_transcoder)) & + DARK_SCREEN_DETECT) { + drm_err(&dev_priv->drm, + "Dark Screen detected %c\n", + pipe_name(crtc->pipe)); + } + + intel_de_rmw(dev_priv, DARK_SCREEN(crtc->config->cpu_transcoder), 0, DARK_SCREEN_DETECT | + DARK_SCREEN_DONE); +} diff --git a/drivers/gpu/drm/i915/display/intel_darkscreen.h b/drivers/gpu/drm/i915/display/intel_darkscreen.h new file mode 100644 index 000000000000..69da1ea56829 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_darkscreen.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2018 Intel Corporation + * + * Author: Nemesa Garg + */ + +#ifndef __INTEL_DARKSCREEN_H__ +#define __INTEL_DARKSCREEN_H__ + +#include + +#define DD_COLOR_DEPTH_6BPC 6 +#define DD_COLOR_DEPTH_8BPC 8 +#define DD_COLOR_DEPTH_10BPC 10 +#define DD_COLOR_DEPTH_12BPC 12 + +// HW Darkscreen Detection Macros +#define DARKSCREEN_PROGRAMMED_COMPARE_VALUE_CALCULATION_FACTOR 12 + +// Compare Value = 16*(2 ^ (bpc-8)) +#define DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_6_BPC 4 +#define DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_8_BPC 16 +#define DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_10_BPC 64 +#define DARKSCREEN_COMPARE_VALUE_LIMITED_RANGE_12_BPC 256 + +struct intel_crtc_state; +struct intel_crtc; + +struct intel_darkscreen { + bool enable; + u64 timer_value; + u8 bpc; + struct hrtimer timer; +}; + +void dark_screen_enable(struct intel_crtc_state *crtc_state); +void intel_darkscreen_crtc_debugfs_add(struct intel_crtc *crtc); + +#endif /* __INTEL_DARKSCREEN_H_ */ diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 65ea37fe8cff..289ecda2e032 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -54,6 +54,7 @@ #include "intel_display_power.h" #include "intel_dpll_mgr.h" #include "intel_wm_types.h" +#include "intel_darkscreen.h" struct drm_printer; struct __intel_global_objs_state; @@ -1515,6 +1516,8 @@ struct intel_crtc { /* for loading single buffered registers during vblank */ struct pm_qos_request vblank_pm_qos; + struct intel_darkscreen dark_screen; + #ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; #endif diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 135e8d8dbdf0..01d9de14f79c 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -2097,6 +2097,15 @@ #define TRANS_PUSH_EN REG_BIT(31) #define TRANS_PUSH_SEND REG_BIT(30) +/* Dark SCREEN */ +#define _DARK_SCREEN_PIPE_A 0x60120 +#define DARK_SCREEN(trans) _MMIO_TRANS2(trans, _DARK_SCREEN_PIPE_A) +#define DARK_SCREEN_ENABLE REG_BIT(31) +#define DARK_SCREEN_DETECT REG_BIT(29) +#define DARK_SCREEN_DONE REG_BIT(28) +#define DARK_SCREEN_COMPARE_MASK REG_GENMASK(9, 0) +#define DARK_SCREEN_COMPARE_VAL(x) REG_FIELD_PREP(DARK_SCREEN_COMPARE_MASK, (x)) + /* VGA port control */ #define ADPA _MMIO(0x61100) #define PCH_ADPA _MMIO(0xe1100) From patchwork Wed Oct 25 10:27:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Garg, Nemesa" X-Patchwork-Id: 13435964 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 88F43C25B6B for ; Wed, 25 Oct 2023 10:37:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5C7B10E63E; Wed, 25 Oct 2023 10:37:11 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C07910E62F for ; Wed, 25 Oct 2023 10:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698230228; x=1729766228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xhb2iRZR1ft8RqOjtfXp8G2rGX64HIUluEMSlQT5ads=; b=SOafeUJRLZls5gMv7uTgXYD3Hjh1RgYU+1JdOU0O9t315pHGA+2IxbrS ViTk5d7Z8YAhcuHBoukiKVKLU9Poxj0ASh9grFmDRYORex7BHl3B9BgfV 648rQFLRQocPTspEkmrIx6SjDTct3FjYD63cKpXde64iT/TqHOwIA0GvT kuL6JXbJkVVlmRzXvYvn19DfHqlyual8sQW8tYAdPKo91/UigdKPkCA8h XG4IRlZq81DfThT67NK5F/Tww/+6QQVEDaGJNxXj/G4+TKd8t2cTzQEtl 3xFpguJZMSmEc3jKdOsreyclFidwrCFaPupMGQl0Ufb2UF9LUZ3JZQywv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="43857" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="43857" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 03:30:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="882409907" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="882409907" Received: from nemesa.iind.intel.com ([10.190.239.22]) by orsmga004.jf.intel.com with ESMTP; 25 Oct 2023 03:30:01 -0700 From: Nemesa Garg To: intel-gfx@lists.freedesktop.org Date: Wed, 25 Oct 2023 15:57:34 +0530 Message-Id: <20231025102734.2783492-3-nemesa.garg@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231025102734.2783492-1-nemesa.garg@intel.com> References: <20231025102734.2783492-1-nemesa.garg@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 2/2] drm/i915: Add the darkscreen debugfs under crtc 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add debugfs entry for darkscreen to know the status bpc and timer value . Signed-off-by: Nemesa Garg --- .../gpu/drm/i915/display/intel_darkscreen.c | 38 +++++++++++++++++++ .../drm/i915/display/intel_display_debugfs.c | 2 + 2 files changed, 40 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_darkscreen.c b/drivers/gpu/drm/i915/display/intel_darkscreen.c index ef68dbc7a296..c6490c16fdb5 100644 --- a/drivers/gpu/drm/i915/display/intel_darkscreen.c +++ b/drivers/gpu/drm/i915/display/intel_darkscreen.c @@ -67,3 +67,41 @@ void dark_screen_enable(struct intel_crtc_state *crtc_state) intel_de_rmw(dev_priv, DARK_SCREEN(crtc->config->cpu_transcoder), 0, DARK_SCREEN_DETECT | DARK_SCREEN_DONE); } + +static int intel_darkscreen_debugfs_status_get(void *data, u64 *val) +{ + struct intel_crtc *crtc = data; + + *val = crtc->dark_screen.enable; + + return 0; +} + +static int intel_darkscreen_debugfs_status_set(void *data, u64 val) +{ + struct intel_crtc *crtc = data; + struct intel_crtc_state *crtc_state; + + crtc->dark_screen.enable = val; + + crtc_state = to_intel_crtc_state(crtc->base.state); + + if (crtc_state) + dark_screen_enable(crtc_state); + + return 0; +} + +/* + * Check the status whether the darkscreen + * is enabled or not. + */ +DEFINE_DEBUGFS_ATTRIBUTE(intel_darkscreen_debugfs_status_fops, + intel_darkscreen_debugfs_status_get, + intel_darkscreen_debugfs_status_set, "%llu\n"); + +void intel_darkscreen_crtc_debugfs_add(struct intel_crtc *crtc) +{ + debugfs_create_file("i915_darkscreen_status", 0644, crtc->base.debugfs_entry, + crtc, &intel_darkscreen_debugfs_status_fops); +} diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c index 2836826f8c05..27a6141eab3e 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -33,6 +33,7 @@ #include "intel_psr.h" #include "intel_psr_regs.h" #include "intel_wm.h" +#include "intel_darkscreen.h" static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node) { @@ -1539,6 +1540,7 @@ void intel_crtc_debugfs_add(struct intel_crtc *crtc) intel_drrs_crtc_debugfs_add(crtc); intel_fbc_crtc_debugfs_add(crtc); hsw_ips_crtc_debugfs_add(crtc); + intel_darkscreen_crtc_debugfs_add(crtc); debugfs_create_file("i915_current_bpc", 0444, root, crtc, &i915_current_bpc_fops);