From 6b34a3cfe4e0cf16507a965de0de9f5d3ccd2459 Mon Sep 17 00:00:00 2001
From: "A. Maitland Bottoms" <bottoms@debian.org>
Date: Sun, 14 Aug 2022 11:14:15 -0400
Subject: [PATCH 1/2] cross platformify

Assume isAvxPresent = true to allow 2020 mode
to be enabled for all processors, even if some are too slow
for good real-time operation.
---
 src/util.cpp | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/util.cpp b/src/util.cpp
index 0e2d8c1..189b106 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -124,43 +124,21 @@ void MainFrame::ClosePTTInPort(void)
 }
 
 //
-// checkAvxSupport
+// Not really checkAvxSupport
 //
 // Tests the underlying platform for AVX support.  2020 needs AVX support to run
 // in real-time, and old processors do not offer AVX support
+// The check for AVX support is not a perfect metric for disabling 2020 mode.
 //
 
-#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
 void MainFrame::checkAvxSupport(void)
 {
-
-    isAvxPresent = false;
-    uint32_t eax, ebx, ecx, edx;
-    eax = ebx = ecx = edx = 0;
-    __cpuid(1, eax, ebx, ecx, edx);
-
-    if (ecx & (1<<27) && ecx & (1<<28)) {
-        // CPU supports XSAVE and AVX
-        uint32_t xcr0, xcr0_high;
-        asm("xgetbv" : "=a" (xcr0), "=d" (xcr0_high) : "c" (0));
-        isAvxPresent = (xcr0 & 6) == 6;    // AVX state saving enabled?
-    }
-}
-#elif defined(__APPLE__) && defined(__aarch64__)
-void MainFrame::checkAvxSupport(void)
-{
-    // Force 2020 mode to be enabled on ARM Macs. This is experimental
+    // Force 2020 mode to be enabled always. This is experimental
     // and may cause problems. During preliminary testing it seems to use
     // NEON optimizations enabled in LPCNet and consumes less than 100% of a single
     // core while decoding audio.
     isAvxPresent = true;
 }
-#else
-void MainFrame::checkAvxSupport(void)
-{
-    isAvxPresent = false;
-}
-#endif
 
 struct FIFO extern  *g_txDataInFifo;
 struct FIFO extern *g_rxDataOutFifo;
-- 
2.35.1

