From patchwork Thu Jul 9 13:28:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8715 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 A4ACFBD792 for ; Thu, 9 Jul 2020 13:28:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33DE061214; Thu, 9 Jul 2020 15:28:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MiWRAYK1"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E76361184 for ; Thu, 9 Jul 2020 15:28:48 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DB77F525; Thu, 9 Jul 2020 15:28:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594301327; bh=3/+LX0E2w1kmwqQcefdCXVLuUT9lO8x/pJEujtwcqQk=; h=From:To:Cc:Subject:Date:From; b=MiWRAYK1vAU5lOHRhhuXk1L+QU9U1pK/ha9tpK3CPEh0dlC4MF0uvFLOQ24qiFtqM Spui/PAIXeoRh434tVT00czhPN4Wn3bij96Pf4f6n/C8IfKyLH5x3X7m04YijluGQJ c4eLOYnIACgNLHUNlCMac2ooPyFhlB26TLFJHRsU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jul 2020 22:28:12 +0900 Message-Id: <20200709132835.112593-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 00/23] Clean up formats in v4l2-compat and pipeline handlers 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" Alright, I'm pretty sure this v5 is enough... just one final check before merging. I tacked on the v4l2-compat test at the end too, since it'll be merged at the same time (and I added one line to tell the v4l2-compat test to test raspi as well). This patch series: - improves format-related calculations (stride, frameSize) - cleans up the v4l2 compatibility layer related to formats - fixes v4l2 compatibility interception for the raspberry pi pipeline handler - fixes unsupported formats in uvcvideo and raspberrypi pipeline handlers (the others were fine already) - moves filling in stride and frameSize from camera configuration time to configuration validation time for all pipeline handlers Patches 1~6 add functions and fields that are necessary in the rest of the patches. Patch 8 forces pipeline handlers to use acquireMediaDevice so that media devices can automatically be mapped to devnums for the v4l2 compatibility layer to intercept, and patch 9 makes the raspberrypi pipeline handler conform to this. Patches 10~11 filter out unsupported formats at configuration generation time, to prevent them from being selected, in the pipeline handlers that hadn't already done so. Patches 12~13, 15~18 move filling in the stide and frameSize parameters from camera configuration time to configuration validation time. Patches 21~22 move formats out of V4L2CameraProxy, and clean up some of its code. Finally, patch 23 adds the test for the v4l2 compatibility layer. Changes in v5: - change default "align" parameter in PixelFormatInfo::stride() to 1 - add optional "align" parameter to PixelFormatInfo::frameSize() - reorder patches to avoid bisection regression: - extend PixelFormatInfo - add stride and frameSize to StreamConfiguration - update pipeline handlers - use in V4L2 compat layer - return error from try_fmt and s_fmt if format negotiation on the V4L2Camera/Camera side fail - add the v4l2-compat test to the end of this patch series, in a v5 that adds raspi support Changes in v4: - upgraded documentation of format info definitions - added overloaded PixelFormatInfo::stride() that takes alignment - added optional parameter to PixelFormatInfo::frameSize that takes array of strides - raspberrypi: fill in default format and frame size - simple: fix stride and frameSize for converter (compared to v3) - use tryFormat to get stride and frameSize for all pipelines except for ipu3 Paul Elder (23): libcamera: formats: Add NV24 and NV42, and reorder NV formats libcamera: formats: Add fields to info to ease calculating stride libcamera: StreamConfiguration: Add frameSize field libcamera: V4L2VideoDevice: Add tryFormat libcamera: formats: PixelFormatInfo: Add v4l2 lookup function libcamera: PixelFormatInfo: Add functions stride and frameSize libcamera: pipeline: raspberrypi: Simplify format fetching libcamera: pipeline: raspberrypi: Acquire media devices with acquireMediaDevice libcamera: pipeline_handler: Fatal if registering camera without media devices libcamera: pipeline: raspberrypi: Filter out unsupported formats libcamera: pipeline: uvcvideo: Filter out unsupported formats libcamera: ipu3: Fill stride and frameSize at config validation libcamera: raspberrypi: Fill stride and frameSize at config validation libcamera: raspberrypi: Set default configuration size at validation libcamera: rkisp1: Fill stride and frameSize at config validation libcamera: simple: Fill stride and frameSize at config validation libcamera: uvcvideo: Fill stride and frameSize at config validation libcamera: vimc: Fill stride and frameSize at config validation libcamera: StreamConfiguration: Update stride documentation v4l2: v4l2_camera: Fix stream selection for buffer operations v4l2: v4l2_camera_proxy: Get stride and frameSize from stream config v4l2: v4l2_camera_proxy: Use stream config in tryFormat tests: v4l2_compat: Add test for v4l2_compat include/libcamera/internal/formats.h | 18 ++ include/libcamera/internal/v4l2_videodevice.h | 7 +- include/libcamera/stream.h | 1 + src/libcamera/formats.cpp | 289 +++++++++++++++++- src/libcamera/pipeline/ipu3/ipu3.cpp | 14 +- .../pipeline/raspberrypi/raspberrypi.cpp | 73 +++-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 +- src/libcamera/pipeline/simple/converter.cpp | 19 ++ src/libcamera/pipeline/simple/converter.h | 4 + src/libcamera/pipeline/simple/simple.cpp | 26 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 36 ++- src/libcamera/pipeline/vimc/vimc.cpp | 23 +- src/libcamera/pipeline_handler.cpp | 4 + src/libcamera/stream.cpp | 22 +- src/libcamera/v4l2_videodevice.cpp | 50 ++- src/v4l2/v4l2_camera.cpp | 26 +- src/v4l2/v4l2_camera.h | 3 + src/v4l2/v4l2_camera_proxy.cpp | 225 ++++---------- src/v4l2/v4l2_camera_proxy.h | 10 +- test/meson.build | 1 + test/v4l2_compat/meson.build | 10 + test/v4l2_compat/v4l2_compat_test.py | 152 +++++++++ 22 files changed, 748 insertions(+), 285 deletions(-) create mode 100644 test/v4l2_compat/meson.build create mode 100755 test/v4l2_compat/v4l2_compat_test.py