From patchwork Fri Dec 16 14:33:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 18034 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 263D3C3200 for ; Fri, 16 Dec 2022 14:33:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 76A836339F; Fri, 16 Dec 2022 15:33:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1671201229; bh=RD/JCYKdDNObt8lsyWujFgzMlrmQ4csJkCVMfg7OSdE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=eJZeQ0WSn7Smm7eLxnQFNN8FdCdaM4yhGpBhLlM+6oPbBvpODrUjOK0WtOK44h6Zt PnIdsWcPwJjO74emvFniDtHvjmuQGYolPQGkIJattwrOqQwOhETH+xPxF+0fFA8l+C gLtAuuIU1riFQ81VgJNBD5sA02vLUhGUrscccnBXjMjmVRmvCO+Dgv0o+AxN9f41xa UaMa2vNMUs8NX/t6THiPCmQWfN3kxRZlK3mPwX/euC70XLiR/mtbNdzq+eqxKCvg3H e9i3wwvhu4YqcpMxupYXDSCNtaiSiTth45Ty/JySjqcg5Cp7Odv7Yfeb3Xc+vgCeAz F7eVTtuJa49kQ== Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E64AB603D0 for ; Fri, 16 Dec 2022 15:33:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="U/x+Hdff"; dkim-atps=neutral Received: by mail-ej1-x629.google.com with SMTP id u19so6558484ejm.8 for ; Fri, 16 Dec 2022 06:33:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=G+ShPsgGPFpoqHj49ZDpjHnLa154NYtk9A6g8Rb5UWY=; b=U/x+HdffQqabf4xuHe/xfKB0XUcfv627v7Ua8GSqbkYfRmDUvSPUphlag4tu00DhHI k0OqhJ3YNeNeUCNVg3Rgk/YoJk7sTyUKdI8VygX279OyTnhdk+toWwqA31GCeE2zdNS/ 5PRS/r9EogKiROs2avddrkJ3bl2qxt4FFj43FILTDw5iT88/WUIVrFwPyJKBrZBIJy99 A6Tt5ks4Zu7sinXiORp1ZmF1jeeEmUOE+eqw9Ks+rxuNnIe0rg6AAE5CsbUWxdJpysw5 xjDsLR4Dp8QArPPrc5gcXqcLltZ4QRnzYIYkdANSI/9HgozIUojlugrbZfR8s/VJ3f6Z vGfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G+ShPsgGPFpoqHj49ZDpjHnLa154NYtk9A6g8Rb5UWY=; b=s+tPw7sm1/XLpStKtnj65aJ0po22ABBrszJD/nRMzHw2nFsMmqcyFJkir0Vfv17Rf6 FCb4Qsly5czDv8TBEvnFtKWEE1W80015MSOVJDi45/Df7kaQnu44Q4PA4PGFRs2Q7Mcu r+Yo6MAy2pwH/DPSp9I2Ovow7Rx5f8mJmXQivs//5sdgySUq73Wj0OYu9bWBY2HjWqPd 3nXvoNsmMAjKepyB7z2Hzxb/EPr/2jzJaW9v2hdhYk3qrb3qvN6DHsw0p+rXgSR3V1PN z75oLcFBKOsUI1v8XN/ZOvRYoVVa5pIPFwJnK+dSaD+wKMeKnuZvFTXGPuBgQCdiS8wm JLkA== X-Gm-Message-State: ANoB5pkvwC4dSBDeKZwJT/XywiigdJ0JFVtINAWa/Tpt1xGko+utsqnW DIVUdLe26UA4HJsT0dpsZhrxjtB2XwtwTeBt X-Google-Smtp-Source: AA0mqf7MKY4r+F2XgUfwfzZwCWXUwzNBVGYROcPrh+YC78kNtfPbR25tIt869VmE+89LgaPtS2Di1w== X-Received: by 2002:a17:906:8241:b0:7be:1ce1:ce3d with SMTP id f1-20020a170906824100b007be1ce1ce3dmr24222291ejx.66.1671201227231; Fri, 16 Dec 2022 06:33:47 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id mb4-20020a170906eb0400b0073dd8e5a39fsm907903ejb.156.2022.12.16.06.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 06:33:46 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Dec 2022 14:33:41 +0000 Message-Id: <20221216143344.8177-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/3] Fix colour spaces on Raspberry Pi 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-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi everyone I'm guessing that not too many of you are aware that mainline libcamera has been broken on the Raspberry Pi since the summer. Specifically, changes to the way colour spaces work were responsible, and since then we've been living off our own fork of the tree with enough of those changes reverted. But clearly this is not a good situation so this patch set makes libcamera work on the Raspberry Pi again. There are 3 patches. I sense some of them may provoke a fair bit of discussion. 1. I think the first patch will be uncontroversial, it merely fixes a bug in validateColorSpaces that has been there since the dawn of time, but no one ever noticed! 2. Again in validateColorSpaces, we note that "streams sharing a colour space" is quite broken because RGB streams have no YCbCr information in them, and would therefore destroy any YUV streams they get "shared" on top of! We fix that by choosing not only a "principal" stream, but also a "principal" YUV stream. This has all become annoyingly complicated and I wonder whether we should just remove this whole "colour space sharing" thing. I thought I was doing the world a favour but honestly, it might be easier to deal with in the Raspberry Pi PH where the options are considerably more constrained. Opinions sought on that, please! 3. The last patch is the worst. It does some massaging on colour spaces so that the "right" conversions happen downstream, the "right" things get passed to the Raspberry Pi hardware drivers (that only care about the V4L2_COLORSPACE) and it also knows how to check more carefully whether what gets returned is really what it expected. There is obviously a degree of trade-off between what is happening here and the behaviour of the underlying layers of software, which is something one might want to look at. Though I wouldn't want people to forget that things are broken for us right now! Having said all that, and in spite of the general angst, these patches do actually work. Thanks! David David Plowman (3): libcamera: camera: fix validateColorSpaces to choose the correct "main" colour space libcamera: camera: Fix validateColorSpaces not to loose YCbCr encodings pipeline: raspberrypi: Fix colour spaces by handling missing YCbCr information src/libcamera/camera.cpp | 51 +++++++++++++++-- .../pipeline/raspberrypi/raspberrypi.cpp | 56 ++++++++++++++++++- 2 files changed, 99 insertions(+), 8 deletions(-)