[{"id":28872,"web_url":"https://patchwork.libcamera.org/comment/28872/","msgid":"<20240305153046.GA29699@pendragon.ideasonboard.com>","date":"2024-03-05T15:30:46","subject":"Re: [PATCH 2/2] ipa: rpi: cam_helper: Extend embedded data parsing\n\tto RAW14 modes","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nick,\n\nThank you for the patch.\n\nOn Tue, Mar 05, 2024 at 11:01:36AM +0000, Nick Hollinghurst wrote:\n> Fix embedded data byte-skipping for 14-bit modes (4 out of 7 bytes\n> carry register data), and allow 14-bit modes in IMX708 PDAF parsing.\n> \n> Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/rpi/cam_helper/cam_helper_imx708.cpp |  2 +-\n>  src/ipa/rpi/cam_helper/md_parser_smia.cpp    | 11 +++++++----\n>  2 files changed, 8 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> index dce39cd5..906c6fa2 100644\n> --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> @@ -269,7 +269,7 @@ bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len,\n>  {\n>  \tsize_t step = bpp >> 1; /* bytes per PDAF grid entry */\n>  \n> -\tif (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {\n> +\tif (bpp < 10 || bpp > 14 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {\n>  \t\tLOG(IPARPI, Error) << \"PDAF data in unsupported format\";\n>  \t\treturn false;\n>  \t}\n> diff --git a/src/ipa/rpi/cam_helper/md_parser_smia.cpp b/src/ipa/rpi/cam_helper/md_parser_smia.cpp\n> index 210787ed..c5b806d7 100644\n> --- a/src/ipa/rpi/cam_helper/md_parser_smia.cpp\n> +++ b/src/ipa/rpi/cam_helper/md_parser_smia.cpp\n> @@ -86,10 +86,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t>\n>  \twhile (1) {\n>  \t\tint tag = buffer[currentOffset++];\n>  \n> -\t\tif ((bitsPerPixel_ == 10 &&\n> -\t\t     (currentOffset + 1 - currentLineStart) % 5 == 0) ||\n> -\t\t    (bitsPerPixel_ == 12 &&\n> -\t\t     (currentOffset + 1 - currentLineStart) % 3 == 0)) {\n> +\t\t/* Non-dummy bytes come in even-sized blocks: skip can only ever follow tag */\n> +\t\twhile ((bitsPerPixel_ == 10 &&\n> +\t\t\t(currentOffset + 1 - currentLineStart) % 5 == 0) ||\n> +\t\t       (bitsPerPixel_ == 12 &&\n> +\t\t\t(currentOffset + 1 - currentLineStart) % 3 == 0) ||\n> +\t\t       (bitsPerPixel_ == 14 &&\n> +\t\t\t(currentOffset - currentLineStart) % 7 >= 4)) {\n>  \t\t\tif (buffer[currentOffset++] != RegSkip)\n>  \t\t\t\treturn BadDummy;\n>  \t\t}","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 18E29BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Mar 2024 15:30:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D68C62871;\n\tTue,  5 Mar 2024 16:30:46 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2539461C8D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Mar 2024 16:30:45 +0100 (CET)","from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D93AE8D0;\n\tTue,  5 Mar 2024 16:30:27 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AIi1DlQl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709652628;\n\tbh=DJXjFLa1HM4pDZbOb4gWoRSnxzkPF4m6HISog7rRMSk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AIi1DlQllByZcnC47n+alBBHHlE+/pxTkU/lCwpJm6cssRyEki7CwuJXMNC0KBBcr\n\tPgtFWAS2oN9fuIQOiBYNdY/uEunkC0BvMtKPWSLMsgryQ9VSPRteQF6C7Xp8g5kwjX\n\tYk6OtDltqo0UYcBQISuWz96KL/2zxuDCaSZYfTLw=","Date":"Tue, 5 Mar 2024 17:30:46 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>","Subject":"Re: [PATCH 2/2] ipa: rpi: cam_helper: Extend embedded data parsing\n\tto RAW14 modes","Message-ID":"<20240305153046.GA29699@pendragon.ideasonboard.com>","References":"<20240305110136.3624-1-nick.hollinghurst@raspberrypi.com>\n\t<20240305110136.3624-3-nick.hollinghurst@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240305110136.3624-3-nick.hollinghurst@raspberrypi.com>","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28877,"web_url":"https://patchwork.libcamera.org/comment/28877/","msgid":"<CAEmqJPpf7Qpjamu=Vrg1EpP5UYwYrLpoOJpWFAhR18uy6SB0-w@mail.gmail.com>","date":"2024-03-06T12:41:54","subject":"Re: [PATCH 2/2] ipa: rpi: cam_helper: Extend embedded data parsing\n\tto RAW14 modes","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Nick,\n\nOn Tue, 5 Mar 2024 at 11:01, Nick Hollinghurst\n<nick.hollinghurst@raspberrypi.com> wrote:\n>\n> Fix embedded data byte-skipping for 14-bit modes (4 out of 7 bytes\n> carry register data), and allow 14-bit modes in IMX708 PDAF parsing.\n>\n> Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n> ---\n>  src/ipa/rpi/cam_helper/cam_helper_imx708.cpp |  2 +-\n>  src/ipa/rpi/cam_helper/md_parser_smia.cpp    | 11 +++++++----\n>  2 files changed, 8 insertions(+), 5 deletions(-)\n>\n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> index dce39cd5..906c6fa2 100644\n> --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> @@ -269,7 +269,7 @@ bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len,\n>  {\n>         size_t step = bpp >> 1; /* bytes per PDAF grid entry */\n>\n> -       if (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {\n> +       if (bpp < 10 || bpp > 14 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {\n>                 LOG(IPARPI, Error) << \"PDAF data in unsupported format\";\n>                 return false;\n>         }\n> diff --git a/src/ipa/rpi/cam_helper/md_parser_smia.cpp b/src/ipa/rpi/cam_helper/md_parser_smia.cpp\n> index 210787ed..c5b806d7 100644\n> --- a/src/ipa/rpi/cam_helper/md_parser_smia.cpp\n> +++ b/src/ipa/rpi/cam_helper/md_parser_smia.cpp\n> @@ -86,10 +86,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t>\n>         while (1) {\n>                 int tag = buffer[currentOffset++];\n>\n> -               if ((bitsPerPixel_ == 10 &&\n> -                    (currentOffset + 1 - currentLineStart) % 5 == 0) ||\n> -                   (bitsPerPixel_ == 12 &&\n> -                    (currentOffset + 1 - currentLineStart) % 3 == 0)) {\n> +               /* Non-dummy bytes come in even-sized blocks: skip can only ever follow tag */\n> +               while ((bitsPerPixel_ == 10 &&\n> +                       (currentOffset + 1 - currentLineStart) % 5 == 0) ||\n> +                      (bitsPerPixel_ == 12 &&\n> +                       (currentOffset + 1 - currentLineStart) % 3 == 0) ||\n> +                      (bitsPerPixel_ == 14 &&\n> +                       (currentOffset - currentLineStart) % 7 >= 4)) {\n>                         if (buffer[currentOffset++] != RegSkip)\n>                                 return BadDummy;\n>                 }\n> --\n> 2.30.2\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 31808BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Mar 2024 12:42:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E14F76286F;\n\tWed,  6 Mar 2024 13:42:32 +0100 (CET)","from mail-ed1-x532.google.com (mail-ed1-x532.google.com\n\t[IPv6:2a00:1450:4864:20::532])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 86CFD61C8F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Mar 2024 13:42:31 +0100 (CET)","by mail-ed1-x532.google.com with SMTP id\n\t4fb4d7f45d1cf-565c6cf4819so1459787a12.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 Mar 2024 04:42:31 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"UnhsE2N7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1709728951; x=1710333751;\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=3r1SPwqyg6ICYXyfoH0vVr5qo/uwVff7uCUL6Aolk3w=;\n\tb=UnhsE2N7CJA6AE6wOBIZAg0rE89AgZhtR7pH2wo1Vnar4m4lbAPg5eaBlINYu8fZMd\n\tONjefHJ6Zno9DJ1/S8nGhi0IjKRUDwhOl6ma/6hzmBDOx4GdpWz6dBsxGOyCMpOn5cWC\n\t/2GenlPUIADHVbys5C9i+0YG0glMC8i4fv4+pJybreJl0JIPs5W2h6Cd/a9OB2sxWFUh\n\tVehaVYono7Tw//az1ORbcP0TIrIAK3ShFR28/fdsMElNDi6MwgCHOuy5l6dy+nYpOh6r\n\tHo3N80DamXPzRb63p8y5nzQelwWOVr/Kp2nV7uPLddR5EIU5BjVcwVknyZwekJM8WDGr\n\tH8KA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1709728951; x=1710333751;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=3r1SPwqyg6ICYXyfoH0vVr5qo/uwVff7uCUL6Aolk3w=;\n\tb=Guyg5LgcNbvx2ZwBmyJb61+BNsjWNXDryw8lKZ2T6MrHsypxQHbQYSdEXtj94UZCzZ\n\tsil6g1irAP9ok7t4l5zExs9nUxxhwcyAllC019JS0nOQPeT1ic6wcw+1bqZwR3wKr95A\n\tb3+HX/WCyI4tlvZflC0nRHtxaUGA4kwJIyQOFMenl9X9MXghnEXj+KDtijcwxSVK+fWA\n\t2xRUVMrYL2YIPWKhxul44y8nI0zGAYKGT6T9krFm4V5hFNwjAEJH6q9vIxsrdmX2c0Pd\n\tb/9VGq5IOFUhNwTTUFZWT5IiXYkeClFIc3s6IawXWY0GOf0ts+pHsFWryRcfe0nytzYp\n\twatA==","X-Gm-Message-State":"AOJu0YyvcjTBtDSVKG17/UvOXzL03HeTemSMqU+0l91R0KCDHhHcWDmL\n\tYLtFXFJ3JCQCCXTSVbLzzxShVRydVfNu+R8HO3dvHz64bbFBAn8oO8KVNdIg9cR6waCnTZPRfOc\n\tuA9nDT5Pz9xmfZeTkwsCt0tsOLDfQcuV/RVaP3OyVl9hnoa8VO9c=","X-Google-Smtp-Source":"AGHT+IFzSyqZom7Sz8e5eiN0kaSg1OVpKW7iwmlLFza7WNc0Hhd+1GvA00/5ItKHVMWrXPHnq3AIZtlrekKFSGNSNpk=","X-Received":"by 2002:a50:8e05:0:b0:566:85aa:e63e with SMTP id\n\t5-20020a508e05000000b0056685aae63emr5458600edw.9.1709728951091;\n\tWed, 06 Mar 2024 04:42:31 -0800 (PST)","MIME-Version":"1.0","References":"<20240305110136.3624-1-nick.hollinghurst@raspberrypi.com>\n\t<20240305110136.3624-3-nick.hollinghurst@raspberrypi.com>","In-Reply-To":"<20240305110136.3624-3-nick.hollinghurst@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 6 Mar 2024 12:41:54 +0000","Message-ID":"<CAEmqJPpf7Qpjamu=Vrg1EpP5UYwYrLpoOJpWFAhR18uy6SB0-w@mail.gmail.com>","Subject":"Re: [PATCH 2/2] ipa: rpi: cam_helper: Extend embedded data parsing\n\tto RAW14 modes","To":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]