From patchwork Tue Aug 2 16:01:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16916 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 73FEBBE173 for ; Tue, 2 Aug 2022 16:02:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 31EBE63326; Tue, 2 Aug 2022 18:02:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659456121; bh=a433SnA8OhWn23BTMvTpWIFAiX/rnV5LCwM9oiMsoh4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=wnS+UC6tNfi2mUFNvMtvxuyW/ok7M/cznShcyx4K1gOxvnqnIBWtflGc4izIuatU0 9r5MhaiBWns1ggfjtaKGmXChA3Xn0KGuCgh120pXeFO3AliNsGZPdrEwjjzquSnmNB Z7TFNcOhdqxFV77ZFUg+IqVikjV5Y9DvlCCE46c6SoCEeeMN/hUjzv1YlIm+06SqVW orgU9wdyv4n/jypkBbZ3rp4tCkRSpVu6DhHionowlmBmsl7k6sYAgdxYx0t+4i0CJt Z2B/fN7202jBJIwESoBgYgoxI+bZYmztqmk+OKNxLxd4/4wiwxEsn8jNWJsb6tMajo lO9Cv3HRCVUmw== Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FBCD63312 for ; Tue, 2 Aug 2022 18:02:00 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id B6BC64000E; Tue, 2 Aug 2022 16:01:58 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 18:01:36 +0200 Message-Id: <20220802160136.63075-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220802160136.63075-1-jacopo@jmondi.org> References: <20220802160136.63075-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/6] libcamera: formats: Map V4L2_PIX_FMT_JPEG to formats::MJPEG 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-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: jozef@mlich.cz, Pavel Machek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The V4L2_PIX_FMT_JPEG and V4L2_PIX_FMT_MJPEG formats are under-specified and are used interchangeably by kernel drivers. Map both of them to formats::MJPEG and use the newly re-introduced V4L2VideoDevice::toV4L2PixelFormat() to map to the one actually used by the video device. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/formats.cpp | 5 ++++- src/libcamera/v4l2_pixelformat.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index b760ec0eff82..4746d38c30d2 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -785,7 +785,10 @@ const std::map pixelFormatInfo{ { formats::MJPEG, { .name = "MJPEG", .format = formats::MJPEG, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), }, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), + V4L2PixelFormat(V4L2_PIX_FMT_JPEG), + }, .bitsPerPixel = 0, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, .packed = false, diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 264ca80aab27..8ec442d6b84d 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -183,6 +183,8 @@ const std::map vpf2pf{ /* Compressed formats. */ { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), { formats::MJPEG, "Motion-JPEG" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_JPEG), + { formats::MJPEG, "JPEG JFIF" } }, }; } /* namespace */