[{"id":39560,"web_url":"https://patchwork.libcamera.org/comment/39560/","msgid":"<CAEmqJPo3r4MaDkNOp06FUFGHbXQLVLKXttr6dv8PHuPgp0VuvA@mail.gmail.com>","date":"2026-07-02T10:46:29","subject":"Re: [PATCH] pipeline: rpi: pisp: Fix colours for NV21 and NV61 pixel\n\tformats","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThanks for the fix.\n\nOn Thu, 2 Jul 2026 at 10:59, David Plowman\n<david.plowman@raspberrypi.com> wrote:\n>\n> Code was previously passing the \"ORDER_SWAPPED\" flag to swap the U and\n> V components, but our hardware doesn't actually support this for\n> semi-planar formats.\n>\n> Instead swap over the 2nd and 3rd rows of the output colour conversion\n> matrices to achieve the same effect.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n> ---\n>  src/libcamera/pipeline/rpi/pisp/pisp.cpp | 27 ++++++++++++++++++++----\n>  1 file changed, 23 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> index 23f4c14d..5ea57399 100644\n> --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> @@ -172,11 +172,14 @@ pisp_image_format_config toPiSPImageFormat(V4L2DeviceFormat &format)\n>                 image.stride2 = image.stride;\n>                 break;\n>         case formats::NV21:\n> +               /*\n> +                * ORDER_SWAPPED does not work with semi-planar formats, so\n> +                * we going to have swap rows in the output CSC matrix.\n> +                */\n>                 image.format = PISP_IMAGE_FORMAT_THREE_CHANNEL +\n>                                PISP_IMAGE_FORMAT_BPS_8 +\n>                                PISP_IMAGE_FORMAT_SAMPLING_420 +\n> -                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR +\n> -                              PISP_IMAGE_FORMAT_ORDER_SWAPPED;\n> +                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR;\n>                 image.stride2 = image.stride;\n>                 break;\n>         case formats::YUYV:\n> @@ -200,11 +203,14 @@ pisp_image_format_config toPiSPImageFormat(V4L2DeviceFormat &format)\n>                 image.stride2 = image.stride;\n>                 break;\n>         case formats::NV61:\n> +               /*\n> +                * ORDER_SWAPPED does not work with semi-planar formats, so\n> +                * we going to have swap rows in the output CSC matrix.\n> +                */\n>                 image.format = PISP_IMAGE_FORMAT_THREE_CHANNEL +\n>                                PISP_IMAGE_FORMAT_BPS_8 +\n>                                PISP_IMAGE_FORMAT_SAMPLING_422 +\n> -                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR +\n> -                              PISP_IMAGE_FORMAT_ORDER_SWAPPED;\n> +                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR;\n>                 image.stride2 = image.stride;\n>                 break;\n>         case formats::RGB888:\n> @@ -1964,6 +1970,19 @@ bool PiSPCameraData::calculateCscConfiguration(const V4L2DeviceFormat &v4l2Forma\n>                                 << \", defaulting to sYCC\";\n>                         be_->InitialiseYcbcr(csc, \"jpeg\");\n>                 }\n> +\n> +               if (pixFormat == formats::NV21 || pixFormat == formats::NV61) {\n> +                       /*\n> +                        * The ORDER_SWAPPED flag doesn't work with semi-planar formats,\n> +                        * so instead we have to swap 2 matrix rows.\n> +                        */\n> +                       pisp_be_ccm_config copy = csc;\n> +                       memcpy(&csc.coeffs[3], &copy.coeffs[6], 3 * sizeof(csc.coeffs[0]));\n> +                       memcpy(&csc.coeffs[6], &copy.coeffs[3], 3 * sizeof(csc.coeffs[0]));\n> +                       csc.offsets[1] = copy.offsets[2];\n> +                       csc.offsets[2] = copy.offsets[1];\n> +               }\n> +\n>                 return true;\n>         }\n>         /* There will be more formats to check for in due course. */\n> --\n> 2.47.3\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 80737C3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2026 10:47:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A4D2D65FB8;\n\tThu,  2 Jul 2026 12:47:08 +0200 (CEST)","from mail-vk1-xa2f.google.com (mail-vk1-xa2f.google.com\n\t[IPv6:2607:f8b0:4864:20::a2f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F331656DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jul 2026 12:47:06 +0200 (CEST)","by mail-vk1-xa2f.google.com with SMTP id\n\t71dfb90a1353d-59db60df4d4so29833e0c.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Jul 2026 03:47:06 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"d0eAFeAo\"; dkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1782989225; cv=none;\n\td=google.com; s=arc-20260327;\n\tb=j6qU3F/V0snronBDFHi47VIUDhTVkcM9kK+8YajUBGa+8Ss1YgRwswx6ek30FhvusI\n\tGdZTq2CpYyTzzVwlYSwZy5YtA0T9j3CgUGDTjjtxyTeqxdmzNzZHg7b8zN5P2epJJupq\n\tf74DK9XtplPr037a8sqTP5IiQ102uUSQcgqOgByThF55zq+F4tBx3gtBP/8Jkf9tXyS5\n\tntTdzEtvmBq3xClIffNUuJ2vRIGC2FKZl4XRNZ9aEjiMPWqqH2+X5krJoEy457RWot0Q\n\tLlp47xcrPYJGD7v4JcYtUQ8IMHw76DJE8I7eV8J4DcvLy3KoDwXo5UgKna5ten87hqKz\n\t2Egw==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20260327; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:dkim-signature;\n\tbh=S4+AiGhafSFp0Yp1v97WqN8NNHCI4M7owenxTxCujUg=;\n\tfh=raf7gMhxwhTsDETG3li6wpOfdJf6YyDg/c7aYJ8coN8=;\n\tb=QezaYQZEk4+UYVnFoYmAbvatOanc/DwE8vfRl30lXvZPtexjY9ffLd0QKNHEmLJCCp\n\tZwnJ3o7qLuqTrYyxt532HeDNx4AqaerXu8s4EIo9waYR+yERgatbhMjWHKvr2DNvU/+3\n\tkAH8QxO3n5PgitIVEu+x/1/7Zd/i1Z69Sn9cr+JvmqT9N6PJuiTQQGKZvF6u3U3ZZRfi\n\tuu5vyh1IbbwFGAuTArG6yVQiDNePjk2tMGAF40eV5hTdCAiUyvNrvJfnsITGarGzd52o\n\tn7EBBm1lNvfRzYotVFyRfsRm2EaQNSd8dY/N2kKBv4Uau4DgUx09V8B4jXVF9evYHXjU\n\t+Gfw==; darn=lists.libcamera.org","ARC-Authentication-Results":"i=1; mx.google.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1782989225; x=1783594025;\n\tdarn=lists.libcamera.org; \n\th=content-type:cc:to:subject:message-id:date:from:in-reply-to\n\t:references:mime-version:from:to:cc:subject:date:message-id:reply-to\n\t:content-type; bh=S4+AiGhafSFp0Yp1v97WqN8NNHCI4M7owenxTxCujUg=;\n\tb=d0eAFeAo27XCJh6VH5H5e+p2cHC9xPCsPT5ERbYmkwqaA+VlJrJGdxDHT7WQKX0vG1\n\tzgCkG0muFMiDlW2erSZOXaTqvV9U6Uv499i2teMyO/0HniNN89/Ui8/2UOPK1nc0CbA6\n\tu4Ja9xKOrHmnOcIZAffWE9sV4bwFlzmotIe4moY03sSrGx6LEXo4ltnYtkSSKIDk2Cv5\n\tsfUq7eXSIKcTbM/m1UKNDNbcfyqVtGANM2W9f5FOSOEA4rrp902tO+M3gkX1czrJjByc\n\tDACcBfcRLXsWnnoHA5E5ViXomIfldZ0M1O4N96Oemr8zbM13ir3cXc1fBUt8WSNf/OmG\n\tbiDQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782989225; x=1783594025;\n\th=content-type:cc:to:subject:message-id:date:from:in-reply-to\n\t:references:mime-version:x-gm-gg:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to:content-type;\n\tbh=S4+AiGhafSFp0Yp1v97WqN8NNHCI4M7owenxTxCujUg=;\n\tb=VoIlxhpZXbxd5lM1NbJGvwFe6vaOSB9T5e5nylL6Faw4qMbXntWd0c19Oy8XmAJzzC\n\thvzutPLzWCMUCd9FZF2IeV2PbUt3/sJBU+oBBIl1CMls9+egsPjJLyfu7bEbpF3HHqDP\n\ttD7nEWXcVMBWNnVuSqjZgEknORL1RiOfn9u2AVfPsDP6gvPngMXR1tcdZvV7eY6ZPy86\n\tZOGSxLgVxy8tVq0FoG4xVINgf2oMRVxfUEV87VRLxrXM2Z0iKAO4T+8JmNHl1uEOLwNW\n\t0muzaTk83ERGsydXluKbwMHpTABtS43jELENburjM16FeDax9LpGYnvYUAm/nQmexwkI\n\tpuNw==","X-Gm-Message-State":"AOJu0YxU5uw2z5UMFF2oUycGCVnufDb3Vq52mM1lEh888ZtXxpYF/T/k\n\trNAZo+A8rYYVaWxvLSOA1It3QAR5ZRpHvW2oi+p4zcqn5OIRsHKPIl9Ft6T5wFRsgraVdtyDtED\n\thXtnkknDpoK6fejdvZYFunor7rgN8vLjOehoia5yWVA==","X-Gm-Gg":"AfdE7ck0ABkOpQxfAeddBgidK79SGxxvzeAXOl9+X3edGHjnrO8Rkkg7ed+UltKRA5b\n\tWh27Ii7ntg9mKNoCC6MY8wU1XXBgF/N6h7O2PNHMzwEZ2snAUdyHmxqPmTJNQNLAZTUtCDF5C08\n\tEegaD9l4PtoYPRlZFalzSvsppskf/kElCQ5I5rZDIopdYuMYekXF9Gdisz7JUcvO3OGox3vJ4RG\n\ttPC2waSQD5IzOlQkZtIa2WJuPa9Dy1G0YEWNpmzZ+XLF4ZIxbvOxra13Tkj4GVQvPbeReNWFCJ1\n\twlWMI8yUlo9xWU2sVaZ0OOfRNeWEUbkqzc+O4yOcuk5Ji/nBp7F/+NO26h1foHwpKf2BvYy2o46\n\tZw522lwdplqJD/DUkeQZwBm2i3YzcH/ontykFXvlW160TzVkG8boyejxZadOhlVxyp+MFaBdxzO\n\tt8s/pEHVNVOPz0","X-Received":"by 2002:a05:6122:2b16:b0:5bd:a3d0:923c with SMTP id\n\t71dfb90a1353d-5bddf2c0d0dmr575233e0c.0.1782989225431; Thu, 02 Jul 2026\n\t03:47:05 -0700 (PDT)","MIME-Version":"1.0","References":"<20260702095903.79640-1-david.plowman@raspberrypi.com>","In-Reply-To":"<20260702095903.79640-1-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Thu, 2 Jul 2026 11:46:29 +0100","X-Gm-Features":"AVVi8Ce8U7PfNyVFIRGYA8ls7LLZuePmKHiNnZvVnf3Yo_YztIg8QLsQAAI0KY4","Message-ID":"<CAEmqJPo3r4MaDkNOp06FUFGHbXQLVLKXttr6dv8PHuPgp0VuvA@mail.gmail.com>","Subject":"Re: [PATCH] pipeline: rpi: pisp: Fix colours for NV21 and NV61 pixel\n\tformats","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":39561,"web_url":"https://patchwork.libcamera.org/comment/39561/","msgid":"<CAHW6GYKhTEEMCfu4Jqq6JhS39U8c=UeCjC8XAZDTt=+_nnC7Dw@mail.gmail.com>","date":"2026-07-02T11:25:17","subject":"Re: [PATCH] pipeline: rpi: pisp: Fix colours for NV21 and NV61 pixel\n\tformats","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for the review, but actually there is a problem.\n\nI'm inclined to drop this patch for the moment, I want to have another\nthink about it.\n\nDavid\n\nOn Thu, 2 Jul 2026 at 11:47, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\n> Hi David,\n>\n> Thanks for the fix.\n>\n> On Thu, 2 Jul 2026 at 10:59, David Plowman\n> <david.plowman@raspberrypi.com> wrote:\n> >\n> > Code was previously passing the \"ORDER_SWAPPED\" flag to swap the U and\n> > V components, but our hardware doesn't actually support this for\n> > semi-planar formats.\n> >\n> > Instead swap over the 2nd and 3rd rows of the output colour conversion\n> > matrices to achieve the same effect.\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n>\n> > ---\n> >  src/libcamera/pipeline/rpi/pisp/pisp.cpp | 27 ++++++++++++++++++++----\n> >  1 file changed, 23 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> > index 23f4c14d..5ea57399 100644\n> > --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> > +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> > @@ -172,11 +172,14 @@ pisp_image_format_config toPiSPImageFormat(V4L2DeviceFormat &format)\n> >                 image.stride2 = image.stride;\n> >                 break;\n> >         case formats::NV21:\n> > +               /*\n> > +                * ORDER_SWAPPED does not work with semi-planar formats, so\n> > +                * we going to have swap rows in the output CSC matrix.\n> > +                */\n> >                 image.format = PISP_IMAGE_FORMAT_THREE_CHANNEL +\n> >                                PISP_IMAGE_FORMAT_BPS_8 +\n> >                                PISP_IMAGE_FORMAT_SAMPLING_420 +\n> > -                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR +\n> > -                              PISP_IMAGE_FORMAT_ORDER_SWAPPED;\n> > +                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR;\n> >                 image.stride2 = image.stride;\n> >                 break;\n> >         case formats::YUYV:\n> > @@ -200,11 +203,14 @@ pisp_image_format_config toPiSPImageFormat(V4L2DeviceFormat &format)\n> >                 image.stride2 = image.stride;\n> >                 break;\n> >         case formats::NV61:\n> > +               /*\n> > +                * ORDER_SWAPPED does not work with semi-planar formats, so\n> > +                * we going to have swap rows in the output CSC matrix.\n> > +                */\n> >                 image.format = PISP_IMAGE_FORMAT_THREE_CHANNEL +\n> >                                PISP_IMAGE_FORMAT_BPS_8 +\n> >                                PISP_IMAGE_FORMAT_SAMPLING_422 +\n> > -                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR +\n> > -                              PISP_IMAGE_FORMAT_ORDER_SWAPPED;\n> > +                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR;\n> >                 image.stride2 = image.stride;\n> >                 break;\n> >         case formats::RGB888:\n> > @@ -1964,6 +1970,19 @@ bool PiSPCameraData::calculateCscConfiguration(const V4L2DeviceFormat &v4l2Forma\n> >                                 << \", defaulting to sYCC\";\n> >                         be_->InitialiseYcbcr(csc, \"jpeg\");\n> >                 }\n> > +\n> > +               if (pixFormat == formats::NV21 || pixFormat == formats::NV61) {\n> > +                       /*\n> > +                        * The ORDER_SWAPPED flag doesn't work with semi-planar formats,\n> > +                        * so instead we have to swap 2 matrix rows.\n> > +                        */\n> > +                       pisp_be_ccm_config copy = csc;\n> > +                       memcpy(&csc.coeffs[3], &copy.coeffs[6], 3 * sizeof(csc.coeffs[0]));\n> > +                       memcpy(&csc.coeffs[6], &copy.coeffs[3], 3 * sizeof(csc.coeffs[0]));\n> > +                       csc.offsets[1] = copy.offsets[2];\n> > +                       csc.offsets[2] = copy.offsets[1];\n> > +               }\n> > +\n> >                 return true;\n> >         }\n> >         /* There will be more formats to check for in due course. */\n> > --\n> > 2.47.3\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1388FC3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2026 11:25:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4B3C265FB2;\n\tThu,  2 Jul 2026 13:25:30 +0200 (CEST)","from mail-ej1-x633.google.com (mail-ej1-x633.google.com\n\t[IPv6:2a00:1450:4864:20::633])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A9934656DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jul 2026 13:25:28 +0200 (CEST)","by mail-ej1-x633.google.com with SMTP id\n\ta640c23a62f3a-c125c082ee2so186336866b.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Jul 2026 04:25:28 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Ha9Rmys/\"; dkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1782991528; cv=none;\n\td=google.com; s=arc-20260327;\n\tb=KTiJK6zKd7XFO9ngbV/pLzeOB1UuHm8QQFE5Tg8qk36LMHfJjlBWC5dTiiePAm2p2M\n\tqWeT1BghbUIi0nXSVyf9g3HD/EyWVO+I7pMHsQloCAg2PXg794DW8fzrLFUuGuUAcudb\n\t8Avx2EYid/Xub5/dPuIr5bU3eKeXgoERztUnA9L92bXa5C+a9daPztdmYJKFUvmbzvrz\n\teS3HiXwqd9jbRaG7xbK6Ih0uXP2zuQqi8Pq7wRhlefN7YSh/MEXkY+CeBiOGEVSbb05v\n\tqNDzJ44pCjF2G0sVAN11hSdkzo7LZp8kC8IVoRq+726VrH6CYSWBVElKnAxC2Q/+BesG\n\t+81w==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20260327; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:dkim-signature;\n\tbh=CL/0Zo9L9qCBABI4nZfIkomnPuoQ2MSzYUK33HnkkHE=;\n\tfh=pViFh4rhBx6810yKb0wI4WZcwBOqDHh72fUf/cLkiP4=;\n\tb=VMg29QISIJWKIjMTJQLlJt2md2N8NTCZUdZ4ijXmrovI2y3/l+iL2URf4sWyEsMpLJ\n\tzxACM3F71HbsCaiXKvydK/ClG9SEc8gD3Le6Smk1Nq8HPJaJvUNC6KthhDzGiyRIg2Cw\n\tFxO3vDY86rcsRpT6WOcgkgIoz0WMD3p2ntGC72NzsE/x6thB4HubUTPD3Y28tuMWAFJo\n\trBnC8VrgMrXkf5nlHpCg0AoCUqD9mm9Mg+jvn3SaxS5w4MQZiA94WW0p+92U3xdCsni1\n\tIRUMZidi22RdW4Pqj0yK6Qt1bL+VjogJx8owfCQqhdleVJ7rG/hfenMGg4a2dvKrepm8\n\tlvCg==; darn=lists.libcamera.org","ARC-Authentication-Results":"i=1; mx.google.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1782991528; x=1783596328;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=CL/0Zo9L9qCBABI4nZfIkomnPuoQ2MSzYUK33HnkkHE=;\n\tb=Ha9Rmys/rQOQjSY0W+afPXRMh5ZIfWY69TZs2wQ+M8lX90Zm49dsd19xUUJfsyXKCj\n\tSjJ5k9BZp6QCuNDI2/5AkdOhDFczBeCYjcKRc6V0UrV5MQBaMYZ5VdukzZ3Y3tZEIV9J\n\tsnkKSEiUXAPRN0tyXLGLe2JWE5nkSTHZtdZKRB/iG5f9jhHnow5qph6ptgaWhN5+EyCq\n\tppBs1R0S0Bw7NMe7PLmMcHGqjcCYoHhWuIWi6DPT/lqchlcE6lB1xhkHeYFP0qOcfMZb\n\tJR0fk76uTHFHPNNKsrdGJA647PYgUmMRRIOa6aZaOa92FeR+mENzZlnH/c1yL0JPW2WT\n\tXMuA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782991528; x=1783596328;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=CL/0Zo9L9qCBABI4nZfIkomnPuoQ2MSzYUK33HnkkHE=;\n\tb=X6CEscBSjqEOt8MXsSEuXA5oYTT/0EAN8057GeYikXcx56Uz+bgRRPu3ScsyP6Yk4L\n\tqA92qWwW9gEMGMELr13UMdHNRaYStvqD0RbpiS88w0jfqcdhvD2r9r3ff98ewRcqSG3M\n\tESV0OEnYjS0CsgvQcwPWEZ1P7nX0j4NY9JrJw9SVlXUiyNCQmPWnjXkZNfAyG8tWFC/z\n\tj4t7wcko3dI/iv9z4pZfGQADVwQqVMytnM+uy3yVNeY6DtFxNrjnAn0bJLfohdDktxpi\n\t2MCceP7/bhteM1x+P03FzfNToeXr51lrcSQMIQVj8qJ0BEb6kmge5U+H/SSniiGyxvpV\n\tabJg==","X-Gm-Message-State":"AOJu0Yz/jVCgjZWbOPRohoE9LnP8nCYMogMCWtOunonC31jppgaby81y\n\tPChMZ3i2PovTvPP2BPHRYo/fBYqGqPisHYR8WNf1+QXxLDlWPFlk3MzptMM55cF+3HrSBJRu6dT\n\tJ7K4pD5a2rWVWkKQ87BTST8QZrYLfKf4+7JNt5fWzjnXUXMfNjwOLfyQ=","X-Gm-Gg":"AfdE7ckCiaHHJ3g7FUFB8Y1diP2ZvsVe1oJr0/jebne9lU8Vdcqhg7xLp13ivhnMNBD\n\t3rtHJ0uXNZfN43bXtmDPaexTXXx14iOQ6qJfQETToE8IDZDT9JgUa0s7lAm499xG8z+XEiGo92W\n\thEPgkIKUdqVfWsK7hD+cRJJRfOQ3GQAAnXloHAoJ49sRiTsV6ZERfLDKXAeQuXuYOXCY9GEMTx+\n\tZu3gR9lQiEHv2sGer/BmyZXlE+dISgTbt4hm1ZoI0iWihOF9GnFOiJNGBWlNeTM/S/v28alGPrA\n\tzxl/R/jKoTchNGan1oXOiuRxHfzDlR7U27ivPPFXR1RL8GflPiAqtyOw3P0bRvZdliXgZQmPWHH\n\tTMS/8EnUF8PZg2g==","X-Received":"by 2002:a17:906:abd8:b0:bee:bbaa:f19d with SMTP id\n\ta640c23a62f3a-c12a9d96d1amr207877266b.14.1782991527814;\n\tThu, 02 Jul 2026 04:25:27 -0700 (PDT)","MIME-Version":"1.0","References":"<20260702095903.79640-1-david.plowman@raspberrypi.com>\n\t<CAEmqJPo3r4MaDkNOp06FUFGHbXQLVLKXttr6dv8PHuPgp0VuvA@mail.gmail.com>","In-Reply-To":"<CAEmqJPo3r4MaDkNOp06FUFGHbXQLVLKXttr6dv8PHuPgp0VuvA@mail.gmail.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Thu, 2 Jul 2026 12:25:17 +0100","X-Gm-Features":"AVVi8Ce6jUl9TC2_5c_44x2_nUBcVmv5CAY_dwVXpcjEUXdp0vOKq8cLLUvAirg","Message-ID":"<CAHW6GYKhTEEMCfu4Jqq6JhS39U8c=UeCjC8XAZDTt=+_nnC7Dw@mail.gmail.com>","Subject":"Re: [PATCH] pipeline: rpi: pisp: Fix colours for NV21 and NV61 pixel\n\tformats","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":39562,"web_url":"https://patchwork.libcamera.org/comment/39562/","msgid":"<CAHW6GYLFZ89ryAHr5in31ycH_=3k+TphiquAVmPuMnp6+5g7bg@mail.gmail.com>","date":"2026-07-02T11:54:56","subject":"Re: [PATCH] pipeline: rpi: pisp: Fix colours for NV21 and NV61 pixel\n\tformats","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Sorry, wrong patch! No, this one is good!\n\nDavid\n\nOn Thu, 2 Jul 2026 at 12:25, David Plowman\n<david.plowman@raspberrypi.com> wrote:\n>\n> Hi Naush\n>\n> Thanks for the review, but actually there is a problem.\n>\n> I'm inclined to drop this patch for the moment, I want to have another\n> think about it.\n>\n> David\n>\n> On Thu, 2 Jul 2026 at 11:47, Naushir Patuck <naush@raspberrypi.com> wrote:\n> >\n> > Hi David,\n> >\n> > Thanks for the fix.\n> >\n> > On Thu, 2 Jul 2026 at 10:59, David Plowman\n> > <david.plowman@raspberrypi.com> wrote:\n> > >\n> > > Code was previously passing the \"ORDER_SWAPPED\" flag to swap the U and\n> > > V components, but our hardware doesn't actually support this for\n> > > semi-planar formats.\n> > >\n> > > Instead swap over the 2nd and 3rd rows of the output colour conversion\n> > > matrices to achieve the same effect.\n> > >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> >\n> > Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> >\n> > > ---\n> > >  src/libcamera/pipeline/rpi/pisp/pisp.cpp | 27 ++++++++++++++++++++----\n> > >  1 file changed, 23 insertions(+), 4 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> > > index 23f4c14d..5ea57399 100644\n> > > --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> > > +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> > > @@ -172,11 +172,14 @@ pisp_image_format_config toPiSPImageFormat(V4L2DeviceFormat &format)\n> > >                 image.stride2 = image.stride;\n> > >                 break;\n> > >         case formats::NV21:\n> > > +               /*\n> > > +                * ORDER_SWAPPED does not work with semi-planar formats, so\n> > > +                * we going to have swap rows in the output CSC matrix.\n> > > +                */\n> > >                 image.format = PISP_IMAGE_FORMAT_THREE_CHANNEL +\n> > >                                PISP_IMAGE_FORMAT_BPS_8 +\n> > >                                PISP_IMAGE_FORMAT_SAMPLING_420 +\n> > > -                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR +\n> > > -                              PISP_IMAGE_FORMAT_ORDER_SWAPPED;\n> > > +                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR;\n> > >                 image.stride2 = image.stride;\n> > >                 break;\n> > >         case formats::YUYV:\n> > > @@ -200,11 +203,14 @@ pisp_image_format_config toPiSPImageFormat(V4L2DeviceFormat &format)\n> > >                 image.stride2 = image.stride;\n> > >                 break;\n> > >         case formats::NV61:\n> > > +               /*\n> > > +                * ORDER_SWAPPED does not work with semi-planar formats, so\n> > > +                * we going to have swap rows in the output CSC matrix.\n> > > +                */\n> > >                 image.format = PISP_IMAGE_FORMAT_THREE_CHANNEL +\n> > >                                PISP_IMAGE_FORMAT_BPS_8 +\n> > >                                PISP_IMAGE_FORMAT_SAMPLING_422 +\n> > > -                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR +\n> > > -                              PISP_IMAGE_FORMAT_ORDER_SWAPPED;\n> > > +                              PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR;\n> > >                 image.stride2 = image.stride;\n> > >                 break;\n> > >         case formats::RGB888:\n> > > @@ -1964,6 +1970,19 @@ bool PiSPCameraData::calculateCscConfiguration(const V4L2DeviceFormat &v4l2Forma\n> > >                                 << \", defaulting to sYCC\";\n> > >                         be_->InitialiseYcbcr(csc, \"jpeg\");\n> > >                 }\n> > > +\n> > > +               if (pixFormat == formats::NV21 || pixFormat == formats::NV61) {\n> > > +                       /*\n> > > +                        * The ORDER_SWAPPED flag doesn't work with semi-planar formats,\n> > > +                        * so instead we have to swap 2 matrix rows.\n> > > +                        */\n> > > +                       pisp_be_ccm_config copy = csc;\n> > > +                       memcpy(&csc.coeffs[3], &copy.coeffs[6], 3 * sizeof(csc.coeffs[0]));\n> > > +                       memcpy(&csc.coeffs[6], &copy.coeffs[3], 3 * sizeof(csc.coeffs[0]));\n> > > +                       csc.offsets[1] = copy.offsets[2];\n> > > +                       csc.offsets[2] = copy.offsets[1];\n> > > +               }\n> > > +\n> > >                 return true;\n> > >         }\n> > >         /* There will be more formats to check for in due course. */\n> > > --\n> > > 2.47.3\n> > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D8C99C3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2026 11:55:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1619365FB2;\n\tThu,  2 Jul 2026 13:55:10 +0200 (CEST)","from mail-ed1-x536.google.com (mail-ed1-x536.google.com\n\t[IPv6:2a00:1450:4864:20::536])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 55F04656DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jul 2026 13:55:09 +0200 (CEST)","by mail-ed1-x536.google.com with SMTP id\n\t4fb4d7f45d1cf-698439b6e8aso3354848a12.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Jul 2026 04:55:09 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"jP1k4B6X\"; dkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1782993309; cv=none;\n\td=google.com; s=arc-20260327;\n\tb=Hum+mAUDeipuHzOPI+9d3w3sIsemtn8erc+OZH+u1D+bpdtRT4BI0GG6saX1K1X7qF\n\tQrVgZqeX1m8BUSorm5VGAM16IAeK9tPz9GX1ExhCr9RNsVLJXgTOHT/Y4jcT139gtWa5\n\t2XJEuZT6KI+wVTTIZ/PqxGNaUJDy5kRCNIv6mhMnYqm3a/HN66XJOHYVbW4NFq0XMMVR\n\tGROGtz8b4dbOOed9HJL+Wt9nzfjDlhdnSU1/jvkdUKrriEiUjsb1AhUZFgNFgj6Hhbba\n\teNX5aYVvMC6CtUNikt/1VzPOiC6lrkEflbJoiCiFBsCoAoffW/vv2f56QegOjJ8yPNpv\n\tOR8Q==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20260327; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:dkim-signature;\n\tbh=crH5PWrbjq2fwyu8q8CUOmy5Nw70k1ip8kROnaCbmRQ=;\n\tfh=pViFh4rhBx6810yKb0wI4WZcwBOqDHh72fUf/cLkiP4=;\n\tb=CUk/CySrQD225gNJp8sORJ7Bs6WT2mYT4eoC7UVgAB5rKV5WF9mYK++0pkzi6DHAa/\n\tjKa1RwCO1dcYY+Z1awQ76Yl3zO/jLVw0MseypvbzkbP4wLkcE0yxLq4MFjSKXMWPNyfR\n\tcjqrlwN55RFmNanaClFs8nyRzWk8Tl00JK/YuL0ad987/pX24ohk01iRBErYYGIHqWO9\n\thI0HCxSi+HCvzVtDgr/bFa/5q+wPlh4J9cc6W4DYaQf9nAITmGLB4kHVzWLr4YvenH8p\n\t69btfUnzJzEP4qAVEgMJqRmRjTngRjFuIfgwFnDAHeYg6GONyAvF31ScLCXGNaRfJjvw\n\tCosw==; darn=lists.libcamera.org","ARC-Authentication-Results":"i=1; mx.google.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1782993309; x=1783598109;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=crH5PWrbjq2fwyu8q8CUOmy5Nw70k1ip8kROnaCbmRQ=;\n\tb=jP1k4B6Xzh3zu4Todhr3o08mt9yK2EIohczikcvgTSzFrS9Z3ufyRP9n1aqG0PRC/s\n\tBs4FUJZXe5mw7hSmovuWwHpVmgZdecGQg2M6MUmzvL55GVcD3MC7tK9jMF9XaM+D3d/c\n\t08WmR2Gs3Hh2ds64eF40GjKUKQ9xAOLU01PDDsiHZyQr2m0OkG77MBmOTlieIMLpUTAZ\n\tQX99ImuChwOXmgxIJTQeL+8ay0/+zRgbOgNLfd0uvkQKiZnkjbSbNGrkqxQX9NkwfNwU\n\trtmPeEMuxMpYBjYirBHf+Jne+PDpdVfwn3dRQ2AwO1legwkcHUOcvUWyVCPvCB3FPnfE\n\tybyA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782993309; x=1783598109;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=crH5PWrbjq2fwyu8q8CUOmy5Nw70k1ip8kROnaCbmRQ=;\n\tb=m825EZFYuWz9tZ9d3gYX8rBtCNjWg5uCHL/ktNbY0x7dYvjZpDVAm3IV+vs7WXbA66\n\tvj1i4iUwYHYEokp+62W4MT9haQrfR1duhZJWTuRELWvX1lDSO1SvPMhhXGlt+vEZS3OW\n\trJ2VhHdYEh3bw6U+QW06/t5J0grah/Zk2AWtkVqXRq9n0jq8jZ6FmoOktNGsieZa4d6F\n\tUwnCIqA1F2XnAUwT6pwh/F2Y+Rjt8HXHR3i/OS8WlxM9x7DSQtHK5yYmT26N934xiX0Z\n\t41YNHzAZZ0gtpG+5PaAQ5dqP0emzqDjG3WF/Ed2trjGYB+xM4FnpDPcyi0LkHX6XuJkE\n\tePxg==","X-Gm-Message-State":"AOJu0YzqoSq+dQ4m/qHxL6vV2Q36A//rRIDvUtaUU4vLwuP4KYB1sfcL\n\tFB9ZTT1FYD+4AIsEUOcWVafV/PjordHHXuFwEwCmE3aiElZWYOxJlpZag7qpnW0LcouKhvUrka7\n\tTrA2HV12GqtuG1WeVkgiOvjtCI/TiK70lMIFaSDHYIw==","X-Gm-Gg":"AfdE7clCw2z7B+oE/aylObfdHTrAVSDI09Udh2+tXb/bP5GNb0B/T/8PnbkD8ol3s6o\n\tl+0fDY8FNyI2BB9myta3MXmSdu3AoJvtIot4nhfl3NFHh+MkgrsM2GyNMOkLdpBoxoQ2VkxU4eg\n\tZUMPrlHW/Z9i8ZfAtDTd8b3gx26cLeEfNYUc+Noagsb/CeHwTl8dout9AtxShIyIyFqnTb4B0DP\n\tuz+B2Lm+AJ84kXm/OWCbseaHKk9BrI45/azfsNpQLclaWtOrwa2BTMNo7kPEATNz8PMcUlDjSYb\n\tgcbImR1taOquIdCKNp0vyDybgZMwJBNAfbdtxdP4fKzLx4KEvVwAKNtK7+5OaRTBmng90JMFrAO\n\tHV6ptxZRTKtmLvSADio6asG7c","X-Received":"by 2002:a05:6402:28c7:b0:698:351c:97ae with SMTP id\n\t4fb4d7f45d1cf-6989f340c5fmr2733490a12.23.1782993308672;\n\tThu, 02 Jul 2026 04:55:08 -0700 (PDT)","MIME-Version":"1.0","References":"<20260702095903.79640-1-david.plowman@raspberrypi.com>\n\t<CAEmqJPo3r4MaDkNOp06FUFGHbXQLVLKXttr6dv8PHuPgp0VuvA@mail.gmail.com>\n\t<CAHW6GYKhTEEMCfu4Jqq6JhS39U8c=UeCjC8XAZDTt=+_nnC7Dw@mail.gmail.com>","In-Reply-To":"<CAHW6GYKhTEEMCfu4Jqq6JhS39U8c=UeCjC8XAZDTt=+_nnC7Dw@mail.gmail.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Thu, 2 Jul 2026 12:54:56 +0100","X-Gm-Features":"AVVi8Cct6pj1iqCYwMHQuWu4c3X27NKrDV1UtWi_IjRgFDNCG3Rr_OR2Gtd_A_8","Message-ID":"<CAHW6GYLFZ89ryAHr5in31ycH_=3k+TphiquAVmPuMnp6+5g7bg@mail.gmail.com>","Subject":"Re: [PATCH] pipeline: rpi: pisp: Fix colours for NV21 and NV61 pixel\n\tformats","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]