DisplayServer (Linux): check HDR support with xx_color_manager_v4_interface (WIP)

This commit is contained in:
Carter Li 2025-01-11 13:10:07 +08:00
parent 10c8c1b4bf
commit 4e3673a2bb
6 changed files with 2768 additions and 0 deletions

View File

@ -491,10 +491,12 @@ if(LINUX)
src/detection/displayserver/linux/wayland/global-output.c
src/detection/displayserver/linux/wayland/zwlr-output.c
src/detection/displayserver/linux/wayland/kde-output.c
src/detection/displayserver/linux/wayland/color-manager.c
src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c
src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c
src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c
src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c
src/detection/displayserver/linux/wayland/xx-color-management-v4-protocol.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c

View File

@ -0,0 +1,114 @@
#include "wayland.h"
#include "xx-color-management-v4-client-protocol.h"
static void waylandSupportedPrimariesNamed(void* data, FF_MAYBE_UNUSED struct xx_color_manager_v4* manager, uint32_t primaries)
{
WaylandData* wldata = data;
switch (primaries)
{
case XX_COLOR_MANAGER_V4_PRIMARIES_SRGB:
printf("Supported named primaries: SRGB\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M:
printf("Supported named primaries: PAL-M\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_PAL:
printf("Supported named primaries: PAL\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_NTSC:
printf("Supported named primaries: NTSC\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM:
printf("Supported named primaries: Generic Film\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_BT2020:
printf("Supported named primaries: BT2020\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_CIE1931_XYZ:
printf("Supported named primaries: CIE1931 XYZ\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3:
printf("Supported named primaries: DCI-P3\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3:
printf("Supported named primaries: Display P3\n");
break;
case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB:
printf("Supported named primaries: Adobe RGB\n");
break;
default:
printf("Supported named primaries: Unknown\n");
break;
}
}
static void waylandSupportedTfNamed(void* data, FF_MAYBE_UNUSED struct xx_color_manager_v4* manager, uint32_t tf)
{
WaylandData* wldata = data;
switch (tf)
{
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_BT709:
printf("Supported named transfer function: BT709\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22:
printf("Supported named transfer function: Gamma 2.2\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28:
printf("Supported named transfer function: Gamma 2.8\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST240:
printf("Supported named transfer function: ST240\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR:
printf("Supported named transfer function: Linear\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LOG_100:
printf("Supported named transfer function: Log 100\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LOG_316:
printf("Supported named transfer function: Log 316\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_XVYCC:
printf("Supported named transfer function: XVYCC\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_BT1361:
printf("Supported named transfer function: BT1361\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB:
printf("Supported named transfer function: SRGB\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_EXT_SRGB:
printf("Supported named transfer function: Extended SRGB\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ:
printf("Supported named transfer function: ST2084 PQ\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST428:
printf("Supported named transfer function: ST428\n");
break;
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG:
printf("Supported named transfer function: HLG\n");
break;
default:
printf("Supported named transfer function: Unknown\n");
break;
}
}
void ffWaylandHandleColorManager(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version)
{
struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, &xx_color_manager_v4_interface, version, name, xx_color_manager_v4_interface.name, version, NULL);
if(output == NULL)
return;
struct xx_color_manager_v4_listener managerListener = {
.supported_feature = (void*) stubListener,
.supported_intent = (void*) stubListener,
.supported_primaries_named = waylandSupportedPrimariesNamed,
.supported_tf_named = waylandSupportedTfNamed,
};
wldata->ffwl_proxy_add_listener(output, (void(**)(void)) &managerListener, wldata);
wldata->ffwl_display_roundtrip(wldata->display);
wldata->ffwl_proxy_destroy(output);
}

View File

@ -17,6 +17,7 @@
#include "kde-output-device-v2-client-protocol.h"
#include "kde-output-order-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"
#include "xx-color-management-v4-client-protocol.h"
#if __FreeBSD__
#include <sys/un.h>
@ -96,6 +97,10 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
{
ffWaylandHandleKdeOutputOrder(wldata, registry, name, version);
}
// else if(ffStrEquals(interface, xx_color_manager_v4_interface.name))
// {
// ffWaylandHandleColorManager(wldata, registry, name, version);
// }
else if((wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_GLOBAL || wldata->protocolType == FF_WAYLAND_PROTOCOL_TYPE_NONE) && ffStrEquals(interface, zxdg_output_manager_v1_interface.name))
{
ffWaylandHandleZxdgOutput(wldata, registry, name, version);

View File

@ -84,5 +84,6 @@ void ffWaylandHandleZwlrOutput(WaylandData* wldata, struct wl_registry* registry
void ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version);
void ffWaylandHandleKdeOutputOrder(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version);
void ffWaylandHandleZxdgOutput(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version);
void ffWaylandHandleColorManager(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version);
#endif

View File

@ -0,0 +1,199 @@
/* Generated by wayland-scanner 1.23.1 */
/*
* Copyright 2019 Sebastian Wick
* Copyright 2019 Erwin Burema
* Copyright 2020 AMD
* Copyright 2020-2024 Collabora, Ltd.
* Copyright 2024 Xaver Hugl
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <wayland-util.h>
extern const struct wl_interface wl_output_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface xx_color_management_feedback_surface_v4_interface;
extern const struct wl_interface xx_color_management_output_v4_interface;
extern const struct wl_interface xx_color_management_surface_v4_interface;
extern const struct wl_interface xx_image_description_creator_icc_v4_interface;
extern const struct wl_interface xx_image_description_creator_params_v4_interface;
extern const struct wl_interface xx_image_description_info_v4_interface;
extern const struct wl_interface xx_image_description_v4_interface;
static const struct wl_interface *color_management_v1_types[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
&xx_color_management_output_v4_interface,
NULL, // &wl_output_interface,
&xx_color_management_surface_v4_interface,
NULL, // &wl_surface_interface,
&xx_color_management_feedback_surface_v4_interface,
NULL, //&wl_surface_interface,
&xx_image_description_creator_icc_v4_interface,
&xx_image_description_creator_params_v4_interface,
&xx_image_description_v4_interface,
&xx_image_description_v4_interface,
NULL,
&xx_image_description_v4_interface,
&xx_image_description_v4_interface,
&xx_image_description_v4_interface,
&xx_image_description_info_v4_interface,
};
static const struct wl_message xx_color_manager_v4_requests[] = {
{ "destroy", "", color_management_v1_types + 0 },
{ "get_output", "no", color_management_v1_types + 8 },
{ "get_surface", "no", color_management_v1_types + 10 },
{ "get_feedback_surface", "no", color_management_v1_types + 12 },
{ "new_icc_creator", "n", color_management_v1_types + 14 },
{ "new_parametric_creator", "n", color_management_v1_types + 15 },
};
static const struct wl_message xx_color_manager_v4_events[] = {
{ "supported_intent", "u", color_management_v1_types + 0 },
{ "supported_feature", "u", color_management_v1_types + 0 },
{ "supported_tf_named", "u", color_management_v1_types + 0 },
{ "supported_primaries_named", "u", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_color_manager_v4_interface = {
"xx_color_manager_v4", 1,
6, xx_color_manager_v4_requests,
4, xx_color_manager_v4_events,
};
static const struct wl_message xx_color_management_output_v4_requests[] = {
{ "destroy", "", color_management_v1_types + 0 },
{ "get_image_description", "n", color_management_v1_types + 16 },
};
static const struct wl_message xx_color_management_output_v4_events[] = {
{ "image_description_changed", "", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_color_management_output_v4_interface = {
"xx_color_management_output_v4", 1,
2, xx_color_management_output_v4_requests,
1, xx_color_management_output_v4_events,
};
static const struct wl_message xx_color_management_surface_v4_requests[] = {
{ "destroy", "", color_management_v1_types + 0 },
{ "set_image_description", "ou", color_management_v1_types + 17 },
{ "unset_image_description", "", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_color_management_surface_v4_interface = {
"xx_color_management_surface_v4", 1,
3, xx_color_management_surface_v4_requests,
0, NULL,
};
static const struct wl_message xx_color_management_feedback_surface_v4_requests[] = {
{ "destroy", "", color_management_v1_types + 0 },
{ "get_preferred", "n", color_management_v1_types + 19 },
};
static const struct wl_message xx_color_management_feedback_surface_v4_events[] = {
{ "preferred_changed", "", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_color_management_feedback_surface_v4_interface = {
"xx_color_management_feedback_surface_v4", 1,
2, xx_color_management_feedback_surface_v4_requests,
1, xx_color_management_feedback_surface_v4_events,
};
static const struct wl_message xx_image_description_creator_icc_v4_requests[] = {
{ "create", "n", color_management_v1_types + 20 },
{ "set_icc_file", "huu", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_image_description_creator_icc_v4_interface = {
"xx_image_description_creator_icc_v4", 1,
2, xx_image_description_creator_icc_v4_requests,
0, NULL,
};
static const struct wl_message xx_image_description_creator_params_v4_requests[] = {
{ "create", "n", color_management_v1_types + 21 },
{ "set_tf_named", "u", color_management_v1_types + 0 },
{ "set_tf_power", "u", color_management_v1_types + 0 },
{ "set_primaries_named", "u", color_management_v1_types + 0 },
{ "set_primaries", "iiiiiiii", color_management_v1_types + 0 },
{ "set_luminances", "uuu", color_management_v1_types + 0 },
{ "set_mastering_display_primaries", "iiiiiiii", color_management_v1_types + 0 },
{ "set_mastering_luminance", "uu", color_management_v1_types + 0 },
{ "set_max_cll", "u", color_management_v1_types + 0 },
{ "set_max_fall", "u", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_image_description_creator_params_v4_interface = {
"xx_image_description_creator_params_v4", 1,
10, xx_image_description_creator_params_v4_requests,
0, NULL,
};
static const struct wl_message xx_image_description_v4_requests[] = {
{ "destroy", "", color_management_v1_types + 0 },
{ "get_information", "n", color_management_v1_types + 22 },
};
static const struct wl_message xx_image_description_v4_events[] = {
{ "failed", "us", color_management_v1_types + 0 },
{ "ready", "u", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_image_description_v4_interface = {
"xx_image_description_v4", 1,
2, xx_image_description_v4_requests,
2, xx_image_description_v4_events,
};
static const struct wl_message xx_image_description_info_v4_events[] = {
{ "done", "", color_management_v1_types + 0 },
{ "icc_file", "hu", color_management_v1_types + 0 },
{ "primaries", "iiiiiiii", color_management_v1_types + 0 },
{ "primaries_named", "u", color_management_v1_types + 0 },
{ "tf_power", "u", color_management_v1_types + 0 },
{ "tf_named", "u", color_management_v1_types + 0 },
{ "luminances", "uuu", color_management_v1_types + 0 },
{ "target_primaries", "iiiiiiii", color_management_v1_types + 0 },
{ "target_luminance", "uu", color_management_v1_types + 0 },
{ "target_max_cll", "u", color_management_v1_types + 0 },
{ "target_max_fall", "u", color_management_v1_types + 0 },
};
WL_EXPORT const struct wl_interface xx_image_description_info_v4_interface = {
"xx_image_description_info_v4", 1,
0, NULL,
11, xx_image_description_info_v4_events,
};