From: 2a6b1cae1a2334b19bd74f695d54a7d6cab28041
Author: Teddy Wang <59642778+teddywlq@users.noreply.github.com>
Date: Fri Feb 21 17:47:43 2025 +0800
Subject: Add support kernel above 6.11
origin: https://github.com/teddywlq/smifb2.git

Signed-off-by: Massimiliano Pellizzer <massimiliano.pellizzer@canonical.com>
---
 smifb2/Kconfig    |    1 +
 smifb2/smi_drv.c  |   16 +++++++++++++---
 smifb2/smi_main.c |    2 ++
 3 files changed, 16 insertions(+), 3 deletions(-)

--- a/smifb2/Kconfig
+++ b/smifb2/Kconfig
@@ -3,6 +3,7 @@
 config DRM_SMI
 	tristate "SiliconMotion SM750/SM768 DRM driver"
 	depends on DRM && PCI && MMU
+	select DRM_CLIENT_SELECTION
 	select DRM_VRAM_HELPER
 	select DRM_KMS_HELPER
 	select DRM_TTM
--- a/smifb2/smi_drv.c
+++ b/smifb2/smi_drv.c
@@ -28,7 +28,10 @@
 #include <drm/drm_vblank.h>
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
+#include <linux/aperture.h>
+#include <drm/drm_client_setup.h>
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
 #include <drm/drm_aperture.h>
 #endif
 
@@ -141,7 +144,9 @@
 	}
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
+       aperture_remove_conflicting_pci_devices(pdev, driver.name);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
 	drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
 	drm_aperture_remove_conflicting_pci_framebuffers(pdev, "smidrmfb");
@@ -192,7 +197,9 @@
 #else
 	if ((sdev->specId == SPC_SM750 && (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) || sdev->specId == SPC_SM768)
 #endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
+           drm_client_setup(dev, NULL);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
 		drm_fbdev_ttm_setup(dev, dev->mode_config.preferred_depth);
 #else
 		drm_fbdev_generic_setup(dev, dev->mode_config.preferred_depth);
@@ -592,6 +599,9 @@
 	.debugfs_init = smi_debugfs_init,
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
+       DRM_FBDEV_TTM_DRIVER_OPS,
+#endif
 
 };
 
--- a/smifb2/smi_main.c
+++ b/smifb2/smi_main.c
@@ -57,7 +57,9 @@
 
 static const struct drm_mode_config_funcs smi_mode_config_funcs = {
 	.fb_create = smi_user_framebuffer_create,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0)
 	.output_poll_changed = drm_fb_helper_output_poll_changed,
+#endif
 	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
