From patchwork Wed Jun 24 14:52:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8398 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC64F60103 for ; Wed, 24 Jun 2020 16:53:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vJswO8JO"; dkim-atps=neutral Received: from jade.rasen.tech (unknown [IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11DCD2A8; Wed, 24 Jun 2020 16:53:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593010395; bh=Ah/Kga12yTFaWZTfajutp60GefsEU5UkpBKnxtD90Lg=; h=From:To:Cc:Subject:Date:From; b=vJswO8JOZRXJwRsipgPUIx4pbMtsUHqm9oBk8UAvUIZK8dhbXNWSgOLeREdeM90l5 f8QLBvsfXNJIqyi5itBEhYzpbhIAOz3G5UGQAsJVubAVi2QS7Yq+jFHNPVp+o9ZJHi v1rfk96kZHByCvB4/U6OiJPLDIfLyuQKVhnYE6HY= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Jun 2020 23:52:34 +0900 Message-Id: <20200624145256.48266-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 00/22] Support v4l2-compliance 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: Wed, 24 Jun 2020 14:53:15 -0000 This patchset makes the V4L2 compatibility layer comply with v4l2-compliance, and v4l2-compliance -s. I have gotten zero failues and 2 warnings with a uvcvideo libcamera camera. The two warnings are that VIDIOC_S_FMT doesn't work from a second fd (after a different fd has already called it), and that VIDIOC_CREATEBUFS is not supported, which I think are fair to not support. The v4l2-compliance used for this test only adds libcamera to businfo prefixes with respect to master. Note that there are a couple failues when using a vimc libcamera camera, as these cameras doesn't support setting frame sizes that are not multiples of 3. Also, while trying to comply with v4l2-compliance I lost support for firefox. It's v4 and I still haven't gotten around to it. qv4l2 still works, though. * Changes in v4 - cosmetic changes and minor code polishing * Changes in v3: - replace exclusive locking of the camera proxy with a concept of ownership - implement v4l2 priority to actually lock the camera similar to v4l2 in the kernel, alongside implicit ownership of the camera - made the compat layer thread-safe by serializing accesses to the camera proxy - split conglomerate v4l2-compliance fix patches into separate small patches * Changes in v2: The biggest change in v2 was adding V4L2CameraFile to contain all the information related to the open file instance, instead of containing maps for them within V4L2CameraProxy. dup is handled solely in V4L2CompatManager, by adding another fd -> V4L2CameraFile map. The V4L2CameraFile recount is handled automatically by V4L2CompatManager with shared pointers, while V4L2CameraProxy recount is handled manually, since it is not constructed and deconstructed but rather is open()ed and close()d. The other changes are minor in comparison. One is consolidating the null arg checks in the ioctl handlerrs. Another is splitting all the v4l2-compliance streaming test fixes to their own patches. Paul Elder (17): v4l2: v4l2_camera_file: Add V4L2CameraFile to model the opened camera file v4l2: v4l2_compat: Support multiple open v4l2: v4l2_camera_proxy: Check for null arg values in main ioctl handler v4l2: v4l2_camera_proxy: Fix v4l2-compliance support for extended formats v4l2: v4l2_camera_proxy: Implement VIDIOC_G/S_PRIORITY v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUM_FRAMESIZES v4l2: v4l2_camera: Add isRunning() v4l2: v4l2_camera_proxy: Disallow dqbuf when not streaming v4l2: v4l2_camera_proxy: noop if streamon when stream is already on v4l2: v4l2_camera_proxy: Reset buffer flags on reqbufs 0 v4l2: v4l2_camera: Don't use libcamera::Semaphore for available buffers v4l2: v4l2_camera: Clear pending requests on freeBuffers and streamOff v4l2: v4l2_camera_proxy: Check arg->index bounds for querybuf, qbuf, dqbuf v4l2: v4l2_camera_proxy: Don't allow streamon if no buffers have been requested v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still mmaped v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing src/v4l2/meson.build | 1 + src/v4l2/v4l2_camera.cpp | 44 +++- src/v4l2/v4l2_camera.h | 10 +- src/v4l2/v4l2_camera_file.cpp | 45 ++++ src/v4l2/v4l2_camera_file.h | 35 +++ src/v4l2/v4l2_camera_proxy.cpp | 402 +++++++++++++++++++++++++------ src/v4l2/v4l2_camera_proxy.h | 57 +++-- src/v4l2/v4l2_compat_manager.cpp | 71 +++--- src/v4l2/v4l2_compat_manager.h | 4 +- 9 files changed, 539 insertions(+), 130 deletions(-) create mode 100644 src/v4l2/v4l2_camera_file.cpp create mode 100644 src/v4l2/v4l2_camera_file.h