wireless/cc1101: Add MSK/4-FSK, dynamic PATABLE ramping, and fix IOCTL safety

This commit overhauls the CC1101 RF driver to address physical hardware
constraints, prevent register wrap-around overflows, and support accurate
dBm power scaling via the standard IOCTL interface.

What this change does:
1. Adds WLIOC_MSK and WLIOC_4FSK modulation support in `ioctl.h` and driver.
2. Replaces static PATABLE initialization with a dynamic Ramp-up curve
   generator `cc1101_ioctl_apply_power()` based on lab calibration data.
3. Modifies WLIOC_SETTXPOWER and WLIOC_GETTXPOWER to process actual dBm
   values with a nearest-match algorithm instead of raw array indices.
4. Removes DEBUGASSERT on user-space IOCTL pointers and replaces them
   with strict -EFAULT checks.
5. Implements saturation clamping (e.g., mantissa to 256-511) to prevent
   bitrate and frequency deviation calculation overflows.
6. Rebuilds volatile PATABLE memory upon SLEEP mode wake-up.

Why it is necessary & what it fixes:
- Fixes severe OOK modulation distortion and FSK spectral splatter caused
  by statically assigned PATABLE indices.
- Fixes potential kernel panic in flat builds when IOCTL receives a NULL
  pointer from user space.
- Fixes register wrap-around (silent failures) when users pass
  out-of-bounds baud rate or FDEV values.
- Prevents RF silence after SLEEP mode due to PATABLE volatility.
- Resolves inaccurate power output when changing frequencies dynamically.

Impact:
Changes the behavior of CC1101 TX power and modulation IOCTLs to strictly
comply with standard `wlioc` definitions. Improves overall driver stability
and hardware safety.

Signed-off-by: Chip L. <chplee@gmail.com>
This commit is contained in:
Chip L.
2026-03-11 16:05:34 +08:00
committed by simbit18
parent 3bea64dbb0
commit 7bfd6ee33e
2 changed files with 375 additions and 53 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -300,7 +300,9 @@ enum wlioc_modulation_e
WLIOC_LORA,
WLIOC_FSK,
WLIOC_GFSK,
WLIOC_OOK
WLIOC_OOK,
WLIOC_4FSK,
WLIOC_MSK
};
/* LoRa common types ********************************************************/