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
This commit is contained in:
Andriy Gapon 2020-08-12 09:56:21 +00:00
parent 8b616b263d
commit 852d135791
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364148

View File

@ -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++) {