media: raspberrypi: Add support for PiSP BE

Add support for the Raspberry Pi PiSP Back End.

The driver has been upported from the Raspberry Pi kernel at revision
f74893f8a0c2 ("drivers: media: pisp_be: Update seqeuence numbers of the
buffers").

The ISP documentation is available at:
https://datasheets.raspberrypi.com/camera/raspberry-pi-image-signal-processor-specification.pdf

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.org>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: drop dev_err after platform_get_irq to fix a coccinelle check]
This commit is contained in:
Naushir Patuck 2024-06-26 20:14:37 +02:00 committed by Hans Verkuil
parent cbc775e060
commit 12187bd5d4
9 changed files with 2347 additions and 0 deletions

View File

@ -18811,6 +18811,7 @@ L: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
L: linux-media@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/media/raspberrypi,pispbe.yaml
F: drivers/media/platform/raspberrypi/pisp_be/
F: include/uapi/linux/media/raspberrypi/
RC-CORE / LIRC FRAMEWORK

View File

@ -79,6 +79,7 @@ source "drivers/media/platform/nuvoton/Kconfig"
source "drivers/media/platform/nvidia/Kconfig"
source "drivers/media/platform/nxp/Kconfig"
source "drivers/media/platform/qcom/Kconfig"
source "drivers/media/platform/raspberrypi/Kconfig"
source "drivers/media/platform/renesas/Kconfig"
source "drivers/media/platform/rockchip/Kconfig"
source "drivers/media/platform/samsung/Kconfig"

View File

@ -22,6 +22,7 @@ obj-y += nuvoton/
obj-y += nvidia/
obj-y += nxp/
obj-y += qcom/
obj-y += raspberrypi/
obj-y += renesas/
obj-y += rockchip/
obj-y += samsung/

View File

@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
comment "Raspberry Pi media platform drivers"
source "drivers/media/platform/raspberrypi/pisp_be/Kconfig"

View File

@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += pisp_be/

View File

@ -0,0 +1,12 @@
config VIDEO_RASPBERRYPI_PISP_BE
tristate "Raspberry Pi PiSP Backend (BE) ISP driver"
depends on V4L_PLATFORM_DRIVERS
depends on VIDEO_DEV
select VIDEO_V4L2_SUBDEV_API
select MEDIA_CONTROLLER
select VIDEOBUF2_DMA_CONTIG
help
Say Y here to enable support for the PiSP Backend (BE) ISP driver.
To compile this driver as a module, choose M here. The module will be
called pisp-be.

View File

@ -0,0 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for Raspberry Pi PiSP Backend driver
#
pisp-be-objs := pisp_be.o
obj-$(CONFIG_VIDEO_RASPBERRYPI_PISP_BE) += pisp-be.o

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,519 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* PiSP Back End driver image format definitions.
*
* Copyright (c) 2021-2024 Raspberry Pi Ltd
*/
#ifndef _PISP_BE_FORMATS_
#define _PISP_BE_FORMATS_
#include <linux/bits.h>
#include <linux/videodev2.h>
#define PISPBE_MAX_PLANES 3
#define P3(x) ((x) * 8)
struct pisp_be_format {
unsigned int fourcc;
unsigned int align;
unsigned int bit_depth;
/* 0P3 factor for plane sizing */
unsigned int plane_factor[PISPBE_MAX_PLANES];
unsigned int num_planes;
unsigned int colorspace_mask;
enum v4l2_colorspace colorspace_default;
};
#define V4L2_COLORSPACE_MASK(colorspace) BIT(colorspace)
#define V4L2_COLORSPACE_MASK_JPEG \
V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_JPEG)
#define V4L2_COLORSPACE_MASK_SMPTE170M \
V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_SMPTE170M)
#define V4L2_COLORSPACE_MASK_REC709 \
V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_REC709)
#define V4L2_COLORSPACE_MASK_SRGB \
V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_SRGB)
#define V4L2_COLORSPACE_MASK_RAW \
V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_RAW)
/*
* All three colour spaces SRGB, SMPTE170M and REC709 are fundamentally sRGB
* underneath (as near as makes no difference to us), just with different YCbCr
* encodings. Therefore the ISP can generate sRGB on its main output and any of
* the others on its low resolution output. Applications should, when using both
* outputs, program the colour spaces on them to be the same, matching whatever
* is requested for the low resolution output, even if the main output is
* producing an RGB format. In turn this requires us to allow all these colour
* spaces for every YUV/RGB output format.
*/
#define V4L2_COLORSPACE_MASK_ALL_SRGB (V4L2_COLORSPACE_MASK_JPEG | \
V4L2_COLORSPACE_MASK_SRGB | \
V4L2_COLORSPACE_MASK_SMPTE170M | \
V4L2_COLORSPACE_MASK_REC709)
static const struct pisp_be_format supported_formats[] = {
/* Single plane YUV formats */
{
.fourcc = V4L2_PIX_FMT_YUV420,
/* 128 alignment to ensure U/V planes are 64 byte aligned. */
.align = 128,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.25), P3(0.25) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YVU420,
/* 128 alignment to ensure U/V planes are 64 byte aligned. */
.align = 128,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.25), P3(0.25) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_NV12,
.align = 32,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.5) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_NV21,
.align = 32,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.5) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YUYV,
.align = 64,
.bit_depth = 16,
.plane_factor = { P3(1) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_UYVY,
.align = 64,
.bit_depth = 16,
.plane_factor = { P3(1) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YVYU,
.align = 64,
.bit_depth = 16,
.plane_factor = { P3(1) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_VYUY,
.align = 64,
.bit_depth = 16,
.plane_factor = { P3(1) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
/* Multiplane YUV formats */
{
.fourcc = V4L2_PIX_FMT_YUV420M,
.align = 64,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.25), P3(0.25) },
.num_planes = 3,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_NV12M,
.align = 32,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.5) },
.num_planes = 2,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_NV21M,
.align = 32,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.5) },
.num_planes = 2,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YVU420M,
.align = 64,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.25), P3(0.25) },
.num_planes = 3,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YUV422M,
.align = 64,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.5), P3(0.5) },
.num_planes = 3,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YVU422M,
.align = 64,
.bit_depth = 8,
.plane_factor = { P3(1), P3(0.5), P3(0.5) },
.num_planes = 3,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YUV444M,
.align = 64,
.bit_depth = 8,
.plane_factor = { P3(1), P3(1), P3(1) },
.num_planes = 3,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
{
.fourcc = V4L2_PIX_FMT_YVU444M,
.align = 64,
.bit_depth = 8,
.plane_factor = { P3(1), P3(1), P3(1) },
.num_planes = 3,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
},
/* RGB formats */
{
.fourcc = V4L2_PIX_FMT_RGB24,
.align = 32,
.bit_depth = 24,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
},
{
.fourcc = V4L2_PIX_FMT_BGR24,
.align = 32,
.bit_depth = 24,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
},
{
.fourcc = V4L2_PIX_FMT_XBGR32,
.align = 64,
.bit_depth = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
},
{
.fourcc = V4L2_PIX_FMT_RGBX32,
.align = 64,
.bit_depth = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
},
{
.fourcc = V4L2_PIX_FMT_RGB48,
.align = 64,
.bit_depth = 48,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
},
{
.fourcc = V4L2_PIX_FMT_BGR48,
.align = 64,
.bit_depth = 48,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_ALL_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
},
/* Bayer formats - 8-bit */
{
.fourcc = V4L2_PIX_FMT_SRGGB8,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SBGGR8,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGRBG8,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGBRG8,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
/* Bayer formats - 16-bit */
{
.fourcc = V4L2_PIX_FMT_SRGGB16,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SBGGR16,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGRBG16,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGBRG16,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
/* Bayer formats unpacked to 16bpp */
/* 10 bit */
.fourcc = V4L2_PIX_FMT_SRGGB10,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SBGGR10,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGRBG10,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGBRG10,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
/* 12 bit */
.fourcc = V4L2_PIX_FMT_SRGGB12,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SBGGR12,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGRBG12,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGBRG12,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
/* 14 bit */
.fourcc = V4L2_PIX_FMT_SRGGB14,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SBGGR14,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGRBG14,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_SGBRG14,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
/* Bayer formats - 16-bit PiSP Compressed */
{
.fourcc = V4L2_PIX_FMT_PISP_COMP1_BGGR,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_PISP_COMP1_RGGB,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_PISP_COMP1_GRBG,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_PISP_COMP1_GBRG,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
/* Greyscale Formats */
{
.fourcc = V4L2_PIX_FMT_GREY,
.bit_depth = 8,
.align = 32,
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_Y16,
.bit_depth = 16,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
{
.fourcc = V4L2_PIX_FMT_PISP_COMP1_MONO,
.bit_depth = 8,
.align = 32,
.plane_factor = { P3(1.0) },
.num_planes = 1,
.colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
},
};
static const struct pisp_be_format meta_out_supported_formats[] = {
/* Configuration buffer format. */
{
.fourcc = V4L2_META_FMT_RPI_BE_CFG,
},
};
#endif /* _PISP_BE_FORMATS_ */