[libcamera-devel,v7,2/6] Add HALFrameBuffer and replace FrameBuffer in src/android
diff mbox series

Message ID 20221201092733.2042078-3-chenghaoyang@google.com
State New
Headers show
Series
  • Add CrOS JEA implementation
Related show

Commit Message

Cheng-Hao Yang Dec. 1, 2022, 9:27 a.m. UTC
From: Harvey Yang <chenghaoyang@chromium.org>

AndroidFrameBuffer is derived from FrameBuffer with access to
buffer_handle_t, which is needed for JEA usage.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
---
 src/android/camera_device.cpp                 |  3 ++-
 src/android/frame_buffer_allocator.h          |  7 ++---
 src/android/hal_framebuffer.cpp               | 22 ++++++++++++++++
 src/android/hal_framebuffer.h                 | 26 +++++++++++++++++++
 src/android/meson.build                       |  1 +
 .../mm/cros_frame_buffer_allocator.cpp        |  9 ++++---
 .../mm/generic_frame_buffer_allocator.cpp     | 11 +++++---
 7 files changed, 67 insertions(+), 12 deletions(-)
 create mode 100644 src/android/hal_framebuffer.cpp
 create mode 100644 src/android/hal_framebuffer.h

Comments

Laurent Pinchart Dec. 7, 2022, 3:26 a.m. UTC | #1
Hi Harvey,

Thank you for the patch.

On Thu, Dec 01, 2022 at 09:27:29AM +0000, Harvey Yang via libcamera-devel wrote:
> From: Harvey Yang <chenghaoyang@chromium.org>
> 
> AndroidFrameBuffer is derived from FrameBuffer with access to

s/AndroidFrameBuffer/HALFrameBuffer/

> buffer_handle_t, which is needed for JEA usage.
> 
> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
> ---
>  src/android/camera_device.cpp                 |  3 ++-
>  src/android/frame_buffer_allocator.h          |  7 ++---
>  src/android/hal_framebuffer.cpp               | 22 ++++++++++++++++
>  src/android/hal_framebuffer.h                 | 26 +++++++++++++++++++
>  src/android/meson.build                       |  1 +
>  .../mm/cros_frame_buffer_allocator.cpp        |  9 ++++---
>  .../mm/generic_frame_buffer_allocator.cpp     | 11 +++++---
>  7 files changed, 67 insertions(+), 12 deletions(-)
>  create mode 100644 src/android/hal_framebuffer.cpp
>  create mode 100644 src/android/hal_framebuffer.h
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index b20e389b..872161ba 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -30,6 +30,7 @@
>  #include "camera_hal_config.h"
>  #include "camera_ops.h"
>  #include "camera_request.h"
> +#include "hal_framebuffer.h"
>  
>  using namespace libcamera;
>  
> @@ -794,7 +795,7 @@ CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer,
>  		planes[i].length = buf.size(i);
>  	}
>  
> -	return std::make_unique<FrameBuffer>(planes);
> +	return std::make_unique<HALFrameBuffer>(planes, camera3buffer);
>  }
>  
>  int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
> diff --git a/src/android/frame_buffer_allocator.h b/src/android/frame_buffer_allocator.h
> index 5d2eeda1..e5c94922 100644
> --- a/src/android/frame_buffer_allocator.h
> +++ b/src/android/frame_buffer_allocator.h
> @@ -13,9 +13,10 @@
>  #include <libcamera/base/class.h>
>  
>  #include <libcamera/camera.h>
> -#include <libcamera/framebuffer.h>
>  #include <libcamera/geometry.h>
>  
> +#include "hal_framebuffer.h"
> +
>  class CameraDevice;
>  
>  class PlatformFrameBufferAllocator : libcamera::Extensible
> @@ -31,7 +32,7 @@ public:
>  	 * Note: The returned FrameBuffer needs to be destroyed before
>  	 * PlatformFrameBufferAllocator is destroyed.
>  	 */
> -	std::unique_ptr<libcamera::FrameBuffer> allocate(
> +	std::unique_ptr<HALFrameBuffer> allocate(
>  		int halPixelFormat, const libcamera::Size &size, uint32_t usage);
>  };
>  
> @@ -44,7 +45,7 @@ PlatformFrameBufferAllocator::PlatformFrameBufferAllocator(		\
>  PlatformFrameBufferAllocator::~PlatformFrameBufferAllocator()		\
>  {									\
>  }									\
> -std::unique_ptr<libcamera::FrameBuffer>					\
> +std::unique_ptr<HALFrameBuffer> 					\
>  PlatformFrameBufferAllocator::allocate(int halPixelFormat,		\
>  				       const libcamera::Size &size,	\
>  				       uint32_t usage)			\
> diff --git a/src/android/hal_framebuffer.cpp b/src/android/hal_framebuffer.cpp
> new file mode 100644
> index 00000000..4ac5a820
> --- /dev/null
> +++ b/src/android/hal_framebuffer.cpp
> @@ -0,0 +1,22 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2022, Google Inc.
> + *
> + * hal_framebuffer.cpp - Android Frame Buffer Handling

s/Android/HAL/

> + */
> +
> +#include "hal_framebuffer.h"
> +
> +#include <hardware/camera3.h>
> +
> +HALFrameBuffer::HALFrameBuffer(std::unique_ptr<Private> d,
> +			       buffer_handle_t handle)
> +	: FrameBuffer(std::move(d)), handle_(handle)
> +{
> +}
> +
> +HALFrameBuffer::HALFrameBuffer(const std::vector<Plane> &planes,
> +			       buffer_handle_t handle)
> +	: FrameBuffer(planes), handle_(handle)
> +{
> +}
> diff --git a/src/android/hal_framebuffer.h b/src/android/hal_framebuffer.h
> new file mode 100644
> index 00000000..ec737e70
> --- /dev/null
> +++ b/src/android/hal_framebuffer.h
> @@ -0,0 +1,26 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2022, Google Inc.
> + *
> + * hal_framebuffer.h - Android Frame Buffer Handling

s/Android/HAL/

> + */
> +
> +#pragma once
> +
> +#include "libcamera/internal/framebuffer.h"
> +
> +#include <hardware/camera3.h>
> +
> +class HALFrameBuffer final : public libcamera::FrameBuffer
> +{
> +public:
> +	HALFrameBuffer(std::unique_ptr<Private> d,
> +		       buffer_handle_t handle);
> +	HALFrameBuffer(const std::vector<Plane> &planes,
> +		       buffer_handle_t handle);
> +
> +	buffer_handle_t handle() const { return handle_; }
> +
> +private:
> +	buffer_handle_t handle_;
> +};
> diff --git a/src/android/meson.build b/src/android/meson.build
> index 1bba54de..c2773f9e 100644
> --- a/src/android/meson.build
> +++ b/src/android/meson.build
> @@ -37,6 +37,7 @@ endif
>  android_deps += [libyuv_dep]
>  
>  android_hal_sources = files([
> +    'hal_framebuffer.cpp',

Alphabetical order please.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>      'camera3_hal.cpp',
>      'camera_capabilities.cpp',
>      'camera_device.cpp',
> diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp
> index 0665c77b..0a5c59f2 100644
> --- a/src/android/mm/cros_frame_buffer_allocator.cpp
> +++ b/src/android/mm/cros_frame_buffer_allocator.cpp
> @@ -16,6 +16,7 @@
>  
>  #include "../camera_device.h"
>  #include "../frame_buffer_allocator.h"
> +#include "../hal_framebuffer.h"
>  #include "cros-camera/camera_buffer_manager.h"
>  
>  using namespace libcamera;
> @@ -48,11 +49,11 @@ public:
>  	{
>  	}
>  
> -	std::unique_ptr<libcamera::FrameBuffer>
> +	std::unique_ptr<HALFrameBuffer>
>  	allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);
>  };
>  
> -std::unique_ptr<libcamera::FrameBuffer>
> +std::unique_ptr<HALFrameBuffer>
>  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
>  						const libcamera::Size &size,
>  						uint32_t usage)
> @@ -81,8 +82,8 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
>  		plane.length = cros::CameraBufferManager::GetPlaneSize(handle, i);
>  	}
>  
> -	return std::make_unique<FrameBuffer>(
> -		std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes));
> +	return std::make_unique<HALFrameBuffer>(
> +		std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes), handle);
>  }
>  
>  PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION
> diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp
> index 956623df..3750e1bf 100644
> --- a/src/android/mm/generic_frame_buffer_allocator.cpp
> +++ b/src/android/mm/generic_frame_buffer_allocator.cpp
> @@ -20,6 +20,7 @@
>  
>  #include "../camera_device.h"
>  #include "../frame_buffer_allocator.h"
> +#include "../hal_framebuffer.h"
>  
>  using namespace libcamera;
>  
> @@ -79,7 +80,7 @@ public:
>  
>  	~Private() override;
>  
> -	std::unique_ptr<libcamera::FrameBuffer>
> +	std::unique_ptr<HALFrameBuffer>
>  	allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);
>  
>  private:
> @@ -94,7 +95,7 @@ PlatformFrameBufferAllocator::Private::~Private()
>  		gralloc_close(allocDevice_);
>  }
>  
> -std::unique_ptr<libcamera::FrameBuffer>
> +std::unique_ptr<HALFrameBuffer>
>  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
>  						const libcamera::Size &size,
>  						uint32_t usage)
> @@ -137,8 +138,10 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
>  		offset += planeSize;
>  	}
>  
> -	return std::make_unique<FrameBuffer>(
> -		std::make_unique<GenericFrameBufferData>(allocDevice_, handle, planes));
> +	return std::make_unique<HALFrameBuffer>(
> +		std::make_unique<GenericFrameBufferData>(
> +			allocDevice_, handle, planes),
> +		handle);
>  }
>  
>  PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION
Cheng-Hao Yang Dec. 14, 2022, 9:35 a.m. UTC | #2
Thanks for the review!

Updated the above in the new patch.

On Wed, Dec 7, 2022 at 11:26 AM Laurent Pinchart <
laurent.pinchart@ideasonboard.com> wrote:

> Hi Harvey,
>
> Thank you for the patch.
>
> On Thu, Dec 01, 2022 at 09:27:29AM +0000, Harvey Yang via libcamera-devel
> wrote:
> > From: Harvey Yang <chenghaoyang@chromium.org>
> >
> > AndroidFrameBuffer is derived from FrameBuffer with access to
>
> s/AndroidFrameBuffer/HALFrameBuffer/
>
> > buffer_handle_t, which is needed for JEA usage.
> >
> > Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
> > ---
> >  src/android/camera_device.cpp                 |  3 ++-
> >  src/android/frame_buffer_allocator.h          |  7 ++---
> >  src/android/hal_framebuffer.cpp               | 22 ++++++++++++++++
> >  src/android/hal_framebuffer.h                 | 26 +++++++++++++++++++
> >  src/android/meson.build                       |  1 +
> >  .../mm/cros_frame_buffer_allocator.cpp        |  9 ++++---
> >  .../mm/generic_frame_buffer_allocator.cpp     | 11 +++++---
> >  7 files changed, 67 insertions(+), 12 deletions(-)
> >  create mode 100644 src/android/hal_framebuffer.cpp
> >  create mode 100644 src/android/hal_framebuffer.h
> >
> > diff --git a/src/android/camera_device.cpp
> b/src/android/camera_device.cpp
> > index b20e389b..872161ba 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -30,6 +30,7 @@
> >  #include "camera_hal_config.h"
> >  #include "camera_ops.h"
> >  #include "camera_request.h"
> > +#include "hal_framebuffer.h"
> >
> >  using namespace libcamera;
> >
> > @@ -794,7 +795,7 @@ CameraDevice::createFrameBuffer(const
> buffer_handle_t camera3buffer,
> >               planes[i].length = buf.size(i);
> >       }
> >
> > -     return std::make_unique<FrameBuffer>(planes);
> > +     return std::make_unique<HALFrameBuffer>(planes, camera3buffer);
> >  }
> >
> >  int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
> > diff --git a/src/android/frame_buffer_allocator.h
> b/src/android/frame_buffer_allocator.h
> > index 5d2eeda1..e5c94922 100644
> > --- a/src/android/frame_buffer_allocator.h
> > +++ b/src/android/frame_buffer_allocator.h
> > @@ -13,9 +13,10 @@
> >  #include <libcamera/base/class.h>
> >
> >  #include <libcamera/camera.h>
> > -#include <libcamera/framebuffer.h>
> >  #include <libcamera/geometry.h>
> >
> > +#include "hal_framebuffer.h"
> > +
> >  class CameraDevice;
> >
> >  class PlatformFrameBufferAllocator : libcamera::Extensible
> > @@ -31,7 +32,7 @@ public:
> >        * Note: The returned FrameBuffer needs to be destroyed before
> >        * PlatformFrameBufferAllocator is destroyed.
> >        */
> > -     std::unique_ptr<libcamera::FrameBuffer> allocate(
> > +     std::unique_ptr<HALFrameBuffer> allocate(
> >               int halPixelFormat, const libcamera::Size &size, uint32_t
> usage);
> >  };
> >
> > @@ -44,7 +45,7 @@
> PlatformFrameBufferAllocator::PlatformFrameBufferAllocator(         \
> >  PlatformFrameBufferAllocator::~PlatformFrameBufferAllocator()
>       \
> >  {                                                                    \
> >  }                                                                    \
> > -std::unique_ptr<libcamera::FrameBuffer>
>       \
> > +std::unique_ptr<HALFrameBuffer>                                      \
> >  PlatformFrameBufferAllocator::allocate(int halPixelFormat,           \
> >                                      const libcamera::Size &size,     \
> >                                      uint32_t usage)                  \
> > diff --git a/src/android/hal_framebuffer.cpp
> b/src/android/hal_framebuffer.cpp
> > new file mode 100644
> > index 00000000..4ac5a820
> > --- /dev/null
> > +++ b/src/android/hal_framebuffer.cpp
> > @@ -0,0 +1,22 @@
> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> > +/*
> > + * Copyright (C) 2022, Google Inc.
> > + *
> > + * hal_framebuffer.cpp - Android Frame Buffer Handling
>
> s/Android/HAL/
>
> > + */
> > +
> > +#include "hal_framebuffer.h"
> > +
> > +#include <hardware/camera3.h>
> > +
> > +HALFrameBuffer::HALFrameBuffer(std::unique_ptr<Private> d,
> > +                            buffer_handle_t handle)
> > +     : FrameBuffer(std::move(d)), handle_(handle)
> > +{
> > +}
> > +
> > +HALFrameBuffer::HALFrameBuffer(const std::vector<Plane> &planes,
> > +                            buffer_handle_t handle)
> > +     : FrameBuffer(planes), handle_(handle)
> > +{
> > +}
> > diff --git a/src/android/hal_framebuffer.h
> b/src/android/hal_framebuffer.h
> > new file mode 100644
> > index 00000000..ec737e70
> > --- /dev/null
> > +++ b/src/android/hal_framebuffer.h
> > @@ -0,0 +1,26 @@
> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> > +/*
> > + * Copyright (C) 2022, Google Inc.
> > + *
> > + * hal_framebuffer.h - Android Frame Buffer Handling
>
> s/Android/HAL/
>
> > + */
> > +
> > +#pragma once
> > +
> > +#include "libcamera/internal/framebuffer.h"
> > +
> > +#include <hardware/camera3.h>
> > +
> > +class HALFrameBuffer final : public libcamera::FrameBuffer
> > +{
> > +public:
> > +     HALFrameBuffer(std::unique_ptr<Private> d,
> > +                    buffer_handle_t handle);
> > +     HALFrameBuffer(const std::vector<Plane> &planes,
> > +                    buffer_handle_t handle);
> > +
> > +     buffer_handle_t handle() const { return handle_; }
> > +
> > +private:
> > +     buffer_handle_t handle_;
> > +};
> > diff --git a/src/android/meson.build b/src/android/meson.build
> > index 1bba54de..c2773f9e 100644
> > --- a/src/android/meson.build
> > +++ b/src/android/meson.build
> > @@ -37,6 +37,7 @@ endif
> >  android_deps += [libyuv_dep]
> >
> >  android_hal_sources = files([
> > +    'hal_framebuffer.cpp',
>
> Alphabetical order please.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> >      'camera3_hal.cpp',
> >      'camera_capabilities.cpp',
> >      'camera_device.cpp',
> > diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp
> b/src/android/mm/cros_frame_buffer_allocator.cpp
> > index 0665c77b..0a5c59f2 100644
> > --- a/src/android/mm/cros_frame_buffer_allocator.cpp
> > +++ b/src/android/mm/cros_frame_buffer_allocator.cpp
> > @@ -16,6 +16,7 @@
> >
> >  #include "../camera_device.h"
> >  #include "../frame_buffer_allocator.h"
> > +#include "../hal_framebuffer.h"
> >  #include "cros-camera/camera_buffer_manager.h"
> >
> >  using namespace libcamera;
> > @@ -48,11 +49,11 @@ public:
> >       {
> >       }
> >
> > -     std::unique_ptr<libcamera::FrameBuffer>
> > +     std::unique_ptr<HALFrameBuffer>
> >       allocate(int halPixelFormat, const libcamera::Size &size, uint32_t
> usage);
> >  };
> >
> > -std::unique_ptr<libcamera::FrameBuffer>
> > +std::unique_ptr<HALFrameBuffer>
> >  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
> >                                               const libcamera::Size
> &size,
> >                                               uint32_t usage)
> > @@ -81,8 +82,8 @@ PlatformFrameBufferAllocator::Private::allocate(int
> halPixelFormat,
> >               plane.length =
> cros::CameraBufferManager::GetPlaneSize(handle, i);
> >       }
> >
> > -     return std::make_unique<FrameBuffer>(
> > -
>  std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes));
> > +     return std::make_unique<HALFrameBuffer>(
> > +
>  std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes),
> handle);
> >  }
> >
> >  PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION
> > diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp
> b/src/android/mm/generic_frame_buffer_allocator.cpp
> > index 956623df..3750e1bf 100644
> > --- a/src/android/mm/generic_frame_buffer_allocator.cpp
> > +++ b/src/android/mm/generic_frame_buffer_allocator.cpp
> > @@ -20,6 +20,7 @@
> >
> >  #include "../camera_device.h"
> >  #include "../frame_buffer_allocator.h"
> > +#include "../hal_framebuffer.h"
> >
> >  using namespace libcamera;
> >
> > @@ -79,7 +80,7 @@ public:
> >
> >       ~Private() override;
> >
> > -     std::unique_ptr<libcamera::FrameBuffer>
> > +     std::unique_ptr<HALFrameBuffer>
> >       allocate(int halPixelFormat, const libcamera::Size &size, uint32_t
> usage);
> >
> >  private:
> > @@ -94,7 +95,7 @@ PlatformFrameBufferAllocator::Private::~Private()
> >               gralloc_close(allocDevice_);
> >  }
> >
> > -std::unique_ptr<libcamera::FrameBuffer>
> > +std::unique_ptr<HALFrameBuffer>
> >  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
> >                                               const libcamera::Size
> &size,
> >                                               uint32_t usage)
> > @@ -137,8 +138,10 @@ PlatformFrameBufferAllocator::Private::allocate(int
> halPixelFormat,
> >               offset += planeSize;
> >       }
> >
> > -     return std::make_unique<FrameBuffer>(
> > -             std::make_unique<GenericFrameBufferData>(allocDevice_,
> handle, planes));
> > +     return std::make_unique<HALFrameBuffer>(
> > +             std::make_unique<GenericFrameBufferData>(
> > +                     allocDevice_, handle, planes),
> > +             handle);
> >  }
> >
> >  PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION
>
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index b20e389b..872161ba 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -30,6 +30,7 @@ 
 #include "camera_hal_config.h"
 #include "camera_ops.h"
 #include "camera_request.h"
+#include "hal_framebuffer.h"
 
 using namespace libcamera;
 
@@ -794,7 +795,7 @@  CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer,
 		planes[i].length = buf.size(i);
 	}
 
-	return std::make_unique<FrameBuffer>(planes);
+	return std::make_unique<HALFrameBuffer>(planes, camera3buffer);
 }
 
 int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
diff --git a/src/android/frame_buffer_allocator.h b/src/android/frame_buffer_allocator.h
index 5d2eeda1..e5c94922 100644
--- a/src/android/frame_buffer_allocator.h
+++ b/src/android/frame_buffer_allocator.h
@@ -13,9 +13,10 @@ 
 #include <libcamera/base/class.h>
 
 #include <libcamera/camera.h>
-#include <libcamera/framebuffer.h>
 #include <libcamera/geometry.h>
 
+#include "hal_framebuffer.h"
+
 class CameraDevice;
 
 class PlatformFrameBufferAllocator : libcamera::Extensible
@@ -31,7 +32,7 @@  public:
 	 * Note: The returned FrameBuffer needs to be destroyed before
 	 * PlatformFrameBufferAllocator is destroyed.
 	 */
-	std::unique_ptr<libcamera::FrameBuffer> allocate(
+	std::unique_ptr<HALFrameBuffer> allocate(
 		int halPixelFormat, const libcamera::Size &size, uint32_t usage);
 };
 
@@ -44,7 +45,7 @@  PlatformFrameBufferAllocator::PlatformFrameBufferAllocator(		\
 PlatformFrameBufferAllocator::~PlatformFrameBufferAllocator()		\
 {									\
 }									\
-std::unique_ptr<libcamera::FrameBuffer>					\
+std::unique_ptr<HALFrameBuffer> 					\
 PlatformFrameBufferAllocator::allocate(int halPixelFormat,		\
 				       const libcamera::Size &size,	\
 				       uint32_t usage)			\
diff --git a/src/android/hal_framebuffer.cpp b/src/android/hal_framebuffer.cpp
new file mode 100644
index 00000000..4ac5a820
--- /dev/null
+++ b/src/android/hal_framebuffer.cpp
@@ -0,0 +1,22 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2022, Google Inc.
+ *
+ * hal_framebuffer.cpp - Android Frame Buffer Handling
+ */
+
+#include "hal_framebuffer.h"
+
+#include <hardware/camera3.h>
+
+HALFrameBuffer::HALFrameBuffer(std::unique_ptr<Private> d,
+			       buffer_handle_t handle)
+	: FrameBuffer(std::move(d)), handle_(handle)
+{
+}
+
+HALFrameBuffer::HALFrameBuffer(const std::vector<Plane> &planes,
+			       buffer_handle_t handle)
+	: FrameBuffer(planes), handle_(handle)
+{
+}
diff --git a/src/android/hal_framebuffer.h b/src/android/hal_framebuffer.h
new file mode 100644
index 00000000..ec737e70
--- /dev/null
+++ b/src/android/hal_framebuffer.h
@@ -0,0 +1,26 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2022, Google Inc.
+ *
+ * hal_framebuffer.h - Android Frame Buffer Handling
+ */
+
+#pragma once
+
+#include "libcamera/internal/framebuffer.h"
+
+#include <hardware/camera3.h>
+
+class HALFrameBuffer final : public libcamera::FrameBuffer
+{
+public:
+	HALFrameBuffer(std::unique_ptr<Private> d,
+		       buffer_handle_t handle);
+	HALFrameBuffer(const std::vector<Plane> &planes,
+		       buffer_handle_t handle);
+
+	buffer_handle_t handle() const { return handle_; }
+
+private:
+	buffer_handle_t handle_;
+};
diff --git a/src/android/meson.build b/src/android/meson.build
index 1bba54de..c2773f9e 100644
--- a/src/android/meson.build
+++ b/src/android/meson.build
@@ -37,6 +37,7 @@  endif
 android_deps += [libyuv_dep]
 
 android_hal_sources = files([
+    'hal_framebuffer.cpp',
     'camera3_hal.cpp',
     'camera_capabilities.cpp',
     'camera_device.cpp',
diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp
index 0665c77b..0a5c59f2 100644
--- a/src/android/mm/cros_frame_buffer_allocator.cpp
+++ b/src/android/mm/cros_frame_buffer_allocator.cpp
@@ -16,6 +16,7 @@ 
 
 #include "../camera_device.h"
 #include "../frame_buffer_allocator.h"
+#include "../hal_framebuffer.h"
 #include "cros-camera/camera_buffer_manager.h"
 
 using namespace libcamera;
@@ -48,11 +49,11 @@  public:
 	{
 	}
 
-	std::unique_ptr<libcamera::FrameBuffer>
+	std::unique_ptr<HALFrameBuffer>
 	allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);
 };
 
-std::unique_ptr<libcamera::FrameBuffer>
+std::unique_ptr<HALFrameBuffer>
 PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
 						const libcamera::Size &size,
 						uint32_t usage)
@@ -81,8 +82,8 @@  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
 		plane.length = cros::CameraBufferManager::GetPlaneSize(handle, i);
 	}
 
-	return std::make_unique<FrameBuffer>(
-		std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes));
+	return std::make_unique<HALFrameBuffer>(
+		std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes), handle);
 }
 
 PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION
diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp
index 956623df..3750e1bf 100644
--- a/src/android/mm/generic_frame_buffer_allocator.cpp
+++ b/src/android/mm/generic_frame_buffer_allocator.cpp
@@ -20,6 +20,7 @@ 
 
 #include "../camera_device.h"
 #include "../frame_buffer_allocator.h"
+#include "../hal_framebuffer.h"
 
 using namespace libcamera;
 
@@ -79,7 +80,7 @@  public:
 
 	~Private() override;
 
-	std::unique_ptr<libcamera::FrameBuffer>
+	std::unique_ptr<HALFrameBuffer>
 	allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);
 
 private:
@@ -94,7 +95,7 @@  PlatformFrameBufferAllocator::Private::~Private()
 		gralloc_close(allocDevice_);
 }
 
-std::unique_ptr<libcamera::FrameBuffer>
+std::unique_ptr<HALFrameBuffer>
 PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
 						const libcamera::Size &size,
 						uint32_t usage)
@@ -137,8 +138,10 @@  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
 		offset += planeSize;
 	}
 
-	return std::make_unique<FrameBuffer>(
-		std::make_unique<GenericFrameBufferData>(allocDevice_, handle, planes));
+	return std::make_unique<HALFrameBuffer>(
+		std::make_unique<GenericFrameBufferData>(
+			allocDevice_, handle, planes),
+		handle);
 }
 
 PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION