{"id":13666,"url":"https://patchwork.libcamera.org/api/1.1/covers/13666/?format=json","web_url":"https://patchwork.libcamera.org/cover/13666/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210906225420.13275-1-laurent.pinchart@ideasonboard.com>","date":"2021-09-06T22:54:20","name":"[libcamera-devel,v3,00/30] libcamera: Handle fallout of FrameBuffer offset support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/cover/13666/mbox/","series":[{"id":2482,"url":"https://patchwork.libcamera.org/api/1.1/series/2482/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2482","date":"2021-09-06T22:54:20","name":"libcamera: Handle fallout of FrameBuffer offset support","version":3,"mbox":"https://patchwork.libcamera.org/series/2482/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/13666/comments/","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3FA8DBE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 22:54:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B4E06916C;\n\tTue,  7 Sep 2021 00:54:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6014660253\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Sep 2021 00:54:43 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AF88D891;\n\tTue,  7 Sep 2021 00:54:42 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ev1WvGgY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630968882;\n\tbh=4j7rI4IdKNlTIWUnngK5z/2QIj6GIs1yYgEo+OtaQY8=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=ev1WvGgY0Rc/Kr6c2pD9gbZyYuqqxJ+4TSastxuMlNLwx0HnB9nljRXl3C649JYtC\n\tGEB22AHycac2A1phzFHqahGRry9UmO6eyQmL09qvuAkrVudcMT1/CxCbSd58TF5+j3\n\thkfZUIyyh38QQgBwamv0ii/slo29XkO1FUkdJCkk=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  7 Sep 2021 01:54:20 +0300","Message-Id":"<20210906225420.13275-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 00/30] libcamera: Handle fallout of\n\tFrameBuffer offset support","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Hello everybody,\n\nThis patch series started as an investigation of a qcam failure with\nIPU3 after the merge of the FrameBuffer offset support. While a hack in\nqcam would be possible, I decided to instead address the core issue and\nfix it in V4L2VideoDevice.\n\nCompared to v2, the series now includes fixes the Android HAL (cam and\nqcam where already included in v2, and the libcamera core was addressed\nin v1).\n\nI have tested this series with the IPU3 (NV12), VIMC (ARGB8888) and UVC\n(MJPEG and YUYV) pipeline handlers using cam, qcam, libcamerasrc and\nv4l2-compat, and with the Raspberry Pi (ARGB8888, NV12 and YUV420)\npipeline handler using cam and qcam only. (On a side note, the qcam\nformat conversion code doesn't take strides into account correctly,\npatches will follow.)\n\nUmang, you have been kind enough to test the Android HAL with the IPU3\npipeline handler on v2, I would be grateful if you could test this\nversion too.\n\nThe most important change is in patches 13/30 and 14/30, which translate\nbetween V4L2 buffers and libcamera FrameBuffer to handle the case where\na multi-planar frame buffer is used with the V4L2 single-planar API.\nIt's working more or less by chance at the moment (except in qcam where\nit's broken, and possibly in other places I haven't tested). Patches\n01/30 to 12/30 are cleanups and additions to prepare for the work in\nV4L2VideoDevice, and patch 15/30 is a small cleanup on top. Patches\n16/30 and 17/30 then improve the FrameBuffer class API as a cleanup.\n\nPatches 18/30 to 30/30 fix issues in the Android HAL, v4l2-compat, cam\nand qcam. Worth being noted is patch 21-30 that introduces an Image\nclass shared by cam and qcam. The class duplicates the MappedFrameBuffer\nimplementation private to libcamera. I've tried to rework\nMappedFrameBuffer into something I would be happy to see in the public\nAPI, but failed to do so in a reasonable amount of time, and I didn't\nwant to delay this important regression fix.\n\nThis series doesn't break any unit test, as vimc doesn't support NV12.\nAddition of NV12 support to the vimc kernel driver would be very nice,\nin order to test multi-planar support in our unit tests. Volunteers are\nwelcome ;-)\n\nLaurent Pinchart (30):\n  libcamera: base: utils: Use size_t for index in utils::enumerate()\n  libcamera: file_descriptor: Add a function to retrieve the inode\n  libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()\n  libcamera: Use V4L2PixelFormat::fromPixelFormat()\n  libcamera: formats: Move plane info structure to PixelFormatInfo\n  libcamera: formats: Add planeSize() helpers to PixelFormatInfo\n  libcamera: formats: Support V4L2 non-contiguous formats\n  libcamera: framebuffer: Move planes check to constructor\n  libcamera: framebuffer: Add a function to check if planes are\n    contiguous\n  libcamera: v4l2_videodevice: Cache PixelFormatInfo\n  libcamera: v4l2_videodevice: Document plane handling in createBuffer()\n  libcamera: v4l2_videodevice: Take stride into account to compute\n    offsets\n  libcamera: v4l2_videodevice: Coalesce planes when queuing buffer\n  libcamera: v4l2_videodevice: Split planes when dequeuing buffer\n  libcamera: v4l2_videodevice: Use utils::enumerate()\n  libcamera: framebuffer: Allocate metadata planes at construction time\n  libcamera: framebuffer: Prevent modifying the number of metadata\n    planes\n  android: camera_device: Don't assume all planes use the same fd\n  android: jpeg: Use stride instead of image width for line address\n  android: jpeg: Support multi-planar buffers\n  cam: Add Image class\n  cam: file_sink: Use Image class to access pixel data\n  cam: drm: Support per-plane stride values\n  cam: drm: Set per-plane offsets when creating DRM frame buffer\n  cam: drm: Avoid importing the same dmabuf multiple times\n  qcam: Print bytesused for all planes\n  qcam: Use Image class to access pixel data\n  qcam: viewfinder_gl: Support multi-planar buffers\n  qcam: viewfinder_qt: Support multi-planar buffers\n  v4l2: Sum bytesused for all planes when dequeuing buffer\n\n include/libcamera/base/utils.h                |   4 +-\n include/libcamera/file_descriptor.h           |   3 +\n include/libcamera/framebuffer.h               |  19 +-\n include/libcamera/internal/formats.h          |  22 +-\n include/libcamera/internal/framebuffer.h      |   2 +\n include/libcamera/internal/v4l2_pixelformat.h |   2 +-\n include/libcamera/internal/v4l2_videodevice.h |   3 +-\n src/android/camera_device.cpp                 |  25 +-\n src/android/jpeg/encoder_libjpeg.cpp          |  19 +-\n src/android/jpeg/encoder_libjpeg.h            |   8 +-\n src/android/jpeg/post_processor_jpeg.cpp      |   2 +-\n src/android/jpeg/thumbnailer.cpp              |   4 +-\n src/android/mm/generic_camera_buffer.cpp      |  11 +-\n src/android/yuv/post_processor_yuv.cpp        |  10 +-\n src/cam/camera_session.cpp                    |   4 +-\n src/cam/drm.cpp                               |  38 +-\n src/cam/drm.h                                 |   7 +-\n src/cam/file_sink.cpp                         |  44 +--\n src/cam/file_sink.h                           |   6 +-\n src/cam/image.cpp                             | 107 +++++\n src/cam/image.h                               |  52 +++\n src/cam/kms_sink.cpp                          |  28 +-\n src/cam/meson.build                           |   1 +\n src/libcamera/file_descriptor.cpp             |  26 ++\n src/libcamera/formats.cpp                     | 373 ++++++++++++++----\n src/libcamera/framebuffer.cpp                 |  57 ++-\n src/libcamera/pipeline/ipu3/cio2.cpp          |   4 +-\n src/libcamera/pipeline/ipu3/imgu.cpp          |   2 +-\n .../pipeline/raspberrypi/raspberrypi.cpp      |   8 +-\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |   6 +-\n src/libcamera/pipeline/simple/converter.cpp   |   8 +-\n src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   6 +-\n src/libcamera/pipeline/vimc/vimc.cpp          |   8 +-\n src/libcamera/v4l2_pixelformat.cpp            |  11 +-\n src/libcamera/v4l2_videodevice.cpp            | 201 +++++++---\n src/qcam/format_converter.cpp                 |  18 +-\n src/qcam/format_converter.h                   |   9 +-\n src/qcam/main_window.cpp                      |  38 +-\n src/qcam/main_window.h                        |   4 +-\n src/qcam/meson.build                          |   1 +\n src/qcam/viewfinder.h                         |   6 +-\n src/qcam/viewfinder_gl.cpp                    |  45 +--\n src/qcam/viewfinder_gl.h                      |   4 +-\n src/qcam/viewfinder_qt.cpp                    |  20 +-\n src/qcam/viewfinder_qt.h                      |   2 +-\n src/v4l2/v4l2_camera_proxy.cpp                |  16 +-\n test/libtest/buffer_source.cpp                |   3 +-\n test/utils.cpp                                |  10 +-\n 49 files changed, 939 insertions(+), 372 deletions(-)\n create mode 100644 src/cam/image.cpp\n create mode 100644 src/cam/image.h"}