From patchwork Tue Nov 30 12:44:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14895 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 90224BDB13 for ; Tue, 30 Nov 2021 12:44:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C95060721; Tue, 30 Nov 2021 13:44:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gafVv0fS"; dkim-atps=neutral Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 351C16071C for ; Tue, 30 Nov 2021 13:44:38 +0100 (CET) Received: by mail-pf1-x42d.google.com with SMTP id r130so20560858pfc.1 for ; Tue, 30 Nov 2021 04:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GITHkqYE3iyWlza17xbqr5Py2eoRlhMegYhPo4txxH0=; b=gafVv0fS+WdG5g5k2+iFPGv3rW+EcONnmwZcjVM5x6tsGpr4K6P3vdn3+ie3wjGgEa /weUE9snHeDe/uhUl12YMkGvFFIF71Os87SSECp3PgXiUdYM+tmUSY4Xdav1X2LBEsju ELg9cv/ICiJH+qXKXOnKcxQr1/ByVvCmD00MU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GITHkqYE3iyWlza17xbqr5Py2eoRlhMegYhPo4txxH0=; b=nyHDzKAKQR0tOkNRykN78XDyiUtoqkNBAf5bQJ1+cviXTYGL6cVh/OD1ZTgP24zE+q XKCG2Qo8Jtf8zeqV4SGUbqu6wtDt+pS9frogHhUi2yx482ss4gA4Ct5eAQqvo7XPGu4X y0Ui8DU/1ms2/utQmiATndWJlqsZIcZOBDkHIjT0+i9T/eDy9wy81+32ZyyuLPIeQvWR n31WftcEI0egKZqnuNtuv5WX1+wPV5z/g6BaitnC/iNvN5JMm8jfTz8R3RiCPLp5EU2c yAZWKKHT5DmEJ6yo80UbKAsr0UNAStFm686qanCfx5nAPzBdw5TRDcSSCGsbgBPVF500 Kikw== X-Gm-Message-State: AOAM5317gWB838TqnJht0uxfOuhlK0swAEsDNtKQsGvKJoqgAc0+Auub EWljFRu1g/Xk6Syv9Ad36RIxIU6Wax1aog== X-Google-Smtp-Source: ABdhPJyIliwsLSninoTrmQKQfFSSrQOzHTqW1aWS7Vb2Nt1WFuwVx7oN78PJBbl16eMyidKiWsHgIw== X-Received: by 2002:a63:66c7:: with SMTP id a190mr365150pgc.463.1638276276386; Tue, 30 Nov 2021 04:44:36 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:c90a:5a53:b139:1336]) by smtp.gmail.com with ESMTPSA id bt2sm2424135pjb.33.2021.11.30.04.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 04:44:35 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Nov 2021 21:44:27 +0900 Message-Id: <20211130124428.2163669-2-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211130124428.2163669-1-hiroh@chromium.org> References: <20211130124428.2163669-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] android: camera_capabilities: Add function to convert PixelFormat to android format 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This adds a function to CameraCapabilities of converting PixelFormat to android format. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- src/android/camera_capabilities.cpp | 18 ++++++++++++++++++ src/android/camera_capabilities.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index f357902e..4c1dc87c 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -545,6 +545,7 @@ int CameraCapabilities::initializeStreamConfigurations() */ if (androidFormat == HAL_PIXEL_FORMAT_BLOB) { formatsMap_[androidFormat] = formats::MJPEG; + revFormatsMap_[formats::MJPEG] = androidFormat; LOG(HAL, Debug) << "Mapped Android format " << camera3Format.name << " to " << formats::MJPEG.toString() @@ -596,6 +597,7 @@ int CameraCapabilities::initializeStreamConfigurations() * stream configurations map, by testing the image resolutions. */ formatsMap_[androidFormat] = mappedFormat; + revFormatsMap_[mappedFormat] = androidFormat; LOG(HAL, Debug) << "Mapped Android format " << camera3Format.name << " to " << mappedFormat.toString(); @@ -1422,6 +1424,22 @@ PixelFormat CameraCapabilities::toPixelFormat(int format) const return it->second; } +/* + * Translate libcamera pixel format to Android format code. -1 if no mapped + * android format is found. + */ +int CameraCapabilities::toAndroidFormat(PixelFormat format) const +{ + auto it = revFormatsMap_.find(format); + if (it == revFormatsMap_.end()) { + LOG(HAL, Error) << "Requested format " << format.toString() + << " not supported"; + return -1; + } + + return it->second; +} + std::unique_ptr CameraCapabilities::requestTemplateManual() const { if (!capabilities_.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) { diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index 2cf97ae8..df6361f1 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -30,6 +30,7 @@ public: CameraMetadata *staticMetadata() const { return staticMetadata_.get(); } libcamera::PixelFormat toPixelFormat(int format) const; + int toAndroidFormat(libcamera::PixelFormat format) const; unsigned int maxJpegBufferSize() const { return maxJpegBufferSize_; } std::unique_ptr requestTemplateManual() const; @@ -77,6 +78,7 @@ private: std::vector streamConfigurations_; std::map formatsMap_; + std::map revFormatsMap_; std::unique_ptr staticMetadata_; unsigned int maxJpegBufferSize_;