fix(display): use active CRTC mode refresh rate on sysfs DRM path#2396
fix(display): use active CRTC mode refresh rate on sysfs DRM path#23961hpEcVns wants to merge 19 commits into
Conversation
…blity with `libfastfetch`
…to the start of process Fixes #2383
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 6 critical |
🟢 Metrics 41 complexity · 0 duplication
Metric Results Complexity 41 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Again. You are not allowed to push code to master branch |
|
|
|
已 rebase 到 dev 分支,不再往 master 推送。此改动由 AI 辅助生成。 |
|
已改用 |
9a6b9e5 to
48db217
Compare
On non-Wayland consoles (kmscon), fastfetch reads EDID and reports the preferred timing refresh rate (e.g. 60Hz) even when the display is actually running at a different mode (e.g. 240Hz). This happens when fastfetch is compiled without libdrm support (FF_HAVE_DRM not defined), causing it to fall through to the sysfs-only drmParseSysfs path which only reads EDID. Add a raw DRM ioctl helper that queries the active CRTC mode via DRM_IOCTL_MODE_GETCRTC without requiring libdrm linkage. The helper navigates connector -> encoder -> CRTC using minimal inline struct definitions matching the kernel UAPI drm_mode.h. Fixes #2392
48db217 to
ea05596
Compare
|
经测试,问题在于用 kmscon 启动时,由于莫名其妙的原因,普通用户失去了访问 根本不是什么没有使用 libdrm 编译。你用 AI 生成这么多代码,第一步打开 /dev/dri/cardN 由于没有权限还是会失败,一点用都没有。 还有你issue里提的解决方案:解析 |
|
你用的啥AI啊,想避个雷 |
我建议所有使用AI生成的提交必须进行人工增强审查 |
|
I recommend that all submissions generated using AI must be manually enhanced for review. |
对绝对不应该鼓励技术人员使用AI,如果一定要使用,则必须进行增强审查 |
|
测试结论: 根因:本机 eDP 面板(AUO26A9)的 sysfs EDID 为空(0 字节),内核驱动未暴露。非 kmscon、非 /dev/dri 权限问题——root 同样读不到 EDID。桌面机(COSMIC Wayland)正常显示 240Hz 是因为 compositor 直接提供刷新率,不走 DRM。 两种方案对比:
场景:tty/无 compositor + eDP EDID 缺失 + 系统包缺 libdrm 时,本 PR 是唯一能读到真实刷新率的路径。 代码已按反馈修改: |
我用的 Opus 4.8 + omp。sudo + ENABLE_DRM 就行。crtc 或许可以作为一个 fallback。 |
|
我看了下,BSD 系统上虽然有 libdrm,但是没有 |
drm设备路径是在/sys目录好吧。。。include那个只是头文件 最后建议一句 任何使用AI的必须遵循人工增强验证 其审核强度必须高于纯人工代码,否则肯定会吃亏的 |
另外 edid数据不可能为空 除非这个接口接的不是显示器,或者没激活 |
edid数据必须通过专门的解码程序解析 |
Summary
On non-Wayland consoles (kmscon, TTY), fastfetch reads EDID and reports the preferred timing refresh rate. When the display has multiple modes at the same resolution (e.g. 2560x1600 @ 60Hz preferred + 240Hz), fastfetch shows 60Hz even when the display is actually running at 240Hz.
Root cause
When fastfetch is compiled without libdrm (
FF_HAVE_DRMnot defined), it falls through todrmParseSysfswhich only reads EDID preferred timing. The libdrm path (drmConnectLibdrm) correctly queries the CRTC for the active mode, but that code is never reached.Fix
Added a raw DRM ioctl helper in
drmParseSysfsthat queries the active CRTC mode without requiring libdrm linkage:/dev/dri/cardNDRM_IOCTL_MODE_GETCONNECTOR→DRM_IOCTL_MODE_GETENCODER→DRM_IOCTL_MODE_GETCRTCAll DRM structs are defined inline (with
ffprefix) to match the kernel UAPIdrm_mode.h, avoiding any dependency on external headers.Before
After
Closes #2392