From patchwork Wed Aug 11 12:40:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13305 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 CDF79C3241 for ; Wed, 11 Aug 2021 12:40:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8AE9668889; Wed, 11 Aug 2021 14:40:32 +0200 (CEST) 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="GRtFzgKG"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 73F0768855 for ; Wed, 11 Aug 2021 14:40:31 +0200 (CEST) Received: by mail-pj1-x1029.google.com with SMTP id w13-20020a17090aea0db029017897a5f7bcso4585433pjy.5 for ; Wed, 11 Aug 2021 05:40:31 -0700 (PDT) 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=WBUGIjr+wc7ofyPPRfY1jSJxy/NlmDYAAjxmkELPkXY=; b=GRtFzgKGzQB911DjENlPHZs3p4Pdj43SOGbMmErgRaHKIycEJCxHz71HQs94YsSapK I8FwSm25CnCyS2/fsbhKJjCA97j1yR4mFsJRqQ/PP8dxAz/6zR4vj/6Yefk1ghOFaudZ b+qTIh2/M3RhUCsP+PxNaOg3Pgffe3RJXCIWQ= 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=WBUGIjr+wc7ofyPPRfY1jSJxy/NlmDYAAjxmkELPkXY=; b=YnH4urc85Ez7SFUAxeMIYGdRlrLO8PCqi4DPWVQ1FgW7I3t0vWF0Jt6BNtoBA+1QdO AL++MaNl1cBvP02KDZa2iCk1XN7tYhzujeFYzeC4+Ht0rv+9QChdJ9dm7N64xjz6mc4m OqGJUcHMa8y0E2AJ9qUrHAfEnPf13qOVRtJnUG4gBwnbJuycNS2kN7tTelaFzSF6oADl kkjYoDxulwqevyJ0a1/J0hV2EGEUYnrZyS0vTcy7oSUjHvzPCMyGMTjwkyPbQyb7g3Yq BXG+5n2I29hmwOsnodQdUXHX6grUQxhqGIXixhE2rJfJ0Dflw5P7Rcta4gFeJq0Nc50a zS2w== X-Gm-Message-State: AOAM530/vP9XOQGwC4bQgNiVynMUm6bfWfDBP4/UCwP6/FUZLFCr1JPl nAtB5usLaPDch21DYd5lpZtWM7q8iIAaTA== X-Google-Smtp-Source: ABdhPJwctDQaZFE/ajeV1RGtWgcRPzBoZCcp30HGWz3gt8SvQ1sWU+5Hquqfwy7dtsOlr4IWUMXJnw== X-Received: by 2002:aa7:9f12:0:b029:3e0:3224:6cd5 with SMTP id g18-20020aa79f120000b02903e032246cd5mr1976379pfr.43.1628685629748; Wed, 11 Aug 2021 05:40:29 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:ba11:c25e:242c:485d]) by smtp.gmail.com with ESMTPSA id p30sm15722876pfh.116.2021.08.11.05.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 05:40:29 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 11 Aug 2021 21:40:14 +0900 Message-Id: <20210811124015.2116188-5-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog In-Reply-To: <20210811124015.2116188-1-hiroh@chromium.org> References: <20210811124015.2116188-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/5] WIP: libcamera: V4L2VideoDevice: Fix a bug in CreateBuffer() 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" FrameBuffer created in V4L2VideoDevice::CreateBuffer() has the same number of planes as v4l2 buffer planes. However, if the format is a single planar format, the number of planes is one. FrameBuffer should have the same number of planes as color format planes. Signed-off-by: Hirokazu Honda --- src/libcamera/v4l2_videodevice.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index ce60dff6..e70076f3 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1269,7 +1269,6 @@ std::unique_ptr V4L2VideoDevice::createBuffer(unsigned int index) const bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); const unsigned int numPlanes = multiPlanar ? buf.length : 1; - if (numPlanes == 0 || numPlanes > VIDEO_MAX_PLANES) { LOG(V4L2, Error) << "Invalid number of planes"; return nullptr; @@ -1289,6 +1288,20 @@ std::unique_ptr V4L2VideoDevice::createBuffer(unsigned int index) planes.push_back(std::move(plane)); } + + V4L2DeviceFormat format{}; + ret = getFormat(&format); + if (ret < 0) { + LOG(V4L2, Error) << "Failed to get buffer format"; + return nullptr; + } + if (format.fourcc == V4L2_PIX_FMT_NV12) { + planes.resize(2); + planes[0].length = format.size.width * format.size.height; + planes[1].fd = planes[0].fd; + planes[1].length = format.size.width * ((format.size.height + 1) / 2); + } + return std::make_unique(std::move(planes)); }