Commit b18d1b08 authored by Shashank Sharma's avatar Shashank Sharma Committed by Harish Krupo

compositor-drm: Add connector's HDR color property

In order to display HDR output properly, we have to set
two output DRM properties in drm-backend:
- HDR output metadata property.
- Output color space property.

This patch:
- Adds a new connector property, HDR metadata, in drm-backend's connector
  property list. This property will allow compositor to control the output
  HDR metadata in form of AVI infoframes.
- Also adds a connector's color state structure to maintain a drm head's
  color correction status per flip.
- Sets/Resets/Modifies this color state, to reflect the color corrcetion
  during atomic flip.

PS: The kernel counterpart of this property in the drm framework can be
   found here: https://patchwork.freedesktop.org/series/25091/

V2: Addressed review comments from Pekka
Signed-off-by: Shashank Sharma's avatarShashank Sharma <shashank.sharma@intel.com>
parent 78a51b95
......@@ -229,6 +229,7 @@ enum wdrm_connector_property {
WDRM_CONNECTOR_DPMS,
WDRM_CONNECTOR_CRTC_ID,
WDRM_CONNECTOR_NON_DESKTOP,
WDRM_CONNECTOR_HDR_METADATA,
WDRM_CONNECTOR__COUNT
};
......@@ -264,6 +265,7 @@ static const struct drm_property_info connector_props[] = {
},
[WDRM_CONNECTOR_CRTC_ID] = { .name = "CRTC_ID", },
[WDRM_CONNECTOR_NON_DESKTOP] = { .name = "non-desktop", },
[WDRM_CONNECTOR_HDR_METADATA] = { .name = "HDR_OUTPUT_METADATA", },
};
/**
......@@ -551,6 +553,16 @@ struct hdr_output_metadata {
};
};
/* Connector's color correction status */
struct drm_conn_color_state {
bool changed;
bool output_is_hdr;
uint8_t o_cs;
uint8_t o_eotf;
uint32_t hdr_md_blob_id;
struct drm_hdr_metadata_static o_md;
};
struct drm_head {
struct weston_head base;
struct drm_backend *backend;
......@@ -565,6 +577,9 @@ struct drm_head {
/* Display's supported color spaces */
uint32_t clrspaces;
/* Connector's color correction status */
struct drm_conn_color_state color_state;
/* Holds the properties for the connector */
struct drm_property_info props_conn[WDRM_CONNECTOR__COUNT];
......@@ -2620,6 +2635,36 @@ plane_add_damage(drmModeAtomicReq *req, struct drm_backend *backend,
return 0;
}
static int
connector_add_color_correction(drmModeAtomicReq *req,
struct drm_head *head, uint32_t *flags)
{
int ret;
struct drm_conn_color_state *conn_state = &head->color_state;
if (!conn_state->changed)
return 0;
if ((int)conn_state->hdr_md_blob_id == -1)
return 0;
ret = connector_add_prop(req,
head,
WDRM_CONNECTOR_HDR_METADATA,
conn_state->hdr_md_blob_id);
if (ret != 0) {
weston_log("Failed to apply output HDR metadata\n");
return ret;
}
*flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
if (!(*flags & DRM_MODE_ATOMIC_TEST_ONLY))
conn_state->changed = false;
return 0;
}
static int
drm_output_apply_state_atomic(struct drm_output_state *state,
drmModeAtomicReq *req,
......@@ -2655,6 +2700,7 @@ drm_output_apply_state_atomic(struct drm_output_state *state,
wl_list_for_each(head, &output->base.head_list, base.output_link) {
ret |= connector_add_prop(req, head, WDRM_CONNECTOR_CRTC_ID,
output->crtc_id);
ret |= connector_add_color_correction(req, head, flags);
}
} else {
ret |= crtc_add_prop(req, output, WDRM_CRTC_MODE_ID, 0);
......@@ -6619,6 +6665,8 @@ err_alloc:
static void
drm_head_destroy(struct drm_head *head)
{
struct drm_backend *b = head->backend;
weston_head_release(&head->base);
drm_property_info_free(head->props_conn, WDRM_CONNECTOR__COUNT);
......@@ -6630,6 +6678,9 @@ drm_head_destroy(struct drm_head *head)
if (head->backlight)
backlight_destroy(head->backlight);
if (head->color_state.hdr_md_blob_id)
drmModeDestroyPropertyBlob(b->drm.fd, head->color_state.hdr_md_blob_id);
free(head);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment