Enable Darkscreen Feature
v3 cover Enable Darkscreen Feature
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 enables/disabled through debugfs.
Nemesa Garg (2):
drm/i915/display: Add support for darskscreen detection drm/i915/display: Add darkscreen debugfs entry under crtc
drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 131 ++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 ++++ .../drm/i915/display/intel_display_debugfs.c | 2 + .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ drivers/gpu/drm/xe/Makefile | 1 + 7 files changed, 171 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.h
Signature · 1 line
2.25.1
PATCH v3 1/2 drm/i915/display: Add support for darskscreen detection
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]
v3: Addressed review comments [Arun]
--- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 95 +++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 +++++ .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ drivers/gpu/drm/xe/Makefile | 1 + 6 files changed, 133 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.h
drivers/gpu/drm/i915/Makefile +1 -0
@@ -244,6 +244,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 \
drivers/gpu/drm/i915/display/intel_darkscreen.c new file +95 -0
95 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2023 Intel Corporation +* +*/ + +#ifndef __INTEL_DARKSCREEN_H__ +#define __INTEL_DARKSCREEN_H__ + +#include <linux/types.h> + +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_ */
drivers/gpu/drm/i915/display/intel_display_types.h +2 -0
@@ -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"
@@ -1539,6 +1540,7 @@ struct intel_crtc {#ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; +struct intel_darkscreen dark_screen;#endif };
drivers/gpu/drm/i915/i915_reg.h +8 -0
@@ -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)
drivers/gpu/drm/xe/Makefile +1 -0
@@ -176,6 +176,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \ i915-display/intel_crtc_state_dump.o \ i915-display/intel_cursor.o \ i915-display/intel_cx0_phy.o \ + i915-display/intel_darkscreen.o \ i915-display/intel_ddi.o \ i915-display/intel_ddi_buf_trans.o \ i915-display/intel_display.o \
Signature · 1 line
2.25.1
Jani Nikula
maintainerRe: [PATCH v3 1/2] drm/i915/display: Add support for darskscreen detection
Quoted 4 lines · Nemesa Garg
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.
Some inline comments below, but really the big problem is the design of the whole thing, and there's no point in tweaking these before the design is right.
BR,
Jani.
Quoted 34 lines
v2: Addressed review comments [Jani]
v3: Addressed review comments [Arun]Signed-off-by Nemesa Garg <[email protected]>--- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 95 +++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 +++++ .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ drivers/gpu/drm/xe/Makefile | 1 + 6 files changed, 133 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.hdrivers/gpu/drm/i915/Makefile +1
-0@@ -244,6 +244,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 \drivers/gpu/drm/i915/display/intel_darkscreen.c new file +0
-0
drivers/gpu/drm/i915/display/intel_darkscreen.c line 4
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_darkscreen.c new file +4
-0@@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2023 Intel Corporation +*
Superfluous blank line.
Quoted 97 lines
drivers/gpu/drm/i915/display/intel_darkscreen.c new file +91
-0+*/ + +#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 + +/* +* Check the color format and compute the compare 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); +unsigned int frame_time_in_us; +u32 comparevalue; + +if (!crtc->dark_screen.enable) +return ; + +if (crtc_state->output_format !=INTEL_OUTPUT_FORMAT_RGB ) { +drm_err (&dev_priv->drm, +"RGB format not supported:%c\n" , +pipe_name (crtc->pipe)); +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)); + + frame_time_in_us = (1000 /drm_mode_vrefresh (&crtc_state->hw.adjusted_mode)) *2 ; + +intel_de_wait_for_set (dev_priv, +DARK_SCREEN (crtc->config->cpu_transcoder),DARK_SCREEN_DONE , + frame_time_in_us); + +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 ); +}drivers/gpu/drm/i915/display/intel_darkscreen.h new file +0
-0
drivers/gpu/drm/i915/display/intel_darkscreen.h line 4
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +4
-0@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2023 Intel Corporation +*
Superfluous blank line.
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +7
-0+*/ + +#ifndef __INTEL_DARKSCREEN_H__ +#define __INTEL_DARKSCREEN_H__ + +#include <linux/types.h> +
drivers/gpu/drm/i915/display/intel_darkscreen.h line 21
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +10
-0+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);
dark_screen is inconsistent with darkscreen everywhere else.
drivers/gpu/drm/i915/display/intel_darkscreen.h line 22
Quoted 1 line
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +1
-0+void intel_darkscreen_crtc_debugfs_add (struct intel_crtc *crtc);
You're not actually adding the implementation of that function in this patch.
drivers/gpu/drm/i915/display/intel_darkscreen.h line 23
Quoted 1 line
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +1
-0+
Superfluous blank line.
drivers/gpu/drm/i915/display/intel_darkscreen.h line 24
Quoted 1 line
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +1
-0+#endif
If all the functionality here is behind #ifdef CONFIG_DEBUG_FS, maybe the file should only be built for CONFIG_DEBUG_FS=y?
Quoted 53 lines
drivers/gpu/drm/i915/display/intel_darkscreen.h new file +2
-0+ +#endif /* __INTEL_DARKSCREEN_H_ */ drivers/gpu/drm/i915/display/intel_display_types.h +2
-0@@ -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" @@ -1539,6 +1540,7 @@ struct intel_crtc {#ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; +struct intel_darkscreen dark_screen;#endif };drivers/gpu/drm/i915/i915_reg.h +8
-0@@ -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)drivers/gpu/drm/xe/Makefile +1
-0@@ -176,6 +176,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \ i915-display/intel_crtc_state_dump.o \ i915-display/intel_cursor.o \ i915-display/intel_cx0_phy.o \ + i915-display/intel_darkscreen.o \ i915-display/intel_ddi.o \ i915-display/intel_ddi_buf_trans.o \ i915-display/intel_display.o \
Signature · 1 line
Jani Nikula, Intel
Rodrigo Vivi
maintainerRe: [PATCH v3 1/2] drm/i915/display: Add support for darskscreen detection
In reply to Nemesa GargQuoted 4 lines · Nemesa Garg
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.
Why? Who is using that? How?
I had to go to the mailing list archive to see that you had provided an initial answer to Jani, but failed to add this information back to the patch.
Even though, without the actual usage of the (un-implemented) debugfs it is hard to accept that answer as the why.
Please make IGT cases that really exercise this idea where you know that the screen shouldn't be ever black but suddently you are getting some black screens.
But also, why not simply using the CRC checks? even if the CRC checks are not global, you could create a test case where you deliver a blank screen and get the result and then you keep checking if the CRC is different from that blank crc.
So, besides the documented why reason, and examples this commit message needs to tell what is this solving that is not already solved by other approaches that we have in IGT, etc.
The idea doesn't look solid or at least not entirely 'sold' yet.
Quoted 215 lines
v2: Addressed review comments [Jani]
v3: Addressed review comments [Arun]Signed-off-by Nemesa Garg <[email protected]>--- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 95 +++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 +++++ .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ drivers/gpu/drm/xe/Makefile | 1 + 6 files changed, 133 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.hdrivers/gpu/drm/i915/Makefile +1
-0@@ -244,6 +244,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 \drivers/gpu/drm/i915/display/intel_darkscreen.c new file +95
-0@@ -0,0 +1,95 @@ +// 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 + +/* +* Check the color format and compute the compare 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); +unsigned int frame_time_in_us; +u32 comparevalue; + +if (!crtc->dark_screen.enable) +return ; + +if (crtc_state->output_format !=INTEL_OUTPUT_FORMAT_RGB ) { +drm_err (&dev_priv->drm, +"RGB format not supported:%c\n" , +pipe_name (crtc->pipe)); +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)); + + frame_time_in_us = (1000 /drm_mode_vrefresh (&crtc_state->hw.adjusted_mode)) *2 ; + +intel_de_wait_for_set (dev_priv, +DARK_SCREEN (crtc->config->cpu_transcoder),DARK_SCREEN_DONE , + frame_time_in_us); + +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 ); +}drivers/gpu/drm/i915/display/intel_darkscreen.h new file +26
-0@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2023 Intel Corporation +* +*/ + +#ifndef __INTEL_DARKSCREEN_H__ +#define __INTEL_DARKSCREEN_H__ + +#include <linux/types.h> + +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_ */ drivers/gpu/drm/i915/display/intel_display_types.h +2
-0@@ -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" @@ -1539,6 +1540,7 @@ struct intel_crtc {#ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; +struct intel_darkscreen dark_screen;#endif };drivers/gpu/drm/i915/i915_reg.h +8
-0@@ -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)drivers/gpu/drm/xe/Makefile +1
-0@@ -176,6 +176,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \ i915-display/intel_crtc_state_dump.o \ i915-display/intel_cursor.o \ i915-display/intel_cx0_phy.o \ + i915-display/intel_darkscreen.o \ i915-display/intel_ddi.o \ i915-display/intel_ddi_buf_trans.o \ i915-display/intel_display.o \Signature · 1 line
2.25.1
Re: [PATCH v3 1/2] drm/i915/display: Add support for darskscreen detection
In reply to Nemesa GargQuoted 4 lines · Nemesa Garg
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.
As others have noted, you seem to be mixing two different designs here in a way that doesn't really make sense. At the hardware level, it's possible to request a check for a dark screen[*] and then get a yes/no response back shortly. But how that functionality gets utilized and exposed to users is something that can be approached in different ways. I can think of a couple options for how this could be handled:
Option 1: The simplest option is to create a debugfs that tells me whether the screen is dark *right now*. I.e., "cat ..../darkscreen" returns an immediate "yes" or "no" answer. Every time I re-cat it, I get a new answer; there's no concept of enable/disable at the API level. I can see this being very useful in some IGT tests like testdisplay (make sure the output isn't blank after switching to a mode) or kms_plane (make sure the output _is_ blank at certain points when all planes are supposed to be off).
Option 2: A more complicated option is to create an interface with start/stop behavior that indicates whether the screen ever went dark between two points in time. I'm sure there are ways this could be used, although it's a little harder to figure out where we'd utilize it to our benefit in the IGT tests we have today.
The code you have in these patches seems to be trying to expose an enable/disable debugfs interface, but only does its checking a single time right at the 'enable' point. There's no reason to actually leave the hardware setting enabled after that point because you never go back and check again. And the current implementation also doesn't return the status to the user in any way, it just prints out a log message, so that pretty much kills the ability to use this in something like IGT.
So as others have said, you need to figure out what the goal is here. I.e., who do you expect to use this and how? Based on the answer to that, you can figure out what kind of user-facing interface is appropriate, and then provide corresponding changes to some userspace software (probably IGT for a debug-specific facility like this) that utilizes the new capability.
[*] BTW, it's also worth noting that no matter what this interface can't detect all cases where the display is blank. The hardware support for this appears to be at the end of the pipe, so if the monitor is blank due to mistakes in the programming of the DSC, transcoder, DDI, or phy, the darkscreen detection won't notice. However it will be useful for catching certain mistakes in the programming of planes, scalers, or color management.
Quoted 3 lines
v2: Addressed review comments [Jani]
v3: Addressed review comments [Arun]
Changelogs like this are pretty useless; without digging through mailing list history, nobody (often including the original reviewers) remembers exactly what the review comments were. It's hard to tell which parts of your patch have been reworked from the previous revision, or to determine whether you saw and handled all of the feedback or just part of it. It's better to give a brief description of what actually changed in the new version. E.g.,
v2:
- Added foo check. (Jani)
- Reordered bar and baz. (Jani)
v3:
- Added locking to xyz. (Arun)
- Drop unnecessary abc check. (Arun)
Matt
Quoted 212 lines
Signed-off-by Nemesa Garg <[email protected]>--- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 95 +++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 +++++ .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ drivers/gpu/drm/xe/Makefile | 1 + 6 files changed, 133 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.hdrivers/gpu/drm/i915/Makefile +1
-0@@ -244,6 +244,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 \drivers/gpu/drm/i915/display/intel_darkscreen.c new file +95
-0@@ -0,0 +1,95 @@ +// 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 + +/* +* Check the color format and compute the compare 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); +unsigned int frame_time_in_us; +u32 comparevalue; + +if (!crtc->dark_screen.enable) +return ; + +if (crtc_state->output_format !=INTEL_OUTPUT_FORMAT_RGB ) { +drm_err (&dev_priv->drm, +"RGB format not supported:%c\n" , +pipe_name (crtc->pipe)); +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)); + + frame_time_in_us = (1000 /drm_mode_vrefresh (&crtc_state->hw.adjusted_mode)) *2 ; + +intel_de_wait_for_set (dev_priv, +DARK_SCREEN (crtc->config->cpu_transcoder),DARK_SCREEN_DONE , + frame_time_in_us); + +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 ); +}drivers/gpu/drm/i915/display/intel_darkscreen.h new file +26
-0@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2023 Intel Corporation +* +*/ + +#ifndef __INTEL_DARKSCREEN_H__ +#define __INTEL_DARKSCREEN_H__ + +#include <linux/types.h> + +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_ */ drivers/gpu/drm/i915/display/intel_display_types.h +2
-0@@ -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" @@ -1539,6 +1540,7 @@ struct intel_crtc {#ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; +struct intel_darkscreen dark_screen;#endif };drivers/gpu/drm/i915/i915_reg.h +8
-0@@ -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)drivers/gpu/drm/xe/Makefile +1
-0@@ -176,6 +176,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \ i915-display/intel_crtc_state_dump.o \ i915-display/intel_cursor.o \ i915-display/intel_cx0_phy.o \ + i915-display/intel_darkscreen.o \ i915-display/intel_ddi.o \ i915-display/intel_ddi_buf_trans.o \ i915-display/intel_display.o \Signature · 1 line
2.25.1
Signature · 4 lines
Matt Roper Graphics Software Engineer Linux GPU Platform Enablement Intel Corporation
PATCH v2 2/2 drm/i915/display: Add darkscreen debugfs entry under crtc
In reply to Nemesa GargThis is to set the enable/disable status.
v2: Addressed review comments [Jani]
--- .../gpu/drm/i915/display/intel_darkscreen.c | 36 +++++++++++++++++++ .../drm/i915/display/intel_display_debugfs.c | 2 ++ 2 files changed, 38 insertions(+)
drivers/gpu/drm/i915/display/intel_darkscreen.c +36 -0
@@ -93,3 +93,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); +}
drivers/gpu/drm/i915/display/intel_display_debugfs.c +2 -0
@@ -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"
@@ -1541,6 +1542,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);
Signature · 1 line
2.25.1
Jani Nikula
maintainerQuoted 4 lines · Nemesa Garg
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 enables/disabled through debugfs.
This does not address the feedback I've given previously. Alas, it wasn't on intel-gfx, so I'm copy-pasting it here:
Quoted 2 lines
IGT patches https://patchwork.freedesktop.org/series/125880/ . Kernel patches https://patchwork.freedesktop.org/series/125563/ .
The current IGT implementation proposal does this:
+ igt_set_dark_screen_detection(data.drm_fd, pipe, true);
+ test_read_crc(&data, pipe, output, tests[i].flags);
+ igt_set_dark_screen_detection(data.drm_fd, pipe, false);
It *looks* nice. But the dark screen detection is *not* reported during or after test_read_crc(). With the current kernel implementation, only the dark screen enable checks if there's a dark screen during enable, and that's it. The above checks what the state was before.
The kernel and the IGT parts don't work together. You need to come up with a plan how the hardware feature can be used to our benefit. This falls short, even for the first phase.
The detection is sticky, so you could fathom enabling it, and checking later if dark screen has happened during testing. But if you enable it before you have something on screen, you'll surely flag a dark screen detection before you've even started the test. Right?
You need to have an idea how it's going to be used in a test case where everything is disabled in the beginning.
BR,
Jani.
Quoted 15 lines
Nemesa Garg (2):
drm/i915/display: Add support for darskscreen detection drm/i915/display: Add darkscreen debugfs entry under crtcdrivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_darkscreen.c | 131 ++++++++++++++++++ .../gpu/drm/i915/display/intel_darkscreen.h | 26 ++++ .../drm/i915/display/intel_display_debugfs.c | 2 + .../drm/i915/display/intel_display_types.h | 2 + drivers/gpu/drm/i915/i915_reg.h | 8 ++ drivers/gpu/drm/xe/Makefile | 1 + 7 files changed, 171 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.c create mode 100644 drivers/gpu/drm/i915/display/intel_darkscreen.h
Signature · 1 line
Jani Nikula, Intel
Patchwork
CI✗ Fi.CI.BUILD: failure for Enable Darkscreen Feature (rev3)
In reply to Nemesa Garg== Series Details ==
== Series Details ==
Series: Enable Darkscreen Feature (rev3)
URL : https://patchwork.freedesktop.org/series/125563/
State : failure
== Summary ==
Error: patch https://patchwork.freedesktop.org/api/1.0/series/125563/revisions/3/mbox/ not applied
Applying: drm/i915/display: Add support for darskscreen detection
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/Makefile).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm/i915/display: Add support for darskscreen detection
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced