diff options
Diffstat (limited to 'dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0103-V4L2VDA-Add-macro-use_linux_v4l2.patch')
| -rw-r--r-- | dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0103-V4L2VDA-Add-macro-use_linux_v4l2.patch | 320 |
1 files changed, 320 insertions, 0 deletions
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 000000000..a0219b8cb --- /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 @@ | |||
| 1 | From fdc95ddfab945de74fe6b0b196df9a6394013243 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Hou Qi <qi.hou@nxp.com> | ||
| 3 | Date: Fri, 2 Sep 2022 13:18:34 +0800 | ||
| 4 | Subject: [PATCH 03/17] V4L2VDA: Add macro use_linux_v4l2 | ||
| 5 | |||
| 6 | Upstream-Status: Inappropriate [NXP specific] | ||
| 7 | --- | ||
| 8 | .../gpu_mjpeg_decode_accelerator_factory.cc | 3 +- | ||
| 9 | media/gpu/BUILD.gn | 1 + | ||
| 10 | media/gpu/args.gni | 4 +++ | ||
| 11 | .../gpu_video_decode_accelerator_factory.cc | 8 ++++++ | ||
| 12 | .../gpu_video_decode_accelerator_factory.h | 2 ++ | ||
| 13 | media/gpu/v4l2/BUILD.gn | 22 +++++++++------ | ||
| 14 | media/gpu/v4l2/generic_v4l2_device.cc | 4 +++ | ||
| 15 | media/gpu/v4l2/v4l2_device.cc | 28 +++++++++++++++++++ | ||
| 16 | media/gpu/v4l2/v4l2_video_decoder.cc | 6 ++++ | ||
| 17 | 9 files changed, 69 insertions(+), 9 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc b/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc | ||
| 20 | index 3772b8ef048a2..dece6b77f6a23 100644 | ||
| 21 | --- a/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc | ||
| 22 | +++ b/components/chromeos_camera/gpu_mjpeg_decode_accelerator_factory.cc | ||
| 23 | @@ -13,7 +13,8 @@ | ||
| 24 | #include "media/base/media_switches.h" | ||
| 25 | #include "media/gpu/buildflags.h" | ||
| 26 | |||
| 27 | -#if BUILDFLAG(USE_V4L2_CODEC) && defined(ARCH_CPU_ARM_FAMILY) | ||
| 28 | +#if BUILDFLAG(USE_V4L2_CODEC) && defined(ARCH_CPU_ARM_FAMILY) && \ | ||
| 29 | + !BUILDFLAG(USE_LINUX_V4L2) | ||
| 30 | #define USE_V4L2_MJPEG_DECODE_ACCELERATOR | ||
| 31 | #endif | ||
| 32 | |||
| 33 | diff --git a/media/gpu/BUILD.gn b/media/gpu/BUILD.gn | ||
| 34 | index 78d151fa630d2..101e2e4f9411e 100644 | ||
| 35 | --- a/media/gpu/BUILD.gn | ||
| 36 | +++ b/media/gpu/BUILD.gn | ||
| 37 | @@ -20,6 +20,7 @@ buildflag_header("buildflags") { | ||
| 38 | "USE_VAAPI_IMAGE_CODECS=$use_vaapi_image_codecs", | ||
| 39 | "USE_V4L2_CODEC=$use_v4l2_codec", | ||
| 40 | "USE_LIBV4L2=$use_v4lplugin", | ||
| 41 | + "USE_LINUX_V4L2=$use_linux_v4l2_only", | ||
| 42 | "USE_VAAPI_X11=$use_vaapi_x11", | ||
| 43 | ] | ||
| 44 | } | ||
| 45 | diff --git a/media/gpu/args.gni b/media/gpu/args.gni | ||
| 46 | index bb2ff0797e031..da20cff798728 100644 | ||
| 47 | --- a/media/gpu/args.gni | ||
| 48 | +++ b/media/gpu/args.gni | ||
| 49 | @@ -21,6 +21,10 @@ declare_args() { | ||
| 50 | # platforms which have v4l2 hardware encoder / decoder. | ||
| 51 | use_v4l2_codec = false | ||
| 52 | |||
| 53 | + # Indicates that only definitions available in the mainline linux kernel | ||
| 54 | + # will be used. | ||
| 55 | + use_linux_v4l2_only = false | ||
| 56 | + | ||
| 57 | # Indicates if Video4Linux2 AML encoder is used. This is used for AML | ||
| 58 | # platforms which have v4l2 hardware encoder | ||
| 59 | use_v4l2_codec_aml = false | ||
| 60 | diff --git a/media/gpu/gpu_video_decode_accelerator_factory.cc b/media/gpu/gpu_video_decode_accelerator_factory.cc | ||
| 61 | index 6687b11865f07..9514786384aa7 100644 | ||
| 62 | --- a/media/gpu/gpu_video_decode_accelerator_factory.cc | ||
| 63 | +++ b/media/gpu/gpu_video_decode_accelerator_factory.cc | ||
| 64 | @@ -29,7 +29,9 @@ | ||
| 65 | #include "ui/gl/gl_implementation.h" | ||
| 66 | #elif BUILDFLAG(USE_V4L2_CODEC) | ||
| 67 | #include "media/gpu/v4l2/v4l2_device.h" | ||
| 68 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 69 | #include "media/gpu/v4l2/v4l2_slice_video_decode_accelerator.h" | ||
| 70 | +#endif | ||
| 71 | #include "media/gpu/v4l2/v4l2_video_decode_accelerator.h" | ||
| 72 | #include "ui/gl/gl_surface_egl.h" | ||
| 73 | #endif | ||
| 74 | @@ -64,10 +66,12 @@ gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilitiesInternal( | ||
| 75 | GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | ||
| 76 | V4L2VideoDecodeAccelerator::GetSupportedProfiles(), | ||
| 77 | &capabilities.supported_profiles); | ||
| 78 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 79 | GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | ||
| 80 | V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(), | ||
| 81 | &capabilities.supported_profiles); | ||
| 82 | #endif | ||
| 83 | +#endif | ||
| 84 | #elif BUILDFLAG(IS_MAC) | ||
| 85 | capabilities.supported_profiles = | ||
| 86 | VTVideoDecodeAccelerator::GetSupportedProfiles(workarounds); | ||
| 87 | @@ -146,8 +150,10 @@ GpuVideoDecodeAcceleratorFactory::CreateVDA( | ||
| 88 | &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA, | ||
| 89 | #elif BUILDFLAG(USE_V4L2_CODEC) | ||
| 90 | &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA, | ||
| 91 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 92 | &GpuVideoDecodeAcceleratorFactory::CreateV4L2SliceVDA, | ||
| 93 | #endif | ||
| 94 | +#endif | ||
| 95 | |||
| 96 | #if BUILDFLAG(IS_MAC) | ||
| 97 | &GpuVideoDecodeAcceleratorFactory::CreateVTVDA, | ||
| 98 | @@ -207,6 +213,7 @@ GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA( | ||
| 99 | return decoder; | ||
| 100 | } | ||
| 101 | |||
| 102 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 103 | std::unique_ptr<VideoDecodeAccelerator> | ||
| 104 | GpuVideoDecodeAcceleratorFactory::CreateV4L2SliceVDA( | ||
| 105 | const gpu::GpuDriverBugWorkarounds& /*workarounds*/, | ||
| 106 | @@ -222,6 +229,7 @@ GpuVideoDecodeAcceleratorFactory::CreateV4L2SliceVDA( | ||
| 107 | return decoder; | ||
| 108 | } | ||
| 109 | #endif | ||
| 110 | +#endif | ||
| 111 | |||
| 112 | #if BUILDFLAG(IS_MAC) | ||
| 113 | std::unique_ptr<VideoDecodeAccelerator> | ||
| 114 | diff --git a/media/gpu/gpu_video_decode_accelerator_factory.h b/media/gpu/gpu_video_decode_accelerator_factory.h | ||
| 115 | index b2e1390c5f02d..5a714eb801d04 100644 | ||
| 116 | --- a/media/gpu/gpu_video_decode_accelerator_factory.h | ||
| 117 | +++ b/media/gpu/gpu_video_decode_accelerator_factory.h | ||
| 118 | @@ -104,11 +104,13 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcceleratorFactory { | ||
| 119 | const gpu::GpuDriverBugWorkarounds& workarounds, | ||
| 120 | const gpu::GpuPreferences& gpu_preferences, | ||
| 121 | MediaLog* media_log) const; | ||
| 122 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 123 | std::unique_ptr<VideoDecodeAccelerator> CreateV4L2SliceVDA( | ||
| 124 | const gpu::GpuDriverBugWorkarounds& workarounds, | ||
| 125 | const gpu::GpuPreferences& gpu_preferences, | ||
| 126 | MediaLog* media_log) const; | ||
| 127 | #endif | ||
| 128 | +#endif | ||
| 129 | #if BUILDFLAG(IS_MAC) | ||
| 130 | std::unique_ptr<VideoDecodeAccelerator> CreateVTVDA( | ||
| 131 | const gpu::GpuDriverBugWorkarounds& workarounds, | ||
| 132 | diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn | ||
| 133 | index 65e5f58d1efef..ebd0a4ad64646 100644 | ||
| 134 | --- a/media/gpu/v4l2/BUILD.gn | ||
| 135 | +++ b/media/gpu/v4l2/BUILD.gn | ||
| 136 | @@ -28,9 +28,6 @@ source_set("v4l2") { | ||
| 137 | "buffer_affinity_tracker.h", | ||
| 138 | "generic_v4l2_device.cc", | ||
| 139 | "generic_v4l2_device.h", | ||
| 140 | - "v4l2_decode_surface.cc", | ||
| 141 | - "v4l2_decode_surface.h", | ||
| 142 | - "v4l2_decode_surface_handler.h", | ||
| 143 | "v4l2_device.cc", | ||
| 144 | "v4l2_device.h", | ||
| 145 | "v4l2_device_poller.cc", | ||
| 146 | @@ -39,8 +36,6 @@ source_set("v4l2") { | ||
| 147 | "v4l2_framerate_control.h", | ||
| 148 | "v4l2_image_processor_backend.cc", | ||
| 149 | "v4l2_image_processor_backend.h", | ||
| 150 | - "v4l2_slice_video_decode_accelerator.cc", | ||
| 151 | - "v4l2_slice_video_decode_accelerator.h", | ||
| 152 | "v4l2_stateful_workaround.cc", | ||
| 153 | "v4l2_stateful_workaround.h", | ||
| 154 | "v4l2_status.h", | ||
| 155 | @@ -56,8 +51,19 @@ source_set("v4l2") { | ||
| 156 | "v4l2_video_decoder_backend.h", | ||
| 157 | "v4l2_video_decoder_backend_stateful.cc", | ||
| 158 | "v4l2_video_decoder_backend_stateful.h", | ||
| 159 | + "v4l2_video_encode_accelerator.cc", | ||
| 160 | + "v4l2_video_encode_accelerator.h", | ||
| 161 | + ] | ||
| 162 | + | ||
| 163 | + if (!use_linux_v4l2_only) { | ||
| 164 | + sources += [ | ||
| 165 | + "v4l2_decode_surface.cc", | ||
| 166 | + "v4l2_decode_surface.h", | ||
| 167 | + "v4l2_decode_surface_handler.h", | ||
| 168 | "v4l2_video_decoder_backend_stateless.cc", | ||
| 169 | "v4l2_video_decoder_backend_stateless.h", | ||
| 170 | + "v4l2_slice_video_decode_accelerator.cc", | ||
| 171 | + "v4l2_slice_video_decode_accelerator.h", | ||
| 172 | "v4l2_video_decoder_delegate_h264.cc", | ||
| 173 | "v4l2_video_decoder_delegate_h264.h", | ||
| 174 | "v4l2_video_decoder_delegate_h264_legacy.cc", | ||
| 175 | @@ -72,9 +78,9 @@ source_set("v4l2") { | ||
| 176 | "v4l2_video_decoder_delegate_vp9_chromium.h", | ||
| 177 | "v4l2_video_decoder_delegate_vp9_legacy.cc", | ||
| 178 | "v4l2_video_decoder_delegate_vp9_legacy.h", | ||
| 179 | - "v4l2_video_encode_accelerator.cc", | ||
| 180 | - "v4l2_video_encode_accelerator.h", | ||
| 181 | - ] | ||
| 182 | + ] | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | |||
| 186 | libs = [ | ||
| 187 | "EGL", | ||
| 188 | diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc | ||
| 189 | index c1fccf3e2e813..319357922c901 100644 | ||
| 190 | --- a/media/gpu/v4l2/generic_v4l2_device.cc | ||
| 191 | +++ b/media/gpu/v4l2/generic_v4l2_device.cc | ||
| 192 | @@ -440,7 +440,11 @@ bool GenericV4L2Device::OpenDevicePath(const std::string& path, Type type) { | ||
| 193 | return false; | ||
| 194 | |||
| 195 | #if BUILDFLAG(USE_LIBV4L2) | ||
| 196 | +#if BUILDFLAG(USE_LINUX_V4L2) | ||
| 197 | + if ( | ||
| 198 | +#else | ||
| 199 | if (type == Type::kEncoder && | ||
| 200 | +#endif | ||
| 201 | HANDLE_EINTR(v4l2_fd_open(device_fd_.get(), V4L2_DISABLE_CONVERSION)) != | ||
| 202 | -1) { | ||
| 203 | DVLOGF(3) << "Using libv4l2 for " << path; | ||
| 204 | diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc | ||
| 205 | index de2800fdab395..722ddbd68cb2b 100644 | ||
| 206 | --- a/media/gpu/v4l2/v4l2_device.cc | ||
| 207 | +++ b/media/gpu/v4l2/v4l2_device.cc | ||
| 208 | @@ -853,7 +853,9 @@ void V4L2WritableBufferRef::SetConfigStore(uint32_t config_store) { | ||
| 209 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | ||
| 210 | DCHECK(buffer_data_); | ||
| 211 | |||
| 212 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 213 | buffer_data_->v4l2_buffer_.config_store = config_store; | ||
| 214 | +#endif | ||
| 215 | } | ||
| 216 | |||
| 217 | V4L2ReadableBuffer::V4L2ReadableBuffer(const struct v4l2_buffer& v4l2_buffer, | ||
| 218 | @@ -1539,6 +1541,25 @@ std::string V4L2Device::GetDriverName() { | ||
| 219 | // static | ||
| 220 | uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile, | ||
| 221 | bool slice_based) { | ||
| 222 | +#if BUILDFLAG(USE_LINUX_V4L2) | ||
| 223 | + if (slice_based) { | ||
| 224 | + LOG(ERROR) << "Unsupported slice"; | ||
| 225 | + return 0; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) { | ||
| 229 | + return V4L2_PIX_FMT_H264; | ||
| 230 | + } else if (profile >= VP8PROFILE_MIN && profile <= VP8PROFILE_MAX) { | ||
| 231 | + return V4L2_PIX_FMT_VP8; | ||
| 232 | + } else if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX) { | ||
| 233 | + return V4L2_PIX_FMT_VP9; | ||
| 234 | + } else if (profile == HEVCPROFILE_MAIN) { | ||
| 235 | + return V4L2_PIX_FMT_HEVC; | ||
| 236 | + } else { | ||
| 237 | + DVLOGF(1) << "Unsupported profile: " << GetProfileName(profile); | ||
| 238 | + return 0; | ||
| 239 | + } | ||
| 240 | +#else | ||
| 241 | if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) { | ||
| 242 | if (slice_based) | ||
| 243 | return V4L2_PIX_FMT_H264_SLICE; | ||
| 244 | @@ -1558,6 +1579,7 @@ uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile, | ||
| 245 | DVLOGF(1) << "Unsupported profile: " << GetProfileName(profile); | ||
| 246 | return 0; | ||
| 247 | } | ||
| 248 | +#endif | ||
| 249 | } | ||
| 250 | |||
| 251 | namespace { | ||
| 252 | @@ -1652,7 +1674,9 @@ std::vector<VideoCodecProfile> V4L2Device::V4L2PixFmtToVideoCodecProfiles( | ||
| 253 | std::vector<VideoCodecProfile> profiles; | ||
| 254 | switch (pix_fmt) { | ||
| 255 | case V4L2_PIX_FMT_H264: | ||
| 256 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 257 | case V4L2_PIX_FMT_H264_SLICE: | ||
| 258 | +#endif | ||
| 259 | if (!get_supported_profiles(VideoCodec::kH264, &profiles)) { | ||
| 260 | DLOG(WARNING) << "Driver doesn't support QUERY H264 profiles, " | ||
| 261 | << "use default values, Base, Main, High"; | ||
| 262 | @@ -1664,11 +1688,15 @@ std::vector<VideoCodecProfile> V4L2Device::V4L2PixFmtToVideoCodecProfiles( | ||
| 263 | } | ||
| 264 | break; | ||
| 265 | case V4L2_PIX_FMT_VP8: | ||
| 266 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 267 | case V4L2_PIX_FMT_VP8_FRAME: | ||
| 268 | +#endif | ||
| 269 | profiles = {VP8PROFILE_ANY}; | ||
| 270 | break; | ||
| 271 | case V4L2_PIX_FMT_VP9: | ||
| 272 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 273 | case V4L2_PIX_FMT_VP9_FRAME: | ||
| 274 | +#endif | ||
| 275 | if (!get_supported_profiles(VideoCodec::kVP9, &profiles)) { | ||
| 276 | DLOG(WARNING) << "Driver doesn't support QUERY VP9 profiles, " | ||
| 277 | << "use default values, Profile0"; | ||
| 278 | diff --git a/media/gpu/v4l2/v4l2_video_decoder.cc b/media/gpu/v4l2/v4l2_video_decoder.cc | ||
| 279 | index 057b28663b15b..691908a3ba8ed 100644 | ||
| 280 | --- a/media/gpu/v4l2/v4l2_video_decoder.cc | ||
| 281 | +++ b/media/gpu/v4l2/v4l2_video_decoder.cc | ||
| 282 | @@ -28,7 +28,9 @@ | ||
| 283 | #include "media/gpu/macros.h" | ||
| 284 | #include "media/gpu/v4l2/v4l2_status.h" | ||
| 285 | #include "media/gpu/v4l2/v4l2_video_decoder_backend_stateful.h" | ||
| 286 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 287 | #include "media/gpu/v4l2/v4l2_video_decoder_backend_stateless.h" | ||
| 288 | +#endif | ||
| 289 | |||
| 290 | namespace media { | ||
| 291 | |||
| 292 | @@ -46,7 +48,9 @@ constexpr size_t kNumInputBuffers = 8; | ||
| 293 | |||
| 294 | // Input format V4L2 fourccs this class supports. | ||
| 295 | constexpr uint32_t kSupportedInputFourccs[] = { | ||
| 296 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 297 | V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME, V4L2_PIX_FMT_VP9_FRAME, | ||
| 298 | +#endif | ||
| 299 | V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9, | ||
| 300 | }; | ||
| 301 | |||
| 302 | @@ -320,6 +324,7 @@ V4L2Status V4L2VideoDecoder::InitializeBackend() { | ||
| 303 | << " and fourcc: " << FourccToString(input_format_fourcc); | ||
| 304 | backend_ = std::make_unique<V4L2StatefulVideoDecoderBackend>( | ||
| 305 | this, device_, profile_, color_space_, decoder_task_runner_); | ||
| 306 | +#if !BUILDFLAG(USE_LINUX_V4L2) | ||
| 307 | } else { | ||
| 308 | DCHECK_EQ(preferred_api_and_format.first, kStateless); | ||
| 309 | VLOGF(1) << "Using a stateless API for profile: " | ||
| 310 | @@ -327,6 +332,7 @@ V4L2Status V4L2VideoDecoder::InitializeBackend() { | ||
| 311 | << " and fourcc: " << FourccToString(input_format_fourcc); | ||
| 312 | backend_ = std::make_unique<V4L2StatelessVideoDecoderBackend>( | ||
| 313 | this, device_, profile_, color_space_, decoder_task_runner_); | ||
| 314 | +#endif | ||
| 315 | } | ||
| 316 | |||
| 317 | if (!backend_->Initialize()) { | ||
| 318 | -- | ||
| 319 | 2.17.1 | ||
| 320 | |||
