From patchwork Wed Oct 21 06:56:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Faizel K B X-Patchwork-Id: 28535 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 D977AC324C for ; Wed, 21 Oct 2026 06:57:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B3F3868F1D; Wed, 21 Oct 2026 08:57:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b1IALrC0"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2631368E44 for ; Wed, 21 Oct 2026 08:57:23 +0200 (CEST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2e74a32a07fso559785ad.1 for ; Tue, 20 Oct 2026 23:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792565841; x=1793170641; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=xwG1aiunkg9fi+/bQZ9478Qkubpx3Wqk/nx1ipo3Fa0=; b=b1IALrC0kjvqWjJIr8BkE0cpBDEtIwfVwv+9gQsj+N7hr2xwUEgp2aB0cudX1s4iMW KZVCFNv1foFyWlYPtn0/pKwtUstXCito37N5Osem/A/+UftOaHQYq5nmXGY85nj0cDUZ O8eVMbFz0p21/0DdaBhs+BTPV0+NGw3Qla4iOUkpm1vp4wSWQCSBDKmq0+oSlDtOzKKe MQlR5/cYwcThUIu/4TVdqHUMqfT0G7SzKKDoc6vum5Pc24IK7xJllnc4ZtuGpCKuCASQ XiXj21G45dYVQDnmkK4ktvpzGWzh6T/UbEvIWlkbUyc8XF8BRGkRPGaB1u3feKq0KueE yyDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792565841; x=1793170641; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xwG1aiunkg9fi+/bQZ9478Qkubpx3Wqk/nx1ipo3Fa0=; b=P27Lhm8yZbDYq9y/EKTxgsAGuje2tB55zLv7DEmCFyyN6STJJEBTUNki945L3ExzdI tnui/p2ZpPcvSokkVCSZuf3UyxITnso4qNZ/7PfUdUshm6z0taLDaP9SeP1RpDABzzlh JMIRnvbvs7ihYjAA0y3qZBSg6mYdPkjBxGMI7wN3Zvun4EfNQ4EJ4T2bBZhbJnckFm5M leX3R7a/2o+xIbK5KbD1u+I3PIivVFM3pScorw94AVkuT4nA0h86MCC+Zln7A+6ZH5uB pKKVuwWfZJ9joBTvvpsvbBH1AD17VNVAR8+mhxFMUAS1yhiPuElpR9ewAnP/7I5zX5z/ qXuQ== X-Gm-Message-State: AFq9FYJJb/0kafnUAZDn8kJbqdeaUKQky9/JwzIb3/WUoQ4sDNx64rcc 1X9Ga6xqXG5JhiWc3lphVdh0EQVPC3YmBb6HYeUjphShCIm3RFtKf71MVFCKI4DE X-Gm-Gg: AYBFou0/dzP//UcyT3OmHj80gvZ5crGoKjjjAKCGW9l2fBITXKAExu1g6iZx0nPBBT5 iIvHKr4aTA9eReBJQn13Um5UE+6+bb70v8HtAl3AVlaH7j6NW8dGCOrN52D3Lrlz1tvNTdIoPXH ezinjXOQ6hmUnqFmC3c9yKvtQZJJ/y7PqsBwV+tbnUikiu2etAi/+OfPBNPGBQihnWWLrzcj8ND FpNa7BJJyvIVYA3mhMcBBEW2DrCNH8uZCL/59dimN/3vQTTaeJ+BjaXiYzwFb+cD6dFULPM+G/F T5TlaxFLX+V1MGbNXvfkxqLzEQ6SXXA8CLchqTPflDgyj8R3f62c2tPaH9asvA8m6SUp4Fprn2S 7XyhzawyLpEcT1jwASUossrBKekLMs86I+wgB0cgFrlyBLRbNKlupUu10INnFb+TMGYPXqEm8vq e1w4Pq4/G7zrmRpN8zdkREnVXKPcjKo2qT/QWc9xSQJGUf0XxBShWfO7yAomxl1yfqLMANm9LCa AhF58GG6KEysqtTUpXf2VOZs+kHiLC4/hzOXgeo3X7ZG1kfkB6qH14JKtNrzNKQrFrcqQDv/0zo ovAgbMebZqo= X-Received: by 2002:a17:902:da8b:b0:2e9:5c29:9955 with SMTP id d9443c01a7336-2ea43e04ea1mr14635225ad.4.1792565841180; Tue, 20 Oct 2026 23:57:21 -0700 (PDT) Received: from FAIZEL-KB.. ([2001:569:5b64:e100:e455:6566:c574:ca8]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2ea3b40fe7fsm7062965ad.13.2026.10.20.23.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 23:57:20 -0700 (PDT) From: Faizel K B To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Bryan O'Donoghue , Faizel K B Subject: [PATCH] libcamera: egl: Fix DRM format for GL_RG dmabuf import Date: Tue, 20 Oct 2026 23:56:24 -0700 Message-ID: <20261021065624.153207-1-faizel.kb@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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" Importing unpacked 10/12-bit Bayer input buffers (e.g. SGBRG10) as dmabufs always fails with Mesa, and DebayerEGL silently falls back to mapping each input buffer and uploading it with glTexImage2D() on every frame: INFO Debayer debayer_egl.cpp:523 Importing input DMABuf failed, falling back to upload The cause is the DRM format used for GL_RG textures. Unpacked Bayer pixels are 16-bit little-endian words, loaded into a GL_RG texture with the low byte in .r and the high byte in .g, which the shaders recombine into a single sample. R and G here are texture channels, not colours. GL names formats in memory byte order, while DRM fourccs describe the components of a little-endian word from MSB to LSB: DRM_FORMAT_RG88 [15:0] R:G 8:8 little endian -> byte 0 = G, byte 1 = R DRM_FORMAT_GR88 [15:0] G:R 8:8 little endian -> byte 0 = R, byte 1 = G The import path maps GL_RG to DRM_FORMAT_RG88, which has the opposite byte order. Mesa has no RG88 entry in its DRI image format table, so eglCreateImageKHR() fails. Map GL_RG to DRM_FORMAT_GR88, which matches the upload path and is supported by Mesa. 8-bit and CSI-2 packed input (GL_LUMINANCE) and the output path (GL_RGBA) are not affected. Fixes: 6e23162ddcae ("egl: Add GL format parameter to eGLImage constructor") Signed-off-by: Faizel K B Reviewed-by: Robert Mader Tested-by: Barnabás Pőcze # ipu6 + ov2740 Reviewed-by: Laurent Pinchart --- Notes: Tested on RK3588 (Mali-G610, Panfrost, Mesa 24.3.4) with an IMX415 sensor (SGBRG10 unpacked, 3864x2192). Panfrost requires the row stride of linear dmabuf imports to be 64-byte aligned. The SGBRG10 stride at 3864 pixels is 7728 bytes, so the import also needed a local rkcif change to honour the 256-byte aligned stride (7936) that DebayerEGL::preferredInputStride() requests. src/libcamera/egl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 3cde9040a..59a7d8cf9 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -184,7 +184,7 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) drm_format = DRM_FORMAT_R8; break; case GL_RG: - drm_format = DRM_FORMAT_RG88; + drm_format = DRM_FORMAT_GR88; break; case GL_RGBA: drm_format = DRM_FORMAT_ARGB8888;