Skip to contentSkip to conversation

drm: make panel orientation quirks optional

PATCH In review Andrew Zhou 4 participants 4 messages Jul 16 – Aug 15

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: make panel orientation quirks optional

DRM currently selects DRM_PANEL_ORIENTATION_QUIRKS unconditionally, forcing all DRM users to compile embedded LCD panel quirk detection. This is unnecessary on desktop and server systems with external monitors.

Add a static inline stub in drm_utils.h that returns DRM_MODE_PANEL_ORIENTATION_UNKNOWN when the option is disabled, and make the Kconfig option user-visible with a description.

Compile-tested with CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y and =n. Boot-tested in QEMU with TinyCorePure64.

---
 drivers/gpu/drm/Kconfig                        | 14 ++++++++++++--
 drivers/gpu/drm/drm_panel_orientation_quirks.c |  6 ++++--
 include/drm/drm_utils.h                        |  8 ++++++++
 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/Kconfig +12 -2
index 323422861e8f..da4ac94bbf61 100644
@@ -8,7 +8,6 @@
 menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
 	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
-	select DRM_PANEL_ORIENTATION_QUIRKS
 	select HDMI
 	select I2C
 	select DMA_SHARED_BUFFER
@@ -369,4 +368,15 @@ endif
 
 # Separate option because drm_panel_orientation_quirks.c is shared with fbdev
 config DRM_PANEL_ORIENTATION_QUIRKS
-	tristate
+	tristate "Panel orientation quirks for DMI-based detection"
+	depends on DRM
+	help
+	  Enable DMI-based quirk detection for devices where the
+	  built-in LCD panel is mounted in a non-standard orientation
+	  relative to the casing (e.g., handheld PCs, tablets).
+
+	  This allows userspace to automatically rotate the display
+	  to match the physical orientation of the device.
+
+	  Desktop and server systems with external monitors do not
+	  need this. If unsure, say N.
drivers/gpu/drm/drm_panel_orientation_quirks.c +4 -2
index 3a218fb592ce..fb09078a831a 100644
@@ -14,7 +14,7 @@
 #include <drm/drm_connector.h>
 #include <drm/drm_utils.h>
 
-#ifdef CONFIG_DMI
+#if defined(CONFIG_DMI) && defined(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS)
 
 /*
  * Some x86 clamshell design devices use portrait tablet screens and a display
@@ -589,7 +589,7 @@ EXPORT_SYMBOL(drm_get_panel_orientation_quirk);
 
 #else
 
-/* There are no quirks for non x86 devices yet */
+/* Fallback stub when DMI or the entire quirk module is disabled. */
 int drm_get_panel_orientation_quirk(int width, int height)
 {
 	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
@@ -598,5 +598,7 @@ EXPORT_SYMBOL(drm_get_panel_orientation_quirk);
 
 #endif
 
+#ifdef CONFIG_DRM_PANEL_ORIENTATION_QUIRKS
 MODULE_DESCRIPTION("Quirks for non-normal panel orientation");
 MODULE_LICENSE("Dual MIT/GPL");
+#endif
include/drm/drm_utils.h +8 -0
index 6a46f755daba..947b8e71260e 100644
@@ -11,10 +11,18 @@
 #define __DRM_UTILS_H__
 
 #include <linux/types.h>
+#include <drm/drm_connector.h>
 
 struct drm_edid;
 
+#ifdef CONFIG_DRM_PANEL_ORIENTATION_QUIRKS
 int drm_get_panel_orientation_quirk(int width, int height);
+#else
+static inline int drm_get_panel_orientation_quirk(int width, int height)
+{
+	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
+}
+#endif
 
 struct drm_panel_backlight_quirk {
 	u16 min_brightness;
Signature · 1 line
2.54.0
#1 lore raw

Hi

Am 16.07.26 um 08:51 schrieb Andrew Zhou:

Quoted 11 lines

DRM currently selects DRM_PANEL_ORIENTATION_QUIRKS unconditionally, forcing all DRM users to compile embedded LCD panel quirk detection. This is unnecessary on desktop and server systems with external monitors.

Add a static inline stub in drm_utils.h that returns DRM_MODE_PANEL_ORIENTATION_UNKNOWN when the option is disabled, and make the Kconfig option user-visible with a description.

Compile-tested with CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y and =n. Boot-tested in QEMU with TinyCorePure64.

NAK. We also need these quirks on desktops, and disabling error workarounds makes little sense IMHO.

Best regards
Thomas

Quoted 90 lines
---
  drivers/gpu/drm/Kconfig                        | 14 ++++++++++++--
  drivers/gpu/drm/drm_panel_orientation_quirks.c |  6 ++++--
  include/drm/drm_utils.h                        |  8 ++++++++
  3 files changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/Kconfig +12 -2
index 323422861e8f..da4ac94bbf61 100644
@@ -8,7 +8,6 @@
  menuconfig DRM
  	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
  	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
-	select DRM_PANEL_ORIENTATION_QUIRKS
  	select HDMI
  	select I2C
  	select DMA_SHARED_BUFFER
@@ -369,4 +368,15 @@ endif
 
  # Separate option because drm_panel_orientation_quirks.c is shared with fbdev
  config DRM_PANEL_ORIENTATION_QUIRKS
-	tristate
+	tristate "Panel orientation quirks for DMI-based detection"
+	depends on DRM
+	help
+	  Enable DMI-based quirk detection for devices where the
+	  built-in LCD panel is mounted in a non-standard orientation
+	  relative to the casing (e.g., handheld PCs, tablets).
+
+	  This allows userspace to automatically rotate the display
+	  to match the physical orientation of the device.
+
+	  Desktop and server systems with external monitors do not
+	  need this. If unsure, say N.
drivers/gpu/drm/drm_panel_orientation_quirks.c +4 -2
index 3a218fb592ce..fb09078a831a 100644
@@ -14,7 +14,7 @@
  #include <drm/drm_connector.h>
  #include <drm/drm_utils.h>
 
-#ifdef CONFIG_DMI
+#if defined(CONFIG_DMI) && defined(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS)
 
  /*
   * Some x86 clamshell design devices use portrait tablet screens and a display
@@ -589,7 +589,7 @@ EXPORT_SYMBOL(drm_get_panel_orientation_quirk);
 
  #else
 
-/* There are no quirks for non x86 devices yet */
+/* Fallback stub when DMI or the entire quirk module is disabled. */
  int drm_get_panel_orientation_quirk(int width, int height)
  {
  	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
@@ -598,5 +598,7 @@ EXPORT_SYMBOL(drm_get_panel_orientation_quirk);
 
  #endif
 
+#ifdef CONFIG_DRM_PANEL_ORIENTATION_QUIRKS
  MODULE_DESCRIPTION("Quirks for non-normal panel orientation");
  MODULE_LICENSE("Dual MIT/GPL");
+#endif
include/drm/drm_utils.h +8 -0
index 6a46f755daba..947b8e71260e 100644
@@ -11,10 +11,18 @@
  #define __DRM_UTILS_H__
 
  #include <linux/types.h>
+#include <drm/drm_connector.h>
 
  struct drm_edid;
 
+#ifdef CONFIG_DRM_PANEL_ORIENTATION_QUIRKS
  int drm_get_panel_orientation_quirk(int width, int height);
+#else
+static inline int drm_get_panel_orientation_quirk(int width, int height)
+{
+	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
+}
+#endif
 
  struct drm_panel_backlight_quirk {
  	u16 min_brightness;
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)
#2 lore raw
In reply to Andrew Zhou
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Decoupling the module state from the core DRM subsystem causes silent feature loss when DRM is…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Decoupling the module state from the core DRM subsystem causes silent feature loss when DRM is built-in and the quirk is a module.
- [Medium] Adding depends on DRM to DRM_PANEL_ORIENTATION_QUIRKS causes Kconfig unmet direct dependency warnings when selected by fbdev drivers.
- [Low] Using #ifdef for a tristate config causes compiler redefinition errors and strips module metadata for loadable module (=m) builds. --

--- Patch [1]: [PATCH] drm: make panel orientation quirks optional --- commit babf1234e204a4c51ca97865c82a0c78512e71b2
Author: Andrew Zhou <[email protected]>

drm: make panel orientation quirks optional

This commit removes the unconditional selection of DRM_PANEL_ORIENTATION_QUIRKS from the DRM subsystem. It makes the option user-visible, adds a dependency on DRM, and provides fallback stubs for when the option is disabled.

drivers/gpu/drm/Kconfig line 11

Quoted 9 lines
drivers/gpu/drm/Kconfig +0 -1
index 323422861e8f6..da4ac94bbf615 100644
@@ -8,7 +8,6 @@
 menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
 	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
-	select DRM_PANEL_ORIENTATION_QUIRKS

[Severity: High]
Does removing this select statement allow the core DRM subsystem to be built-in while DRM_PANEL_ORIENTATION_QUIRKS is configured as a module?

If this configuration happens, the built-in DRM core code might evaluate the preprocessor checks for the quirk module as false, which could cause the panel orientation functionality to be silently dropped even though the module is built.

drivers/gpu/drm/Kconfig endif · line 372

Quoted 9 lines
drivers/gpu/drm/Kconfig +2 -1
 	select HDMI
[ ... ]
@@ -369,4 +368,15 @@ endif
 
 # Separate option because drm_panel_orientation_quirks.c is shared with fbdev
 config DRM_PANEL_ORIENTATION_QUIRKS
-	tristate
+	tristate "Panel orientation quirks for DMI-based detection"
+	depends on DRM

[Severity: Medium]
Can this new dependency cause Kconfig unmet direct dependency warnings?

The FB_EFI config option unconditionally selects DRM_PANEL_ORIENTATION_QUIRKS since it shares this code. If a system is configured with CONFIG_FB_EFI=y and CONFIG_DRM=n, the selection from the EFI framebuffer could violate this new dependency on DRM, causing a Kconfig unmet dependency warning.

Quoted 29 lines
drivers/gpu/drm/Kconfig +1 -0
+	help
[ ... ]
drivers/gpu/drm/drm_panel_orientation_quirks.c +1 -1
index 3a218fb592cef..fb09078a831af 100644
@@ -589,7 +589,7 @@ EXPORT_SYMBOL(drm_get_panel_orientation_quirk);
 
 #else
 
-/* There are no quirks for non x86 devices yet */
+/* Fallback stub when DMI or the entire quirk module is disabled. */
 int drm_get_panel_orientation_quirk(int width, int height)
 {
 	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
@@ -598,5 +598,7 @@ EXPORT_SYMBOL(drm_get_panel_orientation_quirk);
 
 #endif
[ ... ]
include/drm/drm_utils.h +1 -0
index 6a46f755daba0..947b8e71260e3 100644
@@ -11,10 +11,18 @@
 #define __DRM_UTILS_H__
 
 #include <linux/types.h>
+#include <drm/drm_connector.h>
 

include/drm/drm_utils.h line 25

Quoted 10 lines
include/drm/drm_utils.h +7 -0
 struct drm_edid;
 
+#ifdef CONFIG_DRM_PANEL_ORIENTATION_QUIRKS
 int drm_get_panel_orientation_quirk(int width, int height);
+#else
+static inline int drm_get_panel_orientation_quirk(int width, int height)
+{
+	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
+}
+#endif

[Severity: Low]
Does this preprocessor check properly handle tristate module builds?

If CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=m is configured, kbuild defines CONFIG_DRM_PANEL_ORIENTATION_QUIRKS_MODULE instead. This causes the check above to evaluate as false, providing the static inline stub in the header.

Meanwhile, drm_panel_orientation_quirks.c evaluates its own matching check as false and defines a non-static fallback stub for the exact same function. Including this header in that source file could result in a compiler redefinition error.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw
In reply to Andrew Zhou
kernel test robot noticed the following build errors:

Hi Andrew,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on daeinki-drm-exynos/exynos-drm-next drm/drm-next drm-i915/for-linux-next drm-i915/for-linux-next-fixes drm-tip/drm-tip linus/master v7.2-rc7 next-20260813] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andrew-Zhou/drm-make-panel-orientation-quirks-optional/20260815-090825
base:   https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link:    https://lore.kernel.org/r/20260716065106.150760-1-zhoulol888%40gmail.com
patch subject: [PATCH] drm: make panel orientation quirks optional
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20260815/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260815/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/drm_panel_orientation_quirks.c:593:5: error: redefinition of 'drm_get_panel_orientation_quirk'

593 | int drm_get_panel_orientation_quirk(int width, int height)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/gpu/drm/drm_panel_orientation_quirks.c:15:
include/drm/drm_utils.h:21:19: note: previous definition of 'drm_get_panel_orientation_quirk' with type 'int(int, int)'
21 | static inline int drm_get_panel_orientation_quirk(int width, int height)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/drm_get_panel_orientation_quirk +593 drivers/gpu/drm/drm_panel_orientation_quirks.c

404d1a3edc3873 Hans de Goede 2017-11-25 591

8a445de79eeaed Andrew Zhou   2026-07-16  592  /* Fallback stub when DMI or the entire quirk module is disabled. */
404d1a3edc3873 Hans de Goede 2017-11-25 @593  int drm_get_panel_orientation_quirk(int width, int height)
404d1a3edc3873 Hans de Goede 2017-11-25  594  {
404d1a3edc3873 Hans de Goede 2017-11-25  595  	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
404d1a3edc3873 Hans de Goede 2017-11-25  596  }
404d1a3edc3873 Hans de Goede 2017-11-25  597  EXPORT_SYMBOL(drm_get_panel_orientation_quirk);

404d1a3edc3873 Hans de Goede 2017-11-25 598

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki