The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm: make panel orientation quirks optional
@ 2026-07-16  6:51 Andrew Zhou
  2026-07-16  6:59 ` Thomas Zimmermann
  2026-08-15  4:13 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Zhou @ 2026-07-16  6:51 UTC (permalink / raw)
  To: dri-devel
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	linux-kernel, Andrew Zhou

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.

Signed-off-by: Andrew Zhou <zhoulol888@gmail.com>
---
 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(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 323422861e8f..da4ac94bbf61 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -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.
diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 3a218fb592ce..fb09078a831a 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -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
diff --git a/include/drm/drm_utils.h b/include/drm/drm_utils.h
index 6a46f755daba..947b8e71260e 100644
--- a/include/drm/drm_utils.h
+++ b/include/drm/drm_utils.h
@@ -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;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-15  4:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  6:51 [PATCH] drm: make panel orientation quirks optional Andrew Zhou
2026-07-16  6:59 ` Thomas Zimmermann
2026-08-15  4:13 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox