From patchwork Tue Jun 9 23:23:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 4005 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 012846002B for ; Wed, 10 Jun 2020 01:23:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="i7KWI/NM"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EDFC9291 for ; Wed, 10 Jun 2020 01:23:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591745027; bh=9JYggqNsg4n/VoJ7aNLf6wnkadTwgGpMP9vG9Xp7Wn4=; h=From:To:Subject:Date:From; b=i7KWI/NMg24mOmgH8IrvWvIAJgmOMmpQCGUygYAGphq8urQ44DokOpzfNNvtHmzT1 jHik5Tce7SLo2pEx65MBrRfo7Avz3p849vAYsA0D6d1l1YCPZ+hWGM+81YZidKKzDN mvYHj00U8kaM9+H8O0ImpjZ61w6AhtQnTjp0Dl38= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Jun 2020 02:23:16 +0300 Message-Id: <20200609232323.29628-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 0/7] Introduce formats:: namespace for libcamera pixel formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2020 23:23:48 -0000 Hello, This patch series is an attempt to fix a problem caused by a direct dependency on drm_fourcc.h in the libcamera public API. libcamera specifies pixel formats using the DRM pixel format FourCC and modifiers. This requires both internal code and applications to include drm_fourcc.h. For internal code, we carry a copy of the header to avoid external dependencies. For third-party applications, however, drm_fourcc.h needs to be accessible from system includes. It turns out that the file is shipped by two different packages: - libdrm, which typically installs it in /usr/include/libdrm/ - kernel headers or libc headers, which typically installs it in /usr/include/drm We don't want to make libdrm a dependency for applications using libcamera. Unfortunately, depending on drm_fourcc.h being provided by the distribution kernel headers or libc headers package causes issues, as not all distributions install the header in /usr/include/drm/. Ubuntu and Gentoo do, but Debian and Arch don't. The best option may be to remove the dependency on the macros provided by drm_fourcc.h, while keeping the pixel format numerical values identical. This is what this patch series attempts to do. Patch 1/7 creates a new libcamera::formats:: namespace and populates it with constants (in the form of constexpr) for all supported pixel formats. The values are automatically generated from a list of formats, stored in formats.yaml, and the numerical values for the DRM FourCCs and modifiers are extracted from drm_fourcc.h. Patches 2/7 to 7/8 then replace usage of the DRM_FORMAT_* macros through the code. Laurent Pinchart (7): libcamera: Define constants for pixel formats in the public API gst: Replace explicit DRM FourCCs with libcamera formats qcam: Replace explicit DRM FourCCs with libcamera formats v4l2: Replace explicit DRM FourCCs with libcamera formats test: Replace explicit DRM FourCCs with libcamera formats libcamera: pipeline: Replace explicit DRM FourCCs with libcamera formats libcamera: Replace explicit DRM FourCCs with libcamera formats include/libcamera/formats.h.in | 44 ++++++ include/libcamera/gen-formats.py | 118 ++++++++++++++ include/libcamera/meson.build | 22 +++ include/libcamera/pixel_format.h | 2 - src/android/camera_device.cpp | 9 +- src/gstreamer/gstlibcamera-utils.cpp | 62 ++++---- src/libcamera/formats.cpp | 148 +++++++++--------- src/libcamera/formats.yaml | 124 +++++++++++++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 16 +- .../pipeline/raspberrypi/raspberrypi.cpp | 10 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 19 +-- src/libcamera/pipeline/vimc/vimc.cpp | 11 +- src/libcamera/pixel_format.cpp | 4 +- src/libcamera/v4l2_pixelformat.cpp | 83 +++++----- src/qcam/dng_writer.cpp | 17 +- src/qcam/format_converter.cpp | 36 +++-- src/qcam/viewfinder.cpp | 10 +- src/v4l2/v4l2_camera_proxy.cpp | 29 ++-- test/v4l2_videodevice/buffer_cache.cpp | 3 +- 19 files changed, 540 insertions(+), 227 deletions(-) create mode 100644 include/libcamera/formats.h.in create mode 100755 include/libcamera/gen-formats.py create mode 100644 src/libcamera/formats.yaml