svn commit: r364148 - head/sys/arm/allwinner
Andriy Gapon
avg at FreeBSD.org
Wed Aug 12 09:56:21 UTC 2020
Author: avg
Date: Wed Aug 12 09:56:21 2020
New Revision: 364148
URL: https://svnweb.freebsd.org/changeset/base/364148
Log:
aw_cir: lower activation threshold to support NECx protocol
In NECx the leading mark has length of 8T as opposed to 16T in NEC,
where T is 562.5 us. So, 4.5 ms.
Our threshold was set to 128 * 42.7 us (derived from the sampling
frequency of 3/128 MHz). So, ~5.5 ms.
The new threshold is set to AW_IR_L1_MIN. I think that's a good enough
lower bound for detecting the leading pulse.
Also, calculations of active_delay (which is activation delay) are fixed.
Previously they would be wrong if AW_IR_ACTIVE_T was anything but zero,
because the value was already bit-shifted.
Finally, I am not sure why the activation delay was divided by two when
calculating the initial pulse length. I have not found anything that
would explain or justify it. So, I removed that division.
MFC after: 3 weeks
Modified:
head/sys/arm/allwinner/aw_cir.c
Modified: head/sys/arm/allwinner/aw_cir.c
==============================================================================
--- head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:52:39 2020 (r364147)
+++ head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:56:21 2020 (r364148)
@@ -126,8 +126,10 @@ __FBSDID("$FreeBSD$");
#define AW_IR_DMAX 53
/* Active Thresholds */
-#define AW_IR_ACTIVE_T ((0 & 0xff) << 16)
-#define AW_IR_ACTIVE_T_C ((1 & 0xff) << 23)
+#define AW_IR_ACTIVE_T_VAL AW_IR_L1_MIN
+#define AW_IR_ACTIVE_T (((AW_IR_ACTIVE_T_VAL - 1) & 0xff) << 16)
+#define AW_IR_ACTIVE_T_C_VAL 0
+#define AW_IR_ACTIVE_T_C ((AW_IR_ACTIVE_T_C_VAL & 0xff) << 23)
/* Code masks */
#define CODE_MASK 0x00ff00ff
@@ -209,9 +211,9 @@ aw_ir_decode_packets(struct aw_ir_softc *sc)
device_printf(sc->dev, "sc->dcnt = %d\n", sc->dcnt);
/* Find Lead 1 (bit separator) */
- active_delay = (AW_IR_ACTIVE_T + 1) * (AW_IR_ACTIVE_T_C != 0 ? 128 : 1);
- len = 0;
- len += (active_delay >> 1);
+ active_delay = AW_IR_ACTIVE_T_VAL *
+ (AW_IR_ACTIVE_T_C_VAL != 0 ? 128 : 1);
+ len = active_delay;
if (bootverbose)
device_printf(sc->dev, "Initial len: %ld\n", len);
for (i = 0; i < sc->dcnt; i++) {
More information about the svn-src-head
mailing list