From 75f304cf0158518dd8e663f611d50708280c476a Mon Sep 17 00:00:00 2001 From: ZHANG Yuntian <95260730+RadxaYuntian@users.noreply.github.com> Date: Thu, 28 Mar 2024 16:29:03 +0800 Subject: [PATCH] fix: detect Rockchip kernel and their shenanigans Closes #3. Signed-off-by: ZHANG Yuntian --- debian/patches/fix-linux-6.1-build.patch | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/debian/patches/fix-linux-6.1-build.patch b/debian/patches/fix-linux-6.1-build.patch index 30eb735..811edf4 100644 --- a/debian/patches/fix-linux-6.1-build.patch +++ b/debian/patches/fix-linux-6.1-build.patch @@ -6,10 +6,10 @@ index 107e151..a8d2e05 100644 "\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n", __func__); wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy_apply_custom_regulatory(wiphy, regdomain); #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)) memcpy(country_code, default_ccode, sizeof(default_ccode)); @@ -18,10 +18,10 @@ index 107e151..a8d2e05 100644 __func__); wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; - wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) + wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy_apply_custom_regulatory(wiphy, &rwnx_regdom); #endif // Check if custom channel set shall be enabled. In such case only monitor mode is @@ -30,10 +30,10 @@ index 107e151..a8d2e05 100644 return; - wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) + wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; rtnl_lock(); @@ -45,10 +45,10 @@ index 4aa6eba..3d16e63 100644 "\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n", __func__); wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy_apply_custom_regulatory(wiphy, regdomain); #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)) memcpy(country_code, default_ccode, sizeof(default_ccode)); @@ -57,10 +57,10 @@ index 4aa6eba..3d16e63 100644 __func__); wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; - wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) + wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy_apply_custom_regulatory(wiphy, &rwnx_regdom); #endif // Check if custom channel set shall be enabled. In such case only monitor mode is @@ -71,10 +71,10 @@ index 4aa6eba..3d16e63 100644 - - wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; + -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) + wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; rtnl_lock(); @@ -86,10 +86,10 @@ index 146bba6..a4befec 100644 "\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n", __func__); wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy_apply_custom_regulatory(wiphy, regdomain); #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)) memcpy(country_code, default_ccode, sizeof(default_ccode)); @@ -97,10 +97,10 @@ index 146bba6..a4befec 100644 // registration (in rwnx_set_wiphy_params()), so nothing has to be done here #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) -+ /* From kernel 6.1.0, this bit is removed and will be reused later */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) ++ /* From kernel 6.5.0, this bit is removed and will be reused later */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) && IS_ENABLED(CONFIG_ROCKCHIP_RKNPU)) wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF; -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */ ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) */ wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; if (!rwnx_hw->mod_params->custregd)