KWin全解析 —— overview.md(2)

本文详细解释了KWin中DrmAPI的两种模式:legacy(旧有)和atomicmodesetting(AMS)。介绍了它们的区别,如legacyAPI的步骤和AMS的特性,如drmModeAtomicCommit的功能与标志。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

接前一篇文章:KWin全解析 —— overview.md(1)

本文继续解析KWin源码src/backends/drm/overview.md文件的其余内容。

第10段

There's two APIs for drm, legacy and atomic modesetting (AMS).

drm中有两个APIs,legacy(旧有)和atomic modesetting(AMS)。

第11段

Legacy only exposes connectors and crtcs, and only some of their properties. You first enable a connector and set a mode with `drmModeSetCrtc` and then push new frames with `drmModePageFlip`. `drmModePageFlip` has two flags we care about:

- `DRM_MODE_PAGE_FLIP_EVENT` tells the kernel to generate a page flip event for the crtc, which tells us when the new framebuffer has actually been set / when the old one is not needed anymore

- `DRM_MODE_PAGE_FLIP_ASYNC` tells the kernel that it should immediately apply the new framebuffer without waiting. This may cause tearing

legacy只暴露给connector和crtc,以及它们的一些属性。首先使能connector并使用drmModeSetCrtc函数设置模式,然后使用drmModePageFlip函数推送新帧。drmModePageFlip函数有两个我们关心的标志:

  • DRM_MODE_PAGE_FLIP_EVENT

DRM_MODE_PAGE_FLIP_EVENT告诉内核为crtc生成一个页面翻转事件,它告诉何时新的帧缓冲区被实际设置/何时旧的帧缓冲区不再需要。

  • DRM_MODE_PAGE_FLIP_ASYNC

DRM_MODE_PAGE_FLIP_ASYNC告诉内核应该立即应用新的帧缓冲区,而不需要等待。这可能会导致撕裂。

第12段

For dynamic power management (dpms) you set the dpms property with `drmModeObjectSetProperty` and the kernel will handle the rest behind the scenes, or fail the request. Same story with `VRR_ENABLED`, `overscan` and similar.

对于动态电源管理(dpms),可以使用drmModeObjectSetProperty函数设置dpms属性,内核将在后台处理其余内容,或者使请求失败。与“VRR_ENABLED”、“overscan”和类似的情况相同。

第13段

With atomic modesetting all objects and properties are exposed. AMS works very differently from legacy: it has one generic function `drmModeAtomicCommit` that is used for pretty much everything. How this function works is that you first fill a `drmModeAtomicReq` with the properties you want to set, then you call `drmModeAtomicCommit` with some combination of flags. These flags decide on what the function actually does:

- `DRM_MODE_ATOMIC_TEST_ONLY` only tests whether or not the configuration would work but is guaranteed to not change anything

- `DRM_MODE_PAGE_FLIP_EVENT` tells the kernel that it should generate a page flip event for all crtcs that we change in the commit

- `DRM_MODE_ATOMIC_NONBLOCK` tells the kernel to make this function not blocking; it should not wait until things are actually applied before returning

- `DRM_MODE_ATOMIC_ALLOW_MODESET` tells the kernel that it is allowed to make our changes happen with a modeset, that is an event that can cause the display(s) to flicker or black out for a moment

- `DRM_MODE_PAGE_FLIP_ASYNC` is currently *not* supported. All requests with this flag set fail

通过atomic modesetting(AMS),所有对象和属性都将被公开。AMS的工作方式与legacy(旧有,传统)非常不同:它有一个通用函数drmModeAtomicCommit,用于几乎所有内容。这个函数的工作原理是:首先用要设置的属性填充drmModeAtomicReq,然后用一些标志组合调用drmModeAtomicCommit函数。这些标志决定了函数的实际功能:

  • DRM_MODE_ATOMIC_TEST_ONLY

DRM_MODE_ATOMIC_TEST_ONLY只测试配置是否有效,但保证不会更改任何内容。

  • DRM_MODE_PAGE_FLIP_EVENT

DRM_MODE_PAGE_FLIP_EVENT告诉内核为crtc生成一个页面翻转事件告诉内核,它应该为我们在提交中更改的所有crtc生成一个页面翻转事件。

  • DRM_MODE_ATOMIC_NONBLOCK

DRM_MODE_ATOMIC_NONBLOCK告诉内核使这个函数不阻塞;它不应该等到事物实际应用后才返回。

  • DRM_MODE_ATOMIC_ALLOW_MODESET

DRM_MODE_ATOMIC_ALLOW_MODESET告诉内核允许使用modeset进行更改,这是一个可能导致显示器闪烁或熄灭一段时间的事件。

  • DRM_MODE_PAGE_FLIP_ASYNC

DRM_MODE_PAGE_FLIP_ASYNC当前支持。设置了此标志的所有请求都失败。

第15段

Some upstream documentation can be found at https://www.kernel.org/doc/html/latest/gpu/drm-kms.html, https://01.org/linuxgraphics/gfx-docs/drm/drm-kms-properties.html and in the files at https://github.com/torvalds/linux/tree/master/drivers/gpu/drm.

一些上游文档:

https://www.kernel.org/doc/html/latest/gpu/drm-kms.html

https://01.org/linuxgraphics/gfx-docs/drm/drm-kms-properties.html

以及

https://github.com/torvalds/linux/tree/master/drivers/gpu/drm

中的文件(实际上就是Linux内核源码根目录/drivers/gpu/drm/目录下的各文件)。

第16段

For a lot of documentation on properties and capabilities of devices there's also https://drmdb.emersion.fr/

对于许多关于设备属性和能力的文档可参见:。https://drmdb.emersion.fr/

余下内容请参见下一篇文章。

https://store.kde.org/content/show.php/Tiling?content=161151 Description: Note that this requires kde 4.11 for the config interface at least Tiling script for kwin, featuring: - A useractionmenu to selectively tile windows - Three layouts, all mouse-resizable - One layout with the option to set multiple "master" windows ("M-S-+" to increment, "M-S--" to decrement) - The option to deactivate tiling per-desktop via keybinding - A configuration menu for floating windows (by class) - An option to remove windowborders - "Animated" resizing and moving - Optional "useless" gaps Hotkeys: ("M" here stands for what is usually the windows key, "S" stands for shift) M-PgUp / M-PgDown: Switch layout for current desktop M-S-F11: Deactivate tiling on current desktop M-f: Toggle between tiling and floating for active window M-S-m: Swap active window with the master window M-S-+: Increment number of master windows in (default) "HalfLayout" M-S-h, M-S-j, M-S-k, M-S-l: Move window in corresponding direction The following have been removed in 1.6.2 as they are already provided by kwin (but set to different keys): M-u: Toggle window borders M-h, M-j, M-k, M-l: Switch focus in corresponding direction If you would like to help, consider reporting bugs and maybe even sending pullrequests to www.github.com/faho/kwin-tiling Changelog: 2 years ago * Forgot to enable bladelayout, could lead to crashes/script not working. * 1.0.1: Fix some issues with panel at the top * 1.1.0: Add an option to disable borders This should only be used with FocusUnderMouse, as because of a kwin limitation focus can jump and it's impossible to tell which window has focus * 1.1.1: Bugfixes and an attempt to adjust to new or removed panels * 1.1.2: Enable resize "animations" and bugfixes (again including panel struts) * 1.1.3: Retile on layout switch and keep desktop floating state * 1.1.4: Bugfixes related to tabgroups and the focus hotkeys * 1.2: Properly retile when a client resizes (including borders), "animate" moving, improve resizing "animation", add keybinding to toggle window border and bugfixes * 1.2.1: Remove broken tabgroup handling (tabgroups float for now) and add a possible bugfix for some transparency issues * 1.3 (unreleased): Readd clients that return (e.g. are unminimized) to their previous tile, bugfixes (including resizing) * 1.3.1: Tabgroups, add shortcut (Meta+Shift+M) to swap a window with the master, bugfixes * 1.3.1.1: Fix plasmoids immediately closing * 1.3.1.2: Fix maximizing, fullscreen and resizing bugs * 1.3.2: Fix windows not responding and focus-follows-mouse choosing the wrong window, add an option to open windows as master * 1.3.3: Fix movement losing windows, add workaround for steam update window, fix tiling not working * 1.4: Add option to disable tiling by default, add per-desktop layout configuration (as a line of text currently), add shortcut to toggle borders on all clients (M-S-U), add shortcuts to resize the master window (M-Alt-{h,j,k,l}), minor bug fixes * 1.5: Bugfixes (including crashes), optional gaps between windows, respect min/maxsize (unfortunately this could cause crashes under certain circumstances) * 1.6 (unreleased): Make resizing layout-agnostic, a manual tiling mode, code cleanup, fix tiling when compositing is disabled * 1.6.1: Respect min/maxSizes, multiple (or zero) master support in halflayout, bugfixes * 1.6.2: Make respecting min/MaxSizes an option, improve fullscreen behavior, improve configuration UI, remove shortcuts for toggling a border for a single window and switching focus (as they are provided by kwin itself already) * 1.6.3: Fix crash when number of desktops isn't height * width of desktopgrid, fix default floating list * 1.7.0: Bugfixes, add option to defer placement to kwin
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝天居士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值