From patchwork Fri Dec 10 11:21:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15109 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 1DC9DBF415 for ; Fri, 10 Dec 2021 11:22:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BDCA5608E3; Fri, 10 Dec 2021 12:22:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Mvv0Nj4G"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D5F46088E for ; Fri, 10 Dec 2021 12:22:07 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id i12so6546795wmq.4 for ; Fri, 10 Dec 2021 03:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XppW0uYN/+TM2EogMDHujEnG3QJ6JaZY9LDGXon35AQ=; b=Mvv0Nj4GK2BEVkAZ8MQbw6nS/SNjpyfYd2q7vVNY9duqgeb2PRqFGW+U5Wjv2h1fjI dYMHJsaTO7sbwuB5JRx9y0y+nMXAMJhI0VZx84mGY/TQ7vEtNfazH5Brlyl5DREidutc gMuVynssiL8/+qzHmloVshFzkr2ID+taDRh2jef6Cq+Bay5/9l75WD+mlheHfrBAlh1e AGBdRZwJhzkU+z/oPxKVjjk/TCHqVNrAeKNy+/qR9/3BzsnyLa1DEleOzVkLdUaYIB3B ynPwFmm4Im7b6Ok+u6RLAFUZaZmR0LOYpc+LkAUjKScpzTkAEtDc34dX7bAGRjZ4l/Bq NcNA== 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=XppW0uYN/+TM2EogMDHujEnG3QJ6JaZY9LDGXon35AQ=; b=uKgIicihoVtD1RLAzWLUyWewRQcywlmmv0RzonP2j9l5GOIAerkUt3cxmvti2rYHZO iS5BcLMYbizdYv2+DixKIjOaxF8bCRmyVGS+qbZmz/i8Iil8Vvu4qzVltSCF+UjDJ4nn MDuYKhkxFW8bKErqEz5ebZ6/6+p+SJRVKTeOtYGjC/QfvawATC1p0FjiYLEncNdAJ12j jLYabQUVoY9UAaDOUCaWKk8Wu2jq6YwuPqik3GJLiawE7Bj9lJhSNmiw13WmsvAMFspm +Co/6RgzqoXWsMpftsw3wC1k66wZcudl43/oOGD8cFywZQllL7JT+9U8pq5doo67dGec yu3g== X-Gm-Message-State: AOAM531IGbMFOFzMdoPv95qA0UoDiAOCpIqHGLqXH3ap3G46Pe8/mOqV oxHnr8ydFMpCuf3mTuX8M9NnZQ== X-Google-Smtp-Source: ABdhPJyYBORRBy9I9gj79LaxbzoNSxLaDqARb86afXjV/8KATPuOKoUh9X+E3SoDqxU6PNtdpxTLmg== X-Received: by 2002:a05:600c:34d6:: with SMTP id d22mr15981786wmq.111.1639135326853; Fri, 10 Dec 2021 03:22:06 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:e4a2:3070:eea4:e434]) by smtp.gmail.com with ESMTPSA id z18sm2198469wrq.11.2021.12.10.03.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:22:06 -0800 (PST) From: David Plowman To: Laurent Pinchart , Kieran Bingham , Hans Verkuil , Tomasz Figa , Jacopo Mondi , Naushir Patuck , libcamera-devel@lists.libcamera.org Date: Fri, 10 Dec 2021 11:21:39 +0000 Message-Id: <20211210112142.18441-6-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211210112142.18441-1-david.plowman@raspberrypi.com> References: <20211210112142.18441-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v11 5/8] libcamera: v4l2_subdevice: Add colorSpace field to V4L2SubdeviceFormat 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 ColorSpace field to the V4L2SubdeviceFormat so that we can set and request particular color spaces from V4L2. This commit simply adds the field and fixes some occurrences of brace initializers that would otherwise be broken. A subsequent commit will pass and retrieve the value correctly to/from V4l2 itself. Signed-off-by: David Plowman Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/v4l2_subdevice.h | 3 +++ src/libcamera/camera_sensor.cpp | 1 + src/libcamera/pipeline/ipu3/cio2.cpp | 7 +++---- src/libcamera/pipeline/simple/simple.cpp | 8 ++++++-- src/libcamera/v4l2_subdevice.cpp | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index a6873b67..58d1e511 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -8,12 +8,14 @@ #pragma once #include +#include #include #include #include #include +#include #include #include "libcamera/internal/formats.h" @@ -27,6 +29,7 @@ class MediaDevice; struct V4L2SubdeviceFormat { uint32_t mbus_code; Size size; + std::optional colorSpace; const std::string toString() const; uint8_t bitsPerPixel() const; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 7bb39b1e..c3999d35 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -642,6 +642,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector &mbu V4L2SubdeviceFormat format{ .mbus_code = bestCode, .size = *bestSize, + .colorSpace = ColorSpace::Raw, }; return format; diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 59dda56b..f4e8c663 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -322,10 +322,9 @@ V4L2SubdeviceFormat CIO2Device::getSensorFormat(const std::vector return {}; } - V4L2SubdeviceFormat format{ - .mbus_code = bestCode, - .size = bestSize, - }; + V4L2SubdeviceFormat format{}; + format.mbus_code = bestCode; + format.size = bestSize; return format; } diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 701fb4be..a3108fc0 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -457,7 +457,9 @@ int SimpleCameraData::init() * formats on the video node. */ for (unsigned int code : sensor_->mbusCodes()) { - V4L2SubdeviceFormat format{ code, sensor_->resolution() }; + V4L2SubdeviceFormat format{}; + format.mbus_code = code; + format.size = sensor_->resolution(); ret = setupFormats(&format, V4L2Subdevice::TryFormat); if (ret < 0) { @@ -908,7 +910,9 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) return ret; const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig(); - V4L2SubdeviceFormat format{ pipeConfig->code, data->sensor_->resolution() }; + V4L2SubdeviceFormat format{}; + format.mbus_code = pipeConfig->code; + format.size = data->sensor_->resolution(); ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat); if (ret < 0) diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 61e15b69..b782325a 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -169,6 +169,21 @@ const std::map formatInfoMap = { * \brief The image size in pixels */ +/** + * \var V4L2SubdeviceFormat::colorSpace + * \brief The color space of the pixels + * + * The color space of the image. When setting the format this may be + * unset, in which case the driver gets to use its default color space. + * After being set, this value should contain the color space that + * was actually used. If this value is unset, then the color space chosen + * by the driver could not be represented by the ColorSpace class (and + * should probably be added). + * + * It is up to the pipeline handler or application to check if the + * resulting color space is acceptable. + */ + /** * \brief Assemble and return a string describing the format * \return A string describing the V4L2SubdeviceFormat