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>
[john-cabaj: context changes]
Signed-off-by: John Cabaj <john.cabaj@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");
@@ -188,7 +193,9 @@
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
 	if ((g_specId == SPC_SM750 && (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) || g_specId == SPC_SM768)
-#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);
@@ -437,7 +444,6 @@
 }
 #endif
 
-
 static const struct dev_pm_ops smi_pm_ops = {
 	.suspend = smi_pm_suspend,
 	.resume = smi_pm_resume,
@@ -543,6 +549,10 @@
 	DRM_GEM_VRAM_DRIVER_PRIME,
 #endif
 	.gem_prime_import_sg_table = smi_gem_prime_import_sg_table,
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
+       DRM_FBDEV_TTM_DRIVER_OPS,
+#endif
 };
 
 static int __init smi_init(void)
--- a/smifb2/smi_main.c
+++ b/smifb2/smi_main.c
@@ -59,7 +59,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,
 };
