From patchwork Wed Jul 31 16:44:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Link Mauve X-Patchwork-Id: 13748970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93F8CC3DA7F for ; Wed, 31 Jul 2024 16:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=oW9RPRrNQnrlUckAoca3qS20o+6cCbe7zmN2xzHS2pc=; b=Q04I2OqsZe7PE9A4yeyxg6G4E7 q8M6apipq7U9GolwQ2MaAhFU7Fl8HL8fAEcJGZdV29pw5TG8xwUInsTTyc6buJjUIf0Rv2JSIzceg 9Mxvv7Ly3Y8pPw4rBcU6ItrvTH3Edj/jWJSkggAxoEcda/hbITCOlw7ogQqpJYiuXpKdmQzEzScgd IZeIwKkzoLfiToioWcH/JsK5/B1WqGY1p+1cXcqJd0MV2JkgYN2rWntbdIe90rb5M4FiTgNpM0Nhh 1z6LHCX0Z41zGFz2B++HjUA2P5W0o5bIAfOUGQ6SkANDH4Pknofb6o5yHuMoLjQ9rvFZfxwQHQufP nRts8Juw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZCT1-00000001u0r-3ziU; Wed, 31 Jul 2024 16:46:24 +0000 Received: from [2a01:e0a:828:c7c0:e2d5:5eff:fe2d:8e8] (helo=luna.linkmauve.fr) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZCRF-00000001tTd-2J6t for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 16:44:35 +0000 Received: by luna.linkmauve.fr (Postfix, from userid 1000) id CB91714649D5; Wed, 31 Jul 2024 18:44:26 +0200 (CEST) From: Emmanuel Gil Peyrot To: linux-sunxi@lists.linux.dev Cc: Emmanuel Gil Peyrot , Maxime Ripard , Paul Kocialkowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/4] media: cedrus: Add a JPEG decoder Date: Wed, 31 Jul 2024 18:44:10 +0200 Message-ID: <20240731164422.206503-1-linkmauve@linkmauve.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_094433_748994_6DB1F026 X-CRM114-Status: GOOD ( 16.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Video Engine present on all (?) AllWinner SoCs includes a JPEG decoder, which shares the same engine as the MPEG2 decoder. I mostly used the linux-sunxi resources on the engine[0], as well as some reverse-engineered userland using the legacy /dev/cedar_dev API[1]. I wrote the Onix library[2] to exercise this driver. With it, I have tested this series on the A10, A20 and A64, as found in Olimex Lime, Lime 2 and PinePhone respectively, so further testing on other SoCs would be very welcome. On the A10 and A20, since only the tiled ST12 format is supported, the file dump binary is a bit unusable, but I have tested displaying to DRM and to Wayland just fine on these SoCs. They also only support downscaling from 4:4:4 to 4:2:2, unlike newer SoCs which support downscaling from either 4:4:4 or 4:2:2 to 4:2:2 or 4:2:0. This prompts the issue of which formats to advertise: currently I chose to only expose NV12, but ideally NV16 would be exposed when the user tries to decode a 4:2:2 or 4:4:4 image. By the time the user has called ENUM_FMTS on the capture queue, the driver doesn’t know the subsampling in the JPEG file, so it can’t expose only the supported formats. A possible solution could be to add a new v4l2_ext_ctrl describing the JPEG, but this is a new uAPI which should get discussed outside of this driver. [0] https://linux-sunxi.org/VE_Register_guide [1] https://github.com/jemk/cedrus [2] https://linkmauve.fr/dev/onix/ Emmanuel Gil Peyrot (1): media: cedrus: Add JPEG decoder Jernej Skrabec (3): media: cedrus: Setup secondary output formats media: cedrus: Enable JPEG decoding in various variants media: cedrus: Don't require requests for all codecs drivers/staging/media/sunxi/cedrus/Kconfig | 1 + drivers/staging/media/sunxi/cedrus/Makefile | 2 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 10 + drivers/staging/media/sunxi/cedrus/cedrus.h | 5 + .../staging/media/sunxi/cedrus/cedrus_hw.c | 14 +- .../staging/media/sunxi/cedrus/cedrus_jpeg.c | 352 ++++++++++++++++++ .../staging/media/sunxi/cedrus/cedrus_regs.h | 25 +- .../staging/media/sunxi/cedrus/cedrus_video.c | 11 +- 8 files changed, 413 insertions(+), 7 deletions(-) create mode 100644 drivers/staging/media/sunxi/cedrus/cedrus_jpeg.c