Patch Detail
Show a patch.
GET /api/patches/18327/?format=api
{ "id": 18327, "url": "https://patchwork.libcamera.org/api/patches/18327/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18327/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20230227-android-gralloc-v3-1-d3e0a4f4a60f@baylibre.com>", "date": "2023-03-02T08:27:43", "name": "[libcamera-devel,v3] android: mm: generic: use GRALLOC_HARDWARE_MODULE_ID", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "0591ce8b0baca390ecbf6d9510bc629654b5d6d8", "submitter": { "id": 153, "url": "https://patchwork.libcamera.org/api/people/153/?format=api", "name": "Mattijs Korpershoek", "email": "mkorpershoek@baylibre.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18327/mbox/", "series": [ { "id": 3781, "url": "https://patchwork.libcamera.org/api/series/3781/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3781", "date": "2023-03-02T08:27:43", "name": "[libcamera-devel,v3] android: mm: generic: use GRALLOC_HARDWARE_MODULE_ID", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3781/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18327/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18327/checks/", "tags": {}, "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 98A8BBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 2 Mar 2023 08:27:47 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0BDEA626C5;\n\tThu, 2 Mar 2023 09:27:47 +0100 (CET)", "from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C3846265E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 2 Mar 2023 09:27:45 +0100 (CET)", "by mail-wm1-x334.google.com with SMTP id\n\to38-20020a05600c512600b003e8320d1c11so1653182wms.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Mar 2023 00:27:45 -0800 (PST)", "from mkorpershoek-xps13.local ([82.66.159.240])\n\tby smtp.gmail.com with ESMTPSA id\n\tr8-20020a05600c458800b003df5be8987esm2253756wmo.20.2023.03.02.00.27.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 02 Mar 2023 00:27:44 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677745667;\n\tbh=6+pjW13oltCtROF2IVRJffgTr9KVfE/2DAmq3nHKMh8=;\n\th=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=FMsXuMz+3kT00ZBhUIWe9OXgECMBichapIitAfzMZ0X7L9EzmTYlBVcM6aPzAORnm\n\tZ59CE21doapWWLpt1JVh/8Eo51iJw8MDAkrSo4lr57ZJXVHFtM7sXOTq9WkudRcXEU\n\trlmkR0h+q3DIjJlTCL19bXT3uQdv7qprbf+gOZl+lZnuC8IetityWzYNySVMJHTKya\n\tQjoU7s1GwXHBwp2iT21tk7dySnDcsA3ooPNI0xGIWqGjbyVmNAszpVQWvT8cGlFY9m\n\tfQZ55NZpFIP1lV0P3wfDcwHoF+RaNV63FQXLDERhGFcLngpZ1NIPOxH3im5DACFNiB\n\tdgnlC8v+Upl+g==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1677745665;\n\th=cc:to:message-id:content-transfer-encoding:mime-version:subject\n\t:date:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=EvYTol28kVRNmd8znfjquRAfwKGtksg+QahfMbqU5AA=;\n\tb=pm91A6UuhUNATqtKOQWwQtpQ8SYFlUUlb8GXEok7Ofqfxk6qQFS+A3XfVhkgeyXNfv\n\tJhUkM2Ng3mLKNapEpcDO7g4/rNAQGuPmJSgK2FYzGyD2kPsawIqQ190kI9hN+WY3M1Ac\n\txsTP01/uPiDtMCMAY6tmez6pSBfUVNc6RK2RfwdHMrM9btYcCLX5NMla8rQ7MSsMLkNk\n\tpq9XX6TzsSM21RdyGNuChxEmigBV0zLgOWeTcFuGT9kZRQz2rkTpu5uk+Gbm8/gW5vCr\n\thFcEQdlpAvOCJeAHCOD9OR/urihwfRkAlz7Ozh8VSUSNAaYmOTPlZ1Bk2mcA+0ulAOpL\n\tAVIw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"pm91A6Uu\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1677745665;\n\th=cc:to:message-id:content-transfer-encoding:mime-version:subject\n\t:date:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=EvYTol28kVRNmd8znfjquRAfwKGtksg+QahfMbqU5AA=;\n\tb=7iqF8+41R+FE++jq/pQ4oMGazlhs0rk60cr8mwJJoKsDFMElfZPrV7NEQW7VxrkngA\n\trJuz8LNDJ7BJRANh4gw7L7CudjApR1abxF26B1GPNK4xdgCL3IdhwnOazQsJ/eAQ/bj/\n\tzwAjUb5XACTttI9bRc3PifPPNrXAm93rlaIgEUBw0rLoo1UFLjV38JqAg/CBt9o7hmOa\n\tFHVPgaKQY6jwIr1LgT02YdepfL7lx0ev7tjkMlmQ2tmsHB5hEuy2y0HDGoS5A7ZDozbx\n\tiQuo8GCbJYCJijVLM6h+DYvckeCVK4GfEyReS3WmZMT+m5u/826iTBWP7m3iSLYiINsS\n\tq6uQ==", "X-Gm-Message-State": "AO0yUKWQ0PsCtmEX+dZyZMZv23I/D5K0yzxoL7HTUqoB+/dsCcOwRuMj\n\tunRjdVdQuucFXSHGV+7seZhfy+YkSe4bEQtX", "X-Google-Smtp-Source": "AK7set++LZe0ztunu3s3xsx1+JQo8ct1SpXm3Rxp7fCqhSC+atm7RxsbaKbJ0gQojZvvPo/1FJXEog==", "X-Received": "by 2002:a05:600c:3d8e:b0:3eb:4cb5:e13 with SMTP id\n\tbi14-20020a05600c3d8e00b003eb4cb50e13mr7412218wmb.31.1677745664958; \n\tThu, 02 Mar 2023 00:27:44 -0800 (PST)", "Date": "Thu, 02 Mar 2023 09:27:43 +0100", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20230227-android-gralloc-v3-1-d3e0a4f4a60f@baylibre.com>", "X-B4-Tracking": "v=1; b=H4sIAP5dAGQC/4WNzQ6CMBAGX4X0bE1/ENST72E8bNsFmiA1W9JIC\n\tO9uy9HEeJzdfDMri0geI7tWKyNMPvowZdCHitkBph65d5mZEkoLpVoOk6PgHe8JxjFYLmrU0p3\n\tQ2ebM8spARG4IJjuU3RPijFQeL8LOv/fU/ZF58HEOtOzlJMv1dyRJLrnWjehsB60V7mZgGb0hP\n\tNrwZEWX1B+FygqhLqZ2CoStvxXbtn0An+ewrg0BAAA=", "To": "libcamera-devel@lists.libcamera.org", "X-Mailer": "b4 0.12.1", "Subject": "[libcamera-devel] [PATCH v3] android: mm: generic: use\n\tGRALLOC_HARDWARE_MODULE_ID", "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>", "From": "Mattijs Korpershoek via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Mattijs Korpershoek <mkorpershoek@baylibre.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "PlatformFrameBufferAllocator is an abstraction over gralloc.\nRight now hardwareModule_ points towards a CAMERA_HARDWARE_MODULE_ID.\n\nWhen gralloc_open() is called we observe:\nlibcamera: DEBUG HAL camera3_hal.cpp:75 Open camera gpu0\nlibcamera: ERROR Camera camera.cpp:524 Camera in Configured state trying acquire() requiring state Available\n01-23 14:14:04.742 370 416 E libcamera: FATAL HAL generic_frame_buffer_allocator.cpp:105 gralloc_open() failed: -87\n\nWhich is wrong, gralloc_open() is attempting to re-open the camera HAL,\ninstead of the gralloc HAL.\n\nPoint to a GRALLOC_HARDWARE_MODULE_ID instead so that we can request\nbuffers from gralloc in android.\n\nNote: this add a new dependency on android's libhardware [1]\n\n[1] https://android.googlesource.com/platform/hardware/libhardware\n\nFixes: c58662c5770e (\"android: Introduce PlatformFrameBufferAllocator\")\nSigned-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n---\n* Tested on an integration branch in Android 12 (Using android.bp)\n* Build tested with meson setup build -Dandroid=enabled -Dandroid_platform=generic\n---\nChanges in v3:\n- Add missing meson.build change to define libhardware dependency\n- Link to v2: https://lists.libcamera.org/pipermail/libcamera-devel/2023-February/036884.html\n\nChanges in v2:\n- Add dlclose() in PlatformFrameBufferAllocator destructor (Laurent)\n- Removed RFC, as linking against an AOSP lib for android is OK.\n- Link to v1: https://lists.libcamera.org/pipermail/libcamera-devel/2023-February/036857.html\n---\n src/android/mm/generic_frame_buffer_allocator.cpp | 7 +++++--\n src/android/mm/meson.build | 1 +\n 2 files changed, 6 insertions(+), 2 deletions(-)\n\n\n---\nbase-commit: 58e0b6e18c425072a47594f42fc0b61801403aca\nchange-id: 20230227-android-gralloc-04e31d5edc68\n\nBest regards,", "diff": "diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp\nindex 3750e1bf52a9..7ecef2c669df 100644\n--- a/src/android/mm/generic_frame_buffer_allocator.cpp\n+++ b/src/android/mm/generic_frame_buffer_allocator.cpp\n@@ -5,6 +5,7 @@\n * generic_camera_buffer.cpp - Allocate FrameBuffer using gralloc API\n */\n \n+#include <dlfcn.h>\n #include <memory>\n #include <vector>\n \n@@ -72,9 +73,10 @@ class PlatformFrameBufferAllocator::Private : public Extensible::Private\n public:\n \tPrivate(CameraDevice *const cameraDevice)\n \t\t: cameraDevice_(cameraDevice),\n-\t\t hardwareModule_(cameraDevice->camera3Device()->common.module),\n+\t\t hardwareModule_(nullptr),\n \t\t allocDevice_(nullptr)\n \t{\n+\t\thw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hardwareModule_);\n \t\tASSERT(hardwareModule_);\n \t}\n \n@@ -85,7 +87,7 @@ public:\n \n private:\n \tconst CameraDevice *const cameraDevice_;\n-\tstruct hw_module_t *const hardwareModule_;\n+\tconst struct hw_module_t *hardwareModule_;\n \tstruct alloc_device_t *allocDevice_;\n };\n \n@@ -93,6 +95,7 @@ PlatformFrameBufferAllocator::Private::~Private()\n {\n \tif (allocDevice_)\n \t\tgralloc_close(allocDevice_);\n+\tdlclose(hardwareModule_->dso);\n }\n \n std::unique_ptr<HALFrameBuffer>\ndiff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\nindex d40a3b0ba2eb..42eeab3bcfa9 100644\n--- a/src/android/mm/meson.build\n+++ b/src/android/mm/meson.build\n@@ -4,6 +4,7 @@ platform = get_option('android_platform')\n if platform == 'generic'\n android_hal_sources += files(['generic_camera_buffer.cpp',\n 'generic_frame_buffer_allocator.cpp'])\n+ android_deps += [dependency('libhardware')]\n elif platform == 'cros'\n android_hal_sources += files(['cros_camera_buffer.cpp',\n 'cros_frame_buffer_allocator.cpp'])\n", "prefixes": [ "libcamera-devel", "v3" ] }