[libcamera-devel,v2,2/3] android: camera_device: Map HAL RAW to libcamera RAW formats

Message ID 20200729111202.3812677-3-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • android: camera_device: Add RAW support
Related show

Commit Message

Niklas Söderlund July 29, 2020, 11:12 a.m. UTC
Add a mapping from HAL RAW formats to the direct equivalent of libcamera
formats. With this change it is possible to capture RAW images as long
as the hardware can deliver frames in a format that is native to the
HAL.

More work is needed to deal with unpacked 8, 10 and 12 RAW formats as
they don't directly map to a native HAL format. Nor do they belong in
the RAW_OPAQUE category as the content format is generic and not
uncommonly supported by hardware.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/android/camera_device.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Jacopo Mondi July 29, 2020, 4:21 p.m. UTC | #1
Hi Niklas,

On Wed, Jul 29, 2020 at 01:12:01PM +0200, Niklas Söderlund wrote:
> Add a mapping from HAL RAW formats to the direct equivalent of libcamera
> formats. With this change it is possible to capture RAW images as long
> as the hardware can deliver frames in a format that is native to the
> HAL.
>
> More work is needed to deal with unpacked 8, 10 and 12 RAW formats as
> they don't directly map to a native HAL format. Nor do they belong in
> the RAW_OPAQUE category as the content format is generic and not
> uncommonly supported by hardware.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/android/camera_device.cpp | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index ce37fcb8cf5cd4b3..c31950db78a588ed 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -77,6 +77,30 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
>  			true,
>  			"IMPLEMENTATION_DEFINED"
>  		}
> +	}, {
> +		HAL_PIXEL_FORMAT_RAW10, {
> +			{ formats::SBGGR10_CSI2P, formats::SGBRG10_CSI2P, formats::SGRBG10_CSI2P, formats::SRGGB10_CSI2P },

For my own education, how does android distinguish between the diffent
components ordering, if they just report formats as RAWxx ? They don't
care ?

The patch looks good otherwise
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

> +			false,
> +			"RAW10"
> +		}
> +	}, {
> +		HAL_PIXEL_FORMAT_RAW12, {
> +			{ formats::SBGGR12_CSI2P, formats::SGBRG12_CSI2P, formats::SGRBG12_CSI2P, formats::SRGGB12_CSI2P },
> +			false,
> +			"RAW12"
> +		}
> +	}, {
> +		HAL_PIXEL_FORMAT_RAW16, {
> +			{ formats::SBGGR16, formats::SGBRG16, formats::SGRBG16, formats::SRGGB16 },
> +			false,
> +			"RAW16"
> +		}
> +	}, {
> +		HAL_PIXEL_FORMAT_RAW_OPAQUE, {
> +			{ formats::SBGGR10_IPU3, formats::SGBRG10_IPU3, formats::SGRBG10_IPU3, formats::SRGGB10_IPU3 },
> +			false,
> +			"RAW_OPAQUE"
> +		}
>  	},
>  };
>
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart July 29, 2020, 4:38 p.m. UTC | #2
On Wed, Jul 29, 2020 at 06:21:47PM +0200, Jacopo Mondi wrote:
> On Wed, Jul 29, 2020 at 01:12:01PM +0200, Niklas Söderlund wrote:
> > Add a mapping from HAL RAW formats to the direct equivalent of libcamera
> > formats. With this change it is possible to capture RAW images as long
> > as the hardware can deliver frames in a format that is native to the
> > HAL.
> >
> > More work is needed to deal with unpacked 8, 10 and 12 RAW formats as
> > they don't directly map to a native HAL format. Nor do they belong in
> > the RAW_OPAQUE category as the content format is generic and not
> > uncommonly supported by hardware.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  src/android/camera_device.cpp | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index ce37fcb8cf5cd4b3..c31950db78a588ed 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -77,6 +77,30 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
> >  			true,
> >  			"IMPLEMENTATION_DEFINED"
> >  		}
> > +	}, {
> > +		HAL_PIXEL_FORMAT_RAW10, {
> > +			{ formats::SBGGR10_CSI2P, formats::SGBRG10_CSI2P, formats::SGRBG10_CSI2P, formats::SRGGB10_CSI2P },

I'd wrap this:

			{
				formats::SBGGR10_CSI2P,
				formats::SGBRG10_CSI2P,
				formats::SGRBG10_CSI2P,
				formats::SRGGB10_CSI2P
			},

Same below.

> For my own education, how does android distinguish between the diffent
> components ordering, if they just report formats as RAWxx ? They don't
> care ?

android.sensor.info.colorFilterArrangement

> The patch looks good otherwise
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

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

> > +			false,
> > +			"RAW10"
> > +		}
> > +	}, {
> > +		HAL_PIXEL_FORMAT_RAW12, {
> > +			{ formats::SBGGR12_CSI2P, formats::SGBRG12_CSI2P, formats::SGRBG12_CSI2P, formats::SRGGB12_CSI2P },
> > +			false,
> > +			"RAW12"
> > +		}
> > +	}, {
> > +		HAL_PIXEL_FORMAT_RAW16, {
> > +			{ formats::SBGGR16, formats::SGBRG16, formats::SGRBG16, formats::SRGGB16 },
> > +			false,
> > +			"RAW16"
> > +		}
> > +	}, {
> > +		HAL_PIXEL_FORMAT_RAW_OPAQUE, {
> > +			{ formats::SBGGR10_IPU3, formats::SGBRG10_IPU3, formats::SGRBG10_IPU3, formats::SRGGB10_IPU3 },
> > +			false,
> > +			"RAW_OPAQUE"
> > +		}
> >  	},
> >  };
> >

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ce37fcb8cf5cd4b3..c31950db78a588ed 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -77,6 +77,30 @@  const std::map<int, const Camera3Format> camera3FormatsMap = {
 			true,
 			"IMPLEMENTATION_DEFINED"
 		}
+	}, {
+		HAL_PIXEL_FORMAT_RAW10, {
+			{ formats::SBGGR10_CSI2P, formats::SGBRG10_CSI2P, formats::SGRBG10_CSI2P, formats::SRGGB10_CSI2P },
+			false,
+			"RAW10"
+		}
+	}, {
+		HAL_PIXEL_FORMAT_RAW12, {
+			{ formats::SBGGR12_CSI2P, formats::SGBRG12_CSI2P, formats::SGRBG12_CSI2P, formats::SRGGB12_CSI2P },
+			false,
+			"RAW12"
+		}
+	}, {
+		HAL_PIXEL_FORMAT_RAW16, {
+			{ formats::SBGGR16, formats::SGBRG16, formats::SGRBG16, formats::SRGGB16 },
+			false,
+			"RAW16"
+		}
+	}, {
+		HAL_PIXEL_FORMAT_RAW_OPAQUE, {
+			{ formats::SBGGR10_IPU3, formats::SGBRG10_IPU3, formats::SGRBG10_IPU3, formats::SRGGB10_IPU3 },
+			false,
+			"RAW_OPAQUE"
+		}
 	},
 };