drivers/wireless/cc1101: Add MSK/4-FSK, dynamic PATABLE ramping, and fix IOCTL safety#18527
Merged
simbit18 merged 1 commit intoapache:masterfrom Mar 11, 2026
Merged
drivers/wireless/cc1101: Add MSK/4-FSK, dynamic PATABLE ramping, and fix IOCTL safety#18527simbit18 merged 1 commit intoapache:masterfrom
simbit18 merged 1 commit intoapache:masterfrom
Conversation
…L 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>
jerpelea
approved these changes
Mar 11, 2026
xiaoxiang781216
approved these changes
Mar 11, 2026
anchao
approved these changes
Mar 11, 2026
simbit18
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a comprehensive refactoring and stabilization of the CC1101 wireless character driver. It aligns the driver's software logic with the physical hardware state machine defined in the Texas Instruments specifications (DN013/SWRA151A), ensuring safe cross-band operation and robust IOCTL memory safety.
Key Modifications:
ioctl.hto includeWLIOC_MSKandWLIOC_4FSK. Implemented strict hardware constraint checks inWLIOC_SETMODU(e.g., rejecting MSK if baud rate <= 26 kBaud, enforcing Manchester coding exclusions).rfsettings->PAlogic. Introduced a frequency-awareg_cc1101_pa_calibrationmatrix to dynamically reconstruct thePATABLEvia Burst Access. This natively resolves ASK/OOK pulse truncation and minimizes FSK adjacent-channel splatter.WLIOC_SETTXPOWERandWLIOC_GETTXPOWERnow strictly operate ondBmunits (as defined byioctl.h) using a quantized nearest-match algorithm, abandoning the arbitrary 0-8 indexing.WLIOC_FSK_SETBITRATE(256-511) andWLIOC_FSK_SETFDEV(8-15) to prevent silent register wrap-around under extreme input parameters.DEBUGASSERTchecks with strictif (ptr == NULL) return -EFAULT;validations across all IOCTL branches to prevent user-space-triggered segmentation faults.PATABLEreconstruction call insidecc1101_powerup()to fix the known hardware issue where indices 1-7 are lost during SLEEP state.Impact
WLIOC_SETTXPOWERnow accepts dBm instead of raw index values.Testing
I confirm that changes are verified locally.
Build Host: Fedora 43
Target Architecture: Xtensa / ESP32 (Hardware setup featuring dual CC1101 transceivers and an nRF24L01, EvilCrowRF-V2 layout).
Testing Methods & Results:
WLIOC_SETRADIOFREQ,WLIOC_SETTXPOWER,WLIOC_SETMODU,WLIOC_FSK_SETBITRATE,WLIOC_FSK_SETFDEV) on both/dev/radio0and/dev/radio1. The mathematical saturation and clamping logic proved accurate against the hardware limits (e.g., configuring a 250,000 bps target bitrate cleanly quantized to an actual 249,938 bps; 47,000 Hz target FDEV quantized to 44,433 Hz).WLIOC_SETRADIOFREQcalls:Confirmed that the SPI bus and IOCTL interface behavior for other wireless drivers on the same hardware (
/dev/nrf24l01) remain completely unaffected by the CC1101 IOCTL architecture changes.