From 481b7f0468b3f5928f8f0fc6aa21e4836fb3f3c5 Mon Sep 17 00:00:00 2001 From: Chris Dimich Date: Mon, 9 Jan 2023 10:52:50 -0800 Subject: chromium-ozone-wayland: add bbappend and patches as per NXP 5.15.71_2.2.0 rel Changes include: - support on i.MX 8 series platform. - 8MM/8MP/8MQ support h264/hevc/vp8/vp9 hardware decoding. - 8QM/8QXP support h264/hevc/vp8 hardware decoding. - support seek, playrate change and resolution change. - support video acceleration for online media platform such as Youtube, bilibili. Signed-off-by: Chris Dimich (cherry picked from commit 23bdb51b7858db363e56f7748f5523d44f78ac98) --- ...-Fixed-chromium-flicker-with-g2d-renderer.patch | 33 +++ ...omium-met-EGL-API-GetProcAddress-failures.patch | 34 +++ .../0003-Disable-dri-for-imx-gpu.patch | 25 ++ ...tch-to-use-VDA-instead-of-direct-VideoDec.patch | 44 +++ ...L2Device-Correct-v4l2-decoder-device-path.patch | 31 ++ .../0103-V4L2VDA-Add-macro-use_linux_v4l2.patch | 320 +++++++++++++++++++++ ...-V4L2VDA-Create-single-multi-plane-queues.patch | 152 ++++++++++ ...-Allocate-correct-v4l2-buffers-for-queues.patch | 101 +++++++ ...Create-videoframe-according-to-v4l2buffer.patch | 150 ++++++++++ ...-function-IsMultiQueue-for-S_FMT-and-G_FM.patch | 183 ++++++++++++ ...e-correct-size-to-allocate-CAPTURE-buffer.patch | 43 +++ ...2VDA-Use-correct-plane-size-and-bytesused.patch | 65 +++++ .../0110-V4L2VDA-Add-hevc-format-support.patch | 313 ++++++++++++++++++++ ...-vp9-crash-caused-by-DequeueResolutionCha.patch | 31 ++ ...-fps-in-SkiaOutputSurfaceImplOnGpu-by-VLO.patch | 88 ++++++ .../0113-V4L2VDA-Comment-some-unused-ioctl.patch | 108 +++++++ ...-OUTPUT-format-with-parsed-resolution-for.patch | 76 +++++ ...-V4L2_PIX_FMT_NV12M_8L128-format-for-amph.patch | 101 +++++++ ...port-tile-to-linear-transform-for-amphion.patch | 304 ++++++++++++++++++++ ...-V4L2VDA-Enlarge-input-buffer-count-to-16.patch | 29 ++ ...VDA-Use-dlopen-to-dynamically-use-g2d-api.patch | 306 ++++++++++++++++++++ ...2VDA-dlopen-libg2d.so.2-to-avoid-segfault.patch | 40 +++ .../chromium/chromium-ozone-wayland_%.bbappend | 51 ++++ 23 files changed, 2628 insertions(+) create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0001-Fixed-chromium-flicker-with-g2d-renderer.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0002-chromium-met-EGL-API-GetProcAddress-failures.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0003-Disable-dri-for-imx-gpu.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0101-V4L2VDA-Switch-to-use-VDA-instead-of-direct-VideoDec.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0102-GenericV4L2Device-Correct-v4l2-decoder-device-path.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0103-V4L2VDA-Add-macro-use_linux_v4l2.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0104-V4L2VDA-Create-single-multi-plane-queues.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0107-V4L2VDA-Add-function-IsMultiQueue-for-S_FMT-and-G_FM.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0108-V4L2VDA-Use-correct-size-to-allocate-CAPTURE-buffer.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0109-V4L2VDA-Use-correct-plane-size-and-bytesused.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0110-V4L2VDA-Add-hevc-format-support.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0111-V4L2VDA-fix-vp9-crash-caused-by-DequeueResolutionCha.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0112-V4L2VDA-Add-fps-in-SkiaOutputSurfaceImplOnGpu-by-VLO.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0113-V4L2VDA-Comment-some-unused-ioctl.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0114-V4L2VDA-Set-OUTPUT-format-with-parsed-resolution-for.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0115-V4L2VDA-Add-V4L2_PIX_FMT_NV12M_8L128-format-for-amph.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0116-V4L2VDA-Support-tile-to-linear-transform-for-amphion.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0117-V4L2VDA-Enlarge-input-buffer-count-to-16.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0119-V4L2VDA-dlopen-libg2d.so.2-to-avoid-segfault.patch create mode 100644 dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0001-Fixed-chromium-flicker-with-g2d-renderer.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0001-Fixed-chromium-flicker-with-g2d-renderer.patch new file mode 100644 index 00000000..3aa41ecf --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0001-Fixed-chromium-flicker-with-g2d-renderer.patch @@ -0,0 +1,33 @@ +From 1c7fd64b69feb0ea14047ce1ed68138ccf33687e Mon Sep 17 00:00:00 2001 +From: Wujian sun +Date: Mon, 5 Jul 2021 10:28:44 +0800 +Subject: [PATCH] Fixed chromium flicker with g2d-renderer + +chromium V89 reland linux_explicit_synchronization_protocol for +in-fence feature caused the flicker. +The rootcasue is that weston can not acquire fence fd. +A workaround no checking supports_acquire_fence supported. + +Upstream-Status: Inappropriate [i.MX specific] +Signed-off-by: Wujian sun +--- + ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc +index e7d3e7268a08..83c57fd65d72 100644 +--- a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc ++++ b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc +@@ -112,8 +112,7 @@ void GbmSurfacelessWayland::SwapBuffersAsync( + + // If Wayland server supports linux_explicit_synchronization_protocol, fences + // should be shipped with buffers. Otherwise, we will wait for fences. +- if (buffer_manager_->supports_acquire_fence() || !use_egl_fence_sync_ || +- !frame->schedule_planes_succeeded) { ++ if (!use_egl_fence_sync_ || !frame->schedule_planes_succeeded) { + frame->ready = true; + MaybeSubmitFrames(); + return; +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0002-chromium-met-EGL-API-GetProcAddress-failures.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0002-chromium-met-EGL-API-GetProcAddress-failures.patch new file mode 100644 index 00000000..b85e3cfd --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0002-chromium-met-EGL-API-GetProcAddress-failures.patch @@ -0,0 +1,34 @@ +From fc83501ff2105f99183b3f6ea240d6baacf3ea05 Mon Sep 17 00:00:00 2001 +From: Wujian Sun +Date: Wed, 10 Nov 2021 17:28:22 +0800 +Subject: [PATCH] chromium met EGL API GetProcAddress failures + +Wayland not use SwANGLE as below commit, so no need +build SwANGLE on wayland platform. + +commit 97f919dd8b544b583b772664f0d7b8e6b6d8da2e +Reland "Use SwANGLE on all Ozone platforms, except Wayland" + +Upstream-Status: Inappropriate [i.MX-specific] + +Signed-off-by: Wujian Sun +--- + ui/gl/BUILD.gn | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn +index bb7d843c1f363..4b4b360758e1d 100644 +--- a/ui/gl/BUILD.gn ++++ b/ui/gl/BUILD.gn +@@ -252,7 +252,7 @@ component("gl") { + + if (use_ozone) { + deps += [ "//ui/ozone:buildflags" ] +- if (use_egl && !is_fuchsia) { ++ if (use_egl && !is_fuchsia && !ozone_platform_wayland) { + data_deps += [ + "//third_party/angle:libEGL", + "//third_party/angle:libGLESv2", +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0003-Disable-dri-for-imx-gpu.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0003-Disable-dri-for-imx-gpu.patch new file mode 100644 index 00000000..73b917fb --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0003-Disable-dri-for-imx-gpu.patch @@ -0,0 +1,25 @@ +Index: chromium-96.0.4664.45/content/gpu/BUILD.gn +=================================================================== +--- chromium-96.0.4664.45.orig/content/gpu/BUILD.gn ++++ chromium-96.0.4664.45/content/gpu/BUILD.gn +@@ -7,6 +7,11 @@ import("//build/config/ui.gni") + import("//gpu/vulkan/features.gni") + import("//media/media_options.gni") + ++declare_args() { ++ # Checks if i.MX GPU is being used ++ use_imxgpu = false ++} ++ + # See //content/BUILD.gn for how this works. + group("gpu") { + visibility = [ "//content/*" ] # This is an internal content API. +@@ -136,7 +141,7 @@ target(link_target_type, "gpu_sources") + + # Use DRI on desktop Linux builds. + if (current_cpu != "s390x" && current_cpu != "ppc64" && is_linux && +- (!is_chromecast || is_cast_desktop_build)) { ++ (!is_chromecast || is_cast_desktop_build) && !use_imxgpu) { + configs += [ "//build/config/linux/dri" ] + } + } diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0101-V4L2VDA-Switch-to-use-VDA-instead-of-direct-VideoDec.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0101-V4L2VDA-Switch-to-use-VDA-instead-of-direct-VideoDec.patch new file mode 100644 index 00000000..24ae4dd3 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0101-V4L2VDA-Switch-to-use-VDA-instead-of-direct-VideoDec.patch @@ -0,0 +1,44 @@ +From a86b5ee086e281f34ab90498aedde523c47f9df0 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Wed, 17 Aug 2022 16:57:11 +0800 +Subject: [PATCH 01/17] V4L2VDA: Switch to use VDA instead of direct + VideoDecoder + +commit b7f3a9e8058f593d7d88b6b6cafa71957aa3f1a1 aims to default +enable "direct VideoDecoder" support on Linux. So need to switch +to use VDA path iff: + +1. kVaapiVideoDecodeLinux is enabled (disabled by default); +2. kUseChromeOSDirectVideoDecoder is disabled (enabled by default); +3. GL is used; + +Upstream-Status: Inappropriate [NXP specific] +--- + media/base/media_switches.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc +index 36d638adb816e..938bcede9c878 100644 +--- a/media/base/media_switches.cc ++++ b/media/base/media_switches.cc +@@ -487,7 +487,7 @@ const base::Feature kUnifiedAutoplay{"UnifiedAutoplay", + // Enable vaapi video decoding on linux. This is already enabled by default on + // chromeos, but needs an experiment on linux. + const base::Feature kVaapiVideoDecodeLinux{"VaapiVideoDecoder", +- base::FEATURE_DISABLED_BY_DEFAULT}; ++ base::FEATURE_ENABLED_BY_DEFAULT}; + + const base::Feature kVaapiVideoEncodeLinux{"VaapiVideoEncoder", + base::FEATURE_DISABLED_BY_DEFAULT}; +@@ -735,7 +735,7 @@ const base::Feature kUseRealColorSpaceForAndroidVideo{ + // experiment with direct VideoDecoder path on Linux Desktop. + // TODO(b/159825227): remove when the direct video decoder is fully launched. + const base::Feature kUseChromeOSDirectVideoDecoder{ +- "UseChromeOSDirectVideoDecoder", base::FEATURE_ENABLED_BY_DEFAULT}; ++ "UseChromeOSDirectVideoDecoder", base::FEATURE_DISABLED_BY_DEFAULT}; + + #if BUILDFLAG(IS_CHROMEOS) + // ChromeOS has one of two VideoDecoder implementations active based on +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0102-GenericV4L2Device-Correct-v4l2-decoder-device-path.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0102-GenericV4L2Device-Correct-v4l2-decoder-device-path.patch new file mode 100644 index 00000000..f7af6acf --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0102-GenericV4L2Device-Correct-v4l2-decoder-device-path.patch @@ -0,0 +1,31 @@ +From b81ae910fcc8d44ba26ee33923860978b092329a Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Fri, 2 Sep 2022 16:42:58 +0800 +Subject: [PATCH 02/17] GenericV4L2Device: Correct v4l2 decoder device path + +Change decoder device pattern to /dev/video, and select one +correct device path /dev/videox where x is an integer. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/generic_v4l2_device.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc +index a6fe9d914e8d9..c1fccf3e2e813 100644 +--- a/media/gpu/v4l2/generic_v4l2_device.cc ++++ b/media/gpu/v4l2/generic_v4l2_device.cc +@@ -478,8 +478,8 @@ bool GenericV4L2Device::PostSandboxInitialization() { + } + + void GenericV4L2Device::EnumerateDevicesForType(Type type) { +- static const std::string kDecoderDevicePattern = "/dev/video-dec"; +- static const std::string kEncoderDevicePattern = "/dev/video-enc"; ++ static const std::string kDecoderDevicePattern = "/dev/video"; ++ static const std::string kEncoderDevicePattern = "/dev/video"; + static const std::string kImageProcessorDevicePattern = "/dev/image-proc"; + static const std::string kJpegDecoderDevicePattern = "/dev/jpeg-dec"; + static const std::string kJpegEncoderDevicePattern = "/dev/jpeg-enc"; +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0103-V4L2VDA-Add-macro-use_linux_v4l2.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0103-V4L2VDA-Add-macro-use_linux_v4l2.patch new file mode 100644 index 00000000..a0219b8c --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0103-V4L2VDA-Add-macro-use_linux_v4l2.patch @@ -0,0 +1,320 @@ +From fdc95ddfab945de74fe6b0b196df9a6394013243 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Fri, 2 Sep 2022 13:18:34 +0800 +Subject: [PATCH 03/17] V4L2VDA: Add macro use_linux_v4l2 + +Upstream-Status: Inappropriate [NXP specific] +--- + .../gpu_mjpeg_decode_accelerator_factory.cc | 3 +- + media/gpu/BUILD.gn | 1 + + media/gpu/args.gni | 4 +++ + .../gpu_video_decode_accelerator_factory.cc | 8 ++++++ + .../gpu_video_decode_accelerator_factory.h | 2 ++ + media/gpu/v4l2/BUILD.gn | 22 +++++++++------ + media/gpu/v4l2/generic_v4l2_device.cc | 4 +++ + media/gpu/v4l2/v4l2_device.cc | 28 +++++++++++++++++++ + media/gpu/v4l2/v4l2_video_decoder.cc | 6 ++++ + 9 files changed, 69 insertions(+), 9 deletions(-) + +diff --git a/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc b/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc +index 3772b8ef048a2..dece6b77f6a23 100644 +--- a/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc ++++ b/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc +@@ -13,7 +13,8 @@ + #include "media/base/media_switches.h" + #include "media/gpu/buildflags.h" + +-#if BUILDFLAG(USE_V4L2_CODEC) && defined(ARCH_CPU_ARM_FAMILY) ++#if BUILDFLAG(USE_V4L2_CODEC) && defined(ARCH_CPU_ARM_FAMILY) && \ ++ !BUILDFLAG(USE_LINUX_V4L2) + #define USE_V4L2_MJPEG_DECODE_ACCELERATOR + #endif + +diff --git a/media/gpu/BUILD.gn b/media/gpu/BUILD.gn +index 78d151fa630d2..101e2e4f9411e 100644 +--- a/media/gpu/BUILD.gn ++++ b/media/gpu/BUILD.gn +@@ -20,6 +20,7 @@ buildflag_header("buildflags") { + "USE_VAAPI_IMAGE_CODECS=$use_vaapi_image_codecs", + "USE_V4L2_CODEC=$use_v4l2_codec", + "USE_LIBV4L2=$use_v4lplugin", ++ "USE_LINUX_V4L2=$use_linux_v4l2_only", + "USE_VAAPI_X11=$use_vaapi_x11", + ] + } +diff --git a/media/gpu/args.gni b/media/gpu/args.gni +index bb2ff0797e031..da20cff798728 100644 +--- a/media/gpu/args.gni ++++ b/media/gpu/args.gni +@@ -21,6 +21,10 @@ declare_args() { + # platforms which have v4l2 hardware encoder / decoder. + use_v4l2_codec = false + ++ # Indicates that only definitions available in the mainline linux kernel ++ # will be used. ++ use_linux_v4l2_only = false ++ + # Indicates if Video4Linux2 AML encoder is used. This is used for AML + # platforms which have v4l2 hardware encoder + use_v4l2_codec_aml = false +diff --git a/media/gpu/gpu_video_decode_accelerator_factory.cc b/media/gpu/gpu_video_decode_accelerator_factory.cc +index 6687b11865f07..9514786384aa7 100644 +--- a/media/gpu/gpu_video_decode_accelerator_factory.cc ++++ b/media/gpu/gpu_video_decode_accelerator_factory.cc +@@ -29,7 +29,9 @@ + #include "ui/gl/gl_implementation.h" + #elif BUILDFLAG(USE_V4L2_CODEC) + #include "media/gpu/v4l2/v4l2_device.h" ++#if !BUILDFLAG(USE_LINUX_V4L2) + #include "media/gpu/v4l2/v4l2_slice_video_decode_accelerator.h" ++#endif + #include "media/gpu/v4l2/v4l2_video_decode_accelerator.h" + #include "ui/gl/gl_surface_egl.h" + #endif +@@ -64,10 +66,12 @@ gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilitiesInternal( + GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( + V4L2VideoDecodeAccelerator::GetSupportedProfiles(), + &capabilities.supported_profiles); ++#if !BUILDFLAG(USE_LINUX_V4L2) + GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( + V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(), + &capabilities.supported_profiles); + #endif ++#endif + #elif BUILDFLAG(IS_MAC) + capabilities.supported_profiles = + VTVideoDecodeAccelerator::GetSupportedProfiles(workarounds); +@@ -146,8 +150,10 @@ GpuVideoDecodeAcceleratorFactory::CreateVDA( + &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA, + #elif BUILDFLAG(USE_V4L2_CODEC) + &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA, ++#if !BUILDFLAG(USE_LINUX_V4L2) + &GpuVideoDecodeAcceleratorFactory::CreateV4L2SliceVDA, + #endif ++#endif + + #if BUILDFLAG(IS_MAC) + &GpuVideoDecodeAcceleratorFactory::CreateVTVDA, +@@ -207,6 +213,7 @@ GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA( + return decoder; + } + ++#if !BUILDFLAG(USE_LINUX_V4L2) + std::unique_ptr + GpuVideoDecodeAcceleratorFactory::CreateV4L2SliceVDA( + const gpu::GpuDriverBugWorkarounds& /*workarounds*/, +@@ -222,6 +229,7 @@ GpuVideoDecodeAcceleratorFactory::CreateV4L2SliceVDA( + return decoder; + } + #endif ++#endif + + #if BUILDFLAG(IS_MAC) + std::unique_ptr +diff --git a/media/gpu/gpu_video_decode_accelerator_factory.h b/media/gpu/gpu_video_decode_accelerator_factory.h +index b2e1390c5f02d..5a714eb801d04 100644 +--- a/media/gpu/gpu_video_decode_accelerator_factory.h ++++ b/media/gpu/gpu_video_decode_accelerator_factory.h +@@ -104,11 +104,13 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcceleratorFactory { + const gpu::GpuDriverBugWorkarounds& workarounds, + const gpu::GpuPreferences& gpu_preferences, + MediaLog* media_log) const; ++#if !BUILDFLAG(USE_LINUX_V4L2) + std::unique_ptr CreateV4L2SliceVDA( + const gpu::GpuDriverBugWorkarounds& workarounds, + const gpu::GpuPreferences& gpu_preferences, + MediaLog* media_log) const; + #endif ++#endif + #if BUILDFLAG(IS_MAC) + std::unique_ptr CreateVTVDA( + const gpu::GpuDriverBugWorkarounds& workarounds, +diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn +index 65e5f58d1efef..ebd0a4ad64646 100644 +--- a/media/gpu/v4l2/BUILD.gn ++++ b/media/gpu/v4l2/BUILD.gn +@@ -28,9 +28,6 @@ source_set("v4l2") { + "buffer_affinity_tracker.h", + "generic_v4l2_device.cc", + "generic_v4l2_device.h", +- "v4l2_decode_surface.cc", +- "v4l2_decode_surface.h", +- "v4l2_decode_surface_handler.h", + "v4l2_device.cc", + "v4l2_device.h", + "v4l2_device_poller.cc", +@@ -39,8 +36,6 @@ source_set("v4l2") { + "v4l2_framerate_control.h", + "v4l2_image_processor_backend.cc", + "v4l2_image_processor_backend.h", +- "v4l2_slice_video_decode_accelerator.cc", +- "v4l2_slice_video_decode_accelerator.h", + "v4l2_stateful_workaround.cc", + "v4l2_stateful_workaround.h", + "v4l2_status.h", +@@ -56,8 +51,19 @@ source_set("v4l2") { + "v4l2_video_decoder_backend.h", + "v4l2_video_decoder_backend_stateful.cc", + "v4l2_video_decoder_backend_stateful.h", ++ "v4l2_video_encode_accelerator.cc", ++ "v4l2_video_encode_accelerator.h", ++ ] ++ ++ if (!use_linux_v4l2_only) { ++ sources += [ ++ "v4l2_decode_surface.cc", ++ "v4l2_decode_surface.h", ++ "v4l2_decode_surface_handler.h", + "v4l2_video_decoder_backend_stateless.cc", + "v4l2_video_decoder_backend_stateless.h", ++ "v4l2_slice_video_decode_accelerator.cc", ++ "v4l2_slice_video_decode_accelerator.h", + "v4l2_video_decoder_delegate_h264.cc", + "v4l2_video_decoder_delegate_h264.h", + "v4l2_video_decoder_delegate_h264_legacy.cc", +@@ -72,9 +78,9 @@ source_set("v4l2") { + "v4l2_video_decoder_delegate_vp9_chromium.h", + "v4l2_video_decoder_delegate_vp9_legacy.cc", + "v4l2_video_decoder_delegate_vp9_legacy.h", +- "v4l2_video_encode_accelerator.cc", +- "v4l2_video_encode_accelerator.h", +- ] ++ ] ++ } ++ + + libs = [ + "EGL", +diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc +index c1fccf3e2e813..319357922c901 100644 +--- a/media/gpu/v4l2/generic_v4l2_device.cc ++++ b/media/gpu/v4l2/generic_v4l2_device.cc +@@ -440,7 +440,11 @@ bool GenericV4L2Device::OpenDevicePath(const std::string& path, Type type) { + return false; + + #if BUILDFLAG(USE_LIBV4L2) ++#if BUILDFLAG(USE_LINUX_V4L2) ++ if ( ++#else + if (type == Type::kEncoder && ++#endif + HANDLE_EINTR(v4l2_fd_open(device_fd_.get(), V4L2_DISABLE_CONVERSION)) != + -1) { + DVLOGF(3) << "Using libv4l2 for " << path; +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index de2800fdab395..722ddbd68cb2b 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -853,7 +853,9 @@ void V4L2WritableBufferRef::SetConfigStore(uint32_t config_store) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(buffer_data_); + ++#if !BUILDFLAG(USE_LINUX_V4L2) + buffer_data_->v4l2_buffer_.config_store = config_store; ++#endif + } + + V4L2ReadableBuffer::V4L2ReadableBuffer(const struct v4l2_buffer& v4l2_buffer, +@@ -1539,6 +1541,25 @@ std::string V4L2Device::GetDriverName() { + // static + uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile, + bool slice_based) { ++#if BUILDFLAG(USE_LINUX_V4L2) ++ if (slice_based) { ++ LOG(ERROR) << "Unsupported slice"; ++ return 0; ++ } ++ ++ if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) { ++ return V4L2_PIX_FMT_H264; ++ } else if (profile >= VP8PROFILE_MIN && profile <= VP8PROFILE_MAX) { ++ return V4L2_PIX_FMT_VP8; ++ } else if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX) { ++ return V4L2_PIX_FMT_VP9; ++ } else if (profile == HEVCPROFILE_MAIN) { ++ return V4L2_PIX_FMT_HEVC; ++ } else { ++ DVLOGF(1) << "Unsupported profile: " << GetProfileName(profile); ++ return 0; ++ } ++#else + if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) { + if (slice_based) + return V4L2_PIX_FMT_H264_SLICE; +@@ -1558,6 +1579,7 @@ uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile, + DVLOGF(1) << "Unsupported profile: " << GetProfileName(profile); + return 0; + } ++#endif + } + + namespace { +@@ -1652,7 +1674,9 @@ std::vector V4L2Device::V4L2PixFmtToVideoCodecProfiles( + std::vector profiles; + switch (pix_fmt) { + case V4L2_PIX_FMT_H264: ++#if !BUILDFLAG(USE_LINUX_V4L2) + case V4L2_PIX_FMT_H264_SLICE: ++#endif + if (!get_supported_profiles(VideoCodec::kH264, &profiles)) { + DLOG(WARNING) << "Driver doesn't support QUERY H264 profiles, " + << "use default values, Base, Main, High"; +@@ -1664,11 +1688,15 @@ std::vector V4L2Device::V4L2PixFmtToVideoCodecProfiles( + } + break; + case V4L2_PIX_FMT_VP8: ++#if !BUILDFLAG(USE_LINUX_V4L2) + case V4L2_PIX_FMT_VP8_FRAME: ++#endif + profiles = {VP8PROFILE_ANY}; + break; + case V4L2_PIX_FMT_VP9: ++#if !BUILDFLAG(USE_LINUX_V4L2) + case V4L2_PIX_FMT_VP9_FRAME: ++#endif + if (!get_supported_profiles(VideoCodec::kVP9, &profiles)) { + DLOG(WARNING) << "Driver doesn't support QUERY VP9 profiles, " + << "use default values, Profile0"; +diff --git a/media/gpu/v4l2/v4l2_video_decoder.cc b/media/gpu/v4l2/v4l2_video_decoder.cc +index 057b28663b15b..691908a3ba8ed 100644 +--- a/media/gpu/v4l2/v4l2_video_decoder.cc ++++ b/media/gpu/v4l2/v4l2_video_decoder.cc +@@ -28,7 +28,9 @@ + #include "media/gpu/macros.h" + #include "media/gpu/v4l2/v4l2_status.h" + #include "media/gpu/v4l2/v4l2_video_decoder_backend_stateful.h" ++#if !BUILDFLAG(USE_LINUX_V4L2) + #include "media/gpu/v4l2/v4l2_video_decoder_backend_stateless.h" ++#endif + + namespace media { + +@@ -46,7 +48,9 @@ constexpr size_t kNumInputBuffers = 8; + + // Input format V4L2 fourccs this class supports. + constexpr uint32_t kSupportedInputFourccs[] = { ++#if !BUILDFLAG(USE_LINUX_V4L2) + V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME, V4L2_PIX_FMT_VP9_FRAME, ++#endif + V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9, + }; + +@@ -320,6 +324,7 @@ V4L2Status V4L2VideoDecoder::InitializeBackend() { + << " and fourcc: " << FourccToString(input_format_fourcc); + backend_ = std::make_unique( + this, device_, profile_, color_space_, decoder_task_runner_); ++#if !BUILDFLAG(USE_LINUX_V4L2) + } else { + DCHECK_EQ(preferred_api_and_format.first, kStateless); + VLOGF(1) << "Using a stateless API for profile: " +@@ -327,6 +332,7 @@ V4L2Status V4L2VideoDecoder::InitializeBackend() { + << " and fourcc: " << FourccToString(input_format_fourcc); + backend_ = std::make_unique( + this, device_, profile_, color_space_, decoder_task_runner_); ++#endif + } + + if (!backend_->Initialize()) { +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0104-V4L2VDA-Create-single-multi-plane-queues.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0104-V4L2VDA-Create-single-multi-plane-queues.patch new file mode 100644 index 00000000..817868ac --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0104-V4L2VDA-Create-single-multi-plane-queues.patch @@ -0,0 +1,152 @@ +From 9caf73fb012217db1581a5079dfbc9872196571f Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Fri, 2 Sep 2022 15:35:52 +0800 +Subject: [PATCH 04/17] V4L2VDA: Create single/multi plane queues + +Decide to create single-plane queue or multi-plane queue according to +the capabilities returned by VIDIOC_QUERYCAP. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/generic_v4l2_device.cc | 15 ++++++---- + media/gpu/v4l2/v4l2_device.cc | 11 ++++++-- + .../gpu/v4l2/v4l2_video_decode_accelerator.cc | 28 ++++++++++++++----- + 3 files changed, 39 insertions(+), 15 deletions(-) + +diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc +index 319357922c901..a578768f8d3b1 100644 +--- a/media/gpu/v4l2/generic_v4l2_device.cc ++++ b/media/gpu/v4l2/generic_v4l2_device.cc +@@ -489,27 +489,28 @@ void GenericV4L2Device::EnumerateDevicesForType(Type type) { + static const std::string kJpegEncoderDevicePattern = "/dev/jpeg-enc"; + + std::string device_pattern; +- v4l2_buf_type buf_type; ++ std::vector candidate_buf_types; + switch (type) { + case Type::kDecoder: + device_pattern = kDecoderDevicePattern; +- buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ candidate_buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT); ++ candidate_buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + break; + case Type::kEncoder: + device_pattern = kEncoderDevicePattern; +- buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ candidate_buf_types.push_back(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + break; + case Type::kImageProcessor: + device_pattern = kImageProcessorDevicePattern; +- buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ candidate_buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + break; + case Type::kJpegDecoder: + device_pattern = kJpegDecoderDevicePattern; +- buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ candidate_buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + break; + case Type::kJpegEncoder: + device_pattern = kJpegEncoderDevicePattern; +- buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ candidate_buf_types.push_back(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + break; + } + +@@ -529,6 +530,7 @@ void GenericV4L2Device::EnumerateDevicesForType(Type type) { + + Devices devices; + for (const auto& path : candidate_paths) { ++ for (const auto& buf_type : candidate_buf_types){ + if (!OpenDevicePath(path, type)) + continue; + +@@ -541,6 +543,7 @@ void GenericV4L2Device::EnumerateDevicesForType(Type type) { + + CloseDevice(); + } ++ } + + DCHECK_EQ(devices_by_type_.count(type), 0u); + devices_by_type_[type] = devices; +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 722ddbd68cb2b..8194d8646637c 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -1479,6 +1479,8 @@ scoped_refptr V4L2Device::GetQueue(enum v4l2_buf_type type) { + // Supported queue types. + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: ++ case V4L2_BUF_TYPE_VIDEO_OUTPUT: ++ case V4L2_BUF_TYPE_VIDEO_CAPTURE: + break; + default: + VLOGF(1) << "Unsupported V4L2 queue type: " << type; +@@ -2049,8 +2051,13 @@ V4L2Device::EnumerateSupportedDecodeProfiles(const size_t num_formats, + const uint32_t pixelformats[]) { + VideoDecodeAccelerator::SupportedProfiles profiles; + +- const auto& supported_pixelformats = +- EnumerateSupportedPixelformats(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); ++ std::vector enumerated_pixelformats; ++ enumerated_pixelformats = EnumerateSupportedPixelformats(V4L2_BUF_TYPE_VIDEO_OUTPUT); ++ if (enumerated_pixelformats.empty()) { ++ VLOG(1) << "empty.... Try Multi-plane"; ++ enumerated_pixelformats = EnumerateSupportedPixelformats(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); ++ } ++ const auto& supported_pixelformats = enumerated_pixelformats; + + for (uint32_t pixelformat : supported_pixelformats) { + if (std::find(pixelformats, pixelformats + num_formats, pixelformat) == +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index c920940572fb2..631e68e0f9314 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -322,24 +322,38 @@ bool V4L2VideoDecodeAccelerator::CheckConfig(const Config& config) { + + // Capabilities check. + struct v4l2_capability caps; +- const __u32 kCapsRequired = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; +- IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYCAP, &caps); +- if ((caps.capabilities & kCapsRequired) != kCapsRequired) { +- VLOGF(1) << "ioctl() failed: VIDIOC_QUERYCAP" +- << ", caps check failed: 0x" << std::hex << caps.capabilities; ++ unsigned int device_caps; ++ enum v4l2_buf_type input_type, output_type; ++ if (device_->Ioctl(VIDIOC_QUERYCAP, &caps) != 0) { ++ VPLOGF(1) << "ioctl() failed: VIDIOC_QUERYCAP" ++ << ", caps check failed: 0x" << std::hex << caps.capabilities; + return false; + } + ++ if (caps.capabilities & V4L2_CAP_DEVICE_CAPS) ++ device_caps = caps.device_caps; ++ else ++ device_caps = caps.capabilities; ++ ++ if (device_caps & (V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)) ++ input_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ else ++ input_type = V4L2_BUF_TYPE_VIDEO_OUTPUT; ++ if (device_caps & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)) ++ output_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ else ++ output_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ + workarounds_ = + CreateV4L2StatefulWorkarounds(V4L2Device::Type::kDecoder, config.profile); + + output_mode_ = config.output_mode; + +- input_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); ++ input_queue_ = device_->GetQueue(input_type); + if (!input_queue_) + return false; + +- output_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); ++ output_queue_ = device_->GetQueue(output_type); + if (!output_queue_) + return false; + +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch new file mode 100644 index 00000000..b790b9ff --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch @@ -0,0 +1,101 @@ +From 8c5e88c38c6ef5c9864016b90dfc3ae49cc11ddb Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Fri, 2 Sep 2022 17:10:12 +0800 +Subject: [PATCH 05/17] V4L2Buffer: Allocate correct v4l2 buffers for queues + +For single plane queue, need to fill v4l2_planes_[0] with +correct size quried from v4l2 driver. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_device.cc | 45 ++++++++++++++++++++++++----------- + 1 file changed, 31 insertions(+), 14 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 8194d8646637c..9614eb8e71668 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -210,24 +210,30 @@ V4L2Buffer::V4L2Buffer(scoped_refptr device, + DCHECK(V4L2_TYPE_IS_MULTIPLANAR(type)); + DCHECK_LE(format.fmt.pix_mp.num_planes, std::size(v4l2_planes_)); + +- memset(&v4l2_buffer_, 0, sizeof(v4l2_buffer_)); +- memset(v4l2_planes_, 0, sizeof(v4l2_planes_)); +- v4l2_buffer_.m.planes = v4l2_planes_; +- // Just in case we got more planes than we want. +- v4l2_buffer_.length = +- std::min(static_cast(format.fmt.pix_mp.num_planes), +- std::size(v4l2_planes_)); ++ if (V4L2_TYPE_IS_MULTIPLANAR(type)) { ++ memset(&v4l2_buffer_, 0, sizeof(v4l2_buffer_)); ++ memset(v4l2_planes_, 0, sizeof(v4l2_planes_)); ++ v4l2_buffer_.m.planes = v4l2_planes_; ++ // Just in case we got more planes than we want. ++ v4l2_buffer_.length = ++ std::min(static_cast(format.fmt.pix_mp.num_planes), ++ std::size(v4l2_planes_)); ++ } + v4l2_buffer_.index = buffer_id; + v4l2_buffer_.type = type; + v4l2_buffer_.memory = memory; +- plane_mappings_.resize(v4l2_buffer_.length); ++ plane_mappings_.resize(V4L2_TYPE_IS_MULTIPLANAR(type) ? v4l2_buffer_.length : 1); + } + + V4L2Buffer::~V4L2Buffer() { + if (v4l2_buffer_.memory == V4L2_MEMORY_MMAP) { +- for (size_t i = 0; i < plane_mappings_.size(); i++) +- if (plane_mappings_[i] != nullptr) +- device_->Munmap(plane_mappings_[i], v4l2_buffer_.m.planes[i].length); ++ for (size_t i = 0; i < plane_mappings_.size(); i++) { ++ if (plane_mappings_[i] != nullptr) { ++ unsigned int length = V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ? ++ v4l2_buffer_.m.planes[i].length : v4l2_buffer_.length; ++ device_->Munmap(plane_mappings_[i], length); ++ } ++ } + } + } + +@@ -238,6 +244,13 @@ bool V4L2Buffer::Query() { + return false; + } + ++ if (!V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type)) { ++ v4l2_planes_[0].bytesused = v4l2_buffer_.bytesused; ++ v4l2_planes_[0].length = v4l2_buffer_.length; ++ v4l2_planes_[0].data_offset = 0; ++ memcpy (&v4l2_planes_[0].m, &v4l2_buffer_.m, sizeof (v4l2_buffer_.m)); ++ } ++ + DCHECK(plane_mappings_.size() == v4l2_buffer_.length); + + return true; +@@ -260,9 +273,13 @@ void* V4L2Buffer::GetPlaneMapping(const size_t plane) { + return nullptr; + } + +- p = device_->Mmap(nullptr, v4l2_buffer_.m.planes[plane].length, ++ unsigned int length = V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ? ++ v4l2_buffer_.m.planes[plane].length : v4l2_planes_[plane].length; ++ unsigned int mem_offset = V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ? ++ v4l2_buffer_.m.planes[plane].m.mem_offset : v4l2_planes_[plane].m.mem_offset; ++ p = device_->Mmap(nullptr, length, + PROT_READ | PROT_WRITE, MAP_SHARED, +- v4l2_buffer_.m.planes[plane].m.mem_offset); ++ mem_offset); + if (p == MAP_FAILED) { + VPLOGF(1) << "mmap() failed: "; + return nullptr; +@@ -1131,7 +1148,7 @@ size_t V4L2Queue::AllocateBuffers(size_t count, enum v4l2_memory memory) { + VQLOGF(1) << "Cannot get format."; + return 0; + } +- planes_count_ = format->fmt.pix_mp.num_planes; ++ planes_count_ = V4L2_TYPE_IS_MULTIPLANAR(format->type) ? format->fmt.pix_mp.num_planes : 1; + DCHECK_LE(planes_count_, static_cast(VIDEO_MAX_PLANES)); + + struct v4l2_requestbuffers reqbufs; +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch new file mode 100644 index 00000000..f210fe57 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch @@ -0,0 +1,150 @@ +From 0e5dd1497ff0764dc28ef9bbd3f9249617f8af59 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Fri, 2 Sep 2022 17:30:16 +0800 +Subject: [PATCH 06/17] V4L2VDA: Create videoframe according to v4l2buffer + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_device.cc | 70 ++++++++++++++++++++++++----------- + 1 file changed, 48 insertions(+), 22 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 9614eb8e71668..a9462c9a2fb2d 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -305,7 +305,7 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + } + + std::vector dmabuf_fds = device_->GetDmabufsForV4L2Buffer( +- v4l2_buffer_.index, v4l2_buffer_.length, ++ v4l2_buffer_.index, V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ? v4l2_buffer_.length : 1, + static_cast(v4l2_buffer_.type)); + if (dmabuf_fds.empty()) { + VLOGF(1) << "Failed to get DMABUFs of V4L2 buffer"; +@@ -332,7 +332,10 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + dmabuf_fds.emplace_back(duped_fd); + } + +- gfx::Size size(format_.fmt.pix_mp.width, format_.fmt.pix_mp.height); ++ if (V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type)) ++ gfx::Size size(format_.fmt.pix_mp.width, format_.fmt.pix_mp.height); ++ else ++ gfx::Size size(format_.fmt.pix.width, format_.fmt.pix.height); + + return VideoFrame::WrapExternalDmabufs( + *layout, gfx::Rect(size), size, std::move(dmabuf_fds), base::TimeDelta()); +@@ -1897,13 +1900,9 @@ gfx::Size V4L2Device::AllocatedSizeFromV4L2Format( + // static + absl::optional V4L2Device::V4L2FormatToVideoFrameLayout( + const struct v4l2_format& format) { +- if (!V4L2_TYPE_IS_MULTIPLANAR(format.type)) { +- VLOGF(1) << "v4l2_buf_type is not multiplanar: " << std::hex << "0x" +- << format.type; +- return absl::nullopt; +- } + const v4l2_pix_format_mplane& pix_mp = format.fmt.pix_mp; +- const uint32_t& pix_fmt = pix_mp.pixelformat; ++ const v4l2_pix_format& pix = format.fmt.pix; ++ const uint32_t& pix_fmt = V4L2_TYPE_IS_MULTIPLANAR(format.type) ? pix_mp.pixelformat : pix.pixelformat; + const auto video_fourcc = Fourcc::FromV4L2PixFmt(pix_fmt); + if (!video_fourcc) { + VLOGF(1) << "Failed to convert pixel format to VideoPixelFormat: " +@@ -1911,7 +1910,7 @@ absl::optional V4L2Device::V4L2FormatToVideoFrameLayout( + return absl::nullopt; + } + const VideoPixelFormat video_format = video_fourcc->ToVideoPixelFormat(); +- const size_t num_buffers = pix_mp.num_planes; ++ const size_t num_buffers = V4L2_TYPE_IS_MULTIPLANAR(format.type) ? format.fmt.pix_mp.num_planes : 1; + const size_t num_color_planes = VideoFrame::NumPlanes(video_format); + if (num_color_planes == 0) { + VLOGF(1) << "Unsupported video format for NumPlanes(): " +@@ -1929,9 +1928,17 @@ absl::optional V4L2Device::V4L2FormatToVideoFrameLayout( + std::vector planes; + planes.reserve(num_color_planes); + for (size_t i = 0; i < num_buffers; ++i) { +- const v4l2_plane_pix_format& plane_format = pix_mp.plane_fmt[i]; +- planes.emplace_back(static_cast(plane_format.bytesperline), 0u, +- plane_format.sizeimage); ++ if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) { ++ if(i==0) ++ planes.emplace_back(static_cast(pix_mp.width), 0u, ++ pix_mp.width*pix_mp.height); ++ else ++ planes.emplace_back(static_cast(pix_mp.width), 0u, ++ pix_mp.width*pix_mp.height/2); ++ } else { ++ planes.emplace_back(static_cast(pix.bytesperline), 0u, ++ pix.sizeimage); ++ } + } + // For the case that #color planes > #buffers, it fills stride of color + // plane which does not map to buffer. +@@ -1945,8 +1952,12 @@ absl::optional V4L2Device::V4L2FormatToVideoFrameLayout( + case V4L2_PIX_FMT_NV12: + // The stride of UV is the same as Y in NV12. + // The height is half of Y plane. +- planes.emplace_back(y_stride, y_stride_abs * pix_mp.height, +- y_stride_abs * pix_mp.height / 2); ++ if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) ++ planes.emplace_back(y_stride, y_stride_abs * pix_mp.height, ++ y_stride_abs * pix_mp.height / 2); ++ else ++ planes.emplace_back(y_stride, y_stride_abs * pix.height, ++ y_stride_abs * pix.height / 2); + DCHECK_EQ(2u, planes.size()); + break; + case V4L2_PIX_FMT_YUV420: +@@ -1954,13 +1965,18 @@ absl::optional V4L2Device::V4L2FormatToVideoFrameLayout( + // The spec claims that two Cx rows (including padding) is exactly as + // long as one Y row (including padding). So stride of Y must be even + // number. +- if (y_stride % 2 != 0 || pix_mp.height % 2 != 0) { ++ if (V4L2_TYPE_IS_MULTIPLANAR(format.type) && (y_stride % 2 != 0 || pix_mp.height % 2 != 0)) { + VLOGF(1) << "Plane-Y stride and height should be even; stride: " + << y_stride << ", height: " << pix_mp.height; + return absl::nullopt; + } ++ else if (!V4L2_TYPE_IS_MULTIPLANAR(format.type) && (y_stride % 2 != 0 || pix.height % 2 != 0)){ ++ VLOGF(1) << "Plane-Y stride and height should be even; stride: " ++ << y_stride << ", height: " << pix.height; ++ return absl::nullopt; ++ } + const int32_t half_stride = y_stride / 2; +- const size_t plane_0_area = y_stride_abs * pix_mp.height; ++ const size_t plane_0_area = y_stride_abs * (V4L2_TYPE_IS_MULTIPLANAR(format.type) ? pix_mp.height : pix.height); + const size_t plane_1_area = plane_0_area / 4; + planes.emplace_back(half_stride, plane_0_area, plane_1_area); + planes.emplace_back(half_stride, plane_0_area + plane_1_area, +@@ -1979,13 +1995,23 @@ absl::optional V4L2Device::V4L2FormatToVideoFrameLayout( + // such devices individually, so set this as a video frame layout property. + constexpr size_t buffer_alignment = 0x1000; + if (num_buffers == 1) { +- return VideoFrameLayout::CreateWithPlanes( +- video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes), +- buffer_alignment); ++ if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) ++ return VideoFrameLayout::CreateWithPlanes( ++ video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes), ++ buffer_alignment); ++ else ++ return VideoFrameLayout::CreateWithPlanes( ++ video_format, gfx::Size(pix.width, pix.height), std::move(planes), ++ buffer_alignment); + } else { +- return VideoFrameLayout::CreateMultiPlanar( +- video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes), +- buffer_alignment); ++ if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) ++ return VideoFrameLayout::CreateMultiPlanar( ++ video_format, gfx::Size(pix_mp.width, pix_mp.height), std::move(planes), ++ buffer_alignment); ++ else ++ return VideoFrameLayout::CreateMultiPlanar( ++ video_format, gfx::Size(pix.width, pix.height), std::move(planes), ++ buffer_alignment); + } + } + +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0107-V4L2VDA-Add-function-IsMultiQueue-for-S_FMT-and-G_FM.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0107-V4L2VDA-Add-function-IsMultiQueue-for-S_FMT-and-G_FM.patch new file mode 100644 index 00000000..2e9b4431 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0107-V4L2VDA-Add-function-IsMultiQueue-for-S_FMT-and-G_FM.patch @@ -0,0 +1,183 @@ +From 3c9a3ef7f2c45386486a86bdbfa6c355f4c8da05 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Sun, 4 Sep 2022 15:48:00 +0800 +Subject: [PATCH 07/17] V4L2VDA: Add function IsMultiQueue for S_FMT and G_FMT + +Function IsMultiQueue() is used to set correct fotmat type for +8M and 8Q. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_device.cc | 36 +++++++++++--- + media/gpu/v4l2/v4l2_device.h | 1 + + .../gpu/v4l2/v4l2_video_decode_accelerator.cc | 49 +++++++++++++++---- + 3 files changed, 68 insertions(+), 18 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index a9462c9a2fb2d..200b0fccb1232 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -58,11 +58,18 @@ struct v4l2_format BuildV4L2Format(const enum v4l2_buf_type type, + struct v4l2_format format; + memset(&format, 0, sizeof(format)); + format.type = type; +- format.fmt.pix_mp.pixelformat = fourcc; +- format.fmt.pix_mp.width = size.width(); +- format.fmt.pix_mp.height = size.height(); +- format.fmt.pix_mp.num_planes = V4L2Device::GetNumPlanesOfV4L2PixFmt(fourcc); +- format.fmt.pix_mp.plane_fmt[0].sizeimage = buffer_size; ++ if (V4L2_TYPE_IS_MULTIPLANAR(type)) { ++ format.fmt.pix_mp.pixelformat = fourcc; ++ format.fmt.pix_mp.width = size.width(); ++ format.fmt.pix_mp.height = size.height(); ++ format.fmt.pix_mp.num_planes = V4L2Device::GetNumPlanesOfV4L2PixFmt(fourcc); ++ format.fmt.pix_mp.plane_fmt[0].sizeimage = buffer_size; ++ } else { ++ format.fmt.pix.pixelformat = fourcc; ++ format.fmt.pix.width = size.width(); ++ format.fmt.pix.height = size.height(); ++ format.fmt.pix.sizeimage = buffer_size; ++ } + + return format; + } +@@ -476,9 +483,13 @@ V4L2BufferRefBase::V4L2BufferRefBase(const struct v4l2_buffer& v4l2_buffer, + DCHECK(return_to_); + + memcpy(&v4l2_buffer_, &v4l2_buffer, sizeof(v4l2_buffer_)); +- memcpy(v4l2_planes_, v4l2_buffer.m.planes, +- sizeof(struct v4l2_plane) * v4l2_buffer.length); +- v4l2_buffer_.m.planes = v4l2_planes_; ++ if (V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer.type)) { ++ memcpy(v4l2_planes_, v4l2_buffer.m.planes, ++ sizeof(struct v4l2_plane) * v4l2_buffer.length); ++ v4l2_buffer_.m.planes = v4l2_planes_; ++ } else { ++ memcpy(&v4l2_planes_[0].m, &v4l2_buffer.m, sizeof(v4l2_buffer.m)); ++ } + } + + V4L2BufferRefBase::~V4L2BufferRefBase() { +@@ -1434,6 +1445,15 @@ bool V4L2Queue::Streamoff() { + return true; + } + ++bool V4L2Queue::IsMultiQueue() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); ++ ++ if (type_ == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE || type_ == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) ++ return true; ++ else ++ return false; ++} ++ + size_t V4L2Queue::AllocatedBuffersCount() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + +diff --git a/media/gpu/v4l2/v4l2_device.h b/media/gpu/v4l2/v4l2_device.h +index 70f47ae91b648..86ef80fd09579 100644 +--- a/media/gpu/v4l2/v4l2_device.h ++++ b/media/gpu/v4l2/v4l2_device.h +@@ -424,6 +424,7 @@ class MEDIA_GPU_EXPORT V4L2Queue + // still be using them. + bool Streamoff(); + ++ bool IsMultiQueue(); + // Returns the number of buffers currently allocated for this queue. + size_t AllocatedBuffersCount() const; + // Returns the number of currently free buffers on this queue. +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index 631e68e0f9314..54c72c6148d94 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -2153,12 +2153,30 @@ bool V4L2VideoDecodeAccelerator::GetFormatInfo(struct v4l2_format* format, + } + + // Make sure we are still getting the format we set on initialization. +- if (format->fmt.pix_mp.pixelformat != output_format_fourcc_->ToV4L2PixFmt()) { ++ unsigned int pixelformat = V4L2_TYPE_IS_MULTIPLANAR(format->type) ? ++ format->fmt.pix_mp.pixelformat : format->fmt.pix.pixelformat; ++ if (pixelformat != output_format_fourcc_->ToV4L2PixFmt()) { + VLOGF(1) << "Unexpected format from G_FMT on output"; + return false; + } + +- gfx::Size coded_size(format->fmt.pix_mp.width, format->fmt.pix_mp.height); ++ int width, height; ++ if (V4L2_TYPE_IS_MULTIPLANAR(format->type)) { ++ width = format->fmt.pix_mp.width; ++ height = format->fmt.pix_mp.height; ++ if ((format->fmt.pix_mp.width == 0) && (format->fmt.pix_mp.height == 0)) ++ { ++ *again = true; ++ VLOG(1)<<"As got width=height=0 again"; ++ } else { ++ VLOG(1)<<"format wxh" << format->fmt.pix_mp.width << "x" << format->fmt.pix_mp.height; ++ } ++ } else { ++ width = format->fmt.pix.width; ++ height = format->fmt.pix.height; ++ } ++ ++ gfx::Size coded_size(width, height); + if (visible_size != nullptr) + *visible_size = GetVisibleSize(coded_size); + +@@ -2263,7 +2281,7 @@ bool V4L2VideoDecodeAccelerator::SetupFormats() { + + struct v4l2_fmtdesc fmtdesc; + memset(&fmtdesc, 0, sizeof(fmtdesc)); +- fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ fmtdesc.type = input_queue_->IsMultiQueue() ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT; + bool is_format_supported = false; + while (device_->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0) { + if (fmtdesc.pixelformat == input_format_fourcc_) { +@@ -2281,10 +2299,16 @@ bool V4L2VideoDecodeAccelerator::SetupFormats() { + + struct v4l2_format format; + memset(&format, 0, sizeof(format)); +- format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; +- format.fmt.pix_mp.pixelformat = input_format_fourcc_; +- format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; +- format.fmt.pix_mp.num_planes = 1; ++ if (input_queue_->IsMultiQueue()) { ++ format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ format.fmt.pix_mp.pixelformat = input_format_fourcc_; ++ format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; ++ format.fmt.pix_mp.num_planes = 1; ++ } else { ++ format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; ++ format.fmt.pix.pixelformat = input_format_fourcc_; ++ format.fmt.pix.sizeimage = input_size; ++ } + IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format); + DCHECK_EQ(format.fmt.pix_mp.pixelformat, input_format_fourcc_); + +@@ -2292,7 +2316,7 @@ bool V4L2VideoDecodeAccelerator::SetupFormats() { + // changing it once we start streaming; whether it can support our chosen + // output format or not may depend on the input format. + memset(&fmtdesc, 0, sizeof(fmtdesc)); +- fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ fmtdesc.type = output_queue_->IsMultiQueue() ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : V4L2_BUF_TYPE_VIDEO_CAPTURE; + while (device_->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0) { + auto fourcc = Fourcc::FromV4L2PixFmt(fmtdesc.pixelformat); + if (fourcc && device_->CanCreateEGLImageFrom(*fourcc)) { +@@ -2334,8 +2358,13 @@ bool V4L2VideoDecodeAccelerator::SetupFormats() { + // Just set the fourcc for output; resolution, etc., will come from the + // driver once it extracts it from the stream. + memset(&format, 0, sizeof(format)); +- format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; +- format.fmt.pix_mp.pixelformat = output_format_fourcc_->ToV4L2PixFmt(); ++ if (output_queue_->IsMultiQueue()) { ++ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ format.fmt.pix_mp.pixelformat = output_format_fourcc_->ToV4L2PixFmt(); ++ } else { ++ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ format.fmt.pix.pixelformat = output_format_fourcc_->ToV4L2PixFmt(); ++ } + IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format); + DCHECK_EQ(format.fmt.pix_mp.pixelformat, + output_format_fourcc_->ToV4L2PixFmt()); +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0108-V4L2VDA-Use-correct-size-to-allocate-CAPTURE-buffer.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0108-V4L2VDA-Use-correct-size-to-allocate-CAPTURE-buffer.patch new file mode 100644 index 00000000..d10e7046 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0108-V4L2VDA-Use-correct-size-to-allocate-CAPTURE-buffer.patch @@ -0,0 +1,43 @@ +From cd2caf4313d91197092dce6262a6f4b325501c04 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Sun, 4 Sep 2022 20:19:05 +0800 +Subject: [PATCH 08/17] V4L2VDA: Use correct size to allocate CAPTURE buffer + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_video_decode_accelerator.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index 54c72c6148d94..018fe8c25f506 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -2189,7 +2189,10 @@ bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat( + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); + size_t egl_image_planes_count; + +- coded_size_.SetSize(format.fmt.pix_mp.width, format.fmt.pix_mp.height); ++ if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) ++ coded_size_.SetSize(format.fmt.pix_mp.width, format.fmt.pix_mp.height); ++ else ++ coded_size_.SetSize(format.fmt.pix.width, format.fmt.pix.height); + visible_size_ = visible_size; + egl_image_size_ = coded_size_; + if (image_processor_device_) { +@@ -2207,11 +2210,11 @@ bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat( + // In practice, this applies to all Image Processors, i.e. Mediatek devices. + DCHECK_EQ(coded_size_, output_size); + } else { +- egl_image_planes_count = format.fmt.pix_mp.num_planes; ++ egl_image_planes_count = V4L2_TYPE_IS_MULTIPLANAR(format.type) ? format.fmt.pix_mp.num_planes : 1; + } + VLOGF(2) << "new resolution: " << coded_size_.ToString() + << ", visible size: " << visible_size_.ToString() +- << ", decoder output planes count: " << format.fmt.pix_mp.num_planes ++ << ", decoder output planes count: " << egl_image_planes_count + << ", EGLImage size: " << egl_image_size_.ToString() + << ", EGLImage plane count: " << egl_image_planes_count; + +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0109-V4L2VDA-Use-correct-plane-size-and-bytesused.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0109-V4L2VDA-Use-correct-plane-size-and-bytesused.patch new file mode 100644 index 00000000..53a1a973 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0109-V4L2VDA-Use-correct-plane-size-and-bytesused.patch @@ -0,0 +1,65 @@ +From 0fa8f2fb83398d48f54c3462b0d1626037e0ee73 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Sun, 4 Sep 2022 20:30:31 +0800 +Subject: [PATCH 09/17] V4L2VDA: Use correct plane size and bytesused + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_device.cc | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 200b0fccb1232..726ad1ab0f144 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -785,7 +785,10 @@ size_t V4L2WritableBufferRef::GetPlaneSize(const size_t plane) const { + return 0; + } + +- return buffer_data_->v4l2_buffer_.m.planes[plane].length; ++ if (V4L2_TYPE_IS_MULTIPLANAR(buffer_data_->v4l2_buffer_.type)) ++ return buffer_data_->v4l2_buffer_.m.planes[plane].length; ++ else ++ return buffer_data_->v4l2_buffer_.length; + } + + void V4L2WritableBufferRef::SetPlaneSize(const size_t plane, +@@ -845,7 +848,10 @@ void V4L2WritableBufferRef::SetPlaneBytesUsed(const size_t plane, + return; + } + +- buffer_data_->v4l2_buffer_.m.planes[plane].bytesused = bytes_used; ++ if (V4L2_TYPE_IS_MULTIPLANAR(buffer_data_->v4l2_buffer_.type)) ++ buffer_data_->v4l2_buffer_.m.planes[plane].bytesused = bytes_used; ++ else ++ buffer_data_->v4l2_buffer_.bytesused = bytes_used; + } + + size_t V4L2WritableBufferRef::GetPlaneBytesUsed(const size_t plane) const { +@@ -857,7 +863,10 @@ size_t V4L2WritableBufferRef::GetPlaneBytesUsed(const size_t plane) const { + return 0; + } + +- return buffer_data_->v4l2_buffer_.m.planes[plane].bytesused; ++ if (V4L2_TYPE_IS_MULTIPLANAR(buffer_data_->v4l2_buffer_.type)) ++ return buffer_data_->v4l2_buffer_.m.planes[plane].bytesused; ++ else ++ return buffer_data_->v4l2_buffer_.bytesused; + } + + void V4L2WritableBufferRef::SetPlaneDataOffset(const size_t plane, +@@ -959,7 +968,10 @@ size_t V4L2ReadableBuffer::GetPlaneBytesUsed(const size_t plane) const { + return 0; + } + +- return buffer_data_->v4l2_planes_[plane].bytesused; ++ if (V4L2_TYPE_IS_MULTIPLANAR(buffer_data_->v4l2_buffer_.type)) ++ return buffer_data_->v4l2_planes_[plane].bytesused; ++ else ++ return buffer_data_->v4l2_buffer_.bytesused; + } + + size_t V4L2ReadableBuffer::GetPlaneDataOffset(const size_t plane) const { +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0110-V4L2VDA-Add-hevc-format-support.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0110-V4L2VDA-Add-hevc-format-support.patch new file mode 100644 index 00000000..aa4f1648 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0110-V4L2VDA-Add-hevc-format-support.patch @@ -0,0 +1,313 @@ +From e86109fa5e05268acc3557d308e5ae12136b391a Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Mon, 5 Sep 2022 10:38:53 +0800 +Subject: [PATCH 10/17] V4L2VDA: Add hevc format support + +Upstream-Status: Inappropriate [NXP specific] +--- + media/base/supported_types.cc | 2 +- + media/gpu/v4l2/v4l2_device.cc | 28 ++++- + media/gpu/v4l2/v4l2_vda_helpers.cc | 119 ++++++++++++++++++ + media/gpu/v4l2/v4l2_vda_helpers.h | 20 +++ + .../gpu/v4l2/v4l2_video_decode_accelerator.cc | 2 +- + media/media_options.gni | 4 +- + 6 files changed, 170 insertions(+), 5 deletions(-) + +diff --git a/media/base/supported_types.cc b/media/base/supported_types.cc +index 3e174b9320d08..727dc1867e6ff 100644 +--- a/media/base/supported_types.cc ++++ b/media/base/supported_types.cc +@@ -318,7 +318,7 @@ bool IsDefaultSupportedVideoType(const VideoType& type) { + case VideoCodec::kVP9: + return IsVp9ProfileSupported(type); + case VideoCodec::kHEVC: +- return IsHevcProfileSupported(type); ++ return true; + case VideoCodec::kMPEG4: + return IsMPEG4Supported(); + case VideoCodec::kUnknown: +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 726ad1ab0f144..e090cad6626f7 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -1607,6 +1607,8 @@ uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile, + return V4L2_PIX_FMT_VP8; + } else if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX) { + return V4L2_PIX_FMT_VP9; ++ } else if (profile >= HEVCPROFILE_MIN && profile <= HEVCPROFILE_MAX) { ++ return V4L2_PIX_FMT_HEVC; + } else if (profile == HEVCPROFILE_MAIN) { + return V4L2_PIX_FMT_HEVC; + } else { +@@ -1674,6 +1676,16 @@ VideoCodecProfile V4L2ProfileToVideoCodecProfile(VideoCodec codec, + return VP9PROFILE_PROFILE2; + } + break; ++ case VideoCodec::kHEVC: ++ switch (v4l2_profile) { ++ case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN: ++ return HEVCPROFILE_MAIN; ++ case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10: ++ return HEVCPROFILE_MAIN10; ++ case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE: ++ return HEVCPROFILE_MAIN_STILL_PICTURE; ++ } ++ break; + default: + VLOGF(2) << "Unsupported codec: " << GetCodecName(codec); + } +@@ -1699,6 +1711,9 @@ std::vector V4L2Device::V4L2PixFmtToVideoCodecProfiles( + case VideoCodec::kVP9: + query_id = V4L2_CID_MPEG_VIDEO_VP9_PROFILE; + break; ++ case VideoCodec::kHEVC: ++ query_id = V4L2_CID_MPEG_VIDEO_HEVC_PROFILE; ++ break; + default: + return false; + } +@@ -1757,6 +1772,17 @@ std::vector V4L2Device::V4L2PixFmtToVideoCodecProfiles( + profiles = {VP9PROFILE_PROFILE0}; + } + break; ++ case V4L2_PIX_FMT_HEVC: ++ if (!get_supported_profiles(VideoCodec::kHEVC, &profiles)) { ++ DLOG(WARNING) << "Driver doesn't support QUERY HEVC profiles, " ++ << "use default values, main, mian-10, main-still-picture"; ++ profiles = { ++ HEVCPROFILE_MAIN, ++ HEVCPROFILE_MAIN10, ++ HEVCPROFILE_MAIN_STILL_PICTURE, ++ }; ++ } ++ break; + default: + VLOGF(1) << "Unhandled pixelformat " << FourccToString(pix_fmt); + return {}; +@@ -2091,7 +2117,7 @@ void V4L2Device::GetSupportedResolution(uint32_t pixelformat, + } + } + if (max_resolution->IsEmpty()) { +- max_resolution->SetSize(1920, 1088); ++ max_resolution->SetSize(4096, 4096); + VLOGF(1) << "GetSupportedResolution failed to get maximum resolution for " + << "fourcc " << FourccToString(pixelformat) << ", fall back to " + << max_resolution->ToString(); +diff --git a/media/gpu/v4l2/v4l2_vda_helpers.cc b/media/gpu/v4l2/v4l2_vda_helpers.cc +index f25619077035c..5fa8593a5cf1e 100644 +--- a/media/gpu/v4l2/v4l2_vda_helpers.cc ++++ b/media/gpu/v4l2/v4l2_vda_helpers.cc +@@ -12,6 +12,7 @@ + #include "media/gpu/v4l2/v4l2_device.h" + #include "media/gpu/v4l2/v4l2_image_processor_backend.h" + #include "media/video/h264_parser.h" ++#include "media/video/h265_parser.h" + + namespace media { + namespace v4l2_vda_helpers { +@@ -155,6 +156,9 @@ InputBufferFragmentSplitter::CreateFromProfile( + case VideoCodec::kVP9: + // VP8/VP9 don't need any frame splitting, use the default implementation. + return std::make_unique(); ++ case VideoCodec::kHEVC: ++ return std::make_unique< ++ v4l2_vda_helpers::H265InputBufferFragmentSplitter>(); + default: + LOG(ERROR) << "Unhandled profile: " << profile; + return nullptr; +@@ -274,5 +278,120 @@ bool H264InputBufferFragmentSplitter::IsPartialFramePending() const { + return partial_frame_pending_; + } + ++H265InputBufferFragmentSplitter::H265InputBufferFragmentSplitter() ++ : h265_parser_(new H265Parser()) {} ++ ++H265InputBufferFragmentSplitter::~H265InputBufferFragmentSplitter() = default; ++ ++bool H265InputBufferFragmentSplitter::AdvanceFrameFragment(const uint8_t* data, ++ size_t size, ++ size_t* endpos) { ++ DCHECK(h265_parser_); ++ ++ // For H265, we need to feed HW one frame at a time. This is going to take ++ // some parsing of our input stream. ++ h265_parser_->SetStream(data, size); ++ H265NALU nalu; ++ H265Parser::Result result; ++ bool has_frame_data = false; ++ *endpos = 0; ++ DVLOGF(4) << "H265InputBufferFragmentSplitter::AdvanceFrameFragment size" << size; ++ // Keep on peeking the next NALs while they don't indicate a frame ++ // boundary. ++ while (true) { ++ bool end_of_frame = false; ++ result = h265_parser_->AdvanceToNextNALU(&nalu); ++ if (result == H265Parser::kInvalidStream || ++ result == H265Parser::kUnsupportedStream) { ++ return false; ++ } ++ ++ DVLOGF(4) << "NALU type " << nalu.nal_unit_type << "NALU size" << nalu.size; ++ if (result == H265Parser::kEOStream) { ++ // We've reached the end of the buffer before finding a frame boundary. ++ if (has_frame_data){ ++ // partial_frame_pending_ = true; ++ // DVLOGF(4)<<"partial_frame_pending_ true as H265Parser::kEOStream has_frame_data"; ++ } ++ *endpos = size; ++ DVLOGF(4)<< " MET kEOStream endpos " << *endpos <<" nalu.size " << nalu.size; ++ return true; ++ } ++ switch (nalu.nal_unit_type) { ++ case H265NALU::TRAIL_N: ++ case H265NALU::TRAIL_R: ++ case H265NALU::TSA_N: ++ case H265NALU::TSA_R: ++ case H265NALU::STSA_N: ++ case H265NALU::STSA_R: ++ case H265NALU::RADL_R: ++ case H265NALU::RADL_N: ++ case H265NALU::RASL_N: ++ case H265NALU::RASL_R: ++ case H265NALU::BLA_W_LP: ++ case H265NALU::BLA_W_RADL: ++ case H265NALU::BLA_N_LP: ++ case H265NALU::IDR_W_RADL: ++ case H265NALU::IDR_N_LP: ++ case H265NALU::CRA_NUT: ++ if (nalu.size < 1) ++ return false; ++ ++ has_frame_data = true; ++ ++ // For these two, if the "first_mb_in_slice" field is zero, start a ++ // new frame and return. This field is Exp-Golomb coded starting on ++ // the eighth data bit of the NAL; a zero value is encoded with a ++ // leading '1' bit in the byte, which we can detect as the byte being ++ // (unsigned) greater than or equal to 0x80. ++ if (nalu.data[1] >= 0x80) { ++ end_of_frame = true; ++ break; ++ } ++ break; ++ case H265NALU::VPS_NUT: ++ case H265NALU::SPS_NUT: ++ case H265NALU::PPS_NUT: ++ case H265NALU::AUD_NUT: ++ case H265NALU::EOS_NUT: ++ case H265NALU::EOB_NUT: ++ case H265NALU::FD_NUT: ++ case H265NALU::PREFIX_SEI_NUT: ++ case H265NALU::SUFFIX_SEI_NUT: ++ // These unconditionally signal a frame boundary. ++ end_of_frame = true; ++ break; ++ default: ++ // For all others, keep going. ++ break; ++ } ++ if (end_of_frame) { ++ if (!partial_frame_pending_ && *endpos == 0) { ++ // The frame was previously restarted, and we haven't filled the ++ // current frame with any contents yet. Start the new frame here and ++ // continue parsing NALs. ++ } else { ++ // The frame wasn't previously restarted and/or we have contents for ++ // the current frame; signal the start of a new frame here: we don't ++ // have a partial frame anymore. ++ partial_frame_pending_ = false; ++ // return true; ++ } ++ } ++ *endpos = (nalu.data + nalu.size) - data; ++ } ++ NOTREACHED(); ++ return false; ++} ++ ++void H265InputBufferFragmentSplitter::Reset() { ++ partial_frame_pending_ = false; ++ h265_parser_.reset(new H265Parser()); ++} ++ ++bool H265InputBufferFragmentSplitter::IsPartialFramePending() const { ++ return partial_frame_pending_; ++} ++ + } // namespace v4l2_vda_helpers + } // namespace media +diff --git a/media/gpu/v4l2/v4l2_vda_helpers.h b/media/gpu/v4l2/v4l2_vda_helpers.h +index ebd07cf7e5b37..4b7fbd2985473 100644 +--- a/media/gpu/v4l2/v4l2_vda_helpers.h ++++ b/media/gpu/v4l2/v4l2_vda_helpers.h +@@ -18,6 +18,7 @@ namespace media { + + class V4L2Device; + class H264Parser; ++class H265Parser; + + // Helper static methods to be shared between V4L2VideoDecodeAccelerator and + // V4L2SliceVideoDecodeAccelerator. This avoids some code duplication between +@@ -115,6 +116,25 @@ class H264InputBufferFragmentSplitter : public InputBufferFragmentSplitter { + bool partial_frame_pending_ = false; + }; + ++class H265InputBufferFragmentSplitter : public InputBufferFragmentSplitter { ++ public: ++ explicit H265InputBufferFragmentSplitter(); ++ ~H265InputBufferFragmentSplitter() override; ++ ++ bool AdvanceFrameFragment(const uint8_t* data, ++ size_t size, ++ size_t* endpos) override; ++ void Reset() override; ++ bool IsPartialFramePending() const override; ++ ++ private: ++ // For H264 decode, hardware requires that we send it frame-sized chunks. ++ // We'll need to parse the stream. ++ std::unique_ptr h265_parser_; ++ // Set if we have a pending incomplete frame in the input buffer. ++ bool partial_frame_pending_ = false; ++}; ++ + } // namespace v4l2_vda_helpers + } // namespace media + +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index 018fe8c25f506..c00cd2b5f6ad7 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -84,7 +84,7 @@ bool IsVp9KSVCStream(uint32_t input_format_fourcc, + + // static + const uint32_t V4L2VideoDecodeAccelerator::supported_input_fourccs_[] = { +- V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9, ++ V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9, V4L2_PIX_FMT_HEVC, + }; + + // static +diff --git a/media/media_options.gni b/media/media_options.gni +index 1b2af27c5079d..0da73f1f81407 100644 +--- a/media/media_options.gni ++++ b/media/media_options.gni +@@ -92,14 +92,14 @@ declare_args() { + # video on ChromeOS and Windows. + enable_platform_hevc = + proprietary_codecs && +- (is_chromecast || use_fuzzing_engine || enable_platform_encrypted_hevc) ++ (is_chromecast || use_fuzzing_engine || enable_platform_encrypted_hevc || use_v4l2_codec) + + # Enable HEVC/H265 decoding with hardware acceleration assist. Enabled by + # default for fuzzer builds and protected video on ChromeOS. It is also + # enabled for Chromecast by default so the unit tests get run in Chrome CQ. + enable_platform_hevc_decoding = + proprietary_codecs && +- (is_chromecast || use_fuzzing_engine || use_chromeos_protected_media) ++ (is_chromecast || use_fuzzing_engine || use_chromeos_protected_media || use_v4l2_codec) + } + + assert( +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0111-V4L2VDA-fix-vp9-crash-caused-by-DequeueResolutionCha.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0111-V4L2VDA-fix-vp9-crash-caused-by-DequeueResolutionCha.patch new file mode 100644 index 00000000..bf78e1fe --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0111-V4L2VDA-fix-vp9-crash-caused-by-DequeueResolutionCha.patch @@ -0,0 +1,31 @@ +From 46217b35c7ec0a84175882acb4e8c363975d5701 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Thu, 18 Aug 2022 12:20:33 +0800 +Subject: [PATCH 11/17] V4L2VDA: fix vp9 crash caused by + DequeueResolutionChangeEvent + +Handle source change event only when decoder receives driver reported +source change event. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_video_decode_accelerator.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index c00cd2b5f6ad7..ff543f6865802 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -1247,8 +1247,7 @@ void V4L2VideoDecodeAccelerator::ServiceDeviceTask(bool event_pending) { + gfx::Size visible_size; + bool again; + if (GetFormatInfo(&format, &visible_size, &again) && !again) { +- resolution_change_pending = true; +- DequeueResolutionChangeEvent(); ++ resolution_change_pending = DequeueResolutionChangeEvent(); + } + } + +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0112-V4L2VDA-Add-fps-in-SkiaOutputSurfaceImplOnGpu-by-VLO.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0112-V4L2VDA-Add-fps-in-SkiaOutputSurfaceImplOnGpu-by-VLO.patch new file mode 100644 index 00000000..78be7a25 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0112-V4L2VDA-Add-fps-in-SkiaOutputSurfaceImplOnGpu-by-VLO.patch @@ -0,0 +1,88 @@ +From a49818e6727dc3ec25e438b032b761e668542886 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Thu, 18 Aug 2022 12:22:20 +0800 +Subject: [PATCH 12/17] V4L2VDA: Add fps in SkiaOutputSurfaceImplOnGpu by + VLOG(1) + +Upstream-Status: Inappropriate [NXP specific] +--- + .../skia_output_surface_impl_on_gpu.cc | 18 ++++++++++++++++++ + .../skia_output_surface_impl_on_gpu.h | 1 + + 2 files changed, 19 insertions(+) + +diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc +index 946f4f40aaa08..8a05a8c41bd05 100644 +--- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc ++++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc +@@ -6,6 +6,7 @@ + + #include + #include ++#include + + #include "base/atomic_sequence_num.h" + #include "base/bind.h" +@@ -104,6 +105,15 @@ + #include "components/viz/service/display_embedder/output_presenter_fuchsia.h" + #endif + ++static uint64_t start_time = 0; ++static uint64_t stop_time = 0; ++ ++uint64_t NowMicros() { ++ struct timeval tv; ++ gettimeofday(&tv, nullptr); ++ return static_cast(tv.tv_sec) * 1e6 + tv.tv_usec; ++} ++ + namespace viz { + + namespace { +@@ -320,6 +330,7 @@ SkiaOutputSurfaceImplOnGpu::SkiaOutputSurfaceImplOnGpu( + async_read_result_lock_(base::MakeRefCounted()) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + ++ swap_buffers_number_ = 0; + weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); + buffer_presented_callback_ = CreateSafeRepeatingCallback( + weak_ptr_, std::move(buffer_presented_callback)); +@@ -500,10 +511,16 @@ void SkiaOutputSurfaceImplOnGpu::SwapBuffers(OutputSurfaceFrame frame, + TRACE_EVENT0("viz", "SkiaOutputSurfaceImplOnGpu::SwapBuffers"); + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + ++ if ( swap_buffers_number_ == 0) ++ start_time = NowMicros(); + if (release_frame_buffer) + output_device_->ReleaseOneFrameBuffer(); + ++ swap_buffers_number_++; ++ stop_time = NowMicros(); ++ + SwapBuffersInternal(std::move(frame)); ++ VLOG(1) << "total showed " << swap_buffers_number_ << " frames, total time " << (stop_time - start_time) << " ms, fps is " << swap_buffers_number_*1e6/(stop_time - start_time) << std::endl; + } + + void SkiaOutputSurfaceImplOnGpu::AllocateFrameBuffers(size_t n) { +@@ -1525,6 +1542,7 @@ bool SkiaOutputSurfaceImplOnGpu::Initialize() { + if (context_state_) + context_state_->AddContextLostObserver(this); + ++ start_time = NowMicros(); + return true; + } + +diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h +index febdaebbb740c..be1cedf2babc9 100644 +--- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h ++++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h +@@ -423,6 +423,7 @@ class SkiaOutputSurfaceImplOnGpu + BufferPresentedCallback buffer_presented_callback_; + ContextLostCallback context_lost_callback_; + GpuVSyncCallback gpu_vsync_callback_; ++ size_t swap_buffers_number_; + + // ImplOnGpu::CopyOutput can create SharedImages via ImplOnGpu's + // SharedImageFactory. Clients can use these images via CopyOutputResult and +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0113-V4L2VDA-Comment-some-unused-ioctl.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0113-V4L2VDA-Comment-some-unused-ioctl.patch new file mode 100644 index 00000000..d587b835 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0113-V4L2VDA-Comment-some-unused-ioctl.patch @@ -0,0 +1,108 @@ +From 1cae59ad534e9f10f27de3d92e828be5968f1632 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Mon, 5 Sep 2022 12:11:36 +0800 +Subject: [PATCH 13/17] V4L2VDA: Comment some unused ioctl + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_device.cc | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index e090cad6626f7..5a1057c845e85 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -1041,10 +1041,12 @@ V4L2Queue::V4L2Queue(scoped_refptr dev, + return; + } + ++#if !BUILDFLAG(USE_LINUX_V4L2) + if (reqbufs.capabilities & V4L2_BUF_CAP_SUPPORTS_REQUESTS) { + supports_requests_ = true; + DVLOGF(4) << "Queue supports request API."; + } ++#endif + } + + V4L2Queue::~V4L2Queue() { +@@ -2482,10 +2484,14 @@ bool V4L2Request::ApplyCtrls(struct v4l2_ext_controls* ctrls) { + return false; + } + ++#if !BUILDFLAG(USE_LINUX_V4L2) + ctrls->which = V4L2_CTRL_WHICH_REQUEST_VAL; + ctrls->request_fd = request_fd_.get(); + + return true; ++#else ++ return false; ++#endif + } + + bool V4L2Request::ApplyQueueBuffer(struct v4l2_buffer* buffer) { +@@ -2497,10 +2503,14 @@ bool V4L2Request::ApplyQueueBuffer(struct v4l2_buffer* buffer) { + return false; + } + ++#if !BUILDFLAG(USE_LINUX_V4L2) + buffer->flags |= V4L2_BUF_FLAG_REQUEST_FD; + buffer->request_fd = request_fd_.get(); + + return true; ++#else ++ return false; ++#endif + } + + bool V4L2Request::Submit() { +@@ -2511,7 +2521,11 @@ bool V4L2Request::Submit() { + return false; + } + ++#if !BUILDFLAG(USE_LINUX_V4L2) + return HANDLE_EINTR(ioctl(request_fd_.get(), MEDIA_REQUEST_IOC_QUEUE)) == 0; ++#else ++ return false; ++#endif + } + + bool V4L2Request::IsCompleted() { +@@ -2554,6 +2568,7 @@ bool V4L2Request::Reset() { + return false; + } + ++#if !BUILDFLAG(USE_LINUX_V4L2) + // Reinit the request to make sure we can use it for a new submission. + if (HANDLE_EINTR(ioctl(request_fd_.get(), MEDIA_REQUEST_IOC_REINIT)) < 0) { + VPLOGF(1) << "Failed to reinit request."; +@@ -2561,6 +2576,9 @@ bool V4L2Request::Reset() { + } + + return true; ++#else ++ return false; ++#endif + } + + V4L2RequestRefBase::V4L2RequestRefBase(V4L2RequestRefBase&& req_base) { +@@ -2635,6 +2653,7 @@ V4L2RequestsQueue::~V4L2RequestsQueue() { + absl::optional V4L2RequestsQueue::CreateRequestFD() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + ++#if !BUILDFLAG(USE_LINUX_V4L2) + int request_fd; + int ret = HANDLE_EINTR( + ioctl(media_fd_.get(), MEDIA_IOC_REQUEST_ALLOC, &request_fd)); +@@ -2644,6 +2663,9 @@ absl::optional V4L2RequestsQueue::CreateRequestFD() { + } + + return base::ScopedFD(request_fd); ++#else ++ return absl::nullopt; ++#endif + } + + absl::optional V4L2RequestsQueue::GetFreeRequest() { +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0114-V4L2VDA-Set-OUTPUT-format-with-parsed-resolution-for.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0114-V4L2VDA-Set-OUTPUT-format-with-parsed-resolution-for.patch new file mode 100644 index 00000000..6bde73d6 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0114-V4L2VDA-Set-OUTPUT-format-with-parsed-resolution-for.patch @@ -0,0 +1,76 @@ +From b37891b75a53061ce6bdaaab926c2b630f6c1a61 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Mon, 5 Sep 2022 12:23:04 +0800 +Subject: [PATCH 14/17] V4L2VDA: Set OUTPUT format with parsed resolution for + amphion + +For VP8, VC1l, rv, Amphion needs to set correct resolution for OUTPUT +queue as it will be added to amphion customized header. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_video_decode_accelerator.cc | 13 +++++++++++-- + media/gpu/v4l2/v4l2_video_decode_accelerator.h | 2 +- + 2 files changed, 12 insertions(+), 3 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index ff543f6865802..fba38c4021855 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -320,6 +320,9 @@ bool V4L2VideoDecodeAccelerator::CheckConfig(const Config& config) { + return false; + } + ++ int width, height; ++ height = config.initial_expected_coded_size.height(); ++ width = config.initial_expected_coded_size.width(); + // Capabilities check. + struct v4l2_capability caps; + unsigned int device_caps; +@@ -357,7 +360,7 @@ bool V4L2VideoDecodeAccelerator::CheckConfig(const Config& config) { + if (!output_queue_) + return false; + +- if (!SetupFormats()) ++ if (!SetupFormats(width, height)) + return false; + + // We have confirmed that |config| is supported, tell the good news to the +@@ -2266,7 +2269,7 @@ bool V4L2VideoDecodeAccelerator::CreateInputBuffers() { + return true; + } + +-bool V4L2VideoDecodeAccelerator::SetupFormats() { ++bool V4L2VideoDecodeAccelerator::SetupFormats(int width, int height) { + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); + DCHECK_EQ(decoder_state_, kInitialized); + DCHECK(!input_queue_->IsStreaming()); +@@ -2306,6 +2309,12 @@ bool V4L2VideoDecodeAccelerator::SetupFormats() { + format.fmt.pix_mp.pixelformat = input_format_fourcc_; + format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; + format.fmt.pix_mp.num_planes = 1; ++ // For VP8, VC1l, rv, Amphion needs to set correct resolution for ++ // OUTPUT queue as it will be added to amphion customized header. ++ if(V4L2_PIX_FMT_VP8 == input_format_fourcc_){ ++ format.fmt.pix_mp.width = width; ++ format.fmt.pix_mp.height = height; ++ } + } else { + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + format.fmt.pix.pixelformat = input_format_fourcc_; +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.h b/media/gpu/v4l2/v4l2_video_decode_accelerator.h +index 163907129a095..d16ee5857785b 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.h ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.h +@@ -395,7 +395,7 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator + bool DestroyOutputBuffers(); + + // Set input and output formats before starting decode. +- bool SetupFormats(); ++ bool SetupFormats(int, int); + // Reset image processor and drop all processing frames. + bool ResetImageProcessor(); + +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0115-V4L2VDA-Add-V4L2_PIX_FMT_NV12M_8L128-format-for-amph.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0115-V4L2VDA-Add-V4L2_PIX_FMT_NV12M_8L128-format-for-amph.patch new file mode 100644 index 00000000..e9afc8e6 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0115-V4L2VDA-Add-V4L2_PIX_FMT_NV12M_8L128-format-for-amph.patch @@ -0,0 +1,101 @@ +From 4a3c50348edb021d0529d350aabcd78cc0c75164 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Fri, 9 Sep 2022 10:06:51 +0800 +Subject: [PATCH 15/17] V4L2VDA: Add V4L2_PIX_FMT_NV12M_8L128 format for + amphion + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/chromeos/fourcc.cc | 2 ++ + media/gpu/chromeos/fourcc.h | 4 ++++ + media/gpu/v4l2/generic_v4l2_device.cc | 4 ++++ + media/gpu/v4l2/v4l2_video_decode_accelerator.cc | 9 +++++++-- + 4 files changed, 17 insertions(+), 2 deletions(-) + +diff --git a/media/gpu/chromeos/fourcc.cc b/media/gpu/chromeos/fourcc.cc +index 80f392ebf5e41..e8239121d8e96 100644 +--- a/media/gpu/chromeos/fourcc.cc ++++ b/media/gpu/chromeos/fourcc.cc +@@ -26,6 +26,7 @@ absl::optional Fourcc::FromUint32(uint32_t fourcc) { + case YM12: + case YM21: + case YUYV: ++ case NA12: + case NV12: + case NV21: + case NM12: +@@ -149,6 +150,7 @@ VideoPixelFormat Fourcc::ToVideoPixelFormat() const { + return PIXEL_FORMAT_YUY2; + case NV12: + case NM12: ++ case NA12: + return PIXEL_FORMAT_NV12; + case NV21: + case NM21: +diff --git a/media/gpu/chromeos/fourcc.h b/media/gpu/chromeos/fourcc.h +index c4b233ac64562..27f1b679435b1 100644 +--- a/media/gpu/chromeos/fourcc.h ++++ b/media/gpu/chromeos/fourcc.h +@@ -68,6 +68,10 @@ class MEDIA_GPU_EXPORT Fourcc { + // Maps to PIXEL_FORMAT_NV21, V4L2_PIX_FMT_NV21M. + NM21 = ComposeFourcc('N', 'M', '2', '1'), + ++ // Tiled YUV formats, non contiguous planes. ++ // Maps to V4L2_PIX_FMT_NV12M_8L128. ++ NA12 = ComposeFourcc('N', 'A', '1', '2'), ++ + // YUV422 single-planar format. + // https://linuxtv.org/downloads/v4l-dvb-apis-new/userspace-api/v4l/pixfmt-yuv422p.html + // Maps to PIXEL_FORMAT_I422, V4L2_PIX_FMT_YUV422P. +diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc +index a578768f8d3b1..d7b57d180f7f7 100644 +--- a/media/gpu/v4l2/generic_v4l2_device.cc ++++ b/media/gpu/v4l2/generic_v4l2_device.cc +@@ -46,6 +46,9 @@ using media_gpu_v4l2::InitializeStubs; + using media_gpu_v4l2::StubPathMap; + #endif + ++/* Tiled YUV formats, non contiguous planes */ ++#define V4L2_PIX_FMT_NV12M_8L128 v4l2_fourcc('N', 'A', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */ ++ + namespace media { + + namespace { +@@ -54,6 +57,7 @@ uint32_t V4L2PixFmtToDrmFormat(uint32_t format) { + switch (format) { + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV12M: ++ case V4L2_PIX_FMT_NV12M_8L128: + return DRM_FORMAT_NV12; + + case V4L2_PIX_FMT_YUV420: +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +index fba38c4021855..a37efa9a708e8 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +@@ -1356,8 +1356,9 @@ void V4L2VideoDecodeAccelerator::Enqueue() { + // yet. Also, V4L2VDA calls STREAMOFF and STREAMON after resolution + // change. They implicitly send a V4L2_DEC_CMD_STOP and V4L2_DEC_CMD_START + // to the decoder. +- if (input_queue_->QueuedBuffersCount() > 0) +- break; ++ if (input_queue_->QueuedBuffersCount() > 0) { ++ // break; ++ } + + if (coded_size_.IsEmpty() || !input_queue_->IsStreaming()) { + // In these situations, we should call NotifyFlushDone() immediately: +@@ -1499,6 +1500,10 @@ bool V4L2VideoDecodeAccelerator::DequeueOutputBuffer() { + // Dequeue a completed output (VIDEO_CAPTURE) buffer, and queue to the + // completed queue. + auto ret = output_queue_->DequeueBuffer(); ++ if (errno == EPIPE) { ++ VLOG(1) << "Got eos"; ++ flush_awaiting_last_output_buffer_ = false; ++ } + if (ret.first == false) { + LOG(ERROR) << "Error in Dequeue output buffer"; + NOTIFY_ERROR(PLATFORM_FAILURE); +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0116-V4L2VDA-Support-tile-to-linear-transform-for-amphion.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0116-V4L2VDA-Support-tile-to-linear-transform-for-amphion.patch new file mode 100644 index 00000000..f0e4c46b --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0116-V4L2VDA-Support-tile-to-linear-transform-for-amphion.patch @@ -0,0 +1,304 @@ +From 346a96e47990cae31b4afe774d9fabf53219c3a9 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Mon, 5 Sep 2022 14:14:10 +0800 +Subject: [PATCH 16/17] V4L2VDA: Support tile to linear transform for amphion + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/BUILD.gn | 1 + + media/gpu/v4l2/v4l2_device.cc | 182 +++++++++++++++++++++++++++++++++- + media/gpu/v4l2/v4l2_device.h | 1 + + 3 files changed, 179 insertions(+), 5 deletions(-) + +diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn +index ebd0a4ad64646..273f6066de175 100644 +--- a/media/gpu/v4l2/BUILD.gn ++++ b/media/gpu/v4l2/BUILD.gn +@@ -86,6 +86,7 @@ source_set("v4l2") { + "EGL", + "GLESv2", + ] ++ libs += [ "g2d" ] + + if (use_v4l2_codec_aml) { + sources += [ +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 5a1057c845e85..42cd8386f41cb 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -40,6 +40,11 @@ + #include "media/gpu/v4l2/aml_v4l2_device.h" + #endif + ++#include "g2d.h" ++#include "g2dExt.h" ++#include ++#include ++ + namespace media { + + namespace { +@@ -169,6 +174,11 @@ class V4L2Buffer { + size_t GetMemoryUsage() const; + const struct v4l2_buffer& v4l2_buffer() const { return v4l2_buffer_; } + scoped_refptr GetVideoFrame(); ++ std::pair GetSavedmafd(); ++ std::pair GetSavedphys(); ++ std::pair Getg2dbufphys(); ++ std::pair Getg2dbufvirs(); ++ const struct v4l2_format& GetFmt() const {return format_;} + + private: + V4L2Buffer(scoped_refptr device, +@@ -181,6 +191,12 @@ class V4L2Buffer { + + scoped_refptr device_; + std::vector plane_mappings_; ++ int dmafd0; ++ int dmafd1; ++ unsigned long phys_0; ++ unsigned long phys_1; ++ struct g2d_buf *g2dbuf_p0; ++ struct g2d_buf *g2dbuf_p1; + + // V4L2 data as queried by QUERYBUF. + struct v4l2_buffer v4l2_buffer_; +@@ -230,6 +246,9 @@ V4L2Buffer::V4L2Buffer(scoped_refptr device, + v4l2_buffer_.type = type; + v4l2_buffer_.memory = memory; + plane_mappings_.resize(V4L2_TYPE_IS_MULTIPLANAR(type) ? v4l2_buffer_.length : 1); ++ dmafd0 = dmafd1 = -1; ++ phys_0 = phys_1 = 0; ++ g2dbuf_p0 = g2dbuf_p1 = NULL; + } + + V4L2Buffer::~V4L2Buffer() { +@@ -242,6 +261,32 @@ V4L2Buffer::~V4L2Buffer() { + } + } + } ++ if(g2dbuf_p0 && g2dbuf_p1) { ++ g2d_free(g2dbuf_p0); ++ g2d_free(g2dbuf_p1); ++ } ++} ++ ++std::pair V4L2Buffer::GetSavedmafd() { ++ return std::make_pair(dmafd0, dmafd1); ++} ++ ++std::pair V4L2Buffer::GetSavedphys() { ++ return std::make_pair(phys_0, phys_1); ++} ++ ++std::pair V4L2Buffer::Getg2dbufphys() { ++ if(g2dbuf_p0 && g2dbuf_p1) ++ return std::make_pair(g2dbuf_p0->buf_paddr, g2dbuf_p1->buf_paddr); ++ else ++ return std::make_pair(-1, -1); ++} ++ ++std::pair V4L2Buffer::Getg2dbufvirs() { ++ if(g2dbuf_p0 && g2dbuf_p1) ++ return std::make_pair(g2dbuf_p0->buf_vaddr, g2dbuf_p1->buf_vaddr); ++ else ++ return std::make_pair(nullptr, nullptr); + } + + bool V4L2Buffer::Query() { +@@ -325,6 +370,61 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + DLOG(ERROR) << "Fail to get DMABUFs of V4L2 buffer - invalid fd"; + return nullptr; + } ++ if(dmafd0 == -1) ++ dmafd0 = dmabuf_fd.get(); ++ else ++ dmafd1 = dmabuf_fd.get(); ++ } ++ ++ std::vector g2dbufs_fds; ++ if (V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type)) { ++ struct dma_buf_phys{ ++ unsigned long phys; ++ }; ++ #define DMA_BUF_IOCTL_PHYS _IOW(DMA_BUF_BASE, 10, struct dma_buf_phys) ++ struct dma_buf_phys query0, query1; ++ int ret = ioctl(dmafd0, DMA_BUF_IOCTL_PHYS, &query0); ++ if(ret != 0) { ++ DLOG(ERROR)<< "DMA_BUF_IOCTL_PHYS failed at dmafd" << dmafd0; ++ return nullptr; ++ } ++ else ++ phys_0 = query0.phys; ++ ++ ret = ioctl(dmafd1, DMA_BUF_IOCTL_PHYS, &query1); ++ if(ret != 0) { ++ DLOG(ERROR)<< "DMA_BUF_IOCTL_PHYS failed at dmafd" << dmafd1; ++ return nullptr; ++ } ++ else ++ phys_1 = query1.phys; ++ ++ g2dbuf_p0 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height, 0); ++ g2dbuf_p1 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height / 2, 0); ++ if((!g2dbuf_p0) || (!g2dbuf_p1)){ ++ DLOG(ERROR)<<"g2d buf alloc failed"; ++ return nullptr; ++ } ++ ++ int tmpfd = g2d_buf_export_fd(g2dbuf_p0); ++ tmpfd = dup(tmpfd); ++ if(tmpfd > 0) ++ g2dbufs_fds.push_back(base::ScopedFD(tmpfd)); ++ else if(tmpfd == -1) ++ { ++ DLOG(ERROR) << "Failed duplicating g2d fd"; ++ return nullptr; ++ } ++ ++ tmpfd = g2d_buf_export_fd(g2dbuf_p1); ++ tmpfd = dup(tmpfd); ++ if(tmpfd>0) ++ g2dbufs_fds.push_back(base::ScopedFD(tmpfd)); ++ else if(tmpfd == -1) ++ { ++ DLOG(ERROR) << "Failed duplicating g2d fd"; ++ return nullptr; ++ } + } + + // Duplicate the fd of the last v4l2 plane until the number of fds are the +@@ -339,13 +439,16 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + dmabuf_fds.emplace_back(duped_fd); + } + +- if (V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type)) ++ if (V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type)) { + gfx::Size size(format_.fmt.pix_mp.width, format_.fmt.pix_mp.height); +- else ++ return VideoFrame::WrapExternalDmabufs( ++ *layout, gfx::Rect(size), size, std::move(g2dbufs_fds), base::TimeDelta()); ++ } ++ else { + gfx::Size size(format_.fmt.pix.width, format_.fmt.pix.height); +- +- return VideoFrame::WrapExternalDmabufs( +- *layout, gfx::Rect(size), size, std::move(dmabuf_fds), base::TimeDelta()); ++ return VideoFrame::WrapExternalDmabufs( ++ *layout, gfx::Rect(size), size, std::move(dmabuf_fds), base::TimeDelta()); ++ } + } + + scoped_refptr V4L2Buffer::GetVideoFrame() { +@@ -1047,6 +1150,10 @@ V4L2Queue::V4L2Queue(scoped_refptr dev, + DVLOGF(4) << "Queue supports request API."; + } + #endif ++ ++ g2d_handle = NULL; ++ if(g2d_open(&g2d_handle)) ++ VLOGF(1) << "g2d_open fail"; + } + + V4L2Queue::~V4L2Queue() { +@@ -1065,6 +1172,9 @@ V4L2Queue::~V4L2Queue() { + DeallocateBuffers(); + } + ++ if(g2d_handle) ++ g2d_close(g2d_handle); ++ + std::move(destroy_cb_).Run(); + } + +@@ -1103,6 +1213,8 @@ std::pair, int> V4L2Queue::GetFormat() { + VPQLOGF(2) << "Failed to get format"; + return std::make_pair(absl::nullopt, errno); + } ++ if (type_ == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) ++ format.fmt.pix_mp.width = format.fmt.pix_mp.plane_fmt[0].bytesperline; + + return std::make_pair(format, 0); + } +@@ -1404,6 +1516,66 @@ std::pair V4L2Queue::DequeueBuffer() { + device_->SchedulePoll(); + + DCHECK(free_buffers_); ++ ++ if(type_ == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) ++ { ++ std::pair v4l_phys = buffers_[v4l2_buffer.index]->GetSavedphys(); ++ int width = buffers_[v4l2_buffer.index]->GetFmt().fmt.pix_mp.width; ++ int height = buffers_[v4l2_buffer.index]->GetFmt().fmt.pix_mp.height; ++ int stride = buffers_[v4l2_buffer.index]->GetFmt().fmt.pix_mp.plane_fmt[0].bytesperline; ++ bool interlaced = false; ++ switch (buffers_[v4l2_buffer.index]->GetFmt().fmt.pix_mp.field) { ++ case V4L2_FIELD_INTERLACED: ++ case V4L2_FIELD_INTERLACED_TB: ++ case V4L2_FIELD_INTERLACED_BT: ++ case V4L2_FIELD_SEQ_TB: ++ interlaced = true; ++ break; ++ default: ++ break; ++ }; ++ struct g2d_surfaceEx srcEx, dstEx; ++ struct g2d_surface *src = &srcEx.base; ++ struct g2d_surface *dst = &dstEx.base; ++ ++ dst->format = G2D_NV12; ++ dst->planes[0] = buffers_[v4l2_buffer.index]->Getg2dbufphys().first; ++ dst->planes[1] = buffers_[v4l2_buffer.index]->Getg2dbufphys().second; ++ dstEx.tiling = G2D_LINEAR; ++ dst->left = 0; ++ dst->top = 0; ++ dst->right = dst->left + width; ++ dst->bottom = dst->top + height; ++ dst->stride= width; ++ dst->width = width; ++ dst->height = height; ++ dst->rot = G2D_ROTATION_0; ++ dst->global_alpha = 0xff; ++ dst->blendfunc = G2D_ONE_MINUS_SRC_ALPHA; ++ dst->clrcolor = 0; ++ ++ src->format = G2D_NV12; ++ src->planes[0] = v4l_phys.first; ++ src->planes[1] = v4l_phys.second; ++ srcEx.tiling = G2D_AMPHION_TILED; ++ if (interlaced) { ++ srcEx.tiling = static_cast(0x18); //G2D_AMPHION_TILED | G2D_AMPHION_INTERLACED; ++ DVLOGF(4)<<"interlaced video convert"; ++ } ++ src->left = 0; ++ src->top = 0; ++ src->right = src->left + width; ++ src->bottom = src->top + height; ++ src->stride= stride; ++ src->width = width; ++ src->height = height; ++ src->rot = G2D_ROTATION_0; ++ src->global_alpha = 0xff; ++ src->blendfunc = G2D_ONE; ++ ++ g2d_blitEx(g2d_handle, &srcEx, &dstEx); ++ } ++ + return std::make_pair(true, V4L2BufferRefFactory::CreateReadableRef( + v4l2_buffer, weak_this_factory_.GetWeakPtr(), + std::move(queued_frame))); +diff --git a/media/gpu/v4l2/v4l2_device.h b/media/gpu/v4l2/v4l2_device.h +index 86ef80fd09579..516d0a63b5689 100644 +--- a/media/gpu/v4l2/v4l2_device.h ++++ b/media/gpu/v4l2/v4l2_device.h +@@ -457,6 +457,7 @@ class MEDIA_GPU_EXPORT V4L2Queue + absl::optional current_format_; + + std::vector> buffers_; ++ void* g2d_handle; + + // Buffers that are available for client to get and submit. + // Buffers in this list are not referenced by anyone else than ourselves. +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0117-V4L2VDA-Enlarge-input-buffer-count-to-16.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0117-V4L2VDA-Enlarge-input-buffer-count-to-16.patch new file mode 100644 index 00000000..7d962d69 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0117-V4L2VDA-Enlarge-input-buffer-count-to-16.patch @@ -0,0 +1,29 @@ +From cce8813b76367550ca0a934481ff9263afc09698 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Thu, 15 Sep 2022 18:12:55 +0800 +Subject: [PATCH 17/17] V4L2VDA: Enlarge input buffer count to 16 + +Some stream can decode one frame only after queuing over 8 buffers. +So enlarge input buffer count to 16 to avoid such stream cannot play. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_video_decode_accelerator.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.h b/media/gpu/v4l2/v4l2_video_decode_accelerator.h +index d16ee5857785b..5724a972ce4f3 100644 +--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.h ++++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.h +@@ -145,7 +145,7 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator + private: + // These are rather subjectively tuned. + enum { +- kInputBufferCount = 8, ++ kInputBufferCount = 16, + // TODO(posciak): determine input buffer size based on level limits. + // See http://crbug.com/255116. + // Input bitstream buffer size for up to 1080p streams. +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch new file mode 100644 index 00000000..7cd0b852 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch @@ -0,0 +1,306 @@ +From 59bf28174104b591088a08e2ed61644cc93101fd Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Thu, 22 Sep 2022 11:10:46 +0800 +Subject: [PATCH] V4L2VDA: Use dlopen to dynamically use g2d api + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/BUILD.gn | 1 - + media/gpu/v4l2/v4l2_device.cc | 205 ++++++++++++++++++++++++++++++++-- + 2 files changed, 194 insertions(+), 12 deletions(-) + +diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn +index 273f6066de175..ebd0a4ad64646 100644 +--- a/media/gpu/v4l2/BUILD.gn ++++ b/media/gpu/v4l2/BUILD.gn +@@ -86,7 +86,6 @@ source_set("v4l2") { + "EGL", + "GLESv2", + ] +- libs += [ "g2d" ] + + if (use_v4l2_codec_aml) { + sources += [ +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index 42cd8386f41cb..af71f54d141aa 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -40,10 +40,12 @@ + #include "media/gpu/v4l2/aml_v4l2_device.h" + #endif + +-#include "g2d.h" +-#include "g2dExt.h" ++// #include "g2d.h" ++// #include "g2dExt.h" ++ + #include + #include ++#include + + namespace media { + +@@ -142,6 +144,158 @@ void V4L2ProcessingTrace(const struct v4l2_buffer* v4l2_buffer, bool start) { + + } // namespace + ++/* g2d.h g2dExt.h */ ++enum g2d_format ++{ ++//rgb formats ++ G2D_RGB565 = 0, /* [0:4] Blue; [5:10] Green; [11:15] Red */ ++ G2D_RGBA8888 = 1, /* [0:7] Red; [8:15] Green; [16:23] Blue; [23:31] Alpha */ ++ G2D_RGBX8888 = 2, /* [0:7] Red; [8:15] Green; [16:23] Blue; [23:31] don't care */ ++ G2D_BGRA8888 = 3, /* [0:7] Blue; [8:15] Green; [16:23] Red; [23:31] Alpha */ ++ G2D_BGRX8888 = 4, /* [0:7] Blue; [8:15] Green; [16:23] Red; [23:31] don't care */ ++ G2D_BGR565 = 5, /* [0:4] Red; [5:10] Green; [11:15] Blue */ ++ ++ G2D_ARGB8888 = 6, /* [0:7] Alpha; [8:15] Red; [16:23] Green; [23:31] Blue */ ++ G2D_ABGR8888 = 7, /* [0:7] Alpha; [8:15] Blue; [16:23] Green; [23:31] Red */ ++ G2D_XRGB8888 = 8, /* [0:7] don't care; [8:15] Red; [16:23] Green; [23:31] Blue */ ++ G2D_XBGR8888 = 9, /* [0:7] don't care; [8:15] Blue; [16:23] Green; [23:31] Red */ ++ G2D_RGB888 = 10, /* [0:7] Red; [8:15] Green; [16:23] Blue */ ++ G2D_BGR888 = 11, /* [0:7] Blue; [8:15] Green; [16:23] Red */ ++ ++ G2D_RGBA5551 = 12, /* [0:4] Red; [5:9] Green; [10:14] Blue; [15] Alpha */ ++ G2D_RGBX5551 = 13, /* [0:4] Red; [5:9] Green; [10:14] Blue; [15] don't care */ ++ G2D_BGRA5551 = 14, /* [0:4] Blue; [5:9] Green; [10:14] Red; [15] Alpha */ ++ G2D_BGRX5551 = 15, /* [0:4] Blue; [5:9] Green; [10:14] Red; [15] don't care */ ++ ++//yuv formats ++ G2D_NV12 = 20, /* 2 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] U; [8:15] V */ ++ G2D_I420 = 21, /* 3 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] U; plane 3: [0:7] V */ ++ G2D_YV12 = 22, /* 3 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] V; plane 3: [0:7] U */ ++ G2D_NV21 = 23, /* 2 plane 420 format; plane 1: [0:7] Y ; plane 2: [0:7] V; [8:15] U */ ++ G2D_YUYV = 24, /* 1 plane 422 format; [0:7] Y; [8:15; U; [16:23] Y; [24:31] V */ ++ G2D_YVYU = 25, /* 1 plane 422 format; [0:7] Y; [8:15; V; [16:23] Y; [24:31] U */ ++ G2D_UYVY = 26, /* 1 plane 422 format; [0:7] U; [8:15; Y; [16:23] V; [24:31] Y */ ++ G2D_VYUY = 27, /* 1 plane 422 format; [0:7] V; [8:15; Y; [16:23] U; [24:31] Y */ ++ G2D_NV16 = 28, /* 2 plane 422 format; plane 1: [0:7] Y ; plane 2: [0:7] U; [8:15] V */ ++ G2D_NV61 = 29, /* 2 plane 422 format; plane 1: [0:7] Y ; plane 2: [0:7] V; [8:15] U */ ++}; ++ ++enum g2d_tiling ++{ ++ G2D_LINEAR = 0x1, ++ G2D_TILED = 0x2, ++ G2D_SUPERTILED = 0x4, ++ G2D_AMPHION_TILED = 0x8, ++ G2D_AMPHION_INTERLACED = 0x10, ++ G2D_TILED_STATUS = 0x20, ++ G2D_AMPHION_TILED_10BIT = 0x40, ++}; ++ ++struct g2d_tile_status ++{ ++ unsigned int ts_addr; ++ ++ unsigned int fc_enabled; ++ unsigned int fc_value; ++ unsigned int fc_value_upper; ++}; ++ ++struct g2d_buf ++{ ++ void *buf_handle; ++ void *buf_vaddr; ++ int buf_paddr; ++ int buf_size; ++}; ++ ++enum g2d_blend_func ++{ ++//basic blend ++ G2D_ZERO = 0, ++ G2D_ONE = 1, ++ G2D_SRC_ALPHA = 2, ++ G2D_ONE_MINUS_SRC_ALPHA = 3, ++ G2D_DST_ALPHA = 4, ++ G2D_ONE_MINUS_DST_ALPHA = 5, ++ ++// extensive blend is set with basic blend together, ++// such as, G2D_ONE | G2D_PRE_MULTIPLIED_ALPHA ++ G2D_PRE_MULTIPLIED_ALPHA = 0x10, ++ G2D_DEMULTIPLY_OUT_ALPHA = 0x20, ++}; ++ ++enum g2d_rotation ++{ ++ G2D_ROTATION_0 = 0, ++ G2D_ROTATION_90 = 1, ++ G2D_ROTATION_180 = 2, ++ G2D_ROTATION_270 = 3, ++ G2D_FLIP_H = 4, ++ G2D_FLIP_V = 5, ++}; ++ ++struct g2d_surface ++{ ++ enum g2d_format format; ++ ++ int planes[3];//surface buffer addresses are set in physical planes separately ++ //RGB: planes[0] - RGB565/RGBA8888/RGBX8888/BGRA8888/BRGX8888 ++ //NV12: planes[0] - Y, planes[1] - packed UV ++ //I420: planes[0] - Y, planes[1] - U, planes[2] - V ++ //YV12: planes[0] - Y, planes[1] - V, planes[2] - U ++ //NV21: planes[0] - Y, planes[1] - packed VU ++ //YUYV: planes[0] - packed YUYV ++ //YVYU: planes[0] - packed YVYU ++ //UYVY: planes[0] - packed UYVY ++ //VYUY: planes[0] - packed VYUY ++ //NV16: planes[0] - Y, planes[1] - packed UV ++ //NV61: planes[0] - Y, planes[1] - packed VU ++ ++ //blit rectangle in surface ++ int left; ++ int top; ++ int right; ++ int bottom; ++ int stride; ///< buffer stride, in Pixels ++ int width; ///< surface width, in Pixels ++ int height; ///< surface height, in Pixels ++ enum g2d_blend_func blendfunc; ///< alpha blending parameters ++ int global_alpha; ///< value is 0 ~ 255 ++ //clrcolor format is RGBA8888, used as dst for clear, as src for blend dim ++ int clrcolor; ++ ++ //rotation degree ++ enum g2d_rotation rot; ++}; ++ ++struct g2d_surfaceEx ++{ ++ struct g2d_surface base; ++ enum g2d_tiling tiling; ++ ++ struct g2d_tile_status ts; ++ int reserved[8]; ++}; ++ ++void *dl_handle = NULL; ++ ++typedef int (*g2d_api_open)(void **handle); ++typedef int (*g2d_api_close)(void *handle); ++typedef int (*g2d_api_free)(struct g2d_buf *buf); ++typedef struct g2d_buf* (*g2d_api_alloc)(int size, int cacheable); ++typedef int (*g2d_api_buf_export_fd)(struct g2d_buf *); ++typedef int (*g2d_api_blitEx)(void *handle, struct g2d_surfaceEx *srcEx, struct g2d_surfaceEx *dstEx); ++ ++#define G2D_API_SYM(name) g2d_api_##name g2d_##name = nullptr ++G2D_API_SYM(open); ++G2D_API_SYM(close); ++G2D_API_SYM(free); ++G2D_API_SYM(alloc); ++G2D_API_SYM(buf_export_fd); ++G2D_API_SYM(blitEx); ++#undef G2D_API_SYM ++/* g2d.h g2dExt.h */ ++ + V4L2ExtCtrl::V4L2ExtCtrl(uint32_t id) { + memset(&ctrl, 0, sizeof(ctrl)); + ctrl.id = id; +@@ -261,7 +415,7 @@ V4L2Buffer::~V4L2Buffer() { + } + } + } +- if(g2dbuf_p0 && g2dbuf_p1) { ++ if(g2d_free && g2dbuf_p0 && g2dbuf_p1) { + g2d_free(g2dbuf_p0); + g2d_free(g2dbuf_p1); + } +@@ -399,14 +553,18 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + else + phys_1 = query1.phys; + +- g2dbuf_p0 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height, 0); +- g2dbuf_p1 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height / 2, 0); ++ if (g2d_alloc) { ++ g2dbuf_p0 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height, 0); ++ g2dbuf_p1 = g2d_alloc(format_.fmt.pix_mp.width * format_.fmt.pix_mp.height / 2, 0); ++ } + if((!g2dbuf_p0) || (!g2dbuf_p1)){ + DLOG(ERROR)<<"g2d buf alloc failed"; + return nullptr; + } + +- int tmpfd = g2d_buf_export_fd(g2dbuf_p0); ++ int tmpfd = -1; ++ if (g2d_buf_export_fd) ++ tmpfd = g2d_buf_export_fd(g2dbuf_p0); + tmpfd = dup(tmpfd); + if(tmpfd > 0) + g2dbufs_fds.push_back(base::ScopedFD(tmpfd)); +@@ -416,7 +574,8 @@ scoped_refptr V4L2Buffer::CreateVideoFrame() { + return nullptr; + } + +- tmpfd = g2d_buf_export_fd(g2dbuf_p1); ++ if (g2d_buf_export_fd) ++ tmpfd = g2d_buf_export_fd(g2dbuf_p1); + tmpfd = dup(tmpfd); + if(tmpfd>0) + g2dbufs_fds.push_back(base::ScopedFD(tmpfd)); +@@ -1152,7 +1311,7 @@ V4L2Queue::V4L2Queue(scoped_refptr dev, + #endif + + g2d_handle = NULL; +- if(g2d_open(&g2d_handle)) ++ if(g2d_open && g2d_open(&g2d_handle)) + VLOGF(1) << "g2d_open fail"; + } + +@@ -1172,7 +1331,7 @@ V4L2Queue::~V4L2Queue() { + DeallocateBuffers(); + } + +- if(g2d_handle) ++ if(g2d_close && g2d_handle) + g2d_close(g2d_handle); + + std::move(destroy_cb_).Run(); +@@ -1573,7 +1732,8 @@ std::pair V4L2Queue::DequeueBuffer() { + src->global_alpha = 0xff; + src->blendfunc = G2D_ONE; + +- g2d_blitEx(g2d_handle, &srcEx, &dstEx); ++ if (g2d_blitEx) ++ g2d_blitEx(g2d_handle, &srcEx, &dstEx); + } + + return std::make_pair(true, V4L2BufferRefFactory::CreateReadableRef( +@@ -1747,8 +1907,31 @@ scoped_refptr V4L2Device::Create() { + #endif + + device = new GenericV4L2Device(); +- if (device->Initialize()) ++ if (device->Initialize()) { ++ dl_handle = dlopen("/usr/lib/libg2d.so", ++ RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE | RTLD_LAZY); ++ if (!dl_handle) { ++ VLOGF(1) << "Has no libg2d.so"; ++ return device; ++ } ++ ++#define G2D_API_DLSYM(lib, name) \ ++ do { \ ++ g2d_##name = reinterpret_cast(dlsym(lib, "g2d_" #name)); \ ++ if (!(g2d_##name)) \ ++ VLOGF(1) << "Failed to dlsym g2d_" #name; \ ++ } while (0) ++ ++ G2D_API_DLSYM(dl_handle, open); ++ G2D_API_DLSYM(dl_handle, close); ++ G2D_API_DLSYM(dl_handle, free); ++ G2D_API_DLSYM(dl_handle, alloc); ++ G2D_API_DLSYM(dl_handle, buf_export_fd); ++ G2D_API_DLSYM(dl_handle, blitEx); ++ + return device; ++ } ++ + + VLOGF(1) << "Failed to create a V4L2Device"; + return nullptr; +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0119-V4L2VDA-dlopen-libg2d.so.2-to-avoid-segfault.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0119-V4L2VDA-dlopen-libg2d.so.2-to-avoid-segfault.patch new file mode 100644 index 00000000..df6c6fe4 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0119-V4L2VDA-dlopen-libg2d.so.2-to-avoid-segfault.patch @@ -0,0 +1,40 @@ +From 4e33abf0778eba9b6bf5bf4fc01e021775b7d2c7 Mon Sep 17 00:00:00 2001 +From: Hou Qi +Date: Thu, 29 Sep 2022 11:12:12 +0800 +Subject: [PATCH] V4L2VDA: dlopen libg2d.so.2 to avoid segfault + +For rootfs that have no libg2d.so, dlopen libg2d.so.2 instead. + +Upstream-Status: Inappropriate [NXP specific] +--- + media/gpu/v4l2/v4l2_device.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc +index af71f54d141aa..139d32d3a788f 100644 +--- a/media/gpu/v4l2/v4l2_device.cc ++++ b/media/gpu/v4l2/v4l2_device.cc +@@ -286,6 +286,7 @@ typedef struct g2d_buf* (*g2d_api_alloc)(int size, int cacheable); + typedef int (*g2d_api_buf_export_fd)(struct g2d_buf *); + typedef int (*g2d_api_blitEx)(void *handle, struct g2d_surfaceEx *srcEx, struct g2d_surfaceEx *dstEx); + ++#define G2D_LIB_NAME "/usr/lib/libg2d.so.2" + #define G2D_API_SYM(name) g2d_api_##name g2d_##name = nullptr + G2D_API_SYM(open); + G2D_API_SYM(close); +@@ -1908,10 +1909,10 @@ scoped_refptr V4L2Device::Create() { + + device = new GenericV4L2Device(); + if (device->Initialize()) { +- dl_handle = dlopen("/usr/lib/libg2d.so", ++ dl_handle = dlopen(G2D_LIB_NAME, + RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE | RTLD_LAZY); + if (!dl_handle) { +- VLOGF(1) << "Has no libg2d.so"; ++ VLOGF(1) << "Failed to dlopen " << G2D_LIB_NAME; + return device; + } + +-- +2.17.1 + diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend new file mode 100644 index 00000000..6b14bbc8 --- /dev/null +++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend @@ -0,0 +1,51 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append:imx-nxp-bsp = " \ + file://0001-Fixed-chromium-flicker-with-g2d-renderer.patch \ + file://0002-chromium-met-EGL-API-GetProcAddress-failures.patch \ + file://0003-Disable-dri-for-imx-gpu.patch \ +" +SRC_URI:append:mx8-nxp-bsp = " \ + file://0101-V4L2VDA-Switch-to-use-VDA-instead-of-direct-VideoDec.patch \ + file://0102-GenericV4L2Device-Correct-v4l2-decoder-device-path.patch \ + file://0103-V4L2VDA-Add-macro-use_linux_v4l2.patch \ + file://0104-V4L2VDA-Create-single-multi-plane-queues.patch \ + file://0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch \ + file://0106-V4L2VDA-Create-videoframe-according-to-v4l2buffer.patch \ + file://0107-V4L2VDA-Add-function-IsMultiQueue-for-S_FMT-and-G_FM.patch \ + file://0108-V4L2VDA-Use-correct-size-to-allocate-CAPTURE-buffer.patch \ + file://0109-V4L2VDA-Use-correct-plane-size-and-bytesused.patch \ + file://0110-V4L2VDA-Add-hevc-format-support.patch \ + file://0111-V4L2VDA-fix-vp9-crash-caused-by-DequeueResolutionCha.patch \ + file://0112-V4L2VDA-Add-fps-in-SkiaOutputSurfaceImplOnGpu-by-VLO.patch \ + file://0113-V4L2VDA-Comment-some-unused-ioctl.patch \ + file://0114-V4L2VDA-Set-OUTPUT-format-with-parsed-resolution-for.patch \ + file://0115-V4L2VDA-Add-V4L2_PIX_FMT_NV12M_8L128-format-for-amph.patch \ + file://0116-V4L2VDA-Support-tile-to-linear-transform-for-amphion.patch \ + file://0117-V4L2VDA-Enlarge-input-buffer-count-to-16.patch \ + file://0118-V4L2VDA-Use-dlopen-to-dynamically-use-g2d-api.patch \ + file://0119-V4L2VDA-dlopen-libg2d.so.2-to-avoid-segfault.patch \ +" + +GN_ARGS_DISABLE_GBM = "" +GN_ARGS_DISABLE_GBM:mx6-nxp-bsp = "use_system_minigbm=false use_wayland_gbm=false" +GN_ARGS_DISABLE_GBM:mx7-nxp-bsp = "${GN_ARGS_DISABLE_GBM:mx6-nxp-bsp}" +GN_ARGS_USE_IMXGPU = "use_imxgpu=false" +GN_ARGS_USE_IMXGPU:imxgpu = "use_imxgpu=true" +GN_ARGS_ENABLE_PROPRIETARY_CODECS = "" +GN_ARGS_ENABLE_PROPRIETARY_CODECS:mx8-nxp-bsp = "proprietary_codecs=true" +GN_ARGS_FFMPEG_BRANDING = "" +GN_ARGS_FFMPEG_BRANDING:mx8-nxp-bsp = "ffmpeg_branding="Chrome"" +GN_ARGS_USE_V4L2_CODEC = "" +GN_ARGS_USE_V4L2_CODEC:mx8-nxp-bsp = "use_v4l2_codec=true" +GN_ARGS_USE_LINUX_V4L2_ONLY = "" +GN_ARGS_USE_LINUX_V4L2_ONLY:mx8-nxp-bsp = "use_linux_v4l2_only=true" +GN_ARGS:append:imx-nxp-bsp = " \ + ${GN_ARGS_DISABLE_GBM} \ + ${GN_ARGS_USE_IMXGPU} \ + ${GN_ARGS_ENABLE_PROPRIETARY_CODECS} \ + ${GN_ARGS_FFMPEG_BRANDING} \ + ${GN_ARGS_USE_V4L2_CODEC} \ + ${GN_ARGS_USE_LINUX_V4L2_ONLY} \ +" +CHROMIUM_EXTRA_ARGS:append = " --disable-features=VizDisplayCompositor --in-process-gpu --disable-gpu-rasterization" -- cgit v1.2.3-54-g00ecf