From patchwork Fri Oct 27 09:53:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nemesa Garg X-Patchwork-Id: 13438461 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 2BB0EC25B67 for ; Fri, 27 Oct 2023 09:56:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A899F10E96C; Fri, 27 Oct 2023 09:56:11 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id A305A10E96C for ; Fri, 27 Oct 2023 09:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698400569; x=1729936569; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XKFrCiEbh7zAgYbhVRN85zTuGL9CVnkql2/qDHNz9Vo=; b=dBhIb0shFUSFXhbox1GP6wNBf87UD5sPq8j4tAW39460PR1IwGz1edK1 gYeiTi7UnBf97ZEbPXk/mHPTTbi4h1Dc75xKALzXd5DxfTpTpJUjGuxlt IFk0Gc+RSaJiA27+eO0+AA+ga2OIwQto+aDomV+Bfst5Q9uAjtsQCstcr xeU4OqfTIGBR/ihBygfQQ652BE7UWv8yc6KuNUFDcRGDsuxmSELKRK9Y6 LfBsHkwbQKILVtnrzd8J4YBI7f06TVtjXKkFXF85IO9VAI3Crq60+2Fvn nrwLscRbhacLcaL6/anHIscG5liujLxitV16FWkbCHPV6QS3KMdX16SVb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="384953763" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="384953763" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 02:56:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="1090879039" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="1090879039" Received: from nemesa.iind.intel.com ([10.190.239.22]) by fmsmga005.fm.intel.com with ESMTP; 27 Oct 2023 02:56:07 -0700 From: Nemesa Garg To: intel-gfx@lists.freedesktop.org Date: Fri, 27 Oct 2023 15:23:35 +0530 Message-Id: <20231027095336.3059445-2-nemesa.garg@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231027095336.3059445-1-nemesa.garg@intel.com> References: <20231027095336.3059445-1-nemesa.garg@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [v2 1/2] drm/i915/display: Add support for darskscreen detection 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" Darkscreen detection checks if all the pixels of the frame are less then or equal to the comparision value. The comparision value is set to 256 i.e black. So upon getting black pixels from the pipe, the dark screen detect bit is set and an error message will be printed. v2: Addressed review comments (Jani) Signed-off-by: Nemesa Garg --- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 87 +++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 ++++++ .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ 5 files changed, 124 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..0be719c76c4e --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_darkscreen.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2023 Intel Corporation + * + */ + +#include "i915_reg.h" +#include "intel_de.h" +#include "intel_display_types.h" + +#define COLOR_DEPTH_6BPC 6 +#define COLOR_DEPTH_8BPC 8 +#define COLOR_DEPTH_10BPC 10 +#define COLOR_DEPTH_12BPC 12 + +#define COMPARE_VALUE_6_BPC 4 +#define COMPARE_VALUE_8_BPC 16 +#define COMPARE_VALUE_10_BPC 64 +#define COMPARE_VALUE_12_BPC 256 + +#define COMPARE_VALUE_CALCULATION_FACTOR 12 + +/* + * Checks the color format and compute the comapre value based on bpc. + */ +void intel_dark_screen_enable(struct intel_crtc_state *crtc_state) +{ + 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); + u32 comparevalue; + + if (!crtc->dark_screen.enable) + return; + + if (crtc_state->output_format != INTEL_OUTPUT_FORMAT_RGB) + return; + + switch (crtc_state->pipe_bpp / 3) { + case COLOR_DEPTH_6BPC: + comparevalue = COMPARE_VALUE_6_BPC; + break; + case COLOR_DEPTH_8BPC: + comparevalue = COMPARE_VALUE_8_BPC; + break; + case COLOR_DEPTH_10BPC: + comparevalue = COMPARE_VALUE_10_BPC; + break; + case COLOR_DEPTH_12BPC: + comparevalue = COMPARE_VALUE_12_BPC; + break; + default: + drm_dbg(&dev_priv->drm, + "Bpc value is incorrect:%d\n", + crtc_state->pipe_bpp / 3); + return; + } + + comparevalue = comparevalue << + (COMPARE_VALUE_CALCULATION_FACTOR - crtc_state->pipe_bpp / 3); + + 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), 1, DARK_SCREEN_DETECT | + DARK_SCREEN_DONE); +} + +void intel_dark_screen_disable(struct intel_crtc_state *crtc_state) +{ + 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); + + intel_de_write(dev_priv, DARK_SCREEN(cpu_transcoder), 0); +} 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..366e43499fc4 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_darkscreen.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2023 Intel Corporation + * + */ + +#ifndef __INTEL_DARKSCREEN_H__ +#define __INTEL_DARKSCREEN_H__ + +#include + +struct intel_crtc_state; +struct intel_crtc; + +struct intel_darkscreen { + bool enable; +}; + +#ifdef CONFIG_DEBUG_FS +void intel_dark_screen_enable(struct intel_crtc_state *crtc_state); +void intel_dark_screen_disable(struct intel_crtc_state *crtc_state); +void intel_darkscreen_crtc_debugfs_add(struct intel_crtc *crtc); + +#endif + +#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..bd0306e9318f 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -49,6 +49,7 @@ #include "i915_vma.h" #include "i915_vma_types.h" #include "intel_bios.h" +#include "intel_darkscreen.h" #include "intel_display.h" #include "intel_display_limits.h" #include "intel_display_power.h" @@ -1517,6 +1518,7 @@ struct intel_crtc { #ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; + struct intel_darkscreen dark_screen; #endif }; diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 135e8d8dbdf0..a9f7b80a56cf 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -2097,6 +2097,14 @@ #define TRANS_PUSH_EN REG_BIT(31) #define TRANS_PUSH_SEND REG_BIT(30) +#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 Fri Oct 27 09:53:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nemesa Garg X-Patchwork-Id: 13438462 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 E318CC25B67 for ; Fri, 27 Oct 2023 09:56:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A7E710E96D; Fri, 27 Oct 2023 09:56:14 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FDAA10E96D for ; Fri, 27 Oct 2023 09:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698400572; x=1729936572; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MrgKxwWMMeOlA9BtDsmUa1wkajGDUhHK0NyqwT1KjXw=; b=EGqu00VSHOIFA1iiVKX1KzXpO+91GL3V5R/JI/vZtSJFcs30XMKVY63H DhoOIlrmsqJxFb6ONBodgpuGIVajMa1UNaS8e6IuIRT9xprqjYqOXISyZ 4dTpuN1bKRBQp/JK3C7S6ZzPga/GZaLjnpCRhPST4q0+zYoiZQNVZsnby XQz0cJBtur83EIxZbs1yx4X7iH6R23Zbo3DhzTaEAciaZBV79zLdhQqyt BvYcREFwvoA9wXlOuiHdiyOoy7eDTzALiqAJwEDrpnUoKLXAUTo12ZULm N0MYBNacef8+dH4tImCz624z1AlZauceP1scz17+uhtzXkFTf+/YkxCRQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="384953774" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="384953774" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 02:56:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="1090879046" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="1090879046" Received: from nemesa.iind.intel.com ([10.190.239.22]) by fmsmga005.fm.intel.com with ESMTP; 27 Oct 2023 02:56:10 -0700 From: Nemesa Garg To: intel-gfx@lists.freedesktop.org Date: Fri, 27 Oct 2023 15:23:36 +0530 Message-Id: <20231027095336.3059445-3-nemesa.garg@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231027095336.3059445-1-nemesa.garg@intel.com> References: <20231027095336.3059445-1-nemesa.garg@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [v2 2/2] drm/i915/display: Add darkscreen debugfs entry 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" This is to set the enable/disable status. v2: Addressed review comments (Jani) Signed-off-by: Nemesa Garg Reviewed-by: Arun R Murthy --- .../gpu/drm/i915/display/intel_darkscreen.c | 36 +++++++++++++++++++ .../drm/i915/display/intel_display_debugfs.c | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_darkscreen.c b/drivers/gpu/drm/i915/display/intel_darkscreen.c index 0be719c76c4e..2d0b78c4d645 100644 --- a/drivers/gpu/drm/i915/display/intel_darkscreen.c +++ b/drivers/gpu/drm/i915/display/intel_darkscreen.c @@ -85,3 +85,39 @@ void intel_dark_screen_disable(struct intel_crtc_state *crtc_state) intel_de_write(dev_priv, DARK_SCREEN(cpu_transcoder), 0); } + +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 (val) + intel_dark_screen_enable(crtc_state); + else + intel_dark_screen_disable(crtc_state); + + return 0; +} + +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 d76f9aa0b192..48a0d802b838 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -16,6 +16,7 @@ #include "intel_crtc.h" #include "intel_de.h" #include "intel_crtc_state_dump.h" +#include "intel_darkscreen.h" #include "intel_display_debugfs.h" #include "intel_display_power.h" #include "intel_display_power_well.h" @@ -1551,6 +1552,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);