From patchwork Thu Jan 28 09:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11039 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 42212BD808 for ; Thu, 28 Jan 2021 09:10:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1167868383; Thu, 28 Jan 2021 10:10:59 +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="rNuqhqHv"; dkim-atps=neutral Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FB406837A for ; Thu, 28 Jan 2021 10:10:56 +0100 (CET) Received: by mail-wr1-x42e.google.com with SMTP id v15so4612796wrx.4 for ; Thu, 28 Jan 2021 01:10:56 -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=Vjiy0X5vCxiIh0kqLnE5/yh2+p1/5u96Km9Vbm5Nhag=; b=rNuqhqHvbXxbnOQzcjoGf2m0c2lBIWouTC9R6KUmb8A/uuAPTU4dzDDPFN4Y8A97xK 8Iu5gGHrpbxmoHDOPCp/LRjDKe0YCOrHTJqgmA2JaytisdAjCY12laajaCwS0oFXxoK2 OE7yVwyCVouaQOPBCfEcAFIgdqFdnM5mNAEjIDgdyLyVV5VarsE8Vs+orvH6bb7LlI2s 1gSoR8wQ2KKEO4+v4L0SmWVjcwxHTpTwoWFfzlpJuX4ViipkcUtF7w3WueqvQw+qE+EV XIxhB8G5az+Rl2I6R0qqkNdsESjgH1PLEN+lCYVsZ2YbYSnka58ILoQNcjWi06W9YZ8/ 3MQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vjiy0X5vCxiIh0kqLnE5/yh2+p1/5u96Km9Vbm5Nhag=; b=J3RHv/u3hLgWrbUEkTVmHw6htTED6A//dGiFjAva5T+qJaPviTHSwRJ8hVEeo4+rzy 9ZFKSptcTYVe2wO7dmE9o6DSj6I+4QhdMBfbU5LJ5YiUUfbT37YGH2yO2dNYgkh/pCuB bstStYzkYHBurlk/oL5gI2JlJxqAjue5H12iOySB4WafKO7xBoOokqE+gkVRy8au4ioQ 1YWbGD4S3tf2nxC72VCjfL/QH/htJlYSniV2I9EIgjsQmbV4nTVdHwVrZUntImEG0F5i avpnjIujJmj34o3EGs11yu3WlFYujQAkeNwR1UPyJ1UcKmPP9rc8ugADJRSiO60LeeAK nORA== X-Gm-Message-State: AOAM532NExsq9ylpumnWhvHiHps5KoH3GqLMURdrh9APVPB4Xw+LrQ2Z PtlP8qmJlDtN1B4lVwOlHlglr201Yex2Qmdf X-Google-Smtp-Source: ABdhPJxM2OmdeaqnGJFd8KfMV4KA5jahZlTVgMLoPxScmDkH09vQGCWAnxQetyCgg0uRQ5O3sIdIXw== X-Received: by 2002:adf:fc8a:: with SMTP id g10mr15702631wrr.189.1611825055865; Thu, 28 Jan 2021 01:10:55 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id f17sm6517056wrv.0.2021.01.28.01.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 01:10:55 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Jan 2021 09:10:47 +0000 Message-Id: <20210128091050.881815-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128091050.881815-1-naush@raspberrypi.com> References: <20210128091050.881815-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/5] libcamera: camera_sensor: Add frame length limits to CameraSensorInfo 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" Sensor frame length is made up of active and inactive (blanking) lines. The minimum and maximum frame length values may be used by pipeline handlers to limit frame durations based on the sensor mode capabilities. Store the minimum and maximum allowable frame length values (in lines) in the CameraSensorInfo structure. These values are computed in CameraSensor::sensorInfo() by querying the sensor subdevice V4L2_CID_VBLANK control limits. This in turn means that V4L2_CID_VBLANK is now a mandatory subdevice control. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- include/libcamera/internal/camera_sensor.h | 3 ++ src/libcamera/camera_sensor.cpp | 43 ++++++++++++++++++++-- test/ipa/ipa_wrappers_test.cpp | 2 + 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index fed36bf26e47..5d8c9b1a3121 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -33,6 +33,9 @@ struct CameraSensorInfo { uint64_t pixelRate; uint32_t lineLength; + + uint32_t minFrameLength; + uint32_t maxFrameLength; }; class CameraSensor : protected Loggable diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ab315bdc468c..f60d0cc9c6fa 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -113,6 +113,36 @@ LOG_DEFINE_CATEGORY(CameraSensor) * The total line length in pixel clock periods, including blanking. */ +/** + * \var CameraSensorInfo::minFrameLength + * \brief The minimum allowable frame length in units of lines + * + * The sensor frame length comprises of active output lines and blanking lines + * in a frame. The minimum frame length value dictates the minimum allowable + * frame duration of the sensor mode. + * + * To obtain the minimum frame duration: + * + * \verbatim + frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + \endverbatim + */ + +/** + * \var CameraSensorInfo::maxFrameLength + * \brief The maximum allowable frame length in units of lines + * + * The sensor frame length comprises of active output lines and blanking lines + * in a frame. The maximum frame length value dictates the maximum allowable + * frame duration of the sensor mode. + * + * To obtain the maximum frame duration: + * + * \verbatim + frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + \endverbatim + */ + /** * \class CameraSensor * \brief A camera sensor based on V4L2 subdevices @@ -699,12 +729,13 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const info->outputSize = format.size; /* - * Retrieve the pixel rate and the line length through V4L2 controls. - * Support for the V4L2_CID_PIXEL_RATE and V4L2_CID_HBLANK controls is - * mandatory. + * Retrieve the pixel rate, line length and minimum/maximum frame + * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE, + * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory. */ ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE, - V4L2_CID_HBLANK }); + V4L2_CID_HBLANK, + V4L2_CID_VBLANK }); if (ctrls.empty()) { LOG(CameraSensor, Error) << "Failed to retrieve camera info controls"; @@ -715,6 +746,10 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const info->lineLength = info->outputSize.width + hblank; info->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get(); + const ControlInfo vblank = ctrls.infoMap()->at(V4L2_CID_VBLANK); + info->minFrameLength = info->outputSize.height + vblank.min().get(); + info->maxFrameLength = info->outputSize.height + vblank.max().get(); + return 0; } diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index 47533d105d03..eb6d783e8489 100644 --- a/test/ipa/ipa_wrappers_test.cpp +++ b/test/ipa/ipa_wrappers_test.cpp @@ -313,6 +313,8 @@ protected: .outputSize = { 2560, 1940 }, .pixelRate = 96000000, .lineLength = 2918, + .minFrameLength = 1940, + .maxFrameLength = 2880 }; std::map config{ { 1, { V4L2_PIX_FMT_YUYV, { 1024, 768 } } },