feat: Add Linux Kernel 7.0 support#84
Conversation
Add case 0 to fl2000_urb_status switch to prevent logging successful URB completions as errors.
- Use devm_drm_bridge_alloc (required by K7.0 DRM subsystem) - Auto-detect FL2000 I2C adapter via bus scan - Force connector status to connected (HPD unreliable) - Bypass EDID reading, inject standard CEA modes (VIC 16/4) - Move INIT_DELAYED_WORK to probe, add NULL checks in remove
- Search ALL htotal adjustments and pick minimum ppm error - Increase htotal search range from ±10 to ±20 - Relax PLL tolerance to 3000 ppm to enable 1080p - Enables 1920x1080 output with ~213 ppm clock accuracy
There was a problem hiding this comment.
Code Review
This pull request updates the IT66121 bridge driver and FL2000 DRM driver to use modern DRM helpers (SHMEM instead of DMA) and improves mode calculation. Key changes include hardcoding standard HDMI modes for the IT66121, implementing auto-detection for the I2C adapter, and refining the PLL optimization loop in the FL2000 driver to find the best match. However, a critical issue was identified in the IT66121 probe function where a potential NULL pointer dereference could occur if the I2C client is not found. Additionally, the loop logic for htotal adjustments in the FL2000 mode calculation is currently broken due to incorrect variable initialization, preventing the optimization from functioning as intended.
| if (IS_ERR(client)) { | ||
| pr_err("Cannot find IT66121 I2C client"); | ||
| kfree(priv); | ||
| return ret; | ||
| return (int)PTR_ERR(client); | ||
| } |
There was a problem hiding this comment.
The check IS_ERR(client) is insufficient because it66121_i2c_init() calls i2c_new_scanned_device(), which returns NULL if no device is found on the bus. If client is NULL, IS_ERR will be false, and the code will proceed to call devm_drm_bridge_alloc() with &client->dev, leading to a NULL pointer dereference. Furthermore, PTR_ERR(NULL) is 0, which would cause the probe function to incorrectly return success even when the hardware is not found.
if (IS_ERR_OR_NULL(client)) {
pr_err("Cannot find IT66121 I2C client");
return client ? (int)PTR_ERR(client) : -ENODEV;
}| struct fl2000_pll candidate_pll = {}; | ||
| u32 candidate_clock; |
There was a problem hiding this comment.
The loop logic for generating adjustments d is currently ineffective because s is initialized to 0 in the loop header (context line 228). This causes d to remain 0 for all iterations, meaning the PLL optimization only evaluates the original htotal. While the header itself is not modified in this hunk, the added logic for tracking the 'best' match depends on d varying across iterations. Please update the loop header to initialize s = 1 to correctly generate the alternating sequence (0, -1, 1, -2, 2, ...) described in the comments.
- Use IS_ERR_OR_NULL for I2C client check to prevent NULL dereference - Fix htotal adjustment loop: s=0 caused d to remain 0 (s=1 needed)
Summary
Adds compatibility with Linux Kernel 7.0 (tested on Nobara/Fedora 43, kernel 7.0.1).
Changes
DRM Bridge (it66121_drv.c)
PLL Optimization (fl2000_drm.c)
URB Fix (fl2000.h)
Testing