From patchwork Sat Apr 4 00:44:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3385 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E7A61629B9 for ; Sat, 4 Apr 2020 02:44:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IHUoYTgg"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4ACA313C7; Sat, 4 Apr 2020 02:44:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1585961095; bh=eojVJlZ6geJjqQh0s1X8+sYEFg1dITg5+xxKxPU+w/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IHUoYTggU3jvHHK42b8cs4EPOTOvVlKdsulQ2eVYjp913nRwPRSAQYy3kKQepszjd p6Nf0cSwX7RuZjHOJow9etqgw7vRX8mm6J3mESRvbXY/AY+cOPyx0qkyZwDBnKAv2D 2Z/QaUV95+2VPlP/AAaZVRxjygfB6IyJnWo8dlH4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Martijn Braam , Benjamin GAIGNARD , Andrey Konovalov Date: Sat, 4 Apr 2020 03:44:35 +0300 Message-Id: <20200404004438.17992-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200404004438.17992-1-laurent.pinchart@ideasonboard.com> References: <20200404004438.17992-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 08/11] libcamera: v4l2_videodevice: Map V4L2_PIX_FMT_GREY to DRM FourCC 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: , X-List-Received-Date: Sat, 04 Apr 2020 00:44:56 -0000 DRM has a format for 8-bit greyscale data, DRM_FORMAT_R8. Despite the 'R' name, which comes from GL/Vulkan to mean single-channel data, the format maps to greyscale for display. We can thus map it to V4L2_PIX_FMT_GREY. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- Changes since v2: - Rebase on top of PixelFormat class --- src/libcamera/v4l2_videodevice.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 5208e5a47148..437e771d7fe4 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1699,12 +1699,15 @@ PixelFormat V4L2VideoDevice::toPixelFormat(V4L2PixelFormat v4l2Fourcc) case V4L2_PIX_FMT_NV21M: return PixelFormat(DRM_FORMAT_NV21); + /* Greyscale formats. */ + case V4L2_PIX_FMT_GREY: + return PixelFormat(DRM_FORMAT_R8); + /* Compressed formats. */ case V4L2_PIX_FMT_MJPEG: return PixelFormat(DRM_FORMAT_MJPEG); /* V4L2 formats not yet supported by DRM. */ - case V4L2_PIX_FMT_GREY: default: /* * \todo We can't use LOG() in a static method of a Loggable @@ -1790,6 +1793,10 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma case DRM_FORMAT_NV21: return V4L2PixelFormat(V4L2_PIX_FMT_NV21); + /* Greyscale formats. */ + case DRM_FORMAT_R8: + return V4L2PixelFormat(V4L2_PIX_FMT_GREY); + /* Compressed formats. */ case DRM_FORMAT_MJPEG: return V4L2PixelFormat(V4L2_PIX_FMT_MJPEG);