This series implements support for various YUV/YCbCr formats in the vkms writeback connector. The goal is to facilitate driver development of hardware writeback connectors that (only) support these formats. In order to do so the series adds two new optional connector properties, WRITEBACK_COLOR_ENCODING and WRITEBACK_COLOR_RANGE, modeled after the existing plane properties COLOR_ENCODING and COLOR_RANGE. These are needed by user space clients to know - and optionally control - the matrix coefficients and quantization range for YUV to RGB conversions.
While I'm aware of plans to deprecate the COLOR_ENCODING and COLOR_RANGE plane properties in the context of ongoing color work, it is unclear if and when the successor will get implemented in vkms. Thus, and in light of the optional and non-invasive nature of the new properties, I hope there is no strong resistance against the later. The implementation tries to reuse and mirror the existing YUV support for planes as much as possible in order to minimize maintenance burden. On the user space side a Weston compositor and client implementation can be found here: https://gitlab.freedesktop.org/rmader/weston/-/commits/vkms-writeback-yuv-v1 It can be tested with the following steps: 1. Run `weston --debug --drm-device=card0` from a TTY to run Weston with vkms and the screenshot protocol enabled. 2. Run e.g. `WAYLAND_DISPLAY=wayland-1 weston-screenshooter -s 1 -b 2 -c 2 -r 1 -f P010` in order to capture a screenshot with DRM_FORMAT_P010, ITU-R BT.2020 YCbCr color encoding and YCbCr full range. 3. The resulting .yuv files for now lack metadata, but can be opened by various clients such as ffmpeg or YUView (see link below) when adding the information about the used format, size and encoding/range. See https://flathub.org/apps/de.rwth_aachen.ient.YUView Given that Mesas gbm implementation does not support allocation YUV buffers yet, the client implementation (weston-screenshooter) uses udmabuf instead. This approach should work with any writeback connector that has an IOMMU and supports buffer import from virtual system memory. The series is build on top of "drm/vkms: Add support for multiple plane formats" v7, which adds plane/input support for formats like DRM_FORMAT_P010 that are also covered, see https://lore.kernel.org/dri-devel/20250703-b4-new-color-formats-v7-0-15fd8fd2e...@bootlin.com/ Thus I'm taking the freedom to CC everyone involved there, hope that's ok :) Additional notes: - Weston requires a successful gbm_bo_import() of the buffer. Thus when testing with llvmpipe, a recent Mesa version (>=25.2) is required. For the formats DRM_FORMAT_NV61, DRM_FORMAT_NV24 and DRM_FORMAT_NV42 support is not upstream yet, but the following branch can be used for testing: https://gitlab.freedesktop.org/rmader/mesa/-/commits/yuv-formats-nv61-nv24-nv42 It is co-developed with a Weston implementation Robert Mader (5): drm: Add WRITEBACK_COLOR_ENCODING and WRITEBACK_COLOR_RANGE properties drm/vkms: Add RGB to YUV conversion matrices drm/vkms: Add WRITEBACK_COLOR_ENCODING and WRITEBACK_COLOR_RANGE properties drm/vkms: Add support for writing semiplanar YUV/YCbCr formats drm/vkms: Add YUV formats to writeback connector drivers/gpu/drm/drm_atomic_uapi.c | 8 + drivers/gpu/drm/drm_color_mgmt.c | 90 +++++ drivers/gpu/drm/vkms/tests/vkms_format_test.c | 51 ++- drivers/gpu/drm/vkms/vkms_drv.h | 51 ++- drivers/gpu/drm/vkms/vkms_formats.c | 325 +++++++++++++++++- drivers/gpu/drm/vkms/vkms_formats.h | 7 + drivers/gpu/drm/vkms/vkms_writeback.c | 68 +++- include/drm/drm_color_mgmt.h | 7 + include/drm/drm_connector.h | 17 + include/drm/drm_mode_config.h | 14 + 10 files changed, 591 insertions(+), 47 deletions(-) -- 2.50.1