From patchwork Sat Sep 5 17:14:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1358066 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Zm86apHP; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BkLl82VkYz9sSP for ; Sun, 6 Sep 2020 03:14:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8FC5B21515; Sat, 5 Sep 2020 17:14:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QMTDichkDB2Z; Sat, 5 Sep 2020 17:14:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 4935C20C41; Sat, 5 Sep 2020 17:14:49 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id E222D1BF2A4 for ; Sat, 5 Sep 2020 17:14:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DBC8B86278 for ; Sat, 5 Sep 2020 17:14:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IiSL312VRwYy for ; Sat, 5 Sep 2020 17:14:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by fraxinus.osuosl.org (Postfix) with ESMTPS id D22EE85F92 for ; Sat, 5 Sep 2020 17:14:46 +0000 (UTC) Received: by mail-io1-f49.google.com with SMTP id d18so10122179iop.13 for ; Sat, 05 Sep 2020 10:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=20fEtEpFeVguZFVkY/aMYtUGAtKRyn5PRLdHddRdsiI=; b=Zm86apHPSa+44kJ2Ia6lpRAtuGBh94Gyv61V+REPVVzb+LNjUxOunm2MUiTDb6o9KT LG7+A/YY1gP4vR1dO+pYQUqLuXRxb3yIhpKUbyXSynZyHME1czGMBjUCWjuisN87dESA vP+8DsyfQTh5051qRai4z2x020GHpCi0dpPSYKATIpSG+hVR9aldTL6uQ6auoT8NjPv3 9A6YXXhnPbYtEEmcX5mBaHtmXghNkwYAW4iK7b2ya91Ctbi1cTFujI4hpelnxcXa2JV7 3NLDjHGcQzq4bBZnSxx8LhBfMogwdQM3J/Q2ktssmr8ej1/zTNPEEq8jc0xYrsIVBNVM 9Gcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=20fEtEpFeVguZFVkY/aMYtUGAtKRyn5PRLdHddRdsiI=; b=NQQgMbffP5h4ilwRHp4sZv24k9fi6bQiR8d3qvDtp5n6td719KoR5UwyaunK6IHSkh P1WmT8Se+93FDw7hsSVY21ueXrqf5DhV8TWi+rTpYS4VyjCYBCVpPJYrBZHpkrGtghwf G3H/qGBAwzBFpvBsukxJE6fHzXen0CZvvF162WcAN6SJa+hNACYw86gc/eXLUKExhdQW qiTp9bDdQXw+6OSKRYwT+lvexeYXCBCgPi5Qs9N/ApPMk/b56eASmYhjJ0OW4e25xKH0 oBA/3bJBYn+UTDXEL4JTy1bjp7cj5yBs7je07Vad76bTV+VSCB5LTNq/Fetlb8qKjanX wAXQ== X-Gm-Message-State: AOAM533D69kjsW/ruQXVbbbWfZ9s6ZREBIH26HosWmI+M10NLSfhDylP O19ApTWHRsb0rfrGDE+1qaOHVmIvSng= X-Google-Smtp-Source: ABdhPJzUx2/kJkzNGzW308LgmWfZ8RVu8xt6iQR/3FQLulgnPs/JkJavDLwf2qOjfenF+CuUVxuPpw== X-Received: by 2002:a6b:8b8c:: with SMTP id n134mr12101666iod.204.1599326085590; Sat, 05 Sep 2020 10:14:45 -0700 (PDT) Received: from james-x399.localdomain (71-218-238-150.hlrn.qwest.net. [71.218.238.150]) by smtp.gmail.com with ESMTPSA id w15sm406574ilq.46.2020.09.05.10.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 10:14:44 -0700 (PDT) From: James Hilliard To: buildroot@buildroot.org Date: Sat, 5 Sep 2020 11:14:40 -0600 Message-Id: <20200905171440.744310-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/1] package/weston: add patch to support pipewire 0.3 API X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Hilliard , "Yann E . MORIN" , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This is required when building weston against the latest pipewire release. Signed-off-by: James Hilliard --- ...001-pipewire-add-support-for-0.3-API.patch | 391 ++++++++++++++++++ 1 file changed, 391 insertions(+) create mode 100644 package/weston/0001-pipewire-add-support-for-0.3-API.patch diff --git a/package/weston/0001-pipewire-add-support-for-0.3-API.patch b/package/weston/0001-pipewire-add-support-for-0.3-API.patch new file mode 100644 index 0000000000..b486b3de5c --- /dev/null +++ b/package/weston/0001-pipewire-add-support-for-0.3-API.patch @@ -0,0 +1,391 @@ +From cc08737e3fd174ec3c4c208ea4f2a3a6a9e8af3e Mon Sep 17 00:00:00 2001 +From: James Hilliard +Date: Mon, 6 Jul 2020 00:58:02 -0600 +Subject: [PATCH] pipewire: add support for 0.3 API + +Fixes: #369 + +Signed-off-by: James Hilliard +[james.hilliard1@gmail.com: backport from upstream commit +80b585f8d2a31e780b4de41fbd187a742bea7e1a] +--- + .gitlab-ci.yml | 2 +- + .gitlab-ci/debian-install.sh | 16 ++++- + pipewire/meson.build | 28 ++++++--- + pipewire/pipewire-plugin.c | 118 ++++++++++++++++++++++++++++++++++- + 4 files changed, 151 insertions(+), 13 deletions(-) + +diff --git a/pipewire/meson.build b/pipewire/meson.build +index 3d3374b8..e30a0b62 100644 +--- a/pipewire/meson.build ++++ b/pipewire/meson.build +@@ -5,17 +5,25 @@ if get_option('pipewire') + error('Attempting to build the pipewire plugin without the required DRM backend. ' + user_hint) + endif + +- depnames = [ +- 'libpipewire-0.2', 'libspa-0.1' +- ] + deps_pipewire = [ dep_libweston_private ] +- foreach depname : depnames +- dep = dependency(depname, required: false) +- if not dep.found() +- error('Pipewire plugin requires @0@ which was not found. '.format(depname) + user_hint) +- endif +- deps_pipewire += dep +- endforeach ++ ++ dep_libpipewire = dependency('libpipewire-0.3', required: false) ++ if not dep_libpipewire.found() ++ dep_libpipewire = dependency('libpipewire-0.2', required: false) ++ endif ++ if not dep_libpipewire.found() ++ error('Pipewire plugin requires libpipewire which was not found. ' + user_hint) ++ endif ++ deps_pipewire += dep_libpipewire ++ ++ dep_libspa = dependency('libspa-0.2', required: false) ++ if not dep_libspa.found() ++ dep_libspa = dependency('libspa-0.1', required: false) ++ endif ++ if not dep_libspa.found() ++ error('Pipewire plugin requires libspa which was not found. ' + user_hint) ++ endif ++ deps_pipewire += dep_libspa + + plugin_pipewire = shared_library( + 'pipewire-plugin', +diff --git a/pipewire/pipewire-plugin.c b/pipewire/pipewire-plugin.c +index 6f892574..ce70ea63 100644 +--- a/pipewire/pipewire-plugin.c ++++ b/pipewire/pipewire-plugin.c +@@ -34,20 +34,27 @@ + #include + #include + ++#include ++ + #include + #include + #include + +-#include ++#if PW_CHECK_VERSION(0, 2, 90) ++#include ++#include ++#endif + + #define PROP_RANGE(min, max) 2, (min), (max) + ++#if !PW_CHECK_VERSION(0, 2, 90) + struct type { + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; + }; ++#endif + + struct weston_pipewire { + struct weston_compositor *compositor; +@@ -60,12 +67,19 @@ struct weston_pipewire { + struct pw_loop *loop; + struct wl_event_source *loop_source; + ++#if PW_CHECK_VERSION(0, 2, 90) ++ struct pw_context *context; ++#endif + struct pw_core *core; + struct pw_type *t; ++#if PW_CHECK_VERSION(0, 2, 90) ++ struct spa_hook core_listener; ++#else + struct type type; + + struct pw_remote *remote; + struct spa_hook remote_listener; ++#endif + }; + + struct pipewire_output { +@@ -100,6 +114,7 @@ struct pipewire_frame_data { + struct wl_event_source *fence_sync_event_source; + }; + ++#if !PW_CHECK_VERSION(0, 2, 90) + static inline void init_type(struct type *type, struct spa_type_map *map) + { + spa_type_media_type_map(map, &type->media_type); +@@ -107,6 +122,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map) + spa_type_format_video_map(map, &type->format_video); + spa_type_video_format_map(map, &type->video_format); + } ++#endif + + static void + pipewire_debug_impl(struct weston_pipewire *pipewire, +@@ -141,6 +157,7 @@ pipewire_debug_impl(struct weston_pipewire *pipewire, + free(logstr); + } + ++#if !PW_CHECK_VERSION(0, 2, 90) + static void + pipewire_debug(struct weston_pipewire *pipewire, const char *fmt, ...) + { +@@ -150,6 +167,7 @@ pipewire_debug(struct weston_pipewire *pipewire, const char *fmt, ...) + pipewire_debug_impl(pipewire, NULL, fmt, ap); + va_end(ap); + } ++#endif + + static void + pipewire_output_debug(struct pipewire_output *output, const char *fmt, ...) +@@ -185,7 +203,9 @@ pipewire_output_handle_frame(struct pipewire_output *output, int fd, + const struct weston_drm_virtual_output_api *api = + output->pipewire->virtual_output_api; + size_t size = output->output->height * stride; ++#if !PW_CHECK_VERSION(0, 2, 90) + struct pw_type *t = output->pipewire->t; ++#endif + struct pw_buffer *buffer; + struct spa_buffer *spa_buffer; + struct spa_meta_header *h; +@@ -203,7 +223,12 @@ pipewire_output_handle_frame(struct pipewire_output *output, int fd, + + spa_buffer = buffer->buffer; + ++#if PW_CHECK_VERSION(0, 2, 90) ++ if ((h = spa_buffer_find_meta_data(spa_buffer, SPA_META_Header, ++ sizeof(struct spa_meta_header)))) { ++#else + if ((h = spa_buffer_find_meta(spa_buffer, t->meta.Header))) { ++#endif + h->pts = -1; + h->flags = 0; + h->seq = output->seq++; +@@ -375,18 +400,40 @@ pipewire_set_dpms(struct weston_output *base_output, enum dpms_enum level) + static int + pipewire_output_connect(struct pipewire_output *output) + { ++#if !PW_CHECK_VERSION(0, 2, 90) + struct weston_pipewire *pipewire = output->pipewire; + struct type *type = &pipewire->type; ++#endif + uint8_t buffer[1024]; + struct spa_pod_builder builder = + SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + const struct spa_pod *params[1]; ++#if !PW_CHECK_VERSION(0, 2, 90) + struct pw_type *t = pipewire->t; ++#endif + int frame_rate = output->output->current_mode->refresh / 1000; + int width = output->output->width; + int height = output->output->height; + int ret; + ++#if PW_CHECK_VERSION(0, 2, 90) ++ params[0] = spa_pod_builder_add_object(&builder, ++ SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat, ++ SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video), ++ SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), ++ SPA_FORMAT_VIDEO_format, SPA_POD_Id(SPA_VIDEO_FORMAT_BGRx), ++ SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle(&SPA_RECTANGLE(width, height)), ++ SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION (0, 1)), ++ SPA_FORMAT_VIDEO_maxFramerate, ++ SPA_POD_CHOICE_RANGE_Fraction(&SPA_FRACTION(frame_rate, 1), ++ &SPA_FRACTION(1, 1), ++ &SPA_FRACTION(frame_rate, 1))); ++ ++ ret = pw_stream_connect(output->stream, PW_DIRECTION_OUTPUT, SPA_ID_INVALID, ++ (PW_STREAM_FLAG_DRIVER | ++ PW_STREAM_FLAG_MAP_BUFFERS), ++ params, 1); ++#else + params[0] = spa_pod_builder_object(&builder, + t->param.idEnumFormat, t->spa_format, + "I", type->media_type.video, +@@ -406,6 +453,7 @@ pipewire_output_connect(struct pipewire_output *output) + (PW_STREAM_FLAG_DRIVER | + PW_STREAM_FLAG_MAP_BUFFERS), + params, 1); ++#endif + if (ret != 0) { + weston_log("Failed to connect pipewire stream: %s", + spa_strerror(ret)); +@@ -482,26 +530,42 @@ pipewire_output_stream_state_changed(void *data, enum pw_stream_state old, + } + + static void ++#if PW_CHECK_VERSION(0, 2, 90) ++pipewire_output_stream_param_changed(void *data, uint32_t id, const struct spa_pod *format) ++#else + pipewire_output_stream_format_changed(void *data, const struct spa_pod *format) ++#endif + { + struct pipewire_output *output = data; ++#if !PW_CHECK_VERSION(0, 2, 90) + struct weston_pipewire *pipewire = output->pipewire; ++#endif + uint8_t buffer[1024]; + struct spa_pod_builder builder = + SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + const struct spa_pod *params[2]; ++#if !PW_CHECK_VERSION(0, 2, 90) + struct pw_type *t = pipewire->t; ++#endif + int32_t width, height, stride, size; + const int bpp = 4; + + if (!format) { + pipewire_output_debug(output, "format = None"); ++#if PW_CHECK_VERSION(0, 2, 90) ++ pw_stream_update_params(output->stream, NULL, 0); ++#else + pw_stream_finish_format(output->stream, 0, NULL, 0); ++#endif + return; + } + ++#if PW_CHECK_VERSION(0, 2, 90) ++ spa_format_video_raw_parse(format, &output->video_format); ++#else + spa_format_video_raw_parse(format, &output->video_format, + &pipewire->type.format_video); ++#endif + + width = output->video_format.size.width; + height = output->video_format.size.height; +@@ -510,6 +574,21 @@ pipewire_output_stream_format_changed(void *data, const struct spa_pod *format) + + pipewire_output_debug(output, "format = %dx%d", width, height); + ++#if PW_CHECK_VERSION(0, 2, 90) ++ params[0] = spa_pod_builder_add_object(&builder, ++ SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, ++ SPA_PARAM_BUFFERS_size, SPA_POD_Int(size), ++ SPA_PARAM_BUFFERS_stride, SPA_POD_Int(stride), ++ SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(4, 2, 8), ++ SPA_PARAM_BUFFERS_align, SPA_POD_Int(16)); ++ ++ params[1] = spa_pod_builder_add_object(&builder, ++ SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, ++ SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header), ++ SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header))); ++ ++ pw_stream_update_params(output->stream, params, 2); ++#else + params[0] = spa_pod_builder_object(&builder, + t->param.idBuffers, t->param_buffers.Buffers, + ":", t->param_buffers.size, +@@ -527,12 +606,17 @@ pipewire_output_stream_format_changed(void *data, const struct spa_pod *format) + ":", t->param_meta.size, "i", sizeof(struct spa_meta_header)); + + pw_stream_finish_format(output->stream, 0, params, 2); ++#endif + } + + static const struct pw_stream_events stream_events = { + PW_VERSION_STREAM_EVENTS, + .state_changed = pipewire_output_stream_state_changed, ++#if PW_CHECK_VERSION(0, 2, 90) ++ .param_changed = pipewire_output_stream_param_changed, ++#else + .format_changed = pipewire_output_stream_format_changed, ++#endif + }; + + static struct weston_output * +@@ -560,7 +644,11 @@ pipewire_output_create(struct weston_compositor *c, char *name) + if (!head) + goto err; + ++#if PW_CHECK_VERSION(0, 2, 90) ++ output->stream = pw_stream_new(pipewire->core, name, NULL); ++#else + output->stream = pw_stream_new(pipewire->remote, name, NULL); ++#endif + if (!output->stream) { + weston_log("Cannot initialize pipewire stream\n"); + goto err; +@@ -704,6 +792,14 @@ weston_pipewire_loop_handler(int fd, uint32_t mask, void *data) + return 0; + } + ++#if PW_CHECK_VERSION(0, 2, 90) ++static void ++weston_pipewire_error(void *data, uint32_t id, int seq, int res, ++ const char *error) ++{ ++ weston_log("pipewire remote error: %s\n", error); ++} ++#else + static void + weston_pipewire_state_changed(void *data, enum pw_remote_state old, + enum pw_remote_state state, const char *error) +@@ -725,12 +821,20 @@ weston_pipewire_state_changed(void *data, enum pw_remote_state old, + break; + } + } ++#endif + + ++#if PW_CHECK_VERSION(0, 2, 90) ++static const struct pw_core_events core_events = { ++ PW_VERSION_CORE_EVENTS, ++ .error = weston_pipewire_error, ++}; ++#else + static const struct pw_remote_events remote_events = { + PW_VERSION_REMOTE_EVENTS, + .state_changed = weston_pipewire_state_changed, + }; ++#endif + + static int + weston_pipewire_init(struct weston_pipewire *pipewire) +@@ -745,10 +849,19 @@ weston_pipewire_init(struct weston_pipewire *pipewire) + + pw_loop_enter(pipewire->loop); + ++#if PW_CHECK_VERSION(0, 2, 90) ++ pipewire->context = pw_context_new(pipewire->loop, NULL, 0); ++#else + pipewire->core = pw_core_new(pipewire->loop, NULL); + pipewire->t = pw_core_get_type(pipewire->core); + init_type(&pipewire->type, pipewire->t->map); ++#endif + ++#if PW_CHECK_VERSION(0, 2, 90) ++ pw_core_add_listener(pipewire->core, ++ &pipewire->core_listener, ++ &core_events, pipewire); ++#else + pipewire->remote = pw_remote_new(pipewire->core, NULL, 0); + pw_remote_add_listener(pipewire->remote, + &pipewire->remote_listener, +@@ -777,6 +890,7 @@ weston_pipewire_init(struct weston_pipewire *pipewire) + goto err; + } + } ++#endif + + loop = wl_display_get_event_loop(pipewire->compositor->wl_display); + pipewire->loop_source = +@@ -786,12 +900,14 @@ weston_pipewire_init(struct weston_pipewire *pipewire) + pipewire); + + return 0; ++#if !PW_CHECK_VERSION(0, 2, 90) + err: + if (pipewire->remote) + pw_remote_destroy(pipewire->remote); + pw_loop_leave(pipewire->loop); + pw_loop_destroy(pipewire->loop); + return -1; ++#endif + } + + static const struct weston_pipewire_api pipewire_api = { +-- +2.25.1 +