From patchwork Thu Oct 22 23:26:27 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: 28567 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 BB6A4C3261 for ; Thu, 22 Oct 2026 23:26:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A4CF68F9E; Fri, 23 Oct 2026 01:26:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ruH0nfED"; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 645A968E07 for ; Fri, 23 Oct 2026 01:26:48 +0200 (CEST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2d8f2ed7bdcso259605ad.2 for ; Thu, 22 Oct 2026 16:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792711607; x=1793316407; darn=lists.libcamera.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+xRqx/UU69FV67TgUheh05NaA3VHNMHWVM70lo1jcB4=; b=ruH0nfEDb3dYHuA/hyth3rk0ZWVpKIGbQOz1hZgv7NPaKcflEP33g81+Xnk+6v+XwZ 6f9StNQMhiAEKfMizGI0PR8p5dWx6iJ/Zzf+upBh2rhPtyvx9Yf/ML1Bc6KIc+wgy3p7 J3SzxrV+gSQ0BfGpC4NPUEpMonzmOKIq7pEEB9btFaOHCdDFyb06Wg8XnuMR1BJq/YE8 Uqi/vvNJvF/ZLt661VQLLHmWYFNqmzgPgqr9X1gMvsiPJPeJRkMfordV3XvWV6gh08sR yARVhSdgwCNTKOA0vFw6RNUdVyONGci56bIOMlK3w/W5SotEwNapgYba/EyhZ0o3Hdwf qEMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792711607; x=1793316407; h=content-transfer-encoding:content-type: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=+xRqx/UU69FV67TgUheh05NaA3VHNMHWVM70lo1jcB4=; b=nXWfU5k8G2DgudxHTtKdGKTAUFEV1oySlobMftYDEG1DlyqXASwJgg1CT5av1NVAyt 3RZQGk3lGiu9+/gE1uimQ2HIVkvZWBUPsshyhJ8ZsalpbOABCXIQXy1cfmgPDcFoLgI/ HrRLCyX8GZ3iZCxsFFF3CwxKwZOY7tVzqI+gG4rDMh+2nRYX+viFzDvy3TRjQBj09vrA z9CJAQd//ZRkeCIF83lylZA3QxuHG4EM3DA0WZJURcWBzneAjnBLeBNym4ENako9Eola G8X8wlLB/JKsdqBNa6UC/+EvmI56cwHz+EMeXpVgZeoBDqcJfc43+tyH0taZ88QPfVCa WfbQ== X-Gm-Message-State: AFq9FYJyTfT/p301J6L0ovq4gRoX6l6HmZl4ogZ/5KymvgUYfd+Oa3zb HWOxdRCxqfeEwRPzyTgXdancN46OOLlPAmPLSEAdpTepVMV86TjJr8OxdsikZO9K X-Gm-Gg: AYBFou2Glo0anYaP2nXSB+n2wb/8OO2r+jFBLOl52UkOki8OGWtM7oSOZvb9fD55sES wYYaAHTsz62TbhOEyU+4Cj2RV5ultCjyVJtXOvjTjn2RufROaCY88mLtoFDOxsOIQxYo7rXFblY TQyxgEIpBGmxcRLri9moxctyiiSnW559zg43nysrvtsQ1tXQ/b4KGaPle1BiAb9MfCq8fvpNRtX 65BurYe5Q/TohdJNtawPHsp5qKmXNVI7l6HPgSa4kGLTLSCfVgj5iHUL8x32sFMr4X6n1+8Jcr3 3ZhCcg3LxSf6V7HOfPf/NQcDdIisocI7GnU6tb6qXa/IPYFCrJWIxes+jK0uiVGJv1Prq7funNw aLLJaR92ICL2HkB/geuj5tHAg1aii6XDDhXCQcH/0mXaKsTbgk+h9pPlUugj6VW+Oy3qF6XKw1y Ebe0NpQ1i3uON+ua/sYVDekAGmJJ77dNwPfEo/s4YJvXG19AzuPjJTiljuwZd6wwysiiVpO8WEN TUwVoskQFiDU2+AEHVWfZ4IamtJmiX07UR7vG1nt3Y1DjyuyQ13TaKd9Rs9iEsnbLVdvpTv6zY9 HOLUMV9ajgwl/iA5UcK4k+ucsvZrg3Nc1w== X-Received: by 2002:a17:902:fc4f:b0:2e9:65bd:62c7 with SMTP id d9443c01a7336-2ea7bcc5ff2mr12712735ad.0.1792711606635; Thu, 22 Oct 2026 16:26:46 -0700 (PDT) Received: from FAIZEL-KB.. ([2001:569:5b64:e100:30f9:2700:2197:65ca]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2ea7fa8f507sm882005ad.10.2026.10.22.16.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2026 16:26:45 -0700 (PDT) From: Faizel K B To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Bryan O'Donoghue , Laurent Pinchart , =?utf-8?b?QmFybmFiw6FzIFDFkWN6?= =?utf-8?q?e?= , Milan Zamazal Subject: [PATCH v2] libcamera: egl: Fix DRM format for GL_RG dmabuf import Date: Thu, 22 Oct 2026 16:26:27 -0700 Message-ID: <20261022232627.15472-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 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. When importing a dmabuf with EGL_EXT_image_dma_buf_import, the order of the samples in memory is taken from the DRM fourcc, which describes 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 would place the low byte in .g instead of .r. Mesa has no RG88 entry in its DRI image format table, so eglCreateImageKHR() fails before this matters. 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) is 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 Tested-by: Milan Zamazal Reviewed-by: Bryan O'Donoghue --- Notes: Changes in v2: - Drop "silently" from the commit message - Describe the sample order in terms of EGL_EXT_image_dma_buf_import - Drop the incorrect claim that the GL_RGBA output path is not affected. GL_RGBA will be addressed separately once the discussion on the v1 thread concludes - Collect tags v1: https://patchwork.libcamera.org/patch/28535/ 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 b3d3b9abb..ff9e54a19 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;