view old/linux-2.6.37.6-ftdi_sio.c.patch @ 964:a96cb97b66a2

ringtools/imy: fix duplicate definition of tdma_durations[] The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>, although the present fix is slightly different from the contributed patch: because main.c doesn't need this tdma_durations[] array at all, let's simply remove the reference to this array from main.c rather than turn it into an extern. I no longer remember my original thought flow that resulted (by mistake) in tdma_durations[] being multiply defined in main.c and durations.c. My intent might have been to define all globals in main.c and have the reference in durations.c be an extern - and I missed that extern - but without clear memory, I have no certainty. In any case, having this data array defined in the same module that fills it (durations.c) is sensible, so let's make it the new way.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 31 Aug 2023 19:38:18 +0000
parents 40f44aa49dd0
children
line wrap: on
line source

--- ftdi_sio.c.orig	2011-03-27 11:01:41.000000000 -0800
+++ ftdi_sio.c	2015-10-30 13:18:40.879000032 -0800
@@ -949,7 +949,7 @@
 	static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
 	__u32 divisor;
 	/* divisor shifted 3 bits to the left */
-	int divisor3 = base / 2 / baud;
+	int divisor3 = (base / 2 + baud / 2) / baud;
 	divisor = divisor3 >> 3;
 	divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
 	/* Deal with special cases for highest baud rates. */
@@ -1087,6 +1087,17 @@
 	baud = tty_get_baud_rate(tty);
 	dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
 
+	/*
+	 * FreeCalypso hack: translate non-std high
+	 * baud rates for GSM like CP2102 does.
+	 */
+	if (baud == 230400)
+		baud = 203125;
+	else if (baud == 460800)
+		baud = 406250;
+	else if (baud == 921600)
+		baud = 812500;
+
 	/* 2. Observe async-compatible custom_divisor hack, update baudrate
 	   if needed */