backend-drm: move code to kms-color.c

This creates a new file for KMS related color code, to avoid making
drm.c even longer.

The moved code was just added in 5151f9fe9e
so the new file copyrights are written based on that.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago committed by Pekka Paalanen
parent ccb4c383d7
commit c4fedd503f
  1. 3
      libweston/backend-drm/drm-internal.h
  2. 66
      libweston/backend-drm/drm.c
  3. 99
      libweston/backend-drm/kms-color.c
  4. 1
      libweston/backend-drm/meson.build

@ -726,6 +726,9 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
void void
drm_output_set_cursor_view(struct drm_output *output, struct weston_view *ev); drm_output_set_cursor_view(struct drm_output *output, struct weston_view *ev);
int
drm_output_ensure_hdr_output_metadata_blob(struct drm_output *output);
#ifdef BUILD_DRM_GBM #ifdef BUILD_DRM_GBM
extern struct drm_fb * extern struct drm_fb *
drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev, drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev,

@ -51,7 +51,6 @@
#include <libweston/backend-drm.h> #include <libweston/backend-drm.h>
#include <libweston/weston-log.h> #include <libweston/weston-log.h>
#include "drm-internal.h" #include "drm-internal.h"
#include "libdrm-updates.h"
#include "shared/helpers.h" #include "shared/helpers.h"
#include "shared/timespec-util.h" #include "shared/timespec-util.h"
#include "shared/string-helpers.h" #include "shared/string-helpers.h"
@ -441,71 +440,6 @@ drm_output_render(struct drm_output_state *state, pixman_region32_t *damage)
pixman_region32_fini(&scanout_damage); pixman_region32_fini(&scanout_damage);
} }
static int
drm_output_ensure_hdr_output_metadata_blob(struct drm_output *output)
{
struct hdr_output_metadata meta;
uint32_t blob_id = 0;
int ret;
if (output->hdr_output_metadata_blob_id)
return 0;
/*
* Set up the data for Dynamic Range and Mastering InfoFrame,
* CTA-861-G, a.k.a the static HDR metadata.
*/
memset(&meta, 0, sizeof meta);
meta.metadata_type = 0; /* Static Metadata Type 1 */
/* Duplicated field in UABI struct */
meta.hdmi_metadata_type1.metadata_type = meta.metadata_type;
switch (output->base.eotf_mode) {
case WESTON_EOTF_MODE_NONE:
assert(0 && "bad eotf_mode: none");
return -1;
case WESTON_EOTF_MODE_SDR:
/*
* Do not send any static HDR metadata. Video sinks should
* respond by switching to traditional SDR mode. If they
* do not, the kernel should fix that up.
*/
assert(output->hdr_output_metadata_blob_id == 0);
return 0;
case WESTON_EOTF_MODE_TRADITIONAL_HDR:
meta.hdmi_metadata_type1.eotf = 1; /* from CTA-861-G */
break;
case WESTON_EOTF_MODE_ST2084:
meta.hdmi_metadata_type1.eotf = 2; /* from CTA-861-G */
break;
case WESTON_EOTF_MODE_HLG:
meta.hdmi_metadata_type1.eotf = 3; /* from CTA-861-G */
break;
}
if (meta.hdmi_metadata_type1.eotf == 0) {
assert(0 && "bad eotf_mode");
return -1;
}
/* The other fields are intentionally left as zeroes. */
ret = drmModeCreatePropertyBlob(output->backend->drm.fd,
&meta, sizeof meta, &blob_id);
if (ret != 0) {
weston_log("Error: failed to create KMS blob for HDR metadata on output '%s': %s\n",
output->base.name, strerror(-ret));
return -1;
}
output->hdr_output_metadata_blob_id = blob_id;
return 0;
}
static int static int
drm_output_repaint(struct weston_output *output_base, pixman_region32_t *damage) drm_output_repaint(struct weston_output *output_base, pixman_region32_t *damage)
{ {

@ -0,0 +1,99 @@
/*
* Copyright 2021-2022 Collabora, Ltd.
*
* 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 "config.h"
#include <stdint.h>
#include <libweston/libweston.h>
#include <assert.h>
#include <string.h>
#include "drm-internal.h"
#include "libdrm-updates.h"
int
drm_output_ensure_hdr_output_metadata_blob(struct drm_output *output)
{
struct hdr_output_metadata meta;
uint32_t blob_id = 0;
int ret;
if (output->hdr_output_metadata_blob_id)
return 0;
/*
* Set up the data for Dynamic Range and Mastering InfoFrame,
* CTA-861-G, a.k.a the static HDR metadata.
*/
memset(&meta, 0, sizeof meta);
meta.metadata_type = 0; /* Static Metadata Type 1 */
/* Duplicated field in UABI struct */
meta.hdmi_metadata_type1.metadata_type = meta.metadata_type;
switch (output->base.eotf_mode) {
case WESTON_EOTF_MODE_NONE:
assert(0 && "bad eotf_mode: none");
return -1;
case WESTON_EOTF_MODE_SDR:
/*
* Do not send any static HDR metadata. Video sinks should
* respond by switching to traditional SDR mode. If they
* do not, the kernel should fix that up.
*/
assert(output->hdr_output_metadata_blob_id == 0);
return 0;
case WESTON_EOTF_MODE_TRADITIONAL_HDR:
meta.hdmi_metadata_type1.eotf = 1; /* from CTA-861-G */
break;
case WESTON_EOTF_MODE_ST2084:
meta.hdmi_metadata_type1.eotf = 2; /* from CTA-861-G */
break;
case WESTON_EOTF_MODE_HLG:
meta.hdmi_metadata_type1.eotf = 3; /* from CTA-861-G */
break;
}
if (meta.hdmi_metadata_type1.eotf == 0) {
assert(0 && "bad eotf_mode");
return -1;
}
/* The other fields are intentionally left as zeroes. */
ret = drmModeCreatePropertyBlob(output->backend->drm.fd,
&meta, sizeof meta, &blob_id);
if (ret != 0) {
weston_log("Error: failed to create KMS blob for HDR metadata on output '%s': %s\n",
output->base.name, strerror(-ret));
return -1;
}
output->hdr_output_metadata_blob_id = blob_id;
return 0;
}

@ -29,6 +29,7 @@ srcs_drm = [
'fb.c', 'fb.c',
'modes.c', 'modes.c',
'kms.c', 'kms.c',
'kms-color.c',
'state-helpers.c', 'state-helpers.c',
'state-propose.c', 'state-propose.c',
linux_dmabuf_unstable_v1_protocol_c, linux_dmabuf_unstable_v1_protocol_c,

Loading…
Cancel
Save