diff --git a/www/chromium/Makefile b/www/chromium/Makefile index 1a568a70410a..afd3edd0d6a6 100644 --- a/www/chromium/Makefile +++ b/www/chromium/Makefile @@ -1,352 +1,353 @@ PORTNAME= chromium PORTVERSION= 112.0.5615.165 +PORTREVISION= 1 CATEGORIES= www wayland MASTER_SITES= https://commondatastorage.googleapis.com/chromium-browser-official/ \ https://nerd.hu/distfiles/:external DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \ chrome-linux-${PORTVERSION}-llvm13.profdata${EXTRACT_SUFX}:external MAINTAINER= chromium@FreeBSD.org COMMENT= Google web browser based on WebKit WWW= https://www.chromium.org/Home LICENSE= BSD3CLAUSE LGPL21 MPL11 LICENSE_COMB= multi ONLY_FOR_ARCHS= aarch64 amd64 i386 BUILD_DEPENDS= bash:shells/bash \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR} \ gperf:devel/gperf \ flock:sysutils/flock \ node:www/node \ xcb-proto>0:x11/xcb-proto \ ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \ ${LOCALBASE}/share/usbids/usb.ids:misc/usbids \ ${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} \ ${LOCALBASE}/include/va/va.h:multimedia/libva \ ${LOCALBASE}/libdata/pkgconfig/dri.pc:graphics/mesa-dri \ ${LOCALBASE}/libdata/pkgconfig/Qt5Core.pc:devel/qt5-core \ ${LOCALBASE}/libdata/pkgconfig/Qt5Widgets.pc:x11-toolkits/qt5-widgets LIB_DEPENDS= libatk-bridge-2.0.so:accessibility/at-spi2-core \ libatspi.so:accessibility/at-spi2-core \ libspeechd.so:accessibility/speech-dispatcher \ libsnappy.so:archivers/snappy \ libFLAC.so:audio/flac \ libopus.so:audio/opus \ libspeex.so:audio/speex \ libdbus-1.so:devel/dbus \ libdbus-glib-1.so:devel/dbus-glib \ libepoll-shim.so:devel/libepoll-shim \ libevent.so:devel/libevent \ libffi.so:devel/libffi \ libicuuc.so:devel/icu \ libjsoncpp.so:devel/jsoncpp \ libpci.so:devel/libpci \ libnspr4.so:devel/nspr \ libre2.so:devel/re2 \ libcairo.so:graphics/cairo \ libdrm.so:graphics/libdrm \ libexif.so:graphics/libexif \ libpng.so:graphics/png \ libwebp.so:graphics/webp \ libopenh264.so:multimedia/openh264 \ libfreetype.so:print/freetype2 \ libharfbuzz.so:print/harfbuzz \ libharfbuzz-icu.so:print/harfbuzz-icu \ libgcrypt.so:security/libgcrypt \ libsecret-1.so:security/libsecret \ libnss3.so:security/nss \ libexpat.so:textproc/expat2 \ libfontconfig.so:x11-fonts/fontconfig \ libwayland-client.so:graphics/wayland \ libxkbcommon.so:x11/libxkbcommon \ libxshmfence.so:x11/libxshmfence RUN_DEPENDS= xdg-open:devel/xdg-utils \ noto-basic>0:x11-fonts/noto-basic USES= bison compiler:c++17-lang cpe desktop-file-utils gl gnome iconv:wchar_t jpeg \ localbase:ldflags ninja perl5 pkgconfig python:3.7+,build qt:5 shebangfix \ tar:xz xorg CPE_VENDOR= google CPE_PRODUCT= chrome USE_GL= gbm gl USE_GNOME= atk dconf gdkpixbuf2 glib20 gtk30 libxml2 libxslt USE_LDCONFIG= ${DATADIR} USE_PERL5= build USE_XORG= x11 xcb xcomposite xcursor xext xdamage xfixes xi \ xorgproto xrandr xrender xscrnsaver xtst USE_QT= buildtools:build SHEBANG_FILES= chrome/tools/build/linux/chrome-wrapper buildtools/linux64/clang-format MAKE_ARGS= -C out/${BUILDTYPE} ALL_TARGET= chrome BINARY_ALIAS= python3=${PYTHON_CMD} \ moc=${PREFIX}/bin/moc-qt5 # TODO bz@ : install libwidevinecdm.so (see third_party/widevine/cdm/BUILD.gn) # # Run "./out/${BUILDTYPE}/gn args out/${BUILDTYPE} --list" for all variables. # Some parts don't have use_system_* flag, and can be turned on/off by using # replace_gn_files.py script, some parts just turned on/off for target host # OS "target_os == is_bsd", like libusb, libpci. GN_ARGS+= clang_use_chrome_plugins=false \ enable_backup_ref_ptr_support=false \ enable_hangout_services_extension=true \ enable_nacl=false \ enable_remoting=false \ fatal_linker_warnings=false \ icu_use_data_file=false \ is_clang=true \ optimize_webui=true \ toolkit_views=true \ treat_warnings_as_errors=false \ use_allocator_shim=false \ use_aura=true \ use_custom_libcxx=false \ use_gnome_keyring=false \ use_lld=true \ use_partition_alloc=true \ use_partition_alloc_as_malloc=false \ use_sysroot=false \ use_system_freetype=false \ use_system_harfbuzz=true \ use_system_libffi=true \ use_system_libjpeg=true \ use_udev=false \ extra_cxxflags="${CXXFLAGS}" \ extra_ldflags="${LDFLAGS}" # TODO: investigate building with these options: # use_system_minigbm GN_BOOTSTRAP_FLAGS= --no-clean --no-rebuild --skip-generate-buildfiles # FreeBSD Chromium Api Key # Set up Google API keys, see http://www.chromium.org/developers/how-tos/api-keys . # Note: these are for FreeBSD use ONLY. For your own distribution, # please get your own set of keys. GN_ARGS+= google_api_key="AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8" SUB_FILES= chromium-browser.desktop chrome SUB_LIST+= COMMENT="${COMMENT}" OPTIONS_DEFINE= CODECS CUPS DEBUG DRIVER KERBEROS LTO TEST OPTIONS_DEFAULT= CODECS CUPS DRIVER KERBEROS SNDIO OPTIONS_EXCLUDE_aarch64=LTO OPTIONS_GROUP= AUDIO OPTIONS_GROUP_AUDIO= ALSA PULSEAUDIO SNDIO OPTIONS_RADIO= KERBEROS OPTIONS_RADIO_KERBEROS= HEIMDAL HEIMDAL_BASE MIT OPTIONS_SUB= yes CODECS_DESC= Compile and enable patented codecs like H.264 DRIVER_DESC= Install chromedriver HEIMDAL_BASE_DESC= Heimdal Kerberos (base) HEIMDAL_DESC= Heimdal Kerberos (security/heimdal) MIT_DESC= MIT Kerberos (security/krb5) ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib ALSA_RUN_DEPENDS= ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:audio/alsa-plugins \ alsa-lib>=1.1.1_1:audio/alsa-lib ALSA_VARS= GN_ARGS+=use_alsa=true ALSA_VARS_OFF= GN_ARGS+=use_alsa=false CODECS_VARS= GN_ARGS+=ffmpeg_branding="Chrome" \ GN_ARGS+=proprietary_codecs=true CODECS_VARS_OFF= GN_ARGS+=ffmpeg_branding="Chromium" \ GN_ARGS+=proprietary_codecs=false CUPS_LIB_DEPENDS= libcups.so:print/cups CUPS_VARS= GN_ARGS+=use_cups=true CUPS_VARS_OFF= GN_ARGS+=use_cups=false DEBUG_BUILD_DEPENDS= esbuild:devel/esbuild DEBUG_VARS= BUILDTYPE=Debug \ GN_ARGS+=is_debug=true \ GN_ARGS+=is_component_build=false \ GN_ARGS+=symbol_level=1 \ GN_BOOTSTRAP_FLAGS+=--debug \ WANTSPACE="21 GB" DEBUG_VARS_OFF= BUILDTYPE=Release \ GN_ARGS+=blink_symbol_level=0 \ GN_ARGS+=is_debug=false \ GN_ARGS+=is_official_build=true \ GN_ARGS+=symbol_level=0 \ WANTSPACE="14 GB" DRIVER_MAKE_ARGS= chromedriver HEIMDAL_LIB_DEPENDS= libkrb.so.26:security/heimdal KERBEROS_VARS= GN_ARGS+=use_kerberos=true KERBEROS_VARS_OFF= GN_ARGS+=use_kerberos=false LTO_VARS= GN_ARGS+=use_thin_lto=true \ GN_ARGS+=thin_lto_enable_optimizations=true \ WANTSPACE="14 GB" LTO_VARS_OFF= GN_ARGS+=use_thin_lto=false MIT_LIB_DEPENDS= libkrb.so.3:security/krb5 PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio PULSEAUDIO_VARS= GN_ARGS+=use_pulseaudio=true PULSEAUDIO_VARS_OFF= GN_ARGS+=use_pulseaudio=false # With SNDIO=on we exclude audio_manager_linux from the build (see # media/audio/BUILD.gn) and use audio_manager_openbsd which does not # support falling back to ALSA or PulseAudio. SNDIO_PREVENTS= ALSA PULSEAUDIO SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio SNDIO_VARS= GN_ARGS+=use_sndio=true SNDIO_VARS_OFF= GN_ARGS+=use_sndio=false .include "Makefile.tests" TEST_DISTFILES= ${PORTNAME}-${DISTVERSION}-testdata${EXTRACT_SUFX} \ test_fonts-336e775eec536b2d785cc80eff6ac39051931286.tar.gz:external TEST_ALL_TARGET= ${TEST_TARGETS} .include .include # for COMPILER_VERSION .if ${PORT_OPTIONS:MHEIMDAL_BASE} && !exists(/usr/lib/libkrb5.so) IGNORE= you have selected HEIMDAL_BASE but do not have Heimdal installed in base .endif .if ${COMPILER_VERSION} < 150 LLVM_DEFAULT= 15 BUILD_DEPENDS+= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT} BINARY_ALIAS+= cpp=${LOCALBASE}/bin/clang-cpp${LLVM_DEFAULT} \ cc=${LOCALBASE}/bin/clang${LLVM_DEFAULT} \ c++=${LOCALBASE}/bin/clang++${LLVM_DEFAULT} \ ar=${LOCALBASE}/bin/llvm-ar${LLVM_DEFAULT} \ nm=${LOCALBASE}/bin/llvm-nm${LLVM_DEFAULT} \ ld=${LOCALBASE}/bin/ld.lld${LLVM_DEFAULT} .else BINARY_ALIAS+= ar=/usr/bin/llvm-ar \ nm=/usr/bin/llvm-nm .endif # swiftshader/lib/{libEGL.so,libGLESv2.so} is x86 only .if ${ARCH} == aarch64 PLIST_SUB+= NOT_AARCH64="@comment " .else PLIST_SUB+= NOT_AARCH64="" .endif # Allow relocations against read-only segments (override lld default) LDFLAGS_i386= -Wl,-znotext # TODO: -isystem, would be just as ugly as this approach, but more reliably # build would fail without C_INCLUDE_PATH/CPLUS_INCLUDE_PATH env var set. MAKE_ENV+= C_INCLUDE_PATH=${LOCALBASE}/include \ CPLUS_INCLUDE_PATH=${LOCALBASE}/include pre-everything:: @${ECHO_MSG} @${ECHO_MSG} "To build Chromium, you should have around 2GB of memory" @${ECHO_MSG} "and around ${WANTSPACE} of free disk space." @${ECHO_MSG} post-extract-TEST-on: @${MKDIR} ${WRKSRC}/third_party/test_fonts/test_fonts @${MV} ${WRKDIR}/test_fonts ${WRKSRC}/third_party/test_fonts/ pre-configure: # We used to remove bundled libraries to be sure that chromium uses # system libraries and not shipped ones. # cd ${WRKSRC} && ${PYTHON_CMD} \ #./build/linux/unbundle/remove_bundled_libraries.py [list of preserved] cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \ ./build/linux/unbundle/replace_gn_files.py --system-libraries \ flac fontconfig freetype harfbuzz-ng icu libdrm libevent libpng \ libusb libwebp libxml libxslt openh264 opus snappy || ${FALSE} # Chromium uses an unreleased version of FFmpeg, so configure it .for brand in Chrome Chromium ${CP} -R \ ${WRKSRC}/third_party/ffmpeg/chromium/config/${brand}/linux/ \ ${WRKSRC}/third_party/ffmpeg/chromium/config/${brand}/freebsd .endfor do-configure: # GN generator bootstrapping and generating ninja files cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} CC=${CC} CXX=${CXX} LD=${CXX} \ READELF=${READELF} AR=${AR} NM=${NM} ${PYTHON_CMD} \ ./tools/gn/bootstrap/bootstrap.py ${GN_BOOTSTRAP_FLAGS} cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./out/${BUILDTYPE}/gn \ gen --args='${GN_ARGS}' out/${BUILDTYPE} # Setup nodejs dependency @${MKDIR} ${WRKSRC}/third_party/node/freebsd/node-freebsd/bin ${LN} -sf ${LOCALBASE}/bin/node ${WRKSRC}/third_party/node/freebsd/node-freebsd/bin/node # Setup buildtools/freebsd @${MKDIR} ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/buildtools/linux64/clang-format ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/out/${BUILDTYPE}/gn ${WRKSRC}/buildtools/freebsd ${LN} -sf /usr/bin/strip ${WRKSRC}/buildtools/freebsd/strip do-install: @${MKDIR} ${STAGEDIR}${DATADIR} ${INSTALL_MAN} ${WRKSRC}/chrome/app/resources/manpage.1.in \ ${STAGEDIR}${MANPREFIX}/man/man1/chrome.1 @${SED} -i "" -e 's,\@\@PACKAGE\@\@,chromium,g;s,\@\@MENUNAME\@\@,Chromium Web Browser,g' \ ${STAGEDIR}${MANPREFIX}/man/man1/chrome.1 ${CP} ${WRKSRC}/chrome/app/theme/chromium/product_logo_22_mono.png ${WRKSRC}/chrome/app/theme/chromium/product_logo_22.png .for s in 22 24 48 64 128 256 @${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps ${INSTALL_DATA} ${WRKSRC}/chrome/app/theme/chromium/product_logo_${s}.png \ ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps/chrome.png .endfor ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.png ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.pak ${STAGEDIR}${DATADIR} .for d in protoc mksnapshot ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor .for d in snapshot_blob.bin v8_context_snapshot.bin ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chrome \ ${STAGEDIR}${DATADIR} cd ${WRKSRC}/out/${BUILDTYPE} && \ ${COPYTREE_SHARE} "locales resources" ${STAGEDIR}${DATADIR} @${MKDIR} ${STAGEDIR}${DESKTOPDIR} ${INSTALL_DATA} ${WRKDIR}/chromium-browser.desktop \ ${STAGEDIR}${DESKTOPDIR} ${INSTALL_SCRIPT} ${WRKDIR}/chrome ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${WRKSRC}/chrome/tools/build/linux/chrome-wrapper \ ${STAGEDIR}${DATADIR} # ANGLE, EGL, Vk .for f in libEGL.so libGLESv2.so libVkICD_mock_icd.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/${f} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvulkan.so.1 \ ${STAGEDIR}${DATADIR}/libvulkan.so .if ${BUILDTYPE} == Debug ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libVkLayer_khronos_validation.so ${STAGEDIR}${DATADIR} .endif # SwiftShader .if ${ARCH} != aarch64 ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvk_swiftshader.so ${STAGEDIR}${DATADIR} .endif post-install-DEBUG-on: ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/*.so \ ${STAGEDIR}${DATADIR} ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/character_data_generator \ ${STAGEDIR}${DATADIR} post-install-DRIVER-on: ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chromedriver.unstripped \ ${STAGEDIR}${PREFIX}/bin/chromedriver do-test-TEST-on: .for t in ${TEST_TARGETS} cd ${WRKSRC}/out/${BUILDTYPE} && ${SETENV} LC_ALL=en_US.UTF-8 \ ./${t} --gtest_filter=-${EXCLUDE_${t}:ts:} || ${TRUE} .endfor .include diff --git a/www/chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc b/www/chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc index aca534b2857e..e081a554f13d 100644 --- a/www/chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc +++ b/www/chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc @@ -1,63 +1,358 @@ ---- media/capture/video/linux/v4l2_capture_delegate.cc.orig 2023-04-05 11:05:06 UTC +--- media/capture/video/linux/v4l2_capture_delegate.cc.orig 2023-05-02 13:12:51 UTC +++ media/capture/video/linux/v4l2_capture_delegate.cc @@ -4,8 +4,10 @@ #include "media/capture/video/linux/v4l2_capture_delegate.h" -+#if !defined(OS_BSD) ++#if !BUILDFLAG(IS_BSD) #include #include +#endif #include #include #include -@@ -29,10 +31,10 @@ +@@ -20,7 +22,6 @@ + #include "base/task/single_thread_task_runner.h" + #include "base/trace_event/trace_event.h" + #include "build/build_config.h" +-#include "media/base/bind_to_current_loop.h" + #include "media/base/video_frame.h" + #include "media/base/video_types.h" + #include "media/capture/mojom/image_capture_types.h" +@@ -29,10 +30,12 @@ using media::mojom::MeteringMode; --#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) -+// #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) ++#if !BUILDFLAG(IS_BSD) + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) // 16 bit depth, Realsense F200. #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') --#endif -+// #endif + #endif ++#endif // TODO(aleksandar.stojiljkovic): Wrap this with kernel version check once the // format is introduced to kernel. -@@ -728,7 +730,7 @@ base::WeakPtr V4L2CaptureDelegate +@@ -139,47 +142,6 @@ int GetControllingSpecialControl(int control_id) { + return 0; + } + +-// Determines if |control_id| is special, i.e. controls another one's state. +-bool IsSpecialControl(int control_id) { +- switch (control_id) { +- case V4L2_CID_AUTO_WHITE_BALANCE: +- case V4L2_CID_EXPOSURE_AUTO: +- case V4L2_CID_EXPOSURE_AUTO_PRIORITY: +- case V4L2_CID_FOCUS_AUTO: +- return true; +- } +- return false; +-} +- +-// Determines if |control_id| should be skipped, https://crbug.com/697885. +-#if !defined(V4L2_CID_PAN_SPEED) +-#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32) +-#endif +-#if !defined(V4L2_CID_TILT_SPEED) +-#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33) +-#endif +-#if !defined(V4L2_CID_PANTILT_CMD) +-#define V4L2_CID_PANTILT_CMD (V4L2_CID_CAMERA_CLASS_BASE + 34) +-#endif +-bool IsBlockedControl(int control_id) { +- switch (control_id) { +- case V4L2_CID_PAN_RELATIVE: +- case V4L2_CID_TILT_RELATIVE: +- case V4L2_CID_PAN_RESET: +- case V4L2_CID_TILT_RESET: +- case V4L2_CID_PAN_ABSOLUTE: +- case V4L2_CID_TILT_ABSOLUTE: +- case V4L2_CID_ZOOM_ABSOLUTE: +- case V4L2_CID_ZOOM_RELATIVE: +- case V4L2_CID_ZOOM_CONTINUOUS: +- case V4L2_CID_PAN_SPEED: +- case V4L2_CID_TILT_SPEED: +- case V4L2_CID_PANTILT_CMD: +- return true; +- } +- return false; +-} +- + bool IsNonEmptyRange(const mojom::RangePtr& range) { + return range->min < range->max; + } +@@ -253,6 +215,49 @@ std::vector V4L2CaptureDelegate::GetListOfUs + return supported_formats; + } + ++// Determines if |control_id| is special, i.e. controls another one's state. ++// static ++bool V4L2CaptureDelegate::IsSpecialControl(int control_id) { ++ switch (control_id) { ++ case V4L2_CID_AUTO_WHITE_BALANCE: ++ case V4L2_CID_EXPOSURE_AUTO: ++ case V4L2_CID_EXPOSURE_AUTO_PRIORITY: ++ case V4L2_CID_FOCUS_AUTO: ++ return true; ++ } ++ return false; ++} ++ ++// Determines if |control_id| should be skipped, https://crbug.com/697885. ++#if !defined(V4L2_CID_PAN_SPEED) ++#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32) ++#endif ++#if !defined(V4L2_CID_TILT_SPEED) ++#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33) ++#endif ++#if !defined(V4L2_CID_PANTILT_CMD) ++#define V4L2_CID_PANTILT_CMD (V4L2_CID_CAMERA_CLASS_BASE + 34) ++#endif ++// static ++bool V4L2CaptureDelegate::IsBlockedControl(int control_id) { ++ switch (control_id) { ++ case V4L2_CID_PAN_RELATIVE: ++ case V4L2_CID_TILT_RELATIVE: ++ case V4L2_CID_PAN_RESET: ++ case V4L2_CID_TILT_RESET: ++ case V4L2_CID_PAN_ABSOLUTE: ++ case V4L2_CID_TILT_ABSOLUTE: ++ case V4L2_CID_ZOOM_ABSOLUTE: ++ case V4L2_CID_ZOOM_RELATIVE: ++ case V4L2_CID_ZOOM_CONTINUOUS: ++ case V4L2_CID_PAN_SPEED: ++ case V4L2_CID_TILT_SPEED: ++ case V4L2_CID_PANTILT_CMD: ++ return true; ++ } ++ return false; ++} ++ + V4L2CaptureDelegate::V4L2CaptureDelegate( + V4L2CaptureDevice* v4l2, + const VideoCaptureDeviceDescriptor& device_descriptor, +@@ -728,7 +733,7 @@ base::WeakPtr V4L2CaptureDelegate V4L2CaptureDelegate::~V4L2CaptureDelegate() = default; -bool V4L2CaptureDelegate::RunIoctl(int request, void* argp) { +bool V4L2CaptureDelegate::RunIoctl(unsigned int request, void* argp) { int num_retries = 0; for (; DoIoctl(request, argp) < 0 && num_retries < kMaxIOCtrlRetries; ++num_retries) { -@@ -738,7 +740,7 @@ bool V4L2CaptureDelegate::RunIoctl(int request, void* +@@ -738,7 +743,7 @@ bool V4L2CaptureDelegate::RunIoctl(int request, void* return num_retries != kMaxIOCtrlRetries; } -int V4L2CaptureDelegate::DoIoctl(int request, void* argp) { +int V4L2CaptureDelegate::DoIoctl(unsigned int request, void* argp) { return HANDLE_EINTR(v4l2_->ioctl(device_fd_.get(), request, argp)); } -@@ -778,6 +780,10 @@ bool V4L2CaptureDelegate::IsControllableControl(int co +@@ -778,6 +783,7 @@ bool V4L2CaptureDelegate::IsControllableControl(int co } void V4L2CaptureDelegate::ReplaceControlEventSubscriptions() { -+// these ioctls are not implemented on *BSDs -+#if BUILDFLAG(IS_BSD) -+ NOTIMPLEMENTED(); -+#else ++#if !BUILDFLAG(IS_BSD) constexpr uint32_t kControlIds[] = {V4L2_CID_AUTO_EXPOSURE_BIAS, V4L2_CID_AUTO_WHITE_BALANCE, V4L2_CID_BRIGHTNESS, @@ -805,6 +811,7 @@ void V4L2CaptureDelegate::ReplaceControlEventSubscript << ", {type = V4L2_EVENT_CTRL, id = " << control_id << "}"; } } +#endif } mojom::RangePtr V4L2CaptureDelegate::RetrieveUserControlRange(int control_id) { +@@ -829,100 +836,89 @@ mojom::RangePtr V4L2CaptureDelegate::RetrieveUserContr + } + + void V4L2CaptureDelegate::ResetUserAndCameraControlsToDefault() { +- // Set V4L2_CID_AUTO_WHITE_BALANCE to false first. +- v4l2_control auto_white_balance = {}; +- auto_white_balance.id = V4L2_CID_AUTO_WHITE_BALANCE; +- auto_white_balance.value = false; +- if (!RunIoctl(VIDIOC_S_CTRL, &auto_white_balance)) +- return; +- +- std::vector special_camera_controls; +- // Set V4L2_CID_EXPOSURE_AUTO to V4L2_EXPOSURE_MANUAL. +- v4l2_ext_control auto_exposure = {}; +- auto_exposure.id = V4L2_CID_EXPOSURE_AUTO; +- auto_exposure.value = V4L2_EXPOSURE_MANUAL; +- special_camera_controls.push_back(auto_exposure); +- // Set V4L2_CID_EXPOSURE_AUTO_PRIORITY to false. +- v4l2_ext_control priority_auto_exposure = {}; +- priority_auto_exposure.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY; +- priority_auto_exposure.value = false; +- special_camera_controls.push_back(priority_auto_exposure); +- // Set V4L2_CID_FOCUS_AUTO to false. +- v4l2_ext_control auto_focus = {}; +- auto_focus.id = V4L2_CID_FOCUS_AUTO; +- auto_focus.value = false; +- special_camera_controls.push_back(auto_focus); +- + struct v4l2_ext_controls ext_controls = {}; +- ext_controls.ctrl_class = V4L2_CID_CAMERA_CLASS; +- ext_controls.count = special_camera_controls.size(); +- ext_controls.controls = special_camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) +- DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ ext_controls.which = V4L2_CTRL_WHICH_CUR_VAL; ++ ext_controls.count = 0; ++ const bool use_modern_s_ext_ctrls = ++ DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) == 0; + + for (const auto& control : kControls) { + std::vector camera_controls; ++ std::vector manual_special_camera_controls; ++ std::vector special_camera_controls; + + v4l2_queryctrl range = {}; +- range.id = control.control_base | V4L2_CTRL_FLAG_NEXT_CTRL; ++ // Start right below the base so that the first next retrieved control ID ++ // is always the first available control ID within the class even if that ++ // control ID is equal to the base (V4L2_CID_BRIGHTNESS equals to ++ // V4L2_CID_USER_BASE). ++ range.id = (control.control_base - 1) | V4L2_CTRL_FLAG_NEXT_CTRL; + while (0 == DoIoctl(VIDIOC_QUERYCTRL, &range)) { + if (V4L2_CTRL_ID2CLASS(range.id) != V4L2_CTRL_ID2CLASS(control.class_id)) + break; ++ ++ v4l2_ext_control ext_control = {}; ++ ext_control.id = range.id; ++ ext_control.value = range.default_value; ++ ++ // Prepare to query for the next control as `range` is an in-out ++ // parameter. + range.id |= V4L2_CTRL_FLAG_NEXT_CTRL; + +- if (IsSpecialControl(range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) ++ if (range.flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_READ_ONLY)) { ++ // Permanently disabled or permanently read-only. + continue; +- if (IsBlockedControl(range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) ++ } ++ if (IsBlockedControl(ext_control.id)) { + continue; ++ } + +- struct v4l2_ext_control ext_control = {}; +- ext_control.id = range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL; +- ext_control.value = range.default_value; +- camera_controls.push_back(ext_control); ++ if (IsSpecialControl(ext_control.id)) { ++ special_camera_controls.push_back(ext_control); ++ if (ext_control.id == V4L2_CID_EXPOSURE_AUTO) { ++ ext_control.value = V4L2_EXPOSURE_MANUAL; ++ } else { ++ ext_control.value = false; // Not automatic but manual. ++ } ++ manual_special_camera_controls.push_back(ext_control); ++ } else { ++ camera_controls.push_back(ext_control); ++ } + } + + if (!camera_controls.empty()) { +- struct v4l2_ext_controls ext_controls2 = {}; +- ext_controls2.ctrl_class = control.class_id; +- ext_controls2.count = camera_controls.size(); +- ext_controls2.controls = camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls2) < 0) ++ // Set special controls to manual modes first. ++ if (!manual_special_camera_controls.empty()) { ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = manual_special_camera_controls.size(); ++ ext_controls.controls = manual_special_camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { ++ DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } ++ } ++ ++ // Set non-special controls to the default values. ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = camera_controls.size(); ++ ext_controls.controls = camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { + DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } + } +- } + +- // Now set the special flags to the default values +- v4l2_queryctrl range = {}; +- range.id = V4L2_CID_AUTO_WHITE_BALANCE; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_white_balance.value = range.default_value; +- DoIoctl(VIDIOC_S_CTRL, &auto_white_balance); +- +- special_camera_controls.clear(); +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_EXPOSURE_AUTO; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_exposure.value = range.default_value; +- special_camera_controls.push_back(auto_exposure); +- +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- priority_auto_exposure.value = range.default_value; +- special_camera_controls.push_back(priority_auto_exposure); +- +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_FOCUS_AUTO; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_focus.value = range.default_value; +- special_camera_controls.push_back(auto_focus); +- +- memset(&ext_controls, 0, sizeof(ext_controls)); +- ext_controls.ctrl_class = V4L2_CID_CAMERA_CLASS; +- ext_controls.count = special_camera_controls.size(); +- ext_controls.controls = special_camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) +- DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ // Set special controls to the default values. ++ if (!special_camera_controls.empty()) { ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = special_camera_controls.size(); ++ ext_controls.controls = special_camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { ++ DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } ++ } ++ } + } + + bool V4L2CaptureDelegate::MapAndQueueBuffer(int index) { +@@ -985,7 +981,11 @@ void V4L2CaptureDelegate::DoCapture() { + + pollfd device_pfd = {}; + device_pfd.fd = device_fd_.get(); ++#if !BUILDFLAG(IS_BSD) + device_pfd.events = POLLIN | POLLPRI; ++#else ++ device_pfd.events = POLLIN; ++#endif + + const int result = + HANDLE_EINTR(v4l2_->poll(&device_pfd, 1, kCaptureTimeoutMs)); +@@ -1023,6 +1023,7 @@ void V4L2CaptureDelegate::DoCapture() { + timeout_count_ = 0; + } + ++#if !BUILDFLAG(IS_BSD) + // Dequeue events if the driver has filled in some. + if (device_pfd.revents & POLLPRI) { + bool controls_changed = false; +@@ -1057,6 +1058,7 @@ void V4L2CaptureDelegate::DoCapture() { + client_->OnCaptureConfigurationChanged(); + } + } ++#endif + + // Deenqueue, send and reenqueue a buffer if the driver has filled one in. + if (device_pfd.revents & POLLIN) { diff --git a/www/iridium/Makefile b/www/iridium/Makefile index d1053b9cbcff..b234d222a8d9 100644 --- a/www/iridium/Makefile +++ b/www/iridium/Makefile @@ -1,324 +1,325 @@ PORTNAME= iridium PORTVERSION= 2023.04.112.2 +PORTREVISION= 1 CATEGORIES= www wayland MASTER_SITES= https://downloads.iridiumbrowser.de/source/ PKGNAMESUFFIX= -browser DISTNAME= ${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION} MAINTAINER= chromium@FreeBSD.org COMMENT= Iridium browser WWW= https://iridiumbrowser.de/ LICENSE= BSD3CLAUSE LGPL21 MPL11 LICENSE_COMB= multi ONLY_FOR_ARCHS= aarch64 amd64 i386 PATCH_SITES= https://nerd.hu/distfiles/ PATCHFILES+= disable-privacy-sandbox-ce036275d9d21a8408ef48ee9839b3c21b8448ca.patch:-p1 BUILD_DEPENDS= bash:shells/bash \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR} \ gperf:devel/gperf \ flock:sysutils/flock \ node:www/node \ xcb-proto>0:x11/xcb-proto \ ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \ ${LOCALBASE}/share/usbids/usb.ids:misc/usbids \ ${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} \ ${LOCALBASE}/include/va/va.h:multimedia/libva \ ${LOCALBASE}/libdata/pkgconfig/dri.pc:graphics/mesa-dri \ ${LOCALBASE}/libdata/pkgconfig/Qt5Core.pc:devel/qt5-core \ ${LOCALBASE}/libdata/pkgconfig/Qt5Widgets.pc:x11-toolkits/qt5-widgets LIB_DEPENDS= libatk-bridge-2.0.so:accessibility/at-spi2-core \ libatspi.so:accessibility/at-spi2-core \ libspeechd.so:accessibility/speech-dispatcher \ libsnappy.so:archivers/snappy \ libFLAC.so:audio/flac \ libopus.so:audio/opus \ libspeex.so:audio/speex \ libdbus-1.so:devel/dbus \ libdbus-glib-1.so:devel/dbus-glib \ libepoll-shim.so:devel/libepoll-shim \ libevent.so:devel/libevent \ libffi.so:devel/libffi \ libicuuc.so:devel/icu \ libjsoncpp.so:devel/jsoncpp \ libpci.so:devel/libpci \ libnspr4.so:devel/nspr \ libre2.so:devel/re2 \ libcairo.so:graphics/cairo \ libdrm.so:graphics/libdrm \ libexif.so:graphics/libexif \ libpng.so:graphics/png \ libwebp.so:graphics/webp \ libopenh264.so:multimedia/openh264 \ libfreetype.so:print/freetype2 \ libharfbuzz.so:print/harfbuzz \ libharfbuzz-icu.so:print/harfbuzz-icu \ libgcrypt.so:security/libgcrypt \ libsecret-1.so:security/libsecret \ libnss3.so:security/nss \ libexpat.so:textproc/expat2 \ libfontconfig.so:x11-fonts/fontconfig \ libwayland-client.so:graphics/wayland \ libxkbcommon.so:x11/libxkbcommon \ libxshmfence.so:x11/libxshmfence RUN_DEPENDS= xdg-open:devel/xdg-utils \ noto-basic>0:x11-fonts/noto-basic USES= bison compiler:c++17-lang cpe desktop-file-utils gl gnome iconv:wchar_t jpeg \ localbase:ldflags ninja perl5 pkgconfig python:3.7+,build qt:5 shebangfix \ tar:xz xorg CPE_VENDOR= google CPE_PRODUCT= chrome USE_GL= gbm gl USE_GNOME= atk dconf gdkpixbuf2 glib20 gtk30 libxml2 libxslt USE_LDCONFIG= ${DATADIR} USE_PERL5= build USE_XORG= x11 xcb xcomposite xcursor xext xdamage xfixes xi \ xorgproto xrandr xrender xscrnsaver xtst USE_QT= buildtools:build SHEBANG_FILES= chrome/tools/build/linux/chrome-wrapper buildtools/linux64/clang-format MAKE_ARGS= -C out/${BUILDTYPE} ALL_TARGET= chrome BINARY_ALIAS= python3=${PYTHON_CMD} \ moc=${PREFIX}/bin/moc-qt5 # TODO bz@ : install libwidevinecdm.so (see third_party/widevine/cdm/BUILD.gn) # # Run "./out/${BUILDTYPE}/gn args out/${BUILDTYPE} --list" for all variables. # Some parts don't have use_system_* flag, and can be turned on/off by using # replace_gn_files.py script, some parts just turned on/off for target host # OS "target_os == is_bsd", like libusb, libpci. GN_ARGS+= clang_use_chrome_plugins=false \ chrome_pgo_phase=0 \ enable_backup_ref_ptr_support=false \ enable_hangout_services_extension=true \ enable_nacl=false \ enable_remoting=false \ fatal_linker_warnings=false \ icu_use_data_file=false \ is_clang=true \ optimize_webui=true \ toolkit_views=true \ treat_warnings_as_errors=false \ use_allocator_shim=false \ use_aura=true \ use_custom_libcxx=false \ use_gnome_keyring=false \ use_lld=true \ use_partition_alloc=true \ use_partition_alloc_as_malloc=false \ use_sysroot=false \ use_system_freetype=false \ use_system_harfbuzz=true \ use_system_libjpeg=true \ use_udev=false \ extra_cxxflags="${CXXFLAGS}" \ extra_ldflags="${LDFLAGS}" # TODO: investigate building with these options: # use_system_minigbm GN_BOOTSTRAP_FLAGS= --no-clean --no-rebuild --skip-generate-buildfiles SUB_FILES= iridium-browser.desktop iridium SUB_LIST+= COMMENT="${COMMENT}" OPTIONS_DEFINE= CODECS CUPS DEBUG KERBEROS LTO OPTIONS_DEFAULT= CODECS CUPS KERBEROS SNDIO OPTIONS_EXCLUDE_aarch64=LTO OPTIONS_GROUP= AUDIO OPTIONS_GROUP_AUDIO= ALSA PULSEAUDIO SNDIO OPTIONS_RADIO= KERBEROS OPTIONS_RADIO_KERBEROS= HEIMDAL HEIMDAL_BASE MIT OPTIONS_SUB= yes CODECS_DESC= Compile and enable patented codecs like H.264 HEIMDAL_BASE_DESC= Heimdal Kerberos (base) HEIMDAL_DESC= Heimdal Kerberos (security/heimdal) MIT_DESC= MIT Kerberos (security/krb5) ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib ALSA_RUN_DEPENDS= ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:audio/alsa-plugins \ alsa-lib>=1.1.1_1:audio/alsa-lib ALSA_VARS= GN_ARGS+=use_alsa=true ALSA_VARS_OFF= GN_ARGS+=use_alsa=false CODECS_VARS= GN_ARGS+=ffmpeg_branding="Chrome" \ GN_ARGS+=proprietary_codecs=true CODECS_VARS_OFF= GN_ARGS+=ffmpeg_branding="Chromium" \ GN_ARGS+=proprietary_codecs=false CUPS_LIB_DEPENDS= libcups.so:print/cups CUPS_VARS= GN_ARGS+=use_cups=true CUPS_VARS_OFF= GN_ARGS+=use_cups=false DEBUG_VARS= BUILDTYPE=Debug \ GN_ARGS+=is_debug=true \ GN_ARGS+=is_component_build=false \ GN_ARGS+=symbol_level=1 \ GN_BOOTSTRAP_FLAGS+=--debug \ WANTSPACE="21 GB" DEBUG_VARS_OFF= BUILDTYPE=Release \ GN_ARGS+=blink_symbol_level=0 \ GN_ARGS+=is_debug=false \ GN_ARGS+=is_official_build=true \ GN_ARGS+=symbol_level=0 \ WANTSPACE="14 GB" HEIMDAL_LIB_DEPENDS= libkrb.so.26:security/heimdal KERBEROS_VARS= GN_ARGS+=use_kerberos=true KERBEROS_VARS_OFF= GN_ARGS+=use_kerberos=false LTO_VARS= GN_ARGS+=use_thin_lto=true \ GN_ARGS+=thin_lto_enable_optimizations=true \ WANTSPACE="14 GB" LTO_VARS_OFF= GN_ARGS+=use_thin_lto=false MIT_LIB_DEPENDS= libkrb.so.3:security/krb5 PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio PULSEAUDIO_VARS= GN_ARGS+=use_pulseaudio=true PULSEAUDIO_VARS_OFF= GN_ARGS+=use_pulseaudio=false # With SNDIO=on we exclude audio_manager_linux from the build (see # media/audio/BUILD.gn) and use audio_manager_openbsd which does not # support falling back to ALSA or PulseAudio. SNDIO_PREVENTS= ALSA PULSEAUDIO SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio SNDIO_VARS= GN_ARGS+=use_sndio=true SNDIO_VARS_OFF= GN_ARGS+=use_sndio=false .include .include # for COMPILER_VERSION .if ${PORT_OPTIONS:MHEIMDAL_BASE} && !exists(/usr/lib/libkrb5.so) IGNORE= you have selected HEIMDAL_BASE but do not have Heimdal installed in base .endif .if ${COMPILER_VERSION} < 150 LLVM_DEFAULT= 15 BUILD_DEPENDS+= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT} BINARY_ALIAS+= cpp=${LOCALBASE}/bin/clang-cpp${LLVM_DEFAULT} \ cc=${LOCALBASE}/bin/clang${LLVM_DEFAULT} \ c++=${LOCALBASE}/bin/clang++${LLVM_DEFAULT} \ ar=${LOCALBASE}/bin/llvm-ar${LLVM_DEFAULT} \ nm=${LOCALBASE}/bin/llvm-nm${LLVM_DEFAULT} \ ld=${LOCALBASE}/bin/ld.lld${LLVM_DEFAULT} .else BINARY_ALIAS+= ar=/usr/bin/llvm-ar \ nm=/usr/bin/llvm-nm .endif # swiftshader/lib/{libEGL.so,libGLESv2.so} is x86 only .if ${ARCH} == aarch64 PLIST_SUB+= NOT_AARCH64="@comment " .else PLIST_SUB+= NOT_AARCH64="" .endif # Allow relocations against read-only segments (override lld default) LDFLAGS_i386= -Wl,-znotext # TODO: -isystem, would be just as ugly as this approach, but more reliably # build would fail without C_INCLUDE_PATH/CPLUS_INCLUDE_PATH env var set. MAKE_ENV+= C_INCLUDE_PATH=${LOCALBASE}/include \ CPLUS_INCLUDE_PATH=${LOCALBASE}/include pre-everything:: @${ECHO_MSG} @${ECHO_MSG} "To build Iridium, you should have around 2GB of memory" @${ECHO_MSG} "and around ${WANTSPACE} of free disk space." @${ECHO_MSG} pre-configure: # We used to remove bundled libraries to be sure that chromium uses # system libraries and not shipped ones. # cd ${WRKSRC} && ${PYTHON_CMD} \ #./build/linux/unbundle/remove_bundled_libraries.py [list of preserved] cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \ ./build/linux/unbundle/replace_gn_files.py --system-libraries \ flac fontconfig freetype harfbuzz-ng icu libdrm libevent libpng \ libusb libwebp libxml libxslt openh264 opus snappy || ${FALSE} # Iridium uses an unreleased version of FFmpeg, so configure it .for brand in Chrome Chromium ${CP} -R \ ${WRKSRC}/third_party/ffmpeg/chromium/config/${brand}/linux/ \ ${WRKSRC}/third_party/ffmpeg/chromium/config/${brand}/freebsd .endfor do-configure: # GN generator bootstrapping and generating ninja files cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} CC=${CC} CXX=${CXX} LD=${CXX} \ READELF=${READELF} AR=${AR} NM=${NM} ${PYTHON_CMD} \ ./tools/gn/bootstrap/bootstrap.py ${GN_BOOTSTRAP_FLAGS} cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./out/${BUILDTYPE}/gn \ gen --args='${GN_ARGS}' out/${BUILDTYPE} # Setup nodejs dependency @${MKDIR} ${WRKSRC}/third_party/node/freebsd/node-freebsd/bin ${LN} -sf ${LOCALBASE}/bin/node ${WRKSRC}/third_party/node/freebsd/node-freebsd/bin/node # Setup buildtools/freebsd @${MKDIR} ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/buildtools/linux64/clang-format ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/out/${BUILDTYPE}/gn ${WRKSRC}/buildtools/freebsd ${LN} -sf /usr/bin/strip ${WRKSRC}/buildtools/freebsd/strip do-install: @${MKDIR} ${STAGEDIR}${DATADIR} ${INSTALL_MAN} ${WRKSRC}/chrome/app/resources/manpage.1.in \ ${STAGEDIR}${MANPREFIX}/man/man1/iridium.1 @${SED} -i "" -e 's,\@\@PACKAGE\@\@,chromium,g;s,\@\@MENUNAME\@\@,Iridium Web Browser,g' \ ${STAGEDIR}${MANPREFIX}/man/man1/iridium.1 ${CP} ${WRKSRC}/chrome/app/theme/chromium/product_logo_22_mono.png ${WRKSRC}/chrome/app/theme/chromium/product_logo_22.png .for s in 22 24 48 64 128 256 @${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps ${INSTALL_DATA} ${WRKSRC}/chrome/app/theme/chromium/product_logo_${s}.png \ ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps/iridium.png .endfor ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.png ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.pak ${STAGEDIR}${DATADIR} .for d in protoc mksnapshot ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor .for d in snapshot_blob.bin v8_context_snapshot.bin ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chrome \ ${STAGEDIR}${DATADIR}/iridium cd ${WRKSRC}/out/${BUILDTYPE} && \ ${COPYTREE_SHARE} "locales resources" ${STAGEDIR}${DATADIR} @${MKDIR} ${STAGEDIR}${DESKTOPDIR} ${INSTALL_DATA} ${WRKDIR}/iridium-browser.desktop \ ${STAGEDIR}${DESKTOPDIR} ${INSTALL_SCRIPT} ${WRKDIR}/iridium ${STAGEDIR}${PREFIX}/bin # ANGLE, EGL, Vk .for f in libEGL.so libGLESv2.so libVkICD_mock_icd.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/${f} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvulkan.so.1 \ ${STAGEDIR}${DATADIR}/libvulkan.so .if ${BUILDTYPE} == Debug ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libVkLayer_khronos_validation.so ${STAGEDIR}${DATADIR} .endif # SwiftShader .if ${ARCH} != aarch64 @${MKDIR} ${STAGEDIR}${DATADIR}/swiftshader ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvk_swiftshader.so ${STAGEDIR}${DATADIR} .endif post-install-DEBUG-on: ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/*.so \ ${STAGEDIR}${DATADIR} ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/character_data_generator \ ${STAGEDIR}${DATADIR} .include diff --git a/www/iridium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc b/www/iridium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc index 8662b6dde53c..e081a554f13d 100644 --- a/www/iridium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc +++ b/www/iridium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc @@ -1,63 +1,358 @@ ---- media/capture/video/linux/v4l2_capture_delegate.cc.orig 2023-04-22 17:45:15 UTC +--- media/capture/video/linux/v4l2_capture_delegate.cc.orig 2023-05-02 13:12:51 UTC +++ media/capture/video/linux/v4l2_capture_delegate.cc @@ -4,8 +4,10 @@ #include "media/capture/video/linux/v4l2_capture_delegate.h" -+#if !defined(OS_BSD) ++#if !BUILDFLAG(IS_BSD) #include #include +#endif #include #include #include -@@ -29,10 +31,10 @@ +@@ -20,7 +22,6 @@ + #include "base/task/single_thread_task_runner.h" + #include "base/trace_event/trace_event.h" + #include "build/build_config.h" +-#include "media/base/bind_to_current_loop.h" + #include "media/base/video_frame.h" + #include "media/base/video_types.h" + #include "media/capture/mojom/image_capture_types.h" +@@ -29,10 +30,12 @@ using media::mojom::MeteringMode; --#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) -+// #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) ++#if !BUILDFLAG(IS_BSD) + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) // 16 bit depth, Realsense F200. #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') --#endif -+// #endif + #endif ++#endif // TODO(aleksandar.stojiljkovic): Wrap this with kernel version check once the // format is introduced to kernel. -@@ -728,7 +730,7 @@ base::WeakPtr V4L2CaptureDelegate +@@ -139,47 +142,6 @@ int GetControllingSpecialControl(int control_id) { + return 0; + } + +-// Determines if |control_id| is special, i.e. controls another one's state. +-bool IsSpecialControl(int control_id) { +- switch (control_id) { +- case V4L2_CID_AUTO_WHITE_BALANCE: +- case V4L2_CID_EXPOSURE_AUTO: +- case V4L2_CID_EXPOSURE_AUTO_PRIORITY: +- case V4L2_CID_FOCUS_AUTO: +- return true; +- } +- return false; +-} +- +-// Determines if |control_id| should be skipped, https://crbug.com/697885. +-#if !defined(V4L2_CID_PAN_SPEED) +-#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32) +-#endif +-#if !defined(V4L2_CID_TILT_SPEED) +-#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33) +-#endif +-#if !defined(V4L2_CID_PANTILT_CMD) +-#define V4L2_CID_PANTILT_CMD (V4L2_CID_CAMERA_CLASS_BASE + 34) +-#endif +-bool IsBlockedControl(int control_id) { +- switch (control_id) { +- case V4L2_CID_PAN_RELATIVE: +- case V4L2_CID_TILT_RELATIVE: +- case V4L2_CID_PAN_RESET: +- case V4L2_CID_TILT_RESET: +- case V4L2_CID_PAN_ABSOLUTE: +- case V4L2_CID_TILT_ABSOLUTE: +- case V4L2_CID_ZOOM_ABSOLUTE: +- case V4L2_CID_ZOOM_RELATIVE: +- case V4L2_CID_ZOOM_CONTINUOUS: +- case V4L2_CID_PAN_SPEED: +- case V4L2_CID_TILT_SPEED: +- case V4L2_CID_PANTILT_CMD: +- return true; +- } +- return false; +-} +- + bool IsNonEmptyRange(const mojom::RangePtr& range) { + return range->min < range->max; + } +@@ -253,6 +215,49 @@ std::vector V4L2CaptureDelegate::GetListOfUs + return supported_formats; + } + ++// Determines if |control_id| is special, i.e. controls another one's state. ++// static ++bool V4L2CaptureDelegate::IsSpecialControl(int control_id) { ++ switch (control_id) { ++ case V4L2_CID_AUTO_WHITE_BALANCE: ++ case V4L2_CID_EXPOSURE_AUTO: ++ case V4L2_CID_EXPOSURE_AUTO_PRIORITY: ++ case V4L2_CID_FOCUS_AUTO: ++ return true; ++ } ++ return false; ++} ++ ++// Determines if |control_id| should be skipped, https://crbug.com/697885. ++#if !defined(V4L2_CID_PAN_SPEED) ++#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32) ++#endif ++#if !defined(V4L2_CID_TILT_SPEED) ++#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33) ++#endif ++#if !defined(V4L2_CID_PANTILT_CMD) ++#define V4L2_CID_PANTILT_CMD (V4L2_CID_CAMERA_CLASS_BASE + 34) ++#endif ++// static ++bool V4L2CaptureDelegate::IsBlockedControl(int control_id) { ++ switch (control_id) { ++ case V4L2_CID_PAN_RELATIVE: ++ case V4L2_CID_TILT_RELATIVE: ++ case V4L2_CID_PAN_RESET: ++ case V4L2_CID_TILT_RESET: ++ case V4L2_CID_PAN_ABSOLUTE: ++ case V4L2_CID_TILT_ABSOLUTE: ++ case V4L2_CID_ZOOM_ABSOLUTE: ++ case V4L2_CID_ZOOM_RELATIVE: ++ case V4L2_CID_ZOOM_CONTINUOUS: ++ case V4L2_CID_PAN_SPEED: ++ case V4L2_CID_TILT_SPEED: ++ case V4L2_CID_PANTILT_CMD: ++ return true; ++ } ++ return false; ++} ++ + V4L2CaptureDelegate::V4L2CaptureDelegate( + V4L2CaptureDevice* v4l2, + const VideoCaptureDeviceDescriptor& device_descriptor, +@@ -728,7 +733,7 @@ base::WeakPtr V4L2CaptureDelegate V4L2CaptureDelegate::~V4L2CaptureDelegate() = default; -bool V4L2CaptureDelegate::RunIoctl(int request, void* argp) { +bool V4L2CaptureDelegate::RunIoctl(unsigned int request, void* argp) { int num_retries = 0; for (; DoIoctl(request, argp) < 0 && num_retries < kMaxIOCtrlRetries; ++num_retries) { -@@ -738,7 +740,7 @@ bool V4L2CaptureDelegate::RunIoctl(int request, void* +@@ -738,7 +743,7 @@ bool V4L2CaptureDelegate::RunIoctl(int request, void* return num_retries != kMaxIOCtrlRetries; } -int V4L2CaptureDelegate::DoIoctl(int request, void* argp) { +int V4L2CaptureDelegate::DoIoctl(unsigned int request, void* argp) { return HANDLE_EINTR(v4l2_->ioctl(device_fd_.get(), request, argp)); } -@@ -778,6 +780,10 @@ bool V4L2CaptureDelegate::IsControllableControl(int co +@@ -778,6 +783,7 @@ bool V4L2CaptureDelegate::IsControllableControl(int co } void V4L2CaptureDelegate::ReplaceControlEventSubscriptions() { -+// these ioctls are not implemented on *BSDs -+#if BUILDFLAG(IS_BSD) -+ NOTIMPLEMENTED(); -+#else ++#if !BUILDFLAG(IS_BSD) constexpr uint32_t kControlIds[] = {V4L2_CID_AUTO_EXPOSURE_BIAS, V4L2_CID_AUTO_WHITE_BALANCE, V4L2_CID_BRIGHTNESS, @@ -805,6 +811,7 @@ void V4L2CaptureDelegate::ReplaceControlEventSubscript << ", {type = V4L2_EVENT_CTRL, id = " << control_id << "}"; } } +#endif } mojom::RangePtr V4L2CaptureDelegate::RetrieveUserControlRange(int control_id) { +@@ -829,100 +836,89 @@ mojom::RangePtr V4L2CaptureDelegate::RetrieveUserContr + } + + void V4L2CaptureDelegate::ResetUserAndCameraControlsToDefault() { +- // Set V4L2_CID_AUTO_WHITE_BALANCE to false first. +- v4l2_control auto_white_balance = {}; +- auto_white_balance.id = V4L2_CID_AUTO_WHITE_BALANCE; +- auto_white_balance.value = false; +- if (!RunIoctl(VIDIOC_S_CTRL, &auto_white_balance)) +- return; +- +- std::vector special_camera_controls; +- // Set V4L2_CID_EXPOSURE_AUTO to V4L2_EXPOSURE_MANUAL. +- v4l2_ext_control auto_exposure = {}; +- auto_exposure.id = V4L2_CID_EXPOSURE_AUTO; +- auto_exposure.value = V4L2_EXPOSURE_MANUAL; +- special_camera_controls.push_back(auto_exposure); +- // Set V4L2_CID_EXPOSURE_AUTO_PRIORITY to false. +- v4l2_ext_control priority_auto_exposure = {}; +- priority_auto_exposure.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY; +- priority_auto_exposure.value = false; +- special_camera_controls.push_back(priority_auto_exposure); +- // Set V4L2_CID_FOCUS_AUTO to false. +- v4l2_ext_control auto_focus = {}; +- auto_focus.id = V4L2_CID_FOCUS_AUTO; +- auto_focus.value = false; +- special_camera_controls.push_back(auto_focus); +- + struct v4l2_ext_controls ext_controls = {}; +- ext_controls.ctrl_class = V4L2_CID_CAMERA_CLASS; +- ext_controls.count = special_camera_controls.size(); +- ext_controls.controls = special_camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) +- DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ ext_controls.which = V4L2_CTRL_WHICH_CUR_VAL; ++ ext_controls.count = 0; ++ const bool use_modern_s_ext_ctrls = ++ DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) == 0; + + for (const auto& control : kControls) { + std::vector camera_controls; ++ std::vector manual_special_camera_controls; ++ std::vector special_camera_controls; + + v4l2_queryctrl range = {}; +- range.id = control.control_base | V4L2_CTRL_FLAG_NEXT_CTRL; ++ // Start right below the base so that the first next retrieved control ID ++ // is always the first available control ID within the class even if that ++ // control ID is equal to the base (V4L2_CID_BRIGHTNESS equals to ++ // V4L2_CID_USER_BASE). ++ range.id = (control.control_base - 1) | V4L2_CTRL_FLAG_NEXT_CTRL; + while (0 == DoIoctl(VIDIOC_QUERYCTRL, &range)) { + if (V4L2_CTRL_ID2CLASS(range.id) != V4L2_CTRL_ID2CLASS(control.class_id)) + break; ++ ++ v4l2_ext_control ext_control = {}; ++ ext_control.id = range.id; ++ ext_control.value = range.default_value; ++ ++ // Prepare to query for the next control as `range` is an in-out ++ // parameter. + range.id |= V4L2_CTRL_FLAG_NEXT_CTRL; + +- if (IsSpecialControl(range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) ++ if (range.flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_READ_ONLY)) { ++ // Permanently disabled or permanently read-only. + continue; +- if (IsBlockedControl(range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) ++ } ++ if (IsBlockedControl(ext_control.id)) { + continue; ++ } + +- struct v4l2_ext_control ext_control = {}; +- ext_control.id = range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL; +- ext_control.value = range.default_value; +- camera_controls.push_back(ext_control); ++ if (IsSpecialControl(ext_control.id)) { ++ special_camera_controls.push_back(ext_control); ++ if (ext_control.id == V4L2_CID_EXPOSURE_AUTO) { ++ ext_control.value = V4L2_EXPOSURE_MANUAL; ++ } else { ++ ext_control.value = false; // Not automatic but manual. ++ } ++ manual_special_camera_controls.push_back(ext_control); ++ } else { ++ camera_controls.push_back(ext_control); ++ } + } + + if (!camera_controls.empty()) { +- struct v4l2_ext_controls ext_controls2 = {}; +- ext_controls2.ctrl_class = control.class_id; +- ext_controls2.count = camera_controls.size(); +- ext_controls2.controls = camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls2) < 0) ++ // Set special controls to manual modes first. ++ if (!manual_special_camera_controls.empty()) { ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = manual_special_camera_controls.size(); ++ ext_controls.controls = manual_special_camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { ++ DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } ++ } ++ ++ // Set non-special controls to the default values. ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = camera_controls.size(); ++ ext_controls.controls = camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { + DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } + } +- } + +- // Now set the special flags to the default values +- v4l2_queryctrl range = {}; +- range.id = V4L2_CID_AUTO_WHITE_BALANCE; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_white_balance.value = range.default_value; +- DoIoctl(VIDIOC_S_CTRL, &auto_white_balance); +- +- special_camera_controls.clear(); +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_EXPOSURE_AUTO; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_exposure.value = range.default_value; +- special_camera_controls.push_back(auto_exposure); +- +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- priority_auto_exposure.value = range.default_value; +- special_camera_controls.push_back(priority_auto_exposure); +- +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_FOCUS_AUTO; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_focus.value = range.default_value; +- special_camera_controls.push_back(auto_focus); +- +- memset(&ext_controls, 0, sizeof(ext_controls)); +- ext_controls.ctrl_class = V4L2_CID_CAMERA_CLASS; +- ext_controls.count = special_camera_controls.size(); +- ext_controls.controls = special_camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) +- DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ // Set special controls to the default values. ++ if (!special_camera_controls.empty()) { ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = special_camera_controls.size(); ++ ext_controls.controls = special_camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { ++ DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } ++ } ++ } + } + + bool V4L2CaptureDelegate::MapAndQueueBuffer(int index) { +@@ -985,7 +981,11 @@ void V4L2CaptureDelegate::DoCapture() { + + pollfd device_pfd = {}; + device_pfd.fd = device_fd_.get(); ++#if !BUILDFLAG(IS_BSD) + device_pfd.events = POLLIN | POLLPRI; ++#else ++ device_pfd.events = POLLIN; ++#endif + + const int result = + HANDLE_EINTR(v4l2_->poll(&device_pfd, 1, kCaptureTimeoutMs)); +@@ -1023,6 +1023,7 @@ void V4L2CaptureDelegate::DoCapture() { + timeout_count_ = 0; + } + ++#if !BUILDFLAG(IS_BSD) + // Dequeue events if the driver has filled in some. + if (device_pfd.revents & POLLPRI) { + bool controls_changed = false; +@@ -1057,6 +1058,7 @@ void V4L2CaptureDelegate::DoCapture() { + client_->OnCaptureConfigurationChanged(); + } + } ++#endif + + // Deenqueue, send and reenqueue a buffer if the driver has filled one in. + if (device_pfd.revents & POLLIN) { diff --git a/www/ungoogled-chromium/Makefile b/www/ungoogled-chromium/Makefile index 11e19e01f2c7..43d5ecd055af 100644 --- a/www/ungoogled-chromium/Makefile +++ b/www/ungoogled-chromium/Makefile @@ -1,378 +1,379 @@ PORTNAME= ungoogled-chromium PORTVERSION= 112.0.5615.165 UGVERSION= ${DISTVERSION}-1 +PORTREVISION= 1 CATEGORIES= www wayland MASTER_SITES= https://commondatastorage.googleapis.com/chromium-browser-official/ \ https://nerd.hu/distfiles/:external DISTFILES= chromium-${DISTVERSION}${EXTRACT_SUFX} \ ungoogled-chromium-${UGVERSION}.tar.gz:external MAINTAINER= chromium@FreeBSD.org COMMENT= Google web browser based on WebKit sans integration with Google WWW= https://github.com/ungoogled-software/ungoogled-chromium LICENSE= BSD3CLAUSE LGPL21 MPL11 LICENSE_COMB= multi ONLY_FOR_ARCHS= aarch64 amd64 i386 PATCH_DEPENDS= gpatch:devel/patch \ ${PYTHON_VERSION}:lang/python${PYTHON_SUFFIX} BUILD_DEPENDS= bash:shells/bash \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}ply>0:devel/py-ply@${PY_FLAVOR} \ gperf:devel/gperf \ flock:sysutils/flock \ node:www/node \ xcb-proto>0:x11/xcb-proto \ ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \ ${LOCALBASE}/share/usbids/usb.ids:misc/usbids \ ${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} \ ${LOCALBASE}/include/va/va.h:multimedia/libva \ ${LOCALBASE}/libdata/pkgconfig/dri.pc:graphics/mesa-dri \ ${LOCALBASE}/libdata/pkgconfig/Qt5Core.pc:devel/qt5-core \ ${LOCALBASE}/libdata/pkgconfig/Qt5Widgets.pc:x11-toolkits/qt5-widgets LIB_DEPENDS= libatk-bridge-2.0.so:accessibility/at-spi2-core \ libatspi.so:accessibility/at-spi2-core \ libspeechd.so:accessibility/speech-dispatcher \ libsnappy.so:archivers/snappy \ libFLAC.so:audio/flac \ libopus.so:audio/opus \ libspeex.so:audio/speex \ libdbus-1.so:devel/dbus \ libdbus-glib-1.so:devel/dbus-glib \ libepoll-shim.so:devel/libepoll-shim \ libevent.so:devel/libevent \ libffi.so:devel/libffi \ libicuuc.so:devel/icu \ libjsoncpp.so:devel/jsoncpp \ libpci.so:devel/libpci \ libnspr4.so:devel/nspr \ libre2.so:devel/re2 \ libcairo.so:graphics/cairo \ libdrm.so:graphics/libdrm \ libexif.so:graphics/libexif \ libpng.so:graphics/png \ libwebp.so:graphics/webp \ libopenh264.so:multimedia/openh264 \ libfreetype.so:print/freetype2 \ libharfbuzz.so:print/harfbuzz \ libharfbuzz-icu.so:print/harfbuzz-icu \ libgcrypt.so:security/libgcrypt \ libsecret-1.so:security/libsecret \ libnss3.so:security/nss \ libexpat.so:textproc/expat2 \ libfontconfig.so:x11-fonts/fontconfig \ libwayland-client.so:graphics/wayland \ libxkbcommon.so:x11/libxkbcommon \ libxshmfence.so:x11/libxshmfence RUN_DEPENDS= xdg-open:devel/xdg-utils \ noto-basic>0:x11-fonts/noto-basic USES= bison compiler:c++17-lang cpe desktop-file-utils gl gnome iconv:wchar_t jpeg \ localbase:ldflags ninja perl5 pkgconfig python:3.7+,build qt:5 shebangfix \ tar:xz xorg CPE_VENDOR= google CPE_PRODUCT= chrome USE_GL= gbm gl USE_GNOME= atk dconf gdkpixbuf2 glib20 gtk30 libxml2 libxslt USE_LDCONFIG= ${DATADIR} USE_PERL5= build USE_XORG= x11 xcb xcomposite xcursor xext xdamage xfixes xi \ xorgproto xrandr xrender xscrnsaver xtst USE_QT= buildtools:build SHEBANG_FILES= chrome/tools/build/linux/chrome-wrapper buildtools/linux64/clang-format MAKE_ARGS= -C out/${BUILDTYPE} ALL_TARGET= chrome BINARY_ALIAS= python3=${PYTHON_CMD} \ moc=${PREFIX}/bin/moc-qt5 # TODO bz@ : install libwidevinecdm.so (see third_party/widevine/cdm/BUILD.gn) # # Run "./out/${BUILDTYPE}/gn args out/${BUILDTYPE} --list" for all variables. # Some parts don't have use_system_* flag, and can be turned on/off by using # replace_gn_files.py script, some parts just turned on/off for target host # OS "target_os == is_bsd", like libusb, libpci. GN_ARGS+= fatal_linker_warnings=false \ icu_use_data_file=false \ is_clang=true \ optimize_webui=true \ toolkit_views=true \ use_allocator_shim=false \ use_aura=true \ use_custom_libcxx=false \ use_gnome_keyring=false \ use_lld=true \ use_partition_alloc=true \ use_partition_alloc_as_malloc=false \ use_sysroot=false \ use_system_freetype=false \ use_system_harfbuzz=true \ use_system_libffi=true \ use_system_libjpeg=true \ use_udev=false \ extra_cxxflags="${CXXFLAGS}" \ extra_ldflags="${LDFLAGS}" # sync with flags.gni GN_ARGS+= build_with_tflite_lib=false \ chrome_pgo_phase=0 \ clang_use_chrome_plugins=false \ disable_fieldtrial_testing_config=true \ enable_backup_ref_ptr_support=false \ enable_hangout_services_extension=false \ enable_mdns=false \ enable_mse_mpeg2ts_stream_parser=true \ enable_nacl=false \ enable_reading_list=false \ enable_remoting=false \ enable_reporting=false \ enable_service_discovery=false \ exclude_unwind_tables=true \ google_api_key="" \ google_default_client_id="" \ google_default_client_secret="" \ safe_browsing_mode=0 \ treat_warnings_as_errors=false \ use_official_google_api_keys=false \ use_unofficial_version_number=false # TODO: investigate building with these options: # use_system_minigbm GN_BOOTSTRAP_FLAGS= --no-clean --no-rebuild --skip-generate-buildfiles SUB_FILES= ungoogled-chromium.desktop ungoogled-chromium SUB_LIST+= COMMENT="${COMMENT}" OPTIONS_DEFINE= CODECS CUPS DEBUG DRIVER KERBEROS LTO TEST OPTIONS_DEFAULT= CODECS CUPS DRIVER KERBEROS SNDIO OPTIONS_EXCLUDE_aarch64=LTO OPTIONS_GROUP= AUDIO OPTIONS_GROUP_AUDIO= ALSA PULSEAUDIO SNDIO OPTIONS_RADIO= KERBEROS OPTIONS_RADIO_KERBEROS= HEIMDAL HEIMDAL_BASE MIT OPTIONS_SUB= yes CODECS_DESC= Compile and enable patented codecs like H.264 DRIVER_DESC= Install chromedriver HEIMDAL_BASE_DESC= Heimdal Kerberos (base) HEIMDAL_DESC= Heimdal Kerberos (security/heimdal) MIT_DESC= MIT Kerberos (security/krb5) ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib ALSA_RUN_DEPENDS= ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:audio/alsa-plugins \ alsa-lib>=1.1.1_1:audio/alsa-lib ALSA_VARS= GN_ARGS+=use_alsa=true ALSA_VARS_OFF= GN_ARGS+=use_alsa=false CODECS_VARS= GN_ARGS+=ffmpeg_branding="Chrome" \ GN_ARGS+=proprietary_codecs=true CODECS_VARS_OFF= GN_ARGS+=ffmpeg_branding="Chromium" \ GN_ARGS+=proprietary_codecs=false CUPS_LIB_DEPENDS= libcups.so:print/cups CUPS_VARS= GN_ARGS+=use_cups=true CUPS_VARS_OFF= GN_ARGS+=use_cups=false DEBUG_BUILD_DEPENDS= esbuild:devel/esbuild DEBUG_VARS= BUILDTYPE=Debug \ GN_ARGS+=is_debug=true \ GN_ARGS+=is_component_build=false \ GN_ARGS+=symbol_level=1 \ GN_BOOTSTRAP_FLAGS+=--debug \ WANTSPACE="21 GB" DEBUG_VARS_OFF= BUILDTYPE=Release \ GN_ARGS+=blink_symbol_level=0 \ GN_ARGS+=is_debug=false \ GN_ARGS+=is_official_build=true \ GN_ARGS+=symbol_level=0 \ WANTSPACE="14 GB" DRIVER_MAKE_ARGS= chromedriver HEIMDAL_LIB_DEPENDS= libkrb.so.26:security/heimdal KERBEROS_VARS= GN_ARGS+=use_kerberos=true KERBEROS_VARS_OFF= GN_ARGS+=use_kerberos=false LTO_VARS= GN_ARGS+=use_thin_lto=true \ GN_ARGS+=thin_lto_enable_optimizations=true \ WANTSPACE="14 GB" LTO_VARS_OFF= GN_ARGS+=use_thin_lto=false MIT_LIB_DEPENDS= libkrb.so.3:security/krb5 PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio PULSEAUDIO_VARS= GN_ARGS+=use_pulseaudio=true PULSEAUDIO_VARS_OFF= GN_ARGS+=use_pulseaudio=false # With SNDIO=on we exclude audio_manager_linux from the build (see # media/audio/BUILD.gn) and use audio_manager_openbsd which does not # support falling back to ALSA or PulseAudio. SNDIO_PREVENTS= ALSA PULSEAUDIO SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio SNDIO_VARS= GN_ARGS+=use_sndio=true SNDIO_VARS_OFF= GN_ARGS+=use_sndio=false .include "Makefile.tests" TEST_DISTFILES= chromium-${DISTVERSION}-testdata${EXTRACT_SUFX} \ test_fonts-336e775eec536b2d785cc80eff6ac39051931286.tar.gz:external TEST_ALL_TARGET= ${TEST_TARGETS} .include .include # for COMPILER_VERSION .if ${PORT_OPTIONS:MHEIMDAL_BASE} && !exists(/usr/lib/libkrb5.so) IGNORE= you have selected HEIMDAL_BASE but do not have Heimdal installed in base .endif .if ${COMPILER_VERSION} < 150 LLVM_DEFAULT= 15 BUILD_DEPENDS+= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT} BINARY_ALIAS+= cpp=${LOCALBASE}/bin/clang-cpp${LLVM_DEFAULT} \ cc=${LOCALBASE}/bin/clang${LLVM_DEFAULT} \ c++=${LOCALBASE}/bin/clang++${LLVM_DEFAULT} \ ar=${LOCALBASE}/bin/llvm-ar${LLVM_DEFAULT} \ nm=${LOCALBASE}/bin/llvm-nm${LLVM_DEFAULT} \ ld=${LOCALBASE}/bin/ld.lld${LLVM_DEFAULT} .else BINARY_ALIAS+= ar=/usr/bin/llvm-ar \ nm=/usr/bin/llvm-nm .endif # swiftshader/lib/{libEGL.so,libGLESv2.so} is x86 only .if ${ARCH} == aarch64 PLIST_SUB+= NOT_AARCH64="@comment " .else PLIST_SUB+= NOT_AARCH64="" .endif # Allow relocations against read-only segments (override lld default) LDFLAGS_i386= -Wl,-znotext # TODO: -isystem, would be just as ugly as this approach, but more reliably # build would fail without C_INCLUDE_PATH/CPLUS_INCLUDE_PATH env var set. MAKE_ENV+= C_INCLUDE_PATH=${LOCALBASE}/include \ CPLUS_INCLUDE_PATH=${LOCALBASE}/include WRKSRC= ${WRKDIR}/chromium-${DISTVERSION} pre-everything:: @${ECHO_MSG} @${ECHO_MSG} "To build Ungoogled Chromium, you should have around 2GB of memory" @${ECHO_MSG} "and around ${WANTSPACE} of free disk space." @${ECHO_MSG} post-extract-TEST-on: @${MKDIR} ${WRKSRC}/third_party/test_fonts/test_fonts @${MV} ${WRKDIR}/test_fonts ${WRKSRC}/third_party/test_fonts/ pre-patch: cd ${WRKDIR}/ungoogled-chromium-${UGVERSION} && ${PYTHON_CMD} \ utils/prune_binaries.py ${WRKSRC} pruning.list cd ${WRKDIR}/ungoogled-chromium-${UGVERSION} && PATCH_BIN=gpatch \ ${PYTHON_CMD} utils/patches.py apply ${WRKSRC} patches cd ${WRKDIR}/ungoogled-chromium-${UGVERSION} && ${PYTHON_CMD} \ utils/domain_substitution.py apply -r domain_regex.list -f \ domain_substitution.list -c ${WRKSRC}/domsubcache.tar.gz ${WRKSRC} pre-configure: # We used to remove bundled libraries to be sure that chromium uses # system libraries and not shipped ones. # cd ${WRKSRC} && ${PYTHON_CMD} \ #./build/linux/unbundle/remove_bundled_libraries.py [list of preserved] cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \ ./build/linux/unbundle/replace_gn_files.py --system-libraries \ flac fontconfig freetype harfbuzz-ng icu libdrm libevent libpng \ libusb libwebp libxml libxslt openh264 opus snappy || ${FALSE} # Chromium uses an unreleased version of FFmpeg, so configure it .for brand in Chrome Chromium ${CP} -R \ ${WRKSRC}/third_party/ffmpeg/chromium/config/${brand}/linux/ \ ${WRKSRC}/third_party/ffmpeg/chromium/config/${brand}/freebsd .endfor do-configure: # GN generator bootstrapping and generating ninja files cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} CC=${CC} CXX=${CXX} LD=${CXX} \ READELF=${READELF} AR=${AR} NM=${NM} ${PYTHON_CMD} \ ./tools/gn/bootstrap/bootstrap.py ${GN_BOOTSTRAP_FLAGS} cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./out/${BUILDTYPE}/gn \ gen --args='${GN_ARGS}' out/${BUILDTYPE} # Setup nodejs dependency @${MKDIR} ${WRKSRC}/third_party/node/freebsd/node-freebsd/bin ${LN} -sf ${LOCALBASE}/bin/node ${WRKSRC}/third_party/node/freebsd/node-freebsd/bin/node # Setup buildtools/freebsd @${MKDIR} ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/buildtools/linux64/clang-format ${WRKSRC}/buildtools/freebsd ${LN} -sf ${WRKSRC}/out/${BUILDTYPE}/gn ${WRKSRC}/buildtools/freebsd ${LN} -sf /usr/bin/strip ${WRKSRC}/buildtools/freebsd/strip do-install: @${MKDIR} ${STAGEDIR}${DATADIR} ${INSTALL_MAN} ${WRKSRC}/chrome/app/resources/manpage.1.in \ ${STAGEDIR}${MANPREFIX}/man/man1/ungoogled-chromium.1 @${SED} -i "" -e 's,\@\@PACKAGE\@\@,chromium,g;s,\@\@MENUNAME\@\@,Chromium Web Browser,g' \ ${STAGEDIR}${MANPREFIX}/man/man1/ungoogled-chromium.1 ${CP} ${WRKSRC}/chrome/app/theme/chromium/product_logo_22_mono.png ${WRKSRC}/chrome/app/theme/chromium/product_logo_22.png .for s in 22 24 48 64 128 256 @${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps ${INSTALL_DATA} ${WRKSRC}/chrome/app/theme/chromium/product_logo_${s}.png \ ${STAGEDIR}${PREFIX}/share/icons/hicolor/${s}x${s}/apps/ungoogled-chromium.png .endfor ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.png ${STAGEDIR}${DATADIR} ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/*.pak ${STAGEDIR}${DATADIR} .for d in protoc mksnapshot ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor .for d in snapshot_blob.bin v8_context_snapshot.bin ${INSTALL_DATA} ${WRKSRC}/out/${BUILDTYPE}/${d} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chrome \ ${STAGEDIR}${DATADIR}/ungoogled-chromium cd ${WRKSRC}/out/${BUILDTYPE} && \ ${COPYTREE_SHARE} "locales resources" ${STAGEDIR}${DATADIR} @${MKDIR} ${STAGEDIR}${DESKTOPDIR} ${INSTALL_DATA} ${WRKDIR}/ungoogled-chromium.desktop \ ${STAGEDIR}${DESKTOPDIR} ${INSTALL_SCRIPT} ${WRKDIR}/ungoogled-chromium ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${WRKSRC}/chrome/tools/build/linux/chrome-wrapper \ ${STAGEDIR}${DATADIR} # ANGLE, EGL, Vk .for f in libEGL.so libGLESv2.so libVkICD_mock_icd.so ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/${f} ${STAGEDIR}${DATADIR} .endfor ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvulkan.so.1 \ ${STAGEDIR}${DATADIR}/libvulkan.so .if ${BUILDTYPE} == Debug ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libVkLayer_khronos_validation.so ${STAGEDIR}${DATADIR} .endif # SwiftShader .if ${ARCH} != aarch64 ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/libvk_swiftshader.so ${STAGEDIR}${DATADIR} .endif post-install-DEBUG-on: ${INSTALL_LIB} ${WRKSRC}/out/${BUILDTYPE}/*.so \ ${STAGEDIR}${DATADIR} ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/character_data_generator \ ${STAGEDIR}${DATADIR} post-install-DRIVER-on: ${INSTALL_PROGRAM} ${WRKSRC}/out/${BUILDTYPE}/chromedriver \ ${STAGEDIR}${PREFIX}/bin/ungoogled-chromedriver do-test-TEST-on: .for t in ${TEST_TARGETS} cd ${WRKSRC}/out/${BUILDTYPE} && ${SETENV} LC_ALL=en_US.UTF-8 \ ./${t} --gtest_filter=-${EXCLUDE_${t}:ts:} || ${TRUE} .endfor .include diff --git a/www/ungoogled-chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc b/www/ungoogled-chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc index b1ce7e967652..e081a554f13d 100644 --- a/www/ungoogled-chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc +++ b/www/ungoogled-chromium/files/patch-media_capture_video_linux_v4l2__capture__delegate.cc @@ -1,63 +1,358 @@ ---- media/capture/video/linux/v4l2_capture_delegate.cc.orig 2023-04-08 11:38:38 UTC +--- media/capture/video/linux/v4l2_capture_delegate.cc.orig 2023-05-02 13:12:51 UTC +++ media/capture/video/linux/v4l2_capture_delegate.cc @@ -4,8 +4,10 @@ #include "media/capture/video/linux/v4l2_capture_delegate.h" -+#if !defined(OS_BSD) ++#if !BUILDFLAG(IS_BSD) #include #include +#endif #include #include #include -@@ -29,10 +31,10 @@ +@@ -20,7 +22,6 @@ + #include "base/task/single_thread_task_runner.h" + #include "base/trace_event/trace_event.h" + #include "build/build_config.h" +-#include "media/base/bind_to_current_loop.h" + #include "media/base/video_frame.h" + #include "media/base/video_types.h" + #include "media/capture/mojom/image_capture_types.h" +@@ -29,10 +30,12 @@ using media::mojom::MeteringMode; --#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) -+// #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) ++#if !BUILDFLAG(IS_BSD) + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) // 16 bit depth, Realsense F200. #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') --#endif -+// #endif + #endif ++#endif // TODO(aleksandar.stojiljkovic): Wrap this with kernel version check once the // format is introduced to kernel. -@@ -728,7 +730,7 @@ base::WeakPtr V4L2CaptureDelegate +@@ -139,47 +142,6 @@ int GetControllingSpecialControl(int control_id) { + return 0; + } + +-// Determines if |control_id| is special, i.e. controls another one's state. +-bool IsSpecialControl(int control_id) { +- switch (control_id) { +- case V4L2_CID_AUTO_WHITE_BALANCE: +- case V4L2_CID_EXPOSURE_AUTO: +- case V4L2_CID_EXPOSURE_AUTO_PRIORITY: +- case V4L2_CID_FOCUS_AUTO: +- return true; +- } +- return false; +-} +- +-// Determines if |control_id| should be skipped, https://crbug.com/697885. +-#if !defined(V4L2_CID_PAN_SPEED) +-#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32) +-#endif +-#if !defined(V4L2_CID_TILT_SPEED) +-#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33) +-#endif +-#if !defined(V4L2_CID_PANTILT_CMD) +-#define V4L2_CID_PANTILT_CMD (V4L2_CID_CAMERA_CLASS_BASE + 34) +-#endif +-bool IsBlockedControl(int control_id) { +- switch (control_id) { +- case V4L2_CID_PAN_RELATIVE: +- case V4L2_CID_TILT_RELATIVE: +- case V4L2_CID_PAN_RESET: +- case V4L2_CID_TILT_RESET: +- case V4L2_CID_PAN_ABSOLUTE: +- case V4L2_CID_TILT_ABSOLUTE: +- case V4L2_CID_ZOOM_ABSOLUTE: +- case V4L2_CID_ZOOM_RELATIVE: +- case V4L2_CID_ZOOM_CONTINUOUS: +- case V4L2_CID_PAN_SPEED: +- case V4L2_CID_TILT_SPEED: +- case V4L2_CID_PANTILT_CMD: +- return true; +- } +- return false; +-} +- + bool IsNonEmptyRange(const mojom::RangePtr& range) { + return range->min < range->max; + } +@@ -253,6 +215,49 @@ std::vector V4L2CaptureDelegate::GetListOfUs + return supported_formats; + } + ++// Determines if |control_id| is special, i.e. controls another one's state. ++// static ++bool V4L2CaptureDelegate::IsSpecialControl(int control_id) { ++ switch (control_id) { ++ case V4L2_CID_AUTO_WHITE_BALANCE: ++ case V4L2_CID_EXPOSURE_AUTO: ++ case V4L2_CID_EXPOSURE_AUTO_PRIORITY: ++ case V4L2_CID_FOCUS_AUTO: ++ return true; ++ } ++ return false; ++} ++ ++// Determines if |control_id| should be skipped, https://crbug.com/697885. ++#if !defined(V4L2_CID_PAN_SPEED) ++#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32) ++#endif ++#if !defined(V4L2_CID_TILT_SPEED) ++#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33) ++#endif ++#if !defined(V4L2_CID_PANTILT_CMD) ++#define V4L2_CID_PANTILT_CMD (V4L2_CID_CAMERA_CLASS_BASE + 34) ++#endif ++// static ++bool V4L2CaptureDelegate::IsBlockedControl(int control_id) { ++ switch (control_id) { ++ case V4L2_CID_PAN_RELATIVE: ++ case V4L2_CID_TILT_RELATIVE: ++ case V4L2_CID_PAN_RESET: ++ case V4L2_CID_TILT_RESET: ++ case V4L2_CID_PAN_ABSOLUTE: ++ case V4L2_CID_TILT_ABSOLUTE: ++ case V4L2_CID_ZOOM_ABSOLUTE: ++ case V4L2_CID_ZOOM_RELATIVE: ++ case V4L2_CID_ZOOM_CONTINUOUS: ++ case V4L2_CID_PAN_SPEED: ++ case V4L2_CID_TILT_SPEED: ++ case V4L2_CID_PANTILT_CMD: ++ return true; ++ } ++ return false; ++} ++ + V4L2CaptureDelegate::V4L2CaptureDelegate( + V4L2CaptureDevice* v4l2, + const VideoCaptureDeviceDescriptor& device_descriptor, +@@ -728,7 +733,7 @@ base::WeakPtr V4L2CaptureDelegate V4L2CaptureDelegate::~V4L2CaptureDelegate() = default; -bool V4L2CaptureDelegate::RunIoctl(int request, void* argp) { +bool V4L2CaptureDelegate::RunIoctl(unsigned int request, void* argp) { int num_retries = 0; for (; DoIoctl(request, argp) < 0 && num_retries < kMaxIOCtrlRetries; ++num_retries) { -@@ -738,7 +740,7 @@ bool V4L2CaptureDelegate::RunIoctl(int request, void* +@@ -738,7 +743,7 @@ bool V4L2CaptureDelegate::RunIoctl(int request, void* return num_retries != kMaxIOCtrlRetries; } -int V4L2CaptureDelegate::DoIoctl(int request, void* argp) { +int V4L2CaptureDelegate::DoIoctl(unsigned int request, void* argp) { return HANDLE_EINTR(v4l2_->ioctl(device_fd_.get(), request, argp)); } -@@ -778,6 +780,10 @@ bool V4L2CaptureDelegate::IsControllableControl(int co +@@ -778,6 +783,7 @@ bool V4L2CaptureDelegate::IsControllableControl(int co } void V4L2CaptureDelegate::ReplaceControlEventSubscriptions() { -+// these ioctls are not implemented on *BSDs -+#if BUILDFLAG(IS_BSD) -+ NOTIMPLEMENTED(); -+#else ++#if !BUILDFLAG(IS_BSD) constexpr uint32_t kControlIds[] = {V4L2_CID_AUTO_EXPOSURE_BIAS, V4L2_CID_AUTO_WHITE_BALANCE, V4L2_CID_BRIGHTNESS, @@ -805,6 +811,7 @@ void V4L2CaptureDelegate::ReplaceControlEventSubscript << ", {type = V4L2_EVENT_CTRL, id = " << control_id << "}"; } } +#endif } mojom::RangePtr V4L2CaptureDelegate::RetrieveUserControlRange(int control_id) { +@@ -829,100 +836,89 @@ mojom::RangePtr V4L2CaptureDelegate::RetrieveUserContr + } + + void V4L2CaptureDelegate::ResetUserAndCameraControlsToDefault() { +- // Set V4L2_CID_AUTO_WHITE_BALANCE to false first. +- v4l2_control auto_white_balance = {}; +- auto_white_balance.id = V4L2_CID_AUTO_WHITE_BALANCE; +- auto_white_balance.value = false; +- if (!RunIoctl(VIDIOC_S_CTRL, &auto_white_balance)) +- return; +- +- std::vector special_camera_controls; +- // Set V4L2_CID_EXPOSURE_AUTO to V4L2_EXPOSURE_MANUAL. +- v4l2_ext_control auto_exposure = {}; +- auto_exposure.id = V4L2_CID_EXPOSURE_AUTO; +- auto_exposure.value = V4L2_EXPOSURE_MANUAL; +- special_camera_controls.push_back(auto_exposure); +- // Set V4L2_CID_EXPOSURE_AUTO_PRIORITY to false. +- v4l2_ext_control priority_auto_exposure = {}; +- priority_auto_exposure.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY; +- priority_auto_exposure.value = false; +- special_camera_controls.push_back(priority_auto_exposure); +- // Set V4L2_CID_FOCUS_AUTO to false. +- v4l2_ext_control auto_focus = {}; +- auto_focus.id = V4L2_CID_FOCUS_AUTO; +- auto_focus.value = false; +- special_camera_controls.push_back(auto_focus); +- + struct v4l2_ext_controls ext_controls = {}; +- ext_controls.ctrl_class = V4L2_CID_CAMERA_CLASS; +- ext_controls.count = special_camera_controls.size(); +- ext_controls.controls = special_camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) +- DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ ext_controls.which = V4L2_CTRL_WHICH_CUR_VAL; ++ ext_controls.count = 0; ++ const bool use_modern_s_ext_ctrls = ++ DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) == 0; + + for (const auto& control : kControls) { + std::vector camera_controls; ++ std::vector manual_special_camera_controls; ++ std::vector special_camera_controls; + + v4l2_queryctrl range = {}; +- range.id = control.control_base | V4L2_CTRL_FLAG_NEXT_CTRL; ++ // Start right below the base so that the first next retrieved control ID ++ // is always the first available control ID within the class even if that ++ // control ID is equal to the base (V4L2_CID_BRIGHTNESS equals to ++ // V4L2_CID_USER_BASE). ++ range.id = (control.control_base - 1) | V4L2_CTRL_FLAG_NEXT_CTRL; + while (0 == DoIoctl(VIDIOC_QUERYCTRL, &range)) { + if (V4L2_CTRL_ID2CLASS(range.id) != V4L2_CTRL_ID2CLASS(control.class_id)) + break; ++ ++ v4l2_ext_control ext_control = {}; ++ ext_control.id = range.id; ++ ext_control.value = range.default_value; ++ ++ // Prepare to query for the next control as `range` is an in-out ++ // parameter. + range.id |= V4L2_CTRL_FLAG_NEXT_CTRL; + +- if (IsSpecialControl(range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) ++ if (range.flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_READ_ONLY)) { ++ // Permanently disabled or permanently read-only. + continue; +- if (IsBlockedControl(range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) ++ } ++ if (IsBlockedControl(ext_control.id)) { + continue; ++ } + +- struct v4l2_ext_control ext_control = {}; +- ext_control.id = range.id & ~V4L2_CTRL_FLAG_NEXT_CTRL; +- ext_control.value = range.default_value; +- camera_controls.push_back(ext_control); ++ if (IsSpecialControl(ext_control.id)) { ++ special_camera_controls.push_back(ext_control); ++ if (ext_control.id == V4L2_CID_EXPOSURE_AUTO) { ++ ext_control.value = V4L2_EXPOSURE_MANUAL; ++ } else { ++ ext_control.value = false; // Not automatic but manual. ++ } ++ manual_special_camera_controls.push_back(ext_control); ++ } else { ++ camera_controls.push_back(ext_control); ++ } + } + + if (!camera_controls.empty()) { +- struct v4l2_ext_controls ext_controls2 = {}; +- ext_controls2.ctrl_class = control.class_id; +- ext_controls2.count = camera_controls.size(); +- ext_controls2.controls = camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls2) < 0) ++ // Set special controls to manual modes first. ++ if (!manual_special_camera_controls.empty()) { ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = manual_special_camera_controls.size(); ++ ext_controls.controls = manual_special_camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { ++ DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } ++ } ++ ++ // Set non-special controls to the default values. ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = camera_controls.size(); ++ ext_controls.controls = camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { + DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } + } +- } + +- // Now set the special flags to the default values +- v4l2_queryctrl range = {}; +- range.id = V4L2_CID_AUTO_WHITE_BALANCE; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_white_balance.value = range.default_value; +- DoIoctl(VIDIOC_S_CTRL, &auto_white_balance); +- +- special_camera_controls.clear(); +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_EXPOSURE_AUTO; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_exposure.value = range.default_value; +- special_camera_controls.push_back(auto_exposure); +- +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- priority_auto_exposure.value = range.default_value; +- special_camera_controls.push_back(priority_auto_exposure); +- +- memset(&range, 0, sizeof(range)); +- range.id = V4L2_CID_FOCUS_AUTO; +- DoIoctl(VIDIOC_QUERYCTRL, &range); +- auto_focus.value = range.default_value; +- special_camera_controls.push_back(auto_focus); +- +- memset(&ext_controls, 0, sizeof(ext_controls)); +- ext_controls.ctrl_class = V4L2_CID_CAMERA_CLASS; +- ext_controls.count = special_camera_controls.size(); +- ext_controls.controls = special_camera_controls.data(); +- if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) +- DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ // Set special controls to the default values. ++ if (!special_camera_controls.empty()) { ++ ext_controls.which = ++ use_modern_s_ext_ctrls ? V4L2_CTRL_WHICH_CUR_VAL : control.class_id; ++ ext_controls.count = special_camera_controls.size(); ++ ext_controls.controls = special_camera_controls.data(); ++ if (DoIoctl(VIDIOC_S_EXT_CTRLS, &ext_controls) < 0) { ++ DPLOG(INFO) << "VIDIOC_S_EXT_CTRLS"; ++ } ++ } ++ } + } + + bool V4L2CaptureDelegate::MapAndQueueBuffer(int index) { +@@ -985,7 +981,11 @@ void V4L2CaptureDelegate::DoCapture() { + + pollfd device_pfd = {}; + device_pfd.fd = device_fd_.get(); ++#if !BUILDFLAG(IS_BSD) + device_pfd.events = POLLIN | POLLPRI; ++#else ++ device_pfd.events = POLLIN; ++#endif + + const int result = + HANDLE_EINTR(v4l2_->poll(&device_pfd, 1, kCaptureTimeoutMs)); +@@ -1023,6 +1023,7 @@ void V4L2CaptureDelegate::DoCapture() { + timeout_count_ = 0; + } + ++#if !BUILDFLAG(IS_BSD) + // Dequeue events if the driver has filled in some. + if (device_pfd.revents & POLLPRI) { + bool controls_changed = false; +@@ -1057,6 +1058,7 @@ void V4L2CaptureDelegate::DoCapture() { + client_->OnCaptureConfigurationChanged(); + } + } ++#endif + + // Deenqueue, send and reenqueue a buffer if the driver has filled one in. + if (device_pfd.revents & POLLIN) {