From patchwork Tue Mar 24 10:30:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3297 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F1D0C62BDE for ; Tue, 24 Mar 2020 11:30:18 +0100 (CET) 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 85EB1308 for ; Tue, 24 Mar 2020 11:30:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1585045817; bh=fCBOSUe9Xb/5vxvc3OefPlQ+LElKxKLq28eVF7vKRdk=; h=From:To:Subject:Date:From; b=NG3XPtFGViah3PSISrowMrRVhILXXrHIAKIRP2Z8IfyM3iAxwtX3b42PL4P+n9yw5 X7A9N67C5Ph4g3BVdrEKSjFccKOFWLqG5Fjw4gJA9khjY0uirjfwypAaHpbZfxIKMc loRSlY1Us+uV3z3l+oVn86ungkrnzH+uL4TXUdwg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 24 Mar 2020 12:30:11 +0200 Message-Id: <20200324103012.9678-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] qcam: viewfinder: Report the natively supported 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, 24 Mar 2020 10:30:19 -0000 Expose the pixel formats natively supported by the viewfinder, to allow selection of stream formats that would minimize usage of software conversion. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/qcam/viewfinder.cpp | 22 ++++++++++++++-------- src/qcam/viewfinder.h | 3 +++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp index df5ee5ee7b83..0d68f62ee6d7 100644 --- a/src/qcam/viewfinder.cpp +++ b/src/qcam/viewfinder.cpp @@ -19,16 +19,16 @@ #include "format_converter.h" -static const QMap nativeFormats +static const QMap nativeFormats { #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) - { DRM_FORMAT_ABGR8888, QImage::Format_RGBA8888 }, + { libcamera::PixelFormat{ DRM_FORMAT_ABGR8888 }, QImage::Format_RGBA8888 }, #endif - { DRM_FORMAT_ARGB8888, QImage::Format_RGB32 }, + { libcamera::PixelFormat{ DRM_FORMAT_ARGB8888 }, QImage::Format_RGB32 }, #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - { DRM_FORMAT_BGR888, QImage::Format_BGR888 }, + { libcamera::PixelFormat{ DRM_FORMAT_BGR888 }, QImage::Format_BGR888 }, #endif - { DRM_FORMAT_RGB888, QImage::Format_RGB888 }, + { libcamera::PixelFormat{ DRM_FORMAT_RGB888 }, QImage::Format_RGB888 }, }; ViewFinder::ViewFinder(QWidget *parent) @@ -41,6 +41,12 @@ ViewFinder::~ViewFinder() { } +const QList &ViewFinder::nativeFormats() const +{ + static const QList formats = ::nativeFormats.keys(); + return formats; +} + int ViewFinder::setFormat(const libcamera::PixelFormat &format, const QSize &size) { @@ -50,7 +56,7 @@ int ViewFinder::setFormat(const libcamera::PixelFormat &format, * If format conversion is needed, configure the converter and allocate * the destination image. */ - if (!nativeFormats.contains(format)) { + if (!::nativeFormats.contains(format)) { int ret = converter_.configure(format, size); if (ret < 0) return ret; @@ -83,7 +89,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map) { QMutexLocker locker(&mutex_); - if (nativeFormats.contains(format_)) { + if (::nativeFormats.contains(format_)) { /* * If the frame format is identical to the display * format, create a QImage that references the frame @@ -96,7 +102,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map) */ image_ = QImage(memory, size_.width(), size_.height(), size / size_.height(), - nativeFormats[format_]); + ::nativeFormats[format_]); std::swap(buffer, buffer_); } else { /* diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h index 1a27f99ea202..b3f1d25d9d60 100644 --- a/src/qcam/viewfinder.h +++ b/src/qcam/viewfinder.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,8 @@ public: ViewFinder(QWidget *parent); ~ViewFinder(); + const QList &nativeFormats() const; + int setFormat(const libcamera::PixelFormat &format, const QSize &size); void render(libcamera::FrameBuffer *buffer, MappedBuffer *map); void stop();