[{"id":35671,"web_url":"https://patchwork.libcamera.org/comment/35671/","msgid":"<175673346249.560048.3635319847692743876@ping.linuxembedded.co.uk>","date":"2025-09-01T13:31:02","subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-09-01 10:23:20)\n> First there is a single big endian format defined in `formats.yaml`: RGB565_BE.\n> However, while the yaml file specifies \"big_endian: true\", the python script\n> looks for a key named \"big-endian\". Causing `RGB565{,_BE}` both to be the same.\n\nEeek. Good find.\n\n\n> Second, the python script simply appends \" | DRM_FORMAT_BIG_ENDIAN\" to the\n> fourcc of the format. However, there is no definition of that macro is\n> available in the only user, `formats.h.in`.\n\naha, and this would then require users of formats.h to include the drm\nheaders.\n\n> Fix the first one by checking for \"big_endian\" in the script as well, and\n> fix the second one by defining a constant with the same value and using that.\n\nI think that is indeed more preferable in this instance than requiring\ninclusion of the drm headers for a single value.\n\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> Fixes: 7c496f1c54dd58 (\"utils: gen-formats: Support big-endian DRM formats\")\n> ---\n>  include/libcamera/formats.h.in | 4 +++-\n>  utils/codegen/gen-formats.py   | 3 +--\n>  2 files changed, 4 insertions(+), 3 deletions(-)\n> \n> diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in\n> index 5ff9c3bf4..c821ffbb1 100644\n> --- a/include/libcamera/formats.h.in\n> +++ b/include/libcamera/formats.h.in\n> @@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod)\n>                (static_cast<uint64_t>(mod) << 0);\n>  }\n>  \n> +constexpr uint32_t kDrmFormatBigEndian = uint32_t(1) << 31; /* DRM_FORMAT_BIG_ENDIAN */\n> +\n>  } /* namespace */\n>  \n>  {% for f in formats %}\n> -constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}), __mod({{f.mod}}));\n> +constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}){{ ' | kDrmFormatBigEndian' if f.big_endian }}, __mod({{f.mod}}));\n>  {%- endfor %}\n>  \n>  } /* namespace formats */\n> diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py\n> index 872f3fe34..01adf5e1f 100755\n> --- a/utils/codegen/gen-formats.py\n> +++ b/utils/codegen/gen-formats.py\n> @@ -59,13 +59,12 @@ def generate_formats(formats, drm_fourcc):\n>      for format in formats:\n>          name, format = format.popitem()\n>          fourcc = drm_fourcc.fourcc(format['fourcc'])\n> -        if format.get('big-endian'):\n> -            fourcc += '| DRM_FORMAT_BIG_ENDIAN'\n>  \n>          data = {\n>              'name': name,\n>              'fourcc': fourcc,\n>              'mod': '0, 0',\n> +            'big_endian': format.get('big_endian') == True,\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n>          }\n>  \n>          mod = format.get('mod')\n> -- \n> 2.51.0\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 CAA17BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Sep 2025 13:31:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C121869324;\n\tMon,  1 Sep 2025 15:31:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4965369323\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Sep 2025 15:31:05 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DCC9AE92;\n\tMon,  1 Sep 2025 15:29:57 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TM4st3rU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1756733398;\n\tbh=v9JE9WEsDIEvKoyIWENofiGNCVuM+hcHVfUNVPTb7HM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=TM4st3rUWjA9qTOHHc2wyEHNuWMjIe0yczPkmO7APh9dHcmyu6hUHWevgN4Ion/fm\n\tL4kShSQKs4X+JDAO5b58xiZAGCIrUGUa1F3CPxS4ES+aRsM5JH83UUX4M51L6bmG2i\n\tHkBKpXiWtA9hA3FQ4LXQaWbAeY0p8c99vEpCtZBE=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250901092320.44615-2-barnabas.pocze@ideasonboard.com>","References":"<20250901092320.44615-1-barnabas.pocze@ideasonboard.com>\n\t<20250901092320.44615-2-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 01 Sep 2025 14:31:02 +0100","Message-ID":"<175673346249.560048.3635319847692743876@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":35673,"web_url":"https://patchwork.libcamera.org/comment/35673/","msgid":"<9c3d56af-3beb-4472-bae5-dc75b6a6f5c4@ideasonboard.com>","date":"2025-09-01T13:37:57","subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 09. 01. 15:31 keltezéssel, Kieran Bingham írta:\n> Quoting Barnabás Pőcze (2025-09-01 10:23:20)\n>> First there is a single big endian format defined in `formats.yaml`: RGB565_BE.\n>> However, while the yaml file specifies \"big_endian: true\", the python script\n>> looks for a key named \"big-endian\". Causing `RGB565{,_BE}` both to be the same.\n> \n> Eeek. Good find.\n> \n> \n>> Second, the python script simply appends \" | DRM_FORMAT_BIG_ENDIAN\" to the\n>> fourcc of the format. However, there is no definition of that macro is\n>> available in the only user, `formats.h.in`.\n> \n> aha, and this would then require users of formats.h to include the drm\n> headers.\n> \n>> Fix the first one by checking for \"big_endian\" in the script as well, and\n>> fix the second one by defining a constant with the same value and using that.\n> \n> I think that is indeed more preferable in this instance than requiring\n> inclusion of the drm headers for a single value.\n\nBased on e8dc74317afa43ffa4096e7e7e0c25b5c5189682 the explicit goal appears to\nbe to avoid using drm_fourcc.h.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> \n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> Fixes: 7c496f1c54dd58 (\"utils: gen-formats: Support big-endian DRM formats\")\n>> ---\n>>   include/libcamera/formats.h.in | 4 +++-\n>>   utils/codegen/gen-formats.py   | 3 +--\n>>   2 files changed, 4 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in\n>> index 5ff9c3bf4..c821ffbb1 100644\n>> --- a/include/libcamera/formats.h.in\n>> +++ b/include/libcamera/formats.h.in\n>> @@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod)\n>>                 (static_cast<uint64_t>(mod) << 0);\n>>   }\n>>   \n>> +constexpr uint32_t kDrmFormatBigEndian = uint32_t(1) << 31; /* DRM_FORMAT_BIG_ENDIAN */\n>> +\n>>   } /* namespace */\n>>   \n>>   {% for f in formats %}\n>> -constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}), __mod({{f.mod}}));\n>> +constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}){{ ' | kDrmFormatBigEndian' if f.big_endian }}, __mod({{f.mod}}));\n>>   {%- endfor %}\n>>   \n>>   } /* namespace formats */\n>> diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py\n>> index 872f3fe34..01adf5e1f 100755\n>> --- a/utils/codegen/gen-formats.py\n>> +++ b/utils/codegen/gen-formats.py\n>> @@ -59,13 +59,12 @@ def generate_formats(formats, drm_fourcc):\n>>       for format in formats:\n>>           name, format = format.popitem()\n>>           fourcc = drm_fourcc.fourcc(format['fourcc'])\n>> -        if format.get('big-endian'):\n>> -            fourcc += '| DRM_FORMAT_BIG_ENDIAN'\n>>   \n>>           data = {\n>>               'name': name,\n>>               'fourcc': fourcc,\n>>               'mod': '0, 0',\n>> +            'big_endian': format.get('big_endian') == True,\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> \n>>           }\n>>   \n>>           mod = format.get('mod')\n>> -- \n>> 2.51.0\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 89070BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Sep 2025 13:38:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4729F69338;\n\tMon,  1 Sep 2025 15:38:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CC2769323\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Sep 2025 15:38:01 +0200 (CEST)","from [192.168.33.23] (185.221.143.232.nat.pool.zt.hu\n\t[185.221.143.232])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C0439E92;\n\tMon,  1 Sep 2025 15:36:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RMpXX/ei\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1756733813;\n\tbh=IiWiYYC7Xv7q8ynUqt7yHPfregZxaOTiKHbw3tOa940=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=RMpXX/eifFgPzFkuWQRVbpD6OgHHc7GRoxIRVJew6kHtWyW7Bp+srFgqWT+u563db\n\tjmI9BMtBxBO3nCf6QcpLjArEuJsz0ExFNNCbU5fLC98j+iUl1edqGNKMKmBVtBp0oC\n\tIP75orS0GPGuZgKhFFUO9DUKRIoYElCfkBabPKA0=","Message-ID":"<9c3d56af-3beb-4472-bae5-dc75b6a6f5c4@ideasonboard.com>","Date":"Mon, 1 Sep 2025 15:37:57 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250901092320.44615-1-barnabas.pocze@ideasonboard.com>\n\t<20250901092320.44615-2-barnabas.pocze@ideasonboard.com>\n\t<175673346249.560048.3635319847692743876@ping.linuxembedded.co.uk>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<175673346249.560048.3635319847692743876@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":35677,"web_url":"https://patchwork.libcamera.org/comment/35677/","msgid":"<20250901144334.GD1705@pendragon.ideasonboard.com>","date":"2025-09-01T14:43:34","subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Sep 01, 2025 at 03:37:57PM +0200, Barnabás Pőcze wrote:\n> 2025. 09. 01. 15:31 keltezéssel, Kieran Bingham írta:\n> > Quoting Barnabás Pőcze (2025-09-01 10:23:20)\n> >> First there is a single big endian format defined in `formats.yaml`: RGB565_BE.\n> >> However, while the yaml file specifies \"big_endian: true\", the python script\n> >> looks for a key named \"big-endian\". Causing `RGB565{,_BE}` both to be the same.\n> > \n> > Eeek. Good find.\n> > \n> >> Second, the python script simply appends \" | DRM_FORMAT_BIG_ENDIAN\" to the\n> >> fourcc of the format. However, there is no definition of that macro is\n> >> available in the only user, `formats.h.in`.\n> > \n> > aha, and this would then require users of formats.h to include the drm\n> > headers.\n> > \n> >> Fix the first one by checking for \"big_endian\" in the script as well, and\n> >> fix the second one by defining a constant with the same value and using that.\n> > \n> > I think that is indeed more preferable in this instance than requiring\n> > inclusion of the drm headers for a single value.\n> \n> Based on e8dc74317afa43ffa4096e7e7e0c25b5c5189682 the explicit goal appears to\n> be to avoid using drm_fourcc.h.\n> \n> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >> Fixes: 7c496f1c54dd58 (\"utils: gen-formats: Support big-endian DRM formats\")\n> >> ---\n> >>   include/libcamera/formats.h.in | 4 +++-\n> >>   utils/codegen/gen-formats.py   | 3 +--\n> >>   2 files changed, 4 insertions(+), 3 deletions(-)\n> >>\n> >> diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in\n> >> index 5ff9c3bf4..c821ffbb1 100644\n> >> --- a/include/libcamera/formats.h.in\n> >> +++ b/include/libcamera/formats.h.in\n> >> @@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod)\n> >>                 (static_cast<uint64_t>(mod) << 0);\n> >>   }\n> >>   \n> >> +constexpr uint32_t kDrmFormatBigEndian = uint32_t(1) << 31; /* DRM_FORMAT_BIG_ENDIAN */\n\nI would have written\n\nconstexpr uint32_t kDrmFormatBigEndian = 1U << 31; /* DRM_FORMAT_BIG_ENDIAN */\n\n> >> +\n> >>   } /* namespace */\n> >>   \n> >>   {% for f in formats %}\n> >> -constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}), __mod({{f.mod}}));\n> >> +constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}){{ ' | kDrmFormatBigEndian' if f.big_endian }}, __mod({{f.mod}}));\n> >>   {%- endfor %}\n> >>   \n> >>   } /* namespace formats */\n> >> diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py\n> >> index 872f3fe34..01adf5e1f 100755\n> >> --- a/utils/codegen/gen-formats.py\n> >> +++ b/utils/codegen/gen-formats.py\n> >> @@ -59,13 +59,12 @@ def generate_formats(formats, drm_fourcc):\n> >>       for format in formats:\n> >>           name, format = format.popitem()\n> >>           fourcc = drm_fourcc.fourcc(format['fourcc'])\n> >> -        if format.get('big-endian'):\n> >> -            fourcc += '| DRM_FORMAT_BIG_ENDIAN'\n> >>   \n> >>           data = {\n> >>               'name': name,\n> >>               'fourcc': fourcc,\n> >>               'mod': '0, 0',\n> >> +            'big_endian': format.get('big_endian') == True,\n\nDo you need == True ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> >>           }\n> >>   \n> >>           mod = format.get('mod')","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 155D4BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Sep 2025 14:43:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E929569324;\n\tMon,  1 Sep 2025 16:43:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E12469323\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Sep 2025 16:43:55 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(230.215-178-91.adsl-dyn.isp.belgacom.be [91.178.215.230])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id BDF86C71;\n\tMon,  1 Sep 2025 16:42:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wElQ4z7B\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1756737767;\n\tbh=4fpCn31TZlE6mNj1RTk7v39rNaWcjq4Jtyu8buK64Qk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wElQ4z7BQnMQ99ru98Ev1QnRmk7nKcsFBUJyrO7zlG6tfaUMI8lG0vRCD9+mJ9/bx\n\tsrLG7PNaCCcr+gA181FPHqYBQlKLTVVkWJA5UWh1MSE2MiElN21eldXYSkMBYL4qHC\n\tB4NjE15WTg+qLeBdVXQg3IUhKfXmaxb5AERn1Qwk=","Date":"Mon, 1 Sep 2025 16:43:34 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","Message-ID":"<20250901144334.GD1705@pendragon.ideasonboard.com>","References":"<20250901092320.44615-1-barnabas.pocze@ideasonboard.com>\n\t<20250901092320.44615-2-barnabas.pocze@ideasonboard.com>\n\t<175673346249.560048.3635319847692743876@ping.linuxembedded.co.uk>\n\t<9c3d56af-3beb-4472-bae5-dc75b6a6f5c4@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<9c3d56af-3beb-4472-bae5-dc75b6a6f5c4@ideasonboard.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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35679,"web_url":"https://patchwork.libcamera.org/comment/35679/","msgid":"<d6b07679-82ee-440d-a6b0-1a3021003769@ideasonboard.com>","date":"2025-09-01T15:05:05","subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 09. 01. 16:43 keltezéssel, Laurent Pinchart írta:\n> On Mon, Sep 01, 2025 at 03:37:57PM +0200, Barnabás Pőcze wrote:\n>> 2025. 09. 01. 15:31 keltezéssel, Kieran Bingham írta:\n>>> Quoting Barnabás Pőcze (2025-09-01 10:23:20)\n>>>> First there is a single big endian format defined in `formats.yaml`: RGB565_BE.\n>>>> However, while the yaml file specifies \"big_endian: true\", the python script\n>>>> looks for a key named \"big-endian\". Causing `RGB565{,_BE}` both to be the same.\n>>>\n>>> Eeek. Good find.\n>>>\n>>>> Second, the python script simply appends \" | DRM_FORMAT_BIG_ENDIAN\" to the\n>>>> fourcc of the format. However, there is no definition of that macro is\n>>>> available in the only user, `formats.h.in`.\n>>>\n>>> aha, and this would then require users of formats.h to include the drm\n>>> headers.\n>>>\n>>>> Fix the first one by checking for \"big_endian\" in the script as well, and\n>>>> fix the second one by defining a constant with the same value and using that.\n>>>\n>>> I think that is indeed more preferable in this instance than requiring\n>>> inclusion of the drm headers for a single value.\n>>\n>> Based on e8dc74317afa43ffa4096e7e7e0c25b5c5189682 the explicit goal appears to\n>> be to avoid using drm_fourcc.h.\n>>\n>>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>>>> Fixes: 7c496f1c54dd58 (\"utils: gen-formats: Support big-endian DRM formats\")\n>>>> ---\n>>>>    include/libcamera/formats.h.in | 4 +++-\n>>>>    utils/codegen/gen-formats.py   | 3 +--\n>>>>    2 files changed, 4 insertions(+), 3 deletions(-)\n>>>>\n>>>> diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in\n>>>> index 5ff9c3bf4..c821ffbb1 100644\n>>>> --- a/include/libcamera/formats.h.in\n>>>> +++ b/include/libcamera/formats.h.in\n>>>> @@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod)\n>>>>                  (static_cast<uint64_t>(mod) << 0);\n>>>>    }\n>>>>    \n>>>> +constexpr uint32_t kDrmFormatBigEndian = uint32_t(1) << 31; /* DRM_FORMAT_BIG_ENDIAN */\n> \n> I would have written\n> \n> constexpr uint32_t kDrmFormatBigEndian = 1U << 31; /* DRM_FORMAT_BIG_ENDIAN */\n\nRight. I generally like to avoid integer suffixes. I was also considering\nUINT32_C(1), which expands to the type appropriate suffix.\n\n\n> \n>>>> +\n>>>>    } /* namespace */\n>>>>    \n>>>>    {% for f in formats %}\n>>>> -constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}), __mod({{f.mod}}));\n>>>> +constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}){{ ' | kDrmFormatBigEndian' if f.big_endian }}, __mod({{f.mod}}));\n>>>>    {%- endfor %}\n>>>>    \n>>>>    } /* namespace formats */\n>>>> diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py\n>>>> index 872f3fe34..01adf5e1f 100755\n>>>> --- a/utils/codegen/gen-formats.py\n>>>> +++ b/utils/codegen/gen-formats.py\n>>>> @@ -59,13 +59,12 @@ def generate_formats(formats, drm_fourcc):\n>>>>        for format in formats:\n>>>>            name, format = format.popitem()\n>>>>            fourcc = drm_fourcc.fourcc(format['fourcc'])\n>>>> -        if format.get('big-endian'):\n>>>> -            fourcc += '| DRM_FORMAT_BIG_ENDIAN'\n>>>>    \n>>>>            data = {\n>>>>                'name': name,\n>>>>                'fourcc': fourcc,\n>>>>                'mod': '0, 0',\n>>>> +            'big_endian': format.get('big_endian') == True,\n> \n> Do you need == True ?\n\nHmmm... probably not. Maybe it's better to accept any truth-y value.\nI will remove it.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n>>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>>\n>>>>            }\n>>>>    \n>>>>            mod = format.get('mod')\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 5689FBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Sep 2025 15:05:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1EBAF69332;\n\tMon,  1 Sep 2025 17:05:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BEE1A69323\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Sep 2025 17:05:09 +0200 (CEST)","from [192.168.33.23] (185.221.143.232.nat.pool.zt.hu\n\t[185.221.143.232])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3156CEAE;\n\tMon,  1 Sep 2025 17:04:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gMQ4BwO3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1756739042;\n\tbh=PJjrYM/+QUIpdZzlXpo1aihBgxwX0/ks4DdKXWmiGkc=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=gMQ4BwO3u/udS4Tj1sStZKSc5vmvpA8tTl82g7S/7uQJc+G1J40myPnoKXEOQUtzk\n\t7nfWVPE2uhGebfCapCJ/LjIG87U8w+YgKBSVgsnI2zJYk85usaiOqn3AMSYGEyXS6W\n\t9+hYOvBLGOOVCApIfdEfyRNK3qnmm36vqC4M8dss=","Message-ID":"<d6b07679-82ee-440d-a6b0-1a3021003769@ideasonboard.com>","Date":"Mon, 1 Sep 2025 17:05:05 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian\n\tformats","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250901092320.44615-1-barnabas.pocze@ideasonboard.com>\n\t<20250901092320.44615-2-barnabas.pocze@ideasonboard.com>\n\t<175673346249.560048.3635319847692743876@ping.linuxembedded.co.uk>\n\t<9c3d56af-3beb-4472-bae5-dc75b6a6f5c4@ideasonboard.com>\n\t<20250901144334.GD1705@pendragon.ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250901144334.GD1705@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}}]