Provide workarounds to use DRM/KMS with broken graphics hardware
Subsystems (4)
v4 cover Provide workarounds to use DRM/KMS with broken graphics hardware
Changes from V3 to V4:
Reverted the removal of the "brightness_inverted" parameter of the i915 module as suggested by Chris. Inversion of the sense of the brightness variable is now enabled, if either the quirked notebook is encountered or the "brightness_inverted" module parameter switch is set.
Thanks,
-Carsten.
PATCH v4 1/2 drivers-gpu-drm-allow-to-load-edid-firmware.patch
Broken monitors and/or broken graphic boards may send erroneous or no EDID data. This also applies to broken KVM devices that are unable to correctly forward the EDID data of the connected monitor but invent their own fantasy data.
This patch allows to specify an EDID data set to be used instead of probing the monitor for it. It contains built-in data sets of frequently used screen resolutions. In addition, a particular EDID data set may be provided in the /lib/firmware directory and loaded via the firmware interface. The name is passed to the kernel as module parameter of the drm_kms_helper module either when loaded
options drm_kms_helper edid_firmware=edid/1280x1024.bin
or as kernel commandline parameter
drm_kms_helper.edid_firmware=edid/1280x1024.bin
The built-in data sets are
Resolution Name
--------------------------------
1024x768 edid/1024x768.bin 1280x1024 edid/1280x1024.bin 1680x1050 edid/1680x1050.bin 1920x1080 edid/1920x1080.bin
They are ignored, if a file with the same name is available in the /lib/firmware directory.
The built-in EDID data sets are based on standard timings that may not apply to a particular monitor and even crash it. Ideally, EDID data of the connected monitor should be used. They may be obtained through the drm/cardX/cardX-<connector>/edid entry in the /sys/devices PCI directory of a correctly working graphics adapter.
It is also possible to specify the name of an EDID data set on-the-fly via the /sys/module interface, e.g.
echo edid/myedid.bin >/sys/module/drm_kms_helper/parameters/edid_firmware The new screen mode is considered when the related kernel function is called for the first time after the change. Such calls are made when the X server is started or when the display settings dialog is opened in an already running X server.
--- Documentation/EDID/1024x768.S | 44 ++++++ Documentation/EDID/1280x1024.S | 44 ++++++ Documentation/EDID/1680x1050.S | 44 ++++++ Documentation/EDID/1920x1080.S | 44 ++++++ Documentation/EDID/HOWTO.txt | 39 +++++ Documentation/EDID/Makefile | 26 +++ Documentation/EDID/edid.S | 261 ++++++++++++++++++++++++++++++++++++ Documentation/EDID/hex | 1 Documentation/kernel-parameters.txt | 12 + drivers/gpu/drm/Kconfig | 12 + drivers/gpu/drm/Makefile | 3 drivers/gpu/drm/drm_crtc_helper.c | 8 - drivers/gpu/drm/drm_edid.c | 4 drivers/gpu/drm/drm_edid_load.c | 241 +++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 1 include/drm/drm_edid.h | 1 16 files changed, 782 insertions(+), 3 deletions(-)
Documentation/EDID/1024x768.S new file +44 -0
@@ -0,0 +1,44 @@ +/* + 1024x768.S: EDID data set for standard 1024x768 60 Hz monitor + + Copyright (C) 2011 Carsten Emde <[email protected]> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +/* EDID */ +#define VERSION 1 +#define REVISION 3 + +/* Display */ +#define CLOCK 65000 /* kHz */ +#define XPIX 1024 +#define YPIX 768 +#define XY_RATIO XY_RATIO_4_3 +#define XBLANK 320 +#define YBLANK 38 +#define XOFFSET 8 +#define XPULSE 144 +#define YOFFSET (63+3) +#define YPULSE (63+6) +#define DPI 72 +#define VFREQ 60 /* Hz */ +#define TIMING_NAME "Linux XGA" +#define ESTABLISHED_TIMINGS_BITS 0x08 /* Bit 3 -> 1024x768 @60 Hz */ +#define HSYNC_POL 0 +#define VSYNC_POL 0 +#define CRC 0x55 + +#include "edid.S"
Documentation/EDID/1280x1024.S new file +44 -0
44 lines not on this page · raw message
Documentation/EDID/1680x1050.S new file +44 -0
44 lines not on this page · raw message
Documentation/EDID/1920x1080.S new file +44 -0
44 lines not on this page · raw message
Documentation/EDID/HOWTO.txt new file +39 -0
@@ -0,0 +1,39 @@ +In the good old days when graphics parameters were configured explicitly +in a file called xorg.conf, even broken hardware could be managed. + +Today, with the advent of Kernel Mode Setting, a graphics board is +either correctly working because all components follow the standards - +or the computer is unusable, because the screen remains dark after +booting or it displays the wrong area. Cases when this happens are: +- The graphics board does not recognize the monitor. +- The graphics board is unable to detect any EDID data. +- The graphics board incorrectly forwards EDID data to the driver. +- The monitor sends no or bogus EDID data. +- A KVM sends its own EDID data instead of querying the connected monitor. +Adding the kernel parameter "nomodeset" helps in most cases, but causes +restrictions later on. + +As a remedy for such situations, the kernel configuration item +CONFIG_DRM_LOAD_EDID_FIRMWARE was introduced. It allows to provide an +individually prepared or corrected EDID data set in the /lib/firmware +directory from where it is loaded via the firmware interface. The code +(see drivers/gpu/drm/drm_edid_load.c) contains built-in data sets for +commonly used screen resolutions (1024x768, 1280x1024, 1680x1050, +1920x1080) as binary blobs, but the kernel source tree does not contain +code to create these data. In order to elucidate the origin of the +built-in binary EDID blobs and to facilitate the creation of individual +data for a specific misbehaving monitor, commented sources and a +Makefile environment are given here. + +To create binary EDID and C source code files from the existing data +material, simply type "make". + +If you want to create your own EDID file, copy the file 1024x768.S and +replace the settings with your own data. The CRC value in the last line + #define CRC 0x55 +is a bit tricky. After a first version of the binary data set is +created, it must be be checked with the "edid-decode" utility which will +most probably complain about a wrong CRC. Fortunately, the utility also +displays the correct CRC which must then be inserted into the source +file. After the make procedure is repeated, the EDID data set is ready +to be used.
Documentation/EDID/Makefile new file +26 -0
@@ -0,0 +1,26 @@ + +SOURCES := $(wildcard [0-9]*x[0-9]*.S) + +BIN := $(patsubst %.S, %.bin, $(SOURCES)) + +IHEX := $(patsubst %.S, %.bin.ihex, $(SOURCES)) + +CODE := $(patsubst %.S, %.c, $(SOURCES)) + +all: $(BIN) $(IHEX) $(CODE) + +clean: + @rm -f *.o *.bin.ihex *.bin *.c + +%.o: %.S + @cc -c $^ + +%.bin: %.o + @objcopy -Obinary $^ $@ + +%.bin.ihex: %.o + @objcopy -Oihex $^ $@ + @dos2unix $@ 2>/dev/null + +%.c: %.bin + @echo "{" >$@; hexdump -f hex $^ >>$@; echo "};" >>$@
Documentation/EDID/edid.S new file +261 -0
261 lines not on this page · raw message
Documentation/EDID/hex new file +1 -0
@@ -0,0 +1 @@ +"\t" 8/1 "0x%02x, " "\n"
Documentation/kernel-parameters.txt +12 -0
@@ -713,6 +713,18 @@ bytes respectively. Such letter suffixes The filter can be disabled or changed to another driver later using sysfs. + drm_kms_helper.edid_firmware=<file> + Broken monitors, graphic adapters and KVMs may + send no or broken EDID data sets. This parameter + allows to specify an EDID data set in the + /lib/firmware directory that is used instead. + Generic built-in EDID data sets are used, if one of + edid/1024x768.bin, edid/1280x1024.bin, + edid/1680x1050.bin, or edid/1920x1080.bin is given + and no file with the same name exists. Details and + instructions how to build your own EDID data are + given in Documentation/EDID/HOWTO.txt. + dscc4.setup= [NET] earlycon= [KNL] Output early console device and options.
drivers/gpu/drm/Kconfig +12 -0
@@ -27,6 +27,18 @@ config DRM_KMS_HELPER help FB and CRTC helpers for KMS drivers. +config DRM_LOAD_EDID_FIRMWARE + bool "Allow to specify an EDID data set instead of probing for it" + depends on DRM_KMS_HELPER + help + Say Y here, if you want to use EDID data to be loaded from the + /lib/firmware directory or one of the provided built-in + data sets. This may be necessary, if the graphics adapter or + monitor are unable to provide appropriate EDID data. Since this + feature is provided as a workaround for broken hardware, the + default case is N. Details and instructions how to build your own + EDID data are given in Documentation/EDID/HOWTO.txt. + config DRM_TTM tristate depends on DRM
drivers/gpu/drm/Makefile +3 -0
@@ -17,6 +17,9 @@ drm-y := drm_auth.o drm_buffer.o d drm-$(CONFIG_COMPAT) += drm_ioc32.o drm_kms_helper-y := drm_fb_helper.o drm_crtc_helper.o drm_dp_i2c_helper.o +ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE +drm_kms_helper-y += drm_edid_load.o +endif obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
drivers/gpu/drm/drm_crtc_helper.c +7 -1
@@ -37,6 +37,7 @@#include "drm_fourcc.h" #include "drm_crtc_helper.h" #include "drm_fb_helper.h" +#include "drm_edid.h" static bool drm_kms_helper_poll = true;module_param_named (poll, drm_kms_helper_poll, bool,0600 );
@@ -118,7 +119,12 @@ int drm_helper_probe_single_connector_mo goto prune; } - count = (*connector_funcs->get_modes)(connector); +#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE + count =load_edid_firmware (connector); + if (count == 0) +#endif + count = (*connector_funcs->get_modes)(connector); +if (count ==0 && connector->status == connector_status_connected) count =drm_add_modes_noedid (connector,1024 ,768 );if (count ==0 )
drivers/gpu/drm/drm_edid.c +2 -2
@@ -149,8 +149,7 @@ EXPORT_SYMBOL(drm_edid_header_is_valid);* Sanity check the EDID block (base or extension). Return 0 if the block * doesn't check out, or 1 if it's valid. */ -static bool -drm_edid_block_valid (u8 *raw_edid) +bool drm_edid_block_valid (u8 *raw_edid) {int i;u8 csum =0 ;
@@ -203,6 +202,7 @@ bad: }return 0 ; } +EXPORT_SYMBOL (drm_edid_block_valid);/** * drm_edid_is_valid - sanity check EDID data
drivers/gpu/drm/drm_edid_load.c new file +241 -0
241 lines not on this page · raw message
include/drm/drm_crtc.h +1 -0
@@ -995,6 +995,7 @@ extern int drm_add_modes_noedid(struct d int hdisplay, int vdisplay);extern int drm_edid_header_is_valid (const u8 *raw_edid); +extern bool drm_edid_block_valid (u8 *raw_edid);extern bool drm_edid_is_valid (struct edid *edid);struct drm_display_mode *drm_mode_find_dmt (struct drm_device *dev,int hsize,int vsize,int fresh);
include/drm/drm_edid.h +1 -0
@@ -238,5 +238,6 @@ int drm_av_sync_delay(struct drm_connect struct drm_display_mode *mode);struct drm_connector *drm_select_eld (struct drm_encoder *encoder,struct drm_display_mode *mode); +int load_edid_firmware (struct drm_connector *connector);#endif /* __DRM_EDID_H__ */
PATCH v4 2/2 drivers-gpu-drm-i915-backlight-brightness-inverted.patch
In reply to Carsten EmdeFollowing the documentation of the Legacy Backlight Brightness (LBB) Register in the configuration space of some Intel PCI graphics adapters, setting the LBB register with the value 0x0 causes the backlight to be turned off, and 0xFF causes the backlight to be set to 100% intensity
(http://download.intel.com/embedded/processors/Whitepaper/324567.pdf).
The Acer Aspire 5734Z, however, turns the backlight off at 0xFF and sets it to maximum intensity at 0. In consequence, the screen of this systems becomes dark at an early boot stage which makes it unusable. The same inversion applies to the BLC_PWM_CTL I915 register. This problem was introduced in kernel version 2.6.38 when the PCI device of this system was first supported by the i915 KMS module.
This patch adds a quirk to invert the sense of the brightness variable in case an Acer Aspire 5734Z is encountered.
In addition, there is now a parameter of the i915 module to enable inversion of the brightness variable (i915 brightness_inverted).
--- Documentation/kernel-parameters.txt | 9 +++++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 12 ++++++++++++ drivers/gpu/drm/i915/intel_panel.c | 16 ++++++++++++++++ 4 files changed, 38 insertions(+)
Documentation/kernel-parameters.txt +9 -0
@@ -979,6 +979,15 @@ bytes respectively. Such letter suffixes i8k.restricted [HW] Allow controlling fans only if SYS_ADMIN capability is set. + i915.brightness_inverted + [DRM] Invert the sense of the variable that is used to + set the brightness of the panel backlight. Normally a + value of 0 indicates backlight switched off, and the + maximum value sets the backlight to maximum brightness. + If this parameter is specified, a value of 0 sets the + backlight to maximum brightness, and the maximum value + switches the backlight off. + icn= [HW,ISDN] Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -275,6 +275,7 @@ enum intel_pch {#define QUIRK_PIPEA_FORCE (1<<0)#define QUIRK_LVDS_SSC_DISABLE (1<<1) +#define QUIRK_BRIGHTNESS_INVERTED (1<<2)struct intel_fbdev ;struct intel_fbc_work ;
drivers/gpu/drm/i915/intel_display.c +12 -0
@@ -8950,6 +8950,15 @@ static void quirk_ssc_force_disable(stru dev_priv->quirks |=QUIRK_LVDS_SSC_DISABLE ; } +/* +* At least one machine (Acer Aspire 5734Z) has inverted backlight brightness +*/ +static void quirk_brightness_inverted (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + dev_priv->quirks |=QUIRK_BRIGHTNESS_INVERTED ; +} +struct intel_quirk {int device;int subsystem_vendor;
@@ -8984,6 +8993,9 @@ struct intel_quirk intel_quirks[] = {/* Sony Vaio Y cannot use SSC on LVDS */ { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable }, + +/* Acer Aspire 5734Z has inverted backlight brightness */ + { 0x2a42, 0x1025, 0x0459, quirk_brightness_inverted }, };static void intel_init_quirks (struct drm_device *dev)
drivers/gpu/drm/i915/intel_panel.c +16 -0
@@ -28,6 +28,7 @@* Chris Wilson <[email protected]> */ +#include <linux/moduleparam.h> #include "intel_drv.h" #define PCI_LBPC 0xf4/* legacy/combination backlight modes */
@@ -191,6 +192,10 @@ u32 intel_panel_get_max_backlight(structreturn max; } +static bool brightness_inverted; +MODULE_PARM_DESC (brightness_inverted,"Backlight brightness value is inverted " +"(0 = max brightness, max value = backlight switched off)" ); +module_param_named (brightness_inverted, brightness_inverted, bool,0600 );u32 intel_panel_get_backlight (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -212,6 +217,11 @@ u32 intel_panel_get_backlight(struct drm }DRM_DEBUG_DRIVER ("get backlight PWM = %d\n" , val); +if ((dev_priv->quirks &QUIRK_BRIGHTNESS_INVERTED ) || + brightness_inverted) { +u32 max =intel_panel_get_max_backlight (dev); + val = max - val; + }return val; }
@@ -229,6 +239,12 @@ static void intel_panel_actually_set_bacDRM_DEBUG_DRIVER ("set backlight PWM = %d\n" , level); +if ((dev_priv->quirks &QUIRK_BRIGHTNESS_INVERTED ) || + brightness_inverted) { +u32 max =intel_panel_get_max_backlight (dev); + level = max - level; + } +if (HAS_PCH_SPLIT (dev))return intel_pch_panel_set_backlight (dev, level);
Re: [V4 PATCH 2/2] drivers-gpu-drm-i915-backlight-brightness-inverted.patch
Quoted 12 lines · Carsten Emde
Following the documentation of the Legacy Backlight Brightness (LBB) Register in the configuration space of some Intel PCI graphics adapters, setting the LBB register with the value
0x0causes the backlight to be turned off, and0xFFcauses the backlight to be set to 100% intensity
(http://download.intel.com/embedded/processors/Whitepaper/324567.pdf).
The Acer Aspire 5734Z, however, turns the backlight off at0xFFand sets it to maximum intensity at 0. In consequence, the screen of this systems becomes dark at an early boot stage which makes it unusable. The same inversion applies to theBLC_PWM_CTLI915 register. This problem was introduced in kernel version 2.6.38 when the PCI device of this system was first supported by the i915 KMS module.
Quoted 7 lines
This patch adds a quirk to invert the sense of the brightness variable in case an Acer Aspire 5734Z is encountered.
In addition, there is now a parameter of the i915 module to enable inversion of the brightness variable (i915
brightness_inverted).Signed-off-by Carsten Emde <[email protected]>
If we were being really, really strict this should be 3 patches. One to add the module parameter, one to add the quirk infrastructure, and one to enable quirking for your machine. The theory being that we should be able to modify any of those without impacting the others (i.e. revert the quirk for your machine if we discover some other fundamental borkage without disabling the feature).
I'd prefer the variable for the module parameter to be called i915_panel_invert_brightness (I think the active voice is slightly better here wrt to the code flow). And for the paramter's description to include an instruction to send a quirk for the machine should one find oneselve requiring the w/a.
Quoted 82 lines
--- Documentation/kernel-parameters.txt | 9 +++++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 12 ++++++++++++ drivers/gpu/drm/i915/intel_panel.c | 16 ++++++++++++++++ 4 files changed, 38 insertions(+)Index:
linux-3.3-rc7/Documentation/kernel-parameters.txt
===================================================================Documentation/kernel-parameters.txt +9
-0@@ -979,6 +979,15 @@ bytes respectively. Such letter suffixes i8k.restricted [HW] Allow controlling fans only if SYS_ADMIN capability is set. + i915.brightness_inverted + [DRM] Invert the sense of the variable that is used to + set the brightness of the panel backlight. Normally a + value of 0 indicates backlight switched off, and the + maximum value sets the backlight to maximum brightness. + If this parameter is specified, a value of 0 sets the + backlight to maximum brightness, and the maximum value + switches the backlight off. + icn= [HW,ISDN] Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]Index:
linux-3.3-rc7/drivers/gpu/drm/i915/i915_drv.h
===================================================================drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -275,6 +275,7 @@ enum intel_pch {#define QUIRK_PIPEA_FORCE (1<<0)#define QUIRK_LVDS_SSC_DISABLE (1<<1) +#define QUIRK_BRIGHTNESS_INVERTED (1<<2)struct intel_fbdev ;struct intel_fbc_work ;Index:
linux-3.3-rc7/drivers/gpu/drm/i915/intel_display.c
===================================================================drivers/gpu/drm/i915/intel_display.c +12
-0@@ -8950,6 +8950,15 @@ static void quirk_ssc_force_disable(stru dev_priv->quirks |=QUIRK_LVDS_SSC_DISABLE ; } +/* +* At least one machine (Acer Aspire 5734Z) has inverted backlight brightness +*/ +static void quirk_brightness_inverted (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + dev_priv->quirks |=QUIRK_BRIGHTNESS_INVERTED ; +} +struct intel_quirk {int device;int subsystem_vendor;@@ -8984,6 +8993,9 @@ struct intel_quirk intel_quirks[] = {/* Sony Vaio Y cannot use SSC on LVDS */ { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable }, + +/* Acer Aspire 5734Z has inverted backlight brightness */ + { 0x2a42, 0x1025, 0x0459, quirk_brightness_inverted }, };static void intel_init_quirks (struct drm_device *dev)Index:
linux-3.3-rc7/drivers/gpu/drm/i915/intel_panel.c
===================================================================drivers/gpu/drm/i915/intel_panel.c +1
-0@@ -28,6 +28,7 @@* Chris Wilson <[email protected]> */ +#include <linux/moduleparam.h> #include "intel_drv.h" #define PCI_LBPC 0xf4/* legacy/combination backlight modes */
drivers/gpu/drm/i915/intel_panel.c u32 intel_panel_get_max_backlight(struct · line 198
Quoted 7 lines
drivers/gpu/drm/i915/intel_panel.c +4
-0@@ -191,6 +192,10 @@ u32 intel_panel_get_max_backlight(structreturn max; } +static bool brightness_inverted; +MODULE_PARM_DESC (brightness_inverted,"Backlight brightness value is inverted " +"(0 = max brightness, max value = backlight switched off)" ); +module_param_named (brightness_inverted, brightness_inverted, bool,0600 );
Make this an int, so that we can have a tristate for the user to force the inversion, or to override the quirk if need be, or to use the machine default. (-1 force normal, 0 machine defaults, 1 force inversion).
Quoted 4 lines
drivers/gpu/drm/i915/intel_panel.c +0
-0u32 intel_panel_get_backlight (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_panel.c u32 intel_panel_get_backlight(struct drm · line 226
Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +5
-0@@ -212,6 +217,11 @@ u32 intel_panel_get_backlight(struct drm }DRM_DEBUG_DRIVER ("get backlight PWM = %d\n" , val); +if ((dev_priv->quirks &QUIRK_BRIGHTNESS_INVERTED ) || + brightness_inverted) { +u32 max =intel_panel_get_max_backlight (dev); + val = max - val; + }return val; }
Replace these two duplicated blocks with a function please,
static u32 intel_panel_compute_brightness(stuct drm_device *dev,
u32 val)
{
/* Allow the user to override any quirk with the module parameter */
if (i915_panel_invert_brightness < 0)
return val;
if (i915_panel_invert_brightness > 0 ||
dev_priv->quirks & QUIRK_BRIGHTNESS_INVERTED)
return intel_panel_get_max_backlight(dev) - val;
return val;}
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre