From 4b301fe7f27f97d3fd0ca587e8688032daf21dd6 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 4 Feb 2021 17:39:45 +0200 Subject: [PATCH] Add weston-drm-fourcc.h This header is for sharing fallback definitions for drm_fourcc.h. A new test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format, and more new formats will be expected with HDR supports. Share these fallback definitions in one place instead of copying them all over. All users of drm_fourcc.h are converted to include weston-drm-fourcc.h instead for consistency: have the same definitions available everywhere. Signed-off-by: Pekka Paalanen --- clients/simple-dmabuf-egl.c | 2 +- clients/simple-dmabuf-v4l.c | 3 +- libweston/backend-drm/drm-internal.h | 2 +- libweston/backend-drm/drm.c | 2 +- libweston/backend-drm/fb.c | 2 +- libweston/backend-drm/kms.c | 2 +- libweston/backend-drm/modes.c | 2 +- libweston/backend-drm/state-helpers.c | 2 +- libweston/backend-headless/headless.c | 2 +- libweston/backend-wayland/wayland.c | 2 +- libweston/backend-x11/x11.c | 2 +- libweston/linux-dmabuf.c | 3 +- libweston/pixel-formats.c | 2 +- libweston/renderer-gl/gl-renderer.c | 10 +------ remoting/remoting-plugin.c | 2 +- shared/weston-drm-fourcc.h | 41 +++++++++++++++++++++++++++ tests/yuv-buffer-test.c | 3 +- 17 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 shared/weston-drm-fourcc.h diff --git a/clients/simple-dmabuf-egl.c b/clients/simple-dmabuf-egl.c index 6d34942a..987a1011 100644 --- a/clients/simple-dmabuf-egl.c +++ b/clients/simple-dmabuf-egl.c @@ -39,13 +39,13 @@ #include #include -#include #include #include #include #include "shared/helpers.h" #include "shared/platform.h" +#include "shared/weston-drm-fourcc.h" #include #include "xdg-shell-client-protocol.h" #include "fullscreen-shell-unstable-v1-client-protocol.h" diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c index 331f049f..568b9580 100644 --- a/clients/simple-dmabuf-v4l.c +++ b/clients/simple-dmabuf-v4l.c @@ -37,8 +37,6 @@ #include #include -#include - #include #include #include @@ -54,6 +52,7 @@ #include "weston-direct-display-client-protocol.h" #include "shared/helpers.h" +#include "shared/weston-drm-fourcc.h" #define CLEAR(x) memset(&(x), 0, sizeof(x)) #define OPT_FLAG_INVERT (1 << 0) diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 367d4254..74d6c7fb 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -45,7 +45,6 @@ #include #include -#include #ifdef BUILD_DRM_GBM #include @@ -56,6 +55,7 @@ #include #include #include "shared/helpers.h" +#include "shared/weston-drm-fourcc.h" #include "libinput-seat.h" #include "backend.h" #include "libweston-internal.h" diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 1ddf4f7f..c780c1c1 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -44,7 +44,6 @@ #include #include -#include #include @@ -55,6 +54,7 @@ #include "shared/helpers.h" #include "shared/timespec-util.h" #include "shared/string-helpers.h" +#include "shared/weston-drm-fourcc.h" #include "pixman-renderer.h" #include "pixel-formats.h" #include "libbacklight.h" diff --git a/libweston/backend-drm/fb.c b/libweston/backend-drm/fb.c index e7349c4b..25813c37 100644 --- a/libweston/backend-drm/fb.c +++ b/libweston/backend-drm/fb.c @@ -33,13 +33,13 @@ #include #include -#include #include #include #include #include #include "shared/helpers.h" +#include "shared/weston-drm-fourcc.h" #include "drm-internal.h" #include "linux-dmabuf.h" diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c index 64f23d86..f0f85266 100644 --- a/libweston/backend-drm/kms.c +++ b/libweston/backend-drm/kms.c @@ -33,11 +33,11 @@ #include #include -#include #include #include #include "shared/helpers.h" +#include "shared/weston-drm-fourcc.h" #include "drm-internal.h" #include "pixel-formats.h" #include "presentation-time-server-protocol.h" diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c index 03d48450..a071375b 100644 --- a/libweston/backend-drm/modes.c +++ b/libweston/backend-drm/modes.c @@ -31,9 +31,9 @@ #include #include -#include #include "drm-internal.h" +#include "shared/weston-drm-fourcc.h" static const char *const aspect_ratio_as_string[] = { [WESTON_MODE_PIC_AR_NONE] = "", diff --git a/libweston/backend-drm/state-helpers.c b/libweston/backend-drm/state-helpers.c index 0ee663cb..8fc2e03a 100644 --- a/libweston/backend-drm/state-helpers.c +++ b/libweston/backend-drm/state-helpers.c @@ -31,9 +31,9 @@ #include #include -#include #include "drm-internal.h" +#include "shared/weston-drm-fourcc.h" /** * Allocate a new, empty, plane state. diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 7056df8f..a99ac3f1 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -40,6 +39,7 @@ #include "linux-explicit-synchronization.h" #include "pixman-renderer.h" #include "renderer-gl/gl-renderer.h" +#include "shared/weston-drm-fourcc.h" #include "shared/weston-egl-ext.h" #include "linux-dmabuf.h" #include "presentation-time-server-protocol.h" diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index bb98e9c8..f58bba46 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -38,7 +38,6 @@ #include #include -#include #include #include @@ -49,6 +48,7 @@ #include #include #include "renderer-gl/gl-renderer.h" +#include "shared/weston-drm-fourcc.h" #include "shared/weston-egl-ext.h" #include "pixman-renderer.h" #include "shared/helpers.h" diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index 387e97a4..3336370d 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #ifdef HAVE_XCB_XKB @@ -58,6 +57,7 @@ #include "shared/timespec-util.h" #include "shared/file-util.h" #include "renderer-gl/gl-renderer.h" +#include "shared/weston-drm-fourcc.h" #include "shared/weston-egl-ext.h" #include "pixman-renderer.h" #include "presentation-time-server-protocol.h" diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c index fb41897b..a06e324b 100644 --- a/libweston/linux-dmabuf.c +++ b/libweston/linux-dmabuf.c @@ -30,12 +30,11 @@ #include #include -#include - #include #include "linux-dmabuf.h" #include "linux-dmabuf-unstable-v1-server-protocol.h" #include "libweston-internal.h" +#include "shared/weston-drm-fourcc.h" static void linux_dmabuf_buffer_destroy(struct linux_dmabuf_buffer *buffer) diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c index 79dc709c..1233d7b3 100644 --- a/libweston/pixel-formats.c +++ b/libweston/pixel-formats.c @@ -31,10 +31,10 @@ #include #include #include -#include #include #include "shared/helpers.h" +#include "shared/weston-drm-fourcc.h" #include "wayland-util.h" #include "pixel-formats.h" diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 364f87b8..869fdc3e 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include "linux-sync-file.h" @@ -57,6 +56,7 @@ #include "shared/helpers.h" #include "shared/platform.h" #include "shared/timespec-util.h" +#include "shared/weston-drm-fourcc.h" #include "shared/weston-egl-ext.h" #define BUFFER_DAMAGE_COUNT 2 @@ -2303,14 +2303,6 @@ import_simple_dmabuf(struct gl_renderer *gr, return image; } -/* The kernel header drm_fourcc.h defines the DRM formats below. We duplicate - * some of the definitions here so that building Weston won't require - * bleeding-edge kernel headers. - */ -#ifndef DRM_FORMAT_XYUV8888 -#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ -#endif - struct yuv_format_descriptor yuv_formats[] = { { .format = DRM_FORMAT_YUYV, diff --git a/remoting/remoting-plugin.c b/remoting/remoting-plugin.c index ada101c5..6aa4ec8a 100644 --- a/remoting/remoting-plugin.c +++ b/remoting/remoting-plugin.c @@ -41,12 +41,12 @@ #include #include #include -#include #include #include #include "shared/helpers.h" #include "shared/timespec-util.h" +#include "shared/weston-drm-fourcc.h" #include "backend.h" #include "libweston-internal.h" diff --git a/shared/weston-drm-fourcc.h b/shared/weston-drm-fourcc.h new file mode 100644 index 00000000..41b86ed8 --- /dev/null +++ b/shared/weston-drm-fourcc.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2012 Intel Corporation + * Copyright © 2015,2019 Collabora, Ltd. + * Copyright © 2016 NVIDIA Corporation + * + * 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. + */ + +#ifndef WESTON_DRM_FOURCC_H +#define WESTON_DRM_FOURCC_H + +#include + +/* The kernel header drm_fourcc.h defines the DRM formats below. We duplicate + * some of the definitions here so that building Weston won't require + * bleeding-edge kernel headers. + */ +#ifndef DRM_FORMAT_XYUV8888 +#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ +#endif + +#endif diff --git a/tests/yuv-buffer-test.c b/tests/yuv-buffer-test.c index ce34fbd1..41144b94 100644 --- a/tests/yuv-buffer-test.c +++ b/tests/yuv-buffer-test.c @@ -31,11 +31,10 @@ #include #include -#include - #include "weston-test-client-helper.h" #include "weston-test-fixture-compositor.h" #include "shared/os-compatibility.h" +#include "shared/weston-drm-fourcc.h" #include "shared/xalloc.h" static enum test_result_code