diff mbox series

[v3,16/17] media: ipu6/isys: support line-based metadata capture support

Message ID 20240111065531.2418836-17-bingbu.cao@intel.com (mailing list archive)
State New, archived
Headers show
Series Intel IPU6 and IPU6 input system drivers | expand

Commit Message

Bingbu Cao Jan. 11, 2024, 6:55 a.m. UTC
From: Bingbu Cao <bingbu.cao@intel.com>

Some camera sensor can output the embedded data in specific
data type.  This patch add the support for embedded data capture
in IPU6 IS driver.

It's based on Sakari's line-based metadata capture support change:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=metadata>

Signed-off-by: Hongju Wang <hongju.wang@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c |   5 +
 .../media/pci/intel/ipu6/ipu6-isys-queue.c    |  44 ++--
 .../media/pci/intel/ipu6/ipu6-isys-subdev.c   |   5 +
 .../media/pci/intel/ipu6/ipu6-isys-video.c    | 201 +++++++++++++++---
 .../media/pci/intel/ipu6/ipu6-isys-video.h    |   7 +-
 5 files changed, 216 insertions(+), 46 deletions(-)

Comments

Sakari Ailus Jan. 11, 2024, 12:52 p.m. UTC | #1
Hi Bingbu,

Thank you for the update.

On Thu, Jan 11, 2024 at 02:55:30PM +0800, bingbu.cao@intel.com wrote:
> From: Bingbu Cao <bingbu.cao@intel.com>
> 
> Some camera sensor can output the embedded data in specific
> data type.  This patch add the support for embedded data capture
> in IPU6 IS driver.
> 
> It's based on Sakari's line-based metadata capture support change:
> <URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=metadata>
> 
> Signed-off-by: Hongju Wang <hongju.wang@intel.com>
> Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
> ---
>  drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c |   5 +
>  .../media/pci/intel/ipu6/ipu6-isys-queue.c    |  44 ++--
>  .../media/pci/intel/ipu6/ipu6-isys-subdev.c   |   5 +
>  .../media/pci/intel/ipu6/ipu6-isys-video.c    | 201 +++++++++++++++---
>  .../media/pci/intel/ipu6/ipu6-isys-video.h    |   7 +-
>  5 files changed, 216 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
> index ac9fa3e0d7ab..a6430d531129 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
> @@ -42,6 +42,11 @@ static const u32 csi2_supported_codes[] = {
>  	MEDIA_BUS_FMT_SGBRG8_1X8,
>  	MEDIA_BUS_FMT_SGRBG8_1X8,
>  	MEDIA_BUS_FMT_SRGGB8_1X8,
> +	MEDIA_BUS_FMT_META_8,
> +	MEDIA_BUS_FMT_META_10,
> +	MEDIA_BUS_FMT_META_12,
> +	MEDIA_BUS_FMT_META_16,
> +	MEDIA_BUS_FMT_META_24,
>  	0
>  };
>  
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
> index 735d2d642d87..15fa7ed22b2f 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
> @@ -35,11 +35,14 @@ static int queue_setup(struct vb2_queue *q, unsigned int *num_buffers,
>  	/* num_planes == 0: we're being called through VIDIOC_REQBUFS */
>  	if (!*num_planes) {
>  		use_fmt = true;
> -		*num_planes = av->mpix.num_planes;
> +		if (av->vfmt.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +			*num_planes = av->vfmt.fmt.pix_mp.num_planes;
> +		else if (av->vfmt.type == V4L2_BUF_TYPE_META_CAPTURE)
> +			*num_planes = 1;
>  	}
>  
>  	for (i = 0; i < *num_planes; i++) {
> -		size = av->mpix.plane_fmt[i].sizeimage;
> +		size = ipu6_get_data_size(&av->vfmt, i);
>  		if (use_fmt) {
>  			sizes[i] = size;
>  		} else if (sizes[i] < size) {
> @@ -59,16 +62,17 @@ static int ipu6_isys_buf_prepare(struct vb2_buffer *vb)
>  	struct ipu6_isys_queue *aq = vb2_queue_to_isys_queue(vb->vb2_queue);
>  	struct ipu6_isys_video *av = ipu6_isys_queue_to_video(aq);
>  	struct device *dev = &av->isys->adev->auxdev.dev;
> +	u32 bytesperline = ipu6_get_bytes_per_line(&av->vfmt);
> +	u32 height = ipu6_get_frame_height(&av->vfmt);
> +	u32 size = ipu6_get_data_size(&av->vfmt, 0);
>  
>  	dev_dbg(dev, "buffer: %s: configured size %u, buffer size %lu\n",
> -		av->vdev.name, av->mpix.plane_fmt[0].sizeimage,
> -		vb2_plane_size(vb, 0));
> +		av->vdev.name, size, vb2_plane_size(vb, 0));
>  
> -	if (av->mpix.plane_fmt[0].sizeimage > vb2_plane_size(vb, 0))
> +	if (size > vb2_plane_size(vb, 0))
>  		return -EINVAL;
>  
> -	vb2_set_plane_payload(vb, 0, av->mpix.plane_fmt[0].bytesperline *
> -			      av->mpix.height);
> +	vb2_set_plane_payload(vb, 0, bytesperline * height);
>  	vb->planes[0].data_offset = 0;
>  
>  	return 0;
> @@ -437,18 +441,22 @@ static int ipu6_isys_link_fmt_validate(struct ipu6_isys_queue *aq)
>  		return ret;
>  	}
>  
> -	if (format.width != av->mpix.width ||
> -	    format.height != av->mpix.height) {
> -		dev_dbg(dev, "wrong width or height %ux%u (%ux%u expected)\n",
> -			av->mpix.width, av->mpix.height,
> -			format.width, format.height);
> +	if (format.width != ipu6_get_frame_width(&av->vfmt) ||
> +	    format.height != ipu6_get_frame_height(&av->vfmt)) {
> +		dev_err(dev, "wrong width or height %ux%u (%ux%u expected)\n",
> +			ipu6_get_frame_width(&av->vfmt),
> +			ipu6_get_frame_height(&av->vfmt), format.width,
> +			format.height);
>  		return -EINVAL;
>  	}
>  
> -	if (format.field != av->mpix.field) {
> -		dev_dbg(dev, "wrong field value 0x%8.8x (0x%8.8x expected)\n",
> -			av->mpix.field, format.field);
> -		return -EINVAL;
> +	if (av->vfmt.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> +		if (format.field != av->vfmt.fmt.pix_mp.field) {

You could merge the if clauses.

Speaking of the field --- is there a need to check this in buf_prepare()?
Isn't this what the driver sets? So I'd address this in an earlier patch
that adds the check.

> +			dev_dbg(dev,
> +				"wrong field value 0x%8.8x (%8.8x expected)\n",
> +				av->vfmt.fmt.pix_mp.field, format.field);
> +			return -EINVAL;
> +		}
>  	}
>  
>  	if (format.code != av->pfmt->code) {
> @@ -531,8 +539,8 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
>  	int nr_queues, ret;
>  
>  	dev_dbg(dev, "stream: %s: width %u, height %u, css pixelformat %u\n",
> -		av->vdev.name, av->mpix.width, av->mpix.height,
> -		av->pfmt->css_pixelformat);
> +		av->vdev.name, ipu6_get_frame_width(&av->vfmt),
> +		ipu6_get_frame_height(&av->vfmt), av->pfmt->css_pixelformat);
>  
>  	ret = ipu6_isys_setup_video(av, &source_entity, &nr_queues);
>  	if (ret < 0) {
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
> index 510c5ca34f9f..3c9263ac02a3 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
> @@ -20,25 +20,30 @@ unsigned int ipu6_isys_mbus_code_to_bpp(u32 code)
>  {
>  	switch (code) {
>  	case MEDIA_BUS_FMT_RGB888_1X24:
> +	case MEDIA_BUS_FMT_META_24:
>  		return 24;
>  	case MEDIA_BUS_FMT_RGB565_1X16:
>  	case MEDIA_BUS_FMT_UYVY8_1X16:
>  	case MEDIA_BUS_FMT_YUYV8_1X16:
> +	case MEDIA_BUS_FMT_META_16:
>  		return 16;
>  	case MEDIA_BUS_FMT_SBGGR12_1X12:
>  	case MEDIA_BUS_FMT_SGBRG12_1X12:
>  	case MEDIA_BUS_FMT_SGRBG12_1X12:
>  	case MEDIA_BUS_FMT_SRGGB12_1X12:
> +	case MEDIA_BUS_FMT_META_12:
>  		return 12;
>  	case MEDIA_BUS_FMT_SBGGR10_1X10:
>  	case MEDIA_BUS_FMT_SGBRG10_1X10:
>  	case MEDIA_BUS_FMT_SGRBG10_1X10:
>  	case MEDIA_BUS_FMT_SRGGB10_1X10:
> +	case MEDIA_BUS_FMT_META_10:
>  		return 10;
>  	case MEDIA_BUS_FMT_SBGGR8_1X8:
>  	case MEDIA_BUS_FMT_SGBRG8_1X8:
>  	case MEDIA_BUS_FMT_SGRBG8_1X8:
>  	case MEDIA_BUS_FMT_SRGGB8_1X8:
> +	case MEDIA_BUS_FMT_META_8:
>  		return 8;
>  	default:
>  		WARN_ON(1);
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
> index 847eac26bcd6..1a023bf1e1a6 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
> @@ -85,6 +85,11 @@ const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = {
>  	 IPU6_FW_ISYS_FRAME_FORMAT_RGB565},
>  	{V4L2_PIX_FMT_BGR24, 24, 24, MEDIA_BUS_FMT_RGB888_1X24,
>  	 IPU6_FW_ISYS_FRAME_FORMAT_RGBA888},
> +	{V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8, 0},
> +	{V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10, 0},
> +	{V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12, 0},
> +	{V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16, 0},
> +	{V4L2_META_FMT_GENERIC_CSI2_24, 24, 24, MEDIA_BUS_FMT_META_24, 0},
>  };
>  
>  static int video_open(struct file *file)
> @@ -181,12 +186,12 @@ static int ipu6_isys_vidioc_enum_framesizes(struct file *file, void *fh,
>  	return 0;
>  }
>  
> -static int vidioc_g_fmt_vid_cap_mplane(struct file *file, void *fh,
> -				       struct v4l2_format *fmt)
> +static int vidioc_get_format(struct file *file, void *fh,
> +			     struct v4l2_format *fmt)
>  {
>  	struct ipu6_isys_video *av = video_drvdata(file);
>  
> -	fmt->fmt.pix_mp = av->mpix;
> +	*fmt = av->vfmt;
>  
>  	return 0;
>  }
> @@ -245,30 +250,114 @@ ipu6_isys_video_try_fmt_vid_mplane(struct ipu6_isys_video *av,
>  	return pfmt;
>  }
>  
> -static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *fh,
> -				       struct v4l2_format *f)
> +static const struct ipu6_isys_pixelformat *
> +ipu6_isys_video_try_fmt_meta(struct ipu6_isys_video *av,
> +			     struct v4l2_meta_format *meta)
> +{
> +	const struct ipu6_isys_pixelformat *pfmt =
> +		ipu6_isys_get_pixelformat(meta->dataformat);
> +
> +	memset(&av->vfmt, 0, sizeof(av->vfmt));
> +	av->vfmt.type = V4L2_BUF_TYPE_META_CAPTURE;
> +	av->pfmt = pfmt;
> +
> +	meta->dataformat = pfmt->pixelformat;
> +	meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
> +			    IPU6_ISYS_MAX_WIDTH);
> +	meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
> +			     IPU6_ISYS_MAX_HEIGHT);
> +
> +	if (pfmt->bpp != pfmt->bpp_packed)
> +		meta->bytesperline = meta->width *
> +				     DIV_ROUND_UP(pfmt->bpp, BITS_PER_BYTE);
> +	else
> +		meta->bytesperline =
> +			DIV_ROUND_UP(meta->width * pfmt->bpp, BITS_PER_BYTE);
> +
> +	meta->bytesperline = ALIGN(meta->bytesperline, av->isys->line_align);
> +	meta->buffersize =
> +		max(max(meta->buffersize, meta->bytesperline * meta->height +
> +			max(meta->bytesperline,
> +			    av->isys->pdata->ipdata->isys_dma_overshoot)), 1U);
> +
> +	return pfmt;
> +}
> +
> +static const struct ipu6_isys_pixelformat *
> +ipu6_isys_video_try_fmt(struct ipu6_isys_video *av, struct v4l2_format *f)
> +{
> +	if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return ipu6_isys_video_try_fmt_vid_mplane(av, &f->fmt.pix_mp);
> +	else if (f->type == V4L2_BUF_TYPE_META_CAPTURE)
> +		return ipu6_isys_video_try_fmt_meta(av, &f->fmt.meta);
> +	else
> +		return &ipu6_isys_pfmts[0];
> +}
> +
> +static int vidioc_set_format(struct file *file, void *fh,
> +			     struct v4l2_format *f)
>  {
>  	struct ipu6_isys_video *av = video_drvdata(file);
>  
>  	if (av->aq.vbq.streaming)
>  		return -EBUSY;
>  
> -	av->pfmt = ipu6_isys_video_try_fmt_vid_mplane(av, &f->fmt.pix_mp);
> -	av->mpix = f->fmt.pix_mp;
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
> +	    f->type != V4L2_BUF_TYPE_META_CAPTURE)
> +		return -EINVAL;
> +
> +	av->pfmt = ipu6_isys_video_try_fmt(av, f);
> +	av->vfmt = *f;
>  
>  	return 0;
>  }
>  
> -static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *fh,
> -					 struct v4l2_format *f)
> +static int vidioc_try_format(struct file *file, void *fh,
> +			     struct v4l2_format *f)
>  {
>  	struct ipu6_isys_video *av = video_drvdata(file);
>  
> -	ipu6_isys_video_try_fmt_vid_mplane(av, &f->fmt.pix_mp);
> +	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
> +	    f->type != V4L2_BUF_TYPE_META_CAPTURE)
> +		return -EINVAL;
> +
> +	ipu6_isys_video_try_fmt(av, f);
>  
>  	return 0;
>  }
>  
> +static int vidioc_request_qbufs(struct file *file, void *priv,
> +				struct v4l2_requestbuffers *p)
> +{
> +	struct ipu6_isys_video *av = video_drvdata(file);
> +	int ret;
> +
> +	av->aq.vbq.is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(p->type);
> +	av->aq.vbq.is_output = V4L2_TYPE_IS_OUTPUT(p->type);
> +
> +	ret = vb2_queue_change_type(&av->aq.vbq, p->type);
> +	if (ret)
> +		return ret;
> +
> +	return vb2_ioctl_reqbufs(file, priv, p);
> +}
> +
> +static int vidioc_create_bufs(struct file *file, void *priv,
> +			      struct v4l2_create_buffers *p)
> +{
> +	struct ipu6_isys_video *av = video_drvdata(file);
> +	int ret;
> +
> +	av->aq.vbq.is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(p->format.type);
> +	av->aq.vbq.is_output = V4L2_TYPE_IS_OUTPUT(p->format.type);
> +
> +	ret = vb2_queue_change_type(&av->aq.vbq, p->format.type);
> +	if (ret)
> +		return ret;
> +
> +	return vb2_ioctl_create_bufs(file, priv, p);
> +}
> +
>  static int link_validate(struct media_link *link)
>  {
>  	struct ipu6_isys_video *av =
> @@ -279,6 +368,8 @@ static int link_validate(struct media_link *link)
>  	struct v4l2_mbus_framefmt *s_fmt;
>  	struct media_pad *s_pad;
>  	u32 s_stream;
> +	u32 height;
> +	u32 width;
>  	int ret = -EPIPE;
>  
>  	if (!link->source->entity)
> @@ -305,11 +396,13 @@ static int link_validate(struct media_link *link)
>  		goto unlock;
>  	}
>  
> -	if (s_fmt->width != av->mpix.width ||
> -	    s_fmt->height != av->mpix.height || s_fmt->code != av->pfmt->code) {
> +	height = ipu6_get_frame_height(&av->vfmt);
> +	width = ipu6_get_frame_width(&av->vfmt);
> +	if (s_fmt->width != width || s_fmt->height != height ||
> +	    s_fmt->code != av->pfmt->code) {
>  		dev_err(dev, "format mismatch %dx%d,%x != %dx%d,%x\n",
> -			s_fmt->width, s_fmt->height, s_fmt->code,
> -			av->mpix.width, av->mpix.height, av->pfmt->code);
> +			s_fmt->width, s_fmt->height, s_fmt->code, width, height,
> +			av->pfmt->code);
>  		goto unlock;
>  	}
>  
> @@ -393,10 +486,10 @@ static int ipu6_isys_fw_pin_cfg(struct ipu6_isys_video *av,
>  
>  	output_pin = &cfg->output_pins[output_pins];
>  	output_pin->input_pin_id = input_pins;
> -	output_pin->output_res.width = av->mpix.width;
> -	output_pin->output_res.height = av->mpix.height;
> +	output_pin->output_res.width = ipu6_get_frame_width(&av->vfmt);
> +	output_pin->output_res.height = ipu6_get_frame_height(&av->vfmt);
>  
> -	output_pin->stride = av->mpix.plane_fmt[0].bytesperline;
> +	output_pin->stride = ipu6_get_bytes_per_line(&av->vfmt);
>  	if (av->pfmt->bpp != av->pfmt->bpp_packed)
>  		output_pin->pt = IPU6_FW_ISYS_PIN_TYPE_RAW_SOC;
>  	else
> @@ -663,8 +756,8 @@ void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av,
>  
>  	esd = media_entity_to_v4l2_subdev(av->stream->source_entity);
>  
> -	av->watermark.width = av->mpix.width;
> -	av->watermark.height = av->mpix.height;
> +	av->watermark.width = ipu6_get_frame_width(&av->vfmt);
> +	av->watermark.height = ipu6_get_frame_height(&av->vfmt);
>  	av->watermark.sram_gran_shift = isys->pdata->ipdata->sram_gran_shift;
>  	av->watermark.sram_gran_size = isys->pdata->ipdata->sram_gran_size;
>  
> @@ -992,11 +1085,15 @@ static const struct v4l2_ioctl_ops ioctl_ops_mplane = {
>  	.vidioc_querycap = ipu6_isys_vidioc_querycap,
>  	.vidioc_enum_fmt_vid_cap = ipu6_isys_vidioc_enum_fmt,
>  	.vidioc_enum_framesizes = ipu6_isys_vidioc_enum_framesizes,
> -	.vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane,
> -	.vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane,
> -	.vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane,
> -	.vidioc_reqbufs = vb2_ioctl_reqbufs,
> -	.vidioc_create_bufs = vb2_ioctl_create_bufs,
> +	.vidioc_g_fmt_vid_cap_mplane = vidioc_get_format,
> +	.vidioc_s_fmt_vid_cap_mplane = vidioc_set_format,
> +	.vidioc_try_fmt_vid_cap_mplane = vidioc_try_format,
> +	.vidioc_enum_fmt_meta_cap = ipu6_isys_vidioc_enum_fmt,
> +	.vidioc_g_fmt_meta_cap = vidioc_get_format,
> +	.vidioc_s_fmt_meta_cap = vidioc_set_format,
> +	.vidioc_try_fmt_meta_cap = vidioc_try_format,
> +	.vidioc_reqbufs = vidioc_request_qbufs,
> +	.vidioc_create_bufs = vidioc_create_bufs,
>  	.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
>  	.vidioc_querybuf = vb2_ioctl_querybuf,
>  	.vidioc_qbuf = vb2_ioctl_qbuf,
> @@ -1199,7 +1296,8 @@ int ipu6_isys_video_init(struct ipu6_isys_video *av)
>  
>  	mutex_init(&av->mutex);
>  	av->vdev.device_caps = V4L2_CAP_STREAMING | V4L2_CAP_IO_MC |
> -			       V4L2_CAP_VIDEO_CAPTURE_MPLANE;
> +			       V4L2_CAP_VIDEO_CAPTURE_MPLANE |
> +			       V4L2_CAP_META_CAPTURE;
>  	av->vdev.vfl_dir = VFL_DIR_RX;
>  
>  	ret = ipu6_isys_queue_init(&av->aq);
> @@ -1220,8 +1318,8 @@ int ipu6_isys_video_init(struct ipu6_isys_video *av)
>  	av->vdev.queue = &av->aq.vbq;
>  	av->vdev.lock = &av->mutex;
>  
> -	ipu6_isys_video_try_fmt_vid_mplane(av, &format.fmt.pix_mp);
> -	av->mpix = format.fmt.pix_mp;
> +	ipu6_isys_video_try_fmt(av, &format);
> +	av->vfmt = format;
>  
>  	set_bit(V4L2_FL_USES_V4L2_FH, &av->vdev.flags);
>  	video_set_drvdata(&av->vdev, av);
> @@ -1251,3 +1349,52 @@ void ipu6_isys_video_cleanup(struct ipu6_isys_video *av)
>  	media_entity_cleanup(&av->vdev.entity);
>  	mutex_destroy(&av->mutex);
>  }
> +
> +u32 ipu6_get_data_size(struct v4l2_format *vfmt, int plane)
> +{
> +	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return vfmt->fmt.pix_mp.plane_fmt[plane].sizeimage;
> +	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)

Useless use of else. Same below.

> +		return vfmt->fmt.meta.buffersize;
> +
> +	WARN_ON_ONCE(1);
> +
> +	return 0;
> +}
> +
> +u32 ipu6_get_bytes_per_line(struct v4l2_format *vfmt)
> +{
> +	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return vfmt->fmt.pix_mp.plane_fmt[0].bytesperline;
> +	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
> +		return vfmt->fmt.meta.bytesperline;
> +
> +	WARN_ON_ONCE(1);
> +
> +	return 0;
> +}
> +
> +u32 ipu6_get_frame_width(struct v4l2_format *vfmt)
> +{
> +	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return vfmt->fmt.pix_mp.width;
> +	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
> +		return vfmt->fmt.meta.width;
> +
> +	WARN_ON_ONCE(1);
> +
> +	return 0;
> +}
> +
> +u32 ipu6_get_frame_height(struct v4l2_format *vfmt)
> +{
> +	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +		return vfmt->fmt.pix_mp.height;
> +	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
> +		return vfmt->fmt.meta.height;
> +
> +	WARN_ON_ONCE(1);
> +
> +	return 0;
> +}
> +
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.h b/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
> index 21cd33c7e277..2634ec0fd68b 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
> @@ -90,7 +90,7 @@ struct ipu6_isys_video {
>  	struct mutex mutex;
>  	struct media_pad pad;
>  	struct video_device vdev;
> -	struct v4l2_pix_format_mplane mpix;
> +	struct v4l2_format vfmt;
>  	const struct ipu6_isys_pixelformat *pfmt;
>  	struct ipu6_isys *isys;
>  	struct ipu6_isys_stream *stream;
> @@ -133,4 +133,9 @@ void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av,
>  					  bool state);
>  void ipu6_isys_update_stream_watermark(struct ipu6_isys_video *av, bool state);
>  
> +u32 ipu6_get_data_size(struct v4l2_format *vfmt, int plane);
> +u32 ipu6_get_bytes_per_line(struct v4l2_format *vfmt);
> +u32 ipu6_get_frame_width(struct v4l2_format *vfmt);
> +u32 ipu6_get_frame_height(struct v4l2_format *vfmt);
> +
>  #endif /* IPU6_ISYS_VIDEO_H */
kernel test robot Jan. 11, 2024, 9:20 p.m. UTC | #2
Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on media-tree/master]
[also build test ERROR on linuxtv-media-stage/master linus/master v6.7 next-20240111]
[cannot apply to sailus-media-tree/streams]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/bingbu-cao-intel-com/media-intel-ipu6-add-IPU-auxiliary-devices/20240111-155551
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20240111065531.2418836-17-bingbu.cao%40intel.com
patch subject: [PATCH v3 16/17] media: ipu6/isys: support line-based metadata capture support
config: x86_64-buildonly-randconfig-004-20240111 (https://download.01.org/0day-ci/archive/20240112/202401120528.5MY4pum6-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240112/202401120528.5MY4pum6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401120528.5MY4pum6-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c: In function 'ipu6_isys_mbus_code_to_bpp':
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:23:14: error: 'MEDIA_BUS_FMT_META_24' undeclared (first use in this function); did you mean 'MEDIA_BUS_FMT_VUY8_1X24'?
      23 |         case MEDIA_BUS_FMT_META_24:
         |              ^~~~~~~~~~~~~~~~~~~~~
         |              MEDIA_BUS_FMT_VUY8_1X24
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:23:14: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:28:14: error: 'MEDIA_BUS_FMT_META_16' undeclared (first use in this function); did you mean 'MEDIA_BUS_FMT_Y16_1X16'?
      28 |         case MEDIA_BUS_FMT_META_16:
         |              ^~~~~~~~~~~~~~~~~~~~~
         |              MEDIA_BUS_FMT_Y16_1X16
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:34:14: error: 'MEDIA_BUS_FMT_META_12' undeclared (first use in this function); did you mean 'MEDIA_BUS_FMT_UV8_1X8'?
      34 |         case MEDIA_BUS_FMT_META_12:
         |              ^~~~~~~~~~~~~~~~~~~~~
         |              MEDIA_BUS_FMT_UV8_1X8
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:40:14: error: 'MEDIA_BUS_FMT_META_10' undeclared (first use in this function); did you mean 'MEDIA_BUS_FMT_Y10_1X10'?
      40 |         case MEDIA_BUS_FMT_META_10:
         |              ^~~~~~~~~~~~~~~~~~~~~
         |              MEDIA_BUS_FMT_Y10_1X10
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:46:14: error: 'MEDIA_BUS_FMT_META_8' undeclared (first use in this function); did you mean 'MEDIA_BUS_FMT_Y8_1X8'?
      46 |         case MEDIA_BUS_FMT_META_8:
         |              ^~~~~~~~~~~~~~~~~~~~
         |              MEDIA_BUS_FMT_Y8_1X8
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c: In function 'ipu6_isys_subdev_set_fmt':
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:159:15: error: implicit declaration of function 'v4l2_subdev_state_get_stream_format'; did you mean 'v4l2_subdev_state_get_format'? [-Werror=implicit-function-declaration]
     159 |         fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               v4l2_subdev_state_get_format
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:159:13: warning: assignment to 'struct v4l2_mbus_framefmt *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     159 |         fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
         |             ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:185:16: error: implicit declaration of function 'v4l2_subdev_state_get_stream_crop'; did you mean 'v4l2_subdev_state_get_crop'? [-Werror=implicit-function-declaration]
     185 |         crop = v4l2_subdev_state_get_stream_crop(state, other_pad,
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                v4l2_subdev_state_get_crop
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:185:14: warning: assignment to 'struct v4l2_rect *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     185 |         crop = v4l2_subdev_state_get_stream_crop(state, other_pad,
         |              ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c: In function 'ipu6_isys_get_stream_pad_fmt':
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:244:13: warning: assignment to 'struct v4l2_mbus_framefmt *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     244 |         fmt = v4l2_subdev_state_get_stream_format(state, pad, stream);
         |             ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c: In function 'ipu6_isys_get_stream_pad_crop':
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:262:14: warning: assignment to 'struct v4l2_rect *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     262 |         rect = v4l2_subdev_state_get_stream_crop(state, pad, stream);
         |              ^
   cc1: some warnings being treated as errors
--
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:45:9: error: 'MEDIA_BUS_FMT_META_8' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_Y8_1X8'?
      45 |         MEDIA_BUS_FMT_META_8,
         |         ^~~~~~~~~~~~~~~~~~~~
         |         MEDIA_BUS_FMT_Y8_1X8
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:46:9: error: 'MEDIA_BUS_FMT_META_10' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_Y10_1X10'?
      46 |         MEDIA_BUS_FMT_META_10,
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         MEDIA_BUS_FMT_Y10_1X10
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:47:9: error: 'MEDIA_BUS_FMT_META_12' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_UV8_1X8'?
      47 |         MEDIA_BUS_FMT_META_12,
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         MEDIA_BUS_FMT_UV8_1X8
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:48:9: error: 'MEDIA_BUS_FMT_META_16' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_Y16_1X16'?
      48 |         MEDIA_BUS_FMT_META_16,
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         MEDIA_BUS_FMT_Y16_1X16
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:49:9: error: 'MEDIA_BUS_FMT_META_24' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_VUY8_1X24'?
      49 |         MEDIA_BUS_FMT_META_24,
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         MEDIA_BUS_FMT_VUY8_1X24
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c: In function 'ipu6_isys_csi2_set_sel':
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:406:20: error: implicit declaration of function 'v4l2_subdev_state_get_stream_format'; did you mean 'v4l2_subdev_state_get_format'? [-Werror=implicit-function-declaration]
     406 |         src_ffmt = v4l2_subdev_state_get_stream_format(state, sel->pad,
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                    v4l2_subdev_state_get_format
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:406:18: warning: assignment to 'struct v4l2_mbus_framefmt *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     406 |         src_ffmt = v4l2_subdev_state_get_stream_format(state, sel->pad,
         |                  ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:411:16: error: implicit declaration of function 'v4l2_subdev_state_get_stream_crop'; did you mean 'v4l2_subdev_state_get_crop'? [-Werror=implicit-function-declaration]
     411 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                v4l2_subdev_state_get_crop
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:411:14: warning: assignment to 'struct v4l2_rect *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     411 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |              ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c: In function 'ipu6_isys_csi2_get_sel':
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:456:14: warning: assignment to 'struct v4l2_rect *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     456 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |              ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c: At top level:
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:483:10: error: 'const struct v4l2_subdev_pad_ops' has no member named 'init_cfg'
     483 |         .init_cfg = ipu6_isys_subdev_init_cfg,
         |          ^~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:483:21: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
     483 |         .init_cfg = ipu6_isys_subdev_init_cfg,
         |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:483:21: note: (near initialization for 'csi2_sd_pad_ops')
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:483:21: error: invalid initializer
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:483:21: note: (near initialization for 'csi2_sd_pad_ops.<anonymous>')
   cc1: some warnings being treated as errors
--
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:88:10: error: 'V4L2_META_FMT_GENERIC_8' undeclared here (not in a function); did you mean 'V4L2_META_FMT_VIVID'?
      88 |         {V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8, 0},
         |          ^~~~~~~~~~~~~~~~~~~~~~~
         |          V4L2_META_FMT_VIVID
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:88:41: error: 'MEDIA_BUS_FMT_META_8' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_Y8_1X8'?
      88 |         {V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8, 0},
         |                                         ^~~~~~~~~~~~~~~~~~~~
         |                                         MEDIA_BUS_FMT_Y8_1X8
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:89:10: error: 'V4L2_META_FMT_GENERIC_CSI2_10' undeclared here (not in a function)
      89 |         {V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10, 0},
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:89:49: error: 'MEDIA_BUS_FMT_META_10' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_Y10_1X10'?
      89 |         {V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10, 0},
         |                                                 ^~~~~~~~~~~~~~~~~~~~~
         |                                                 MEDIA_BUS_FMT_Y10_1X10
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:90:10: error: 'V4L2_META_FMT_GENERIC_CSI2_12' undeclared here (not in a function)
      90 |         {V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12, 0},
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:90:49: error: 'MEDIA_BUS_FMT_META_12' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_UV8_1X8'?
      90 |         {V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12, 0},
         |                                                 ^~~~~~~~~~~~~~~~~~~~~
         |                                                 MEDIA_BUS_FMT_UV8_1X8
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:91:10: error: 'V4L2_META_FMT_GENERIC_CSI2_16' undeclared here (not in a function)
      91 |         {V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16, 0},
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:91:49: error: 'MEDIA_BUS_FMT_META_16' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_Y16_1X16'?
      91 |         {V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16, 0},
         |                                                 ^~~~~~~~~~~~~~~~~~~~~
         |                                                 MEDIA_BUS_FMT_Y16_1X16
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:92:10: error: 'V4L2_META_FMT_GENERIC_CSI2_24' undeclared here (not in a function)
      92 |         {V4L2_META_FMT_GENERIC_CSI2_24, 24, 24, MEDIA_BUS_FMT_META_24, 0},
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:92:49: error: 'MEDIA_BUS_FMT_META_24' undeclared here (not in a function); did you mean 'MEDIA_BUS_FMT_VUY8_1X24'?
      92 |         {V4L2_META_FMT_GENERIC_CSI2_24, 24, 24, MEDIA_BUS_FMT_META_24, 0},
         |                                                 ^~~~~~~~~~~~~~~~~~~~~
         |                                                 MEDIA_BUS_FMT_VUY8_1X24
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c: In function 'ipu6_isys_video_try_fmt_meta':
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:13: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |             ^~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:21,
                    from drivers/media/pci/intel/ipu6/ipu6-isys-video.c:7:
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/compiler.h:236:55: note: in definition of macro '__is_constexpr'
     236 |         (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
         |                                                       ^
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   In file included from include/linux/kernel.h:28,
                    from arch/x86/include/asm/percpu.h:27,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:79,
                    from include/linux/spinlock.h:56,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from drivers/media/pci/intel/ipu6/ipu6-isys-video.c:9:
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/minmax.h:61:11: note: in definition of macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |           ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/minmax.h:61:35: note: in definition of macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |                                   ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/minmax.h:61:58: note: in definition of macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |                                                          ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/minmax.h:64:16: note: in definition of macro '__clamp_once'
      64 |         typeof(val) unique_val = (val);                                         \
         |                ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/minmax.h:64:35: note: in definition of macro '__clamp_once'
      64 |         typeof(val) unique_val = (val);                                         \
         |                                   ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:70:9: note: in expansion of macro 'static_assert'
      70 |         static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error");    \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:31:31: note: in expansion of macro '__is_constexpr'
      31 |         __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))),        \
         |                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:46: note: in expansion of macro 'is_signed_type'
      31 |         __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))),        \
         |                                              ^~~~~~~~~~~~~~
--
         |                                                        ^~~~
   include/linux/minmax.h:71:9: note: in expansion of macro 'static_assert'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:36:53: note: in expansion of macro '__is_signed'
      36 |         (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
         |                                                     ^~~~~~~~~~~
   include/linux/minmax.h:41:17: note: in expansion of macro '__is_noneg_int'
      41 |                 __is_noneg_int(x) || __is_noneg_int(y))
         |                 ^~~~~~~~~~~~~~
   include/linux/minmax.h:71:23: note: in expansion of macro '__types_ok'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:77:17: note: in expansion of macro '__clamp_once'
      77 |                 __clamp_once(val, lo, hi, __UNIQUE_ID(__val),           \
         |                 ^~~~~~~~~~~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:33: error: 'struct v4l2_meta_format' has no member named 'width'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                                 ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:71:9: note: in expansion of macro 'static_assert'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:41:17: note: in expansion of macro '__is_noneg_int'
      41 |                 __is_noneg_int(x) || __is_noneg_int(y))
         |                 ^~~~~~~~~~~~~~
   include/linux/minmax.h:71:23: note: in expansion of macro '__types_ok'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:77:17: note: in expansion of macro '__clamp_once'
      77 |                 __clamp_once(val, lo, hi, __UNIQUE_ID(__val),           \
         |                 ^~~~~~~~~~~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   include/linux/minmax.h:36:10: error: first argument to '__builtin_choose_expr' not a constant
      36 |         (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
         |          ^~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:71:9: note: in expansion of macro 'static_assert'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:41:17: note: in expansion of macro '__is_noneg_int'
      41 |                 __is_noneg_int(x) || __is_noneg_int(y))
         |                 ^~~~~~~~~~~~~~
   include/linux/minmax.h:71:23: note: in expansion of macro '__types_ok'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:77:17: note: in expansion of macro '__clamp_once'
      77 |                 __clamp_once(val, lo, hi, __UNIQUE_ID(__val),           \
         |                 ^~~~~~~~~~~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   include/linux/minmax.h:39:9: error: expression in static assertion is not an integer
      39 |         (__is_signed(x) == __is_signed(y) ||                    \
         |         ^
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:71:9: note: in expansion of macro 'static_assert'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:71:23: note: in expansion of macro '__types_ok'
      71 |         static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");    \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:77:17: note: in expansion of macro '__clamp_once'
      77 |                 __clamp_once(val, lo, hi, __UNIQUE_ID(__val),           \
         |                 ^~~~~~~~~~~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
   include/linux/minmax.h:75:9: error: first argument to '__builtin_choose_expr' not a constant
      75 |         __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)),      \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:23: note: in expansion of macro 'clamp'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                       ^~~~~
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:13: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |             ^~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/compiler.h:236:55: note: in definition of macro '__is_constexpr'
     236 |         (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
         |                                                       ^
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:24: note: in expansion of macro 'clamp'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                        ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/minmax.h:61:11: note: in definition of macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |           ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:24: note: in expansion of macro 'clamp'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                        ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/minmax.h:61:35: note: in definition of macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |                                   ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:24: note: in expansion of macro 'clamp'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                        ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/minmax.h:61:58: note: in definition of macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |                                                          ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:24: note: in expansion of macro 'clamp'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                        ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/minmax.h:64:16: note: in definition of macro '__clamp_once'
      64 |         typeof(val) unique_val = (val);                                         \
         |                ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:24: note: in expansion of macro 'clamp'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                        ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/minmax.h:64:35: note: in definition of macro '__clamp_once'
      64 |         typeof(val) unique_val = (val);                                         \
         |                                   ^~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                            ^~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:24: note: in expansion of macro 'clamp'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                        ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:267:34: error: 'struct v4l2_meta_format' has no member named 'height'
     267 |         meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
         |                                  ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:70:9: note: in expansion of macro 'static_assert'
      70 |         static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error");    \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:31:31: note: in expansion of macro '__is_constexpr'
      31 |         __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))),        \
         |                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:46: note: in expansion of macro 'is_signed_type'
      31 |         __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))),        \
         |                                              ^~~~~~~~~~~~~~
   include/linux/minmax.h:39:10: note: in expansion of macro '__is_signed'
      39 |         (__is_signed(x) == __is_signed(y) ||                    \
         |          ^~~~~~~~~~~
   include/linux/minmax.h:70:23: note: in expansion of macro '__types_ok'
      70 |         static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error");    \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:77:17: note: in expansion of macro '__clamp_once'
      77 |                 __clamp_once(val, lo, hi, __UNIQUE_ID(__val),           \
         |                 ^~~~~~~~~~~~
   include/linux/minmax.h:146:28: note: in expansion of macro '__careful_clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
..


vim +23 drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c

    18	
    19	unsigned int ipu6_isys_mbus_code_to_bpp(u32 code)
    20	{
    21		switch (code) {
    22		case MEDIA_BUS_FMT_RGB888_1X24:
  > 23		case MEDIA_BUS_FMT_META_24:
    24			return 24;
    25		case MEDIA_BUS_FMT_RGB565_1X16:
    26		case MEDIA_BUS_FMT_UYVY8_1X16:
    27		case MEDIA_BUS_FMT_YUYV8_1X16:
  > 28		case MEDIA_BUS_FMT_META_16:
    29			return 16;
    30		case MEDIA_BUS_FMT_SBGGR12_1X12:
    31		case MEDIA_BUS_FMT_SGBRG12_1X12:
    32		case MEDIA_BUS_FMT_SGRBG12_1X12:
    33		case MEDIA_BUS_FMT_SRGGB12_1X12:
  > 34		case MEDIA_BUS_FMT_META_12:
    35			return 12;
    36		case MEDIA_BUS_FMT_SBGGR10_1X10:
    37		case MEDIA_BUS_FMT_SGBRG10_1X10:
    38		case MEDIA_BUS_FMT_SGRBG10_1X10:
    39		case MEDIA_BUS_FMT_SRGGB10_1X10:
  > 40		case MEDIA_BUS_FMT_META_10:
    41			return 10;
    42		case MEDIA_BUS_FMT_SBGGR8_1X8:
    43		case MEDIA_BUS_FMT_SGBRG8_1X8:
    44		case MEDIA_BUS_FMT_SGRBG8_1X8:
    45		case MEDIA_BUS_FMT_SRGGB8_1X8:
  > 46		case MEDIA_BUS_FMT_META_8:
    47			return 8;
    48		default:
    49			WARN_ON(1);
    50			return 8;
    51		}
    52	}
    53
kernel test robot Jan. 12, 2024, 3:31 a.m. UTC | #3
Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on media-tree/master]
[also build test ERROR on linuxtv-media-stage/master linus/master v6.7 next-20240111]
[cannot apply to sailus-media-tree/streams]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/bingbu-cao-intel-com/media-intel-ipu6-add-IPU-auxiliary-devices/20240111-155551
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20240111065531.2418836-17-bingbu.cao%40intel.com
patch subject: [PATCH v3 16/17] media: ipu6/isys: support line-based metadata capture support
config: x86_64-allmodconfig (https://download.01.org/0day-ci/archive/20240112/202401121120.4CiWmH5y-lkp@intel.com/config)
compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240112/202401121120.4CiWmH5y-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401121120.4CiWmH5y-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:45:2: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_8'
      45 |         MEDIA_BUS_FMT_META_8,
         |         ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:46:2: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_10'
      46 |         MEDIA_BUS_FMT_META_10,
         |         ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:47:2: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_12'
      47 |         MEDIA_BUS_FMT_META_12,
         |         ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:48:2: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_16'
      48 |         MEDIA_BUS_FMT_META_16,
         |         ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:49:2: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_24'
      49 |         MEDIA_BUS_FMT_META_24,
         |         ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:406:13: error: call to undeclared function 'v4l2_subdev_state_get_stream_format'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     406 |         src_ffmt = v4l2_subdev_state_get_stream_format(state, sel->pad,
         |                    ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:406:11: error: incompatible integer to pointer conversion assigning to 'struct v4l2_mbus_framefmt *' from 'int' [-Wint-conversion]
     406 |         src_ffmt = v4l2_subdev_state_get_stream_format(state, sel->pad,
         |                  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     407 |                                                        sel->stream);
         |                                                        ~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:411:9: error: call to undeclared function 'v4l2_subdev_state_get_stream_crop'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     411 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |                ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:411:7: error: incompatible integer to pointer conversion assigning to 'struct v4l2_rect *' from 'int' [-Wint-conversion]
     411 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:456:9: error: call to undeclared function 'v4l2_subdev_state_get_stream_crop'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     456 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |                ^
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:456:7: error: incompatible integer to pointer conversion assigning to 'struct v4l2_rect *' from 'int' [-Wint-conversion]
     456 |         crop = v4l2_subdev_state_get_stream_crop(state, sel->pad, sel->stream);
         |              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c:483:3: error: field designator 'init_cfg' does not refer to any field in type 'const struct v4l2_subdev_pad_ops'
     483 |         .init_cfg = ipu6_isys_subdev_init_cfg,
         |         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   12 errors generated.
--
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:88:3: error: use of undeclared identifier 'V4L2_META_FMT_GENERIC_8'
      88 |         {V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8, 0},
         |          ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:88:34: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_8'
      88 |         {V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8, 0},
         |                                         ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:89:3: error: use of undeclared identifier 'V4L2_META_FMT_GENERIC_CSI2_10'
      89 |         {V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10, 0},
         |          ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:89:42: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_10'
      89 |         {V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10, 0},
         |                                                 ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:90:3: error: use of undeclared identifier 'V4L2_META_FMT_GENERIC_CSI2_12'
      90 |         {V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12, 0},
         |          ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:90:42: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_12'
      90 |         {V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12, 0},
         |                                                 ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:91:3: error: use of undeclared identifier 'V4L2_META_FMT_GENERIC_CSI2_16'
      91 |         {V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16, 0},
         |          ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:91:42: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_16'
      91 |         {V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16, 0},
         |                                                 ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:92:3: error: use of undeclared identifier 'V4L2_META_FMT_GENERIC_CSI2_24'
      92 |         {V4L2_META_FMT_GENERIC_CSI2_24, 24, 24, MEDIA_BUS_FMT_META_24, 0},
         |          ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:92:42: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_24'
      92 |         {V4L2_META_FMT_GENERIC_CSI2_24, 24, 24, MEDIA_BUS_FMT_META_24, 0},
         |                                                 ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:122:18: error: invalid application of 'sizeof' to an incomplete type 'const struct ipu6_isys_pixelformat[]'
     122 |         for (i = 0; i < ARRAY_SIZE(ipu6_isys_pfmts); i++) {
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/array_size.h:11:32: note: expanded from macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:148:18: error: invalid application of 'sizeof' to an incomplete type 'const struct ipu6_isys_pixelformat[]'
     148 |         if (f->index >= ARRAY_SIZE(ipu6_isys_pfmts))
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/array_size.h:11:32: note: expanded from macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                ^~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:157:18: error: invalid application of 'sizeof' to an incomplete type 'const struct ipu6_isys_pixelformat[]'
     157 |         for (i = 0; i < ARRAY_SIZE(ipu6_isys_pfmts); i++) {
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/array_size.h:11:32: note: expanded from macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                ^~~~~
>> drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:8: error: no member named 'width' in 'struct v4l2_meta_format'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |         ~~~~  ^
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:28: error: no member named 'width' in 'struct v4l2_meta_format'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                             ~~~~  ^
   include/linux/minmax.h:146:44: note: expanded from macro 'clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                                            ^~~
   include/linux/minmax.h:75:40: note: expanded from macro '__careful_clamp'
      75 |         __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)),      \
         |                                               ^~~
   include/linux/compiler.h:236:48: note: expanded from macro '__is_constexpr'
     236 |         (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
         |                                                       ^
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:28: error: no member named 'width' in 'struct v4l2_meta_format'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                             ~~~~  ^
   include/linux/minmax.h:146:44: note: expanded from macro 'clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                                            ^~~
   include/linux/minmax.h:76:11: note: expanded from macro '__careful_clamp'
      76 |                 __clamp(val, lo, hi),                                   \
         |                         ^~~
   include/linux/minmax.h:61:4: note: expanded from macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |           ^~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:28: error: no member named 'width' in 'struct v4l2_meta_format'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                             ~~~~  ^
   include/linux/minmax.h:146:44: note: expanded from macro 'clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                                            ^~~
   include/linux/minmax.h:76:11: note: expanded from macro '__careful_clamp'
      76 |                 __clamp(val, lo, hi),                                   \
         |                         ^~~
   include/linux/minmax.h:61:28: note: expanded from macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |                                   ^~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:28: error: no member named 'width' in 'struct v4l2_meta_format'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                             ~~~~  ^
   include/linux/minmax.h:146:44: note: expanded from macro 'clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                                            ^~~
   include/linux/minmax.h:76:11: note: expanded from macro '__careful_clamp'
      76 |                 __clamp(val, lo, hi),                                   \
         |                         ^~~
   include/linux/minmax.h:61:51: note: expanded from macro '__clamp'
      61 |         ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
         |                                                          ^~~
   drivers/media/pci/intel/ipu6/ipu6-isys-video.c:265:28: error: no member named 'width' in 'struct v4l2_meta_format'
     265 |         meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
         |                             ~~~~  ^
   include/linux/minmax.h:146:44: note: expanded from macro 'clamp'
     146 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
         |                                            ^~~
   include/linux/minmax.h:77:16: note: expanded from macro '__careful_clamp'
      77 |                 __clamp_once(val, lo, hi, __UNIQUE_ID(__val),           \
         |                              ^~~
   include/linux/minmax.h:64:9: note: expanded from macro '__clamp_once'
      64 |         typeof(val) unique_val = (val);                                         \
         |                ^~~
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.
--
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:23:7: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_24'
      23 |         case MEDIA_BUS_FMT_META_24:
         |              ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:28:7: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_16'
      28 |         case MEDIA_BUS_FMT_META_16:
         |              ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:34:7: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_12'
      34 |         case MEDIA_BUS_FMT_META_12:
         |              ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:40:7: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_10'
      40 |         case MEDIA_BUS_FMT_META_10:
         |              ^
>> drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:46:7: error: use of undeclared identifier 'MEDIA_BUS_FMT_META_8'
      46 |         case MEDIA_BUS_FMT_META_8:
         |              ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:159:8: error: call to undeclared function 'v4l2_subdev_state_get_stream_format'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     159 |         fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
         |               ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:159:6: error: incompatible integer to pointer conversion assigning to 'struct v4l2_mbus_framefmt *' from 'int' [-Wint-conversion]
     159 |         fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
         |             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     160 |                                                   format->stream);
         |                                                   ~~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:185:9: error: call to undeclared function 'v4l2_subdev_state_get_stream_crop'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     185 |         crop = v4l2_subdev_state_get_stream_crop(state, other_pad,
         |                ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:185:7: error: incompatible integer to pointer conversion assigning to 'struct v4l2_rect *' from 'int' [-Wint-conversion]
     185 |         crop = v4l2_subdev_state_get_stream_crop(state, other_pad,
         |              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     186 |                                                  other_stream);
         |                                                  ~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:244:8: error: call to undeclared function 'v4l2_subdev_state_get_stream_format'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     244 |         fmt = v4l2_subdev_state_get_stream_format(state, pad, stream);
         |               ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:244:6: error: incompatible integer to pointer conversion assigning to 'struct v4l2_mbus_framefmt *' from 'int' [-Wint-conversion]
     244 |         fmt = v4l2_subdev_state_get_stream_format(state, pad, stream);
         |             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:262:9: error: call to undeclared function 'v4l2_subdev_state_get_stream_crop'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     262 |         rect = v4l2_subdev_state_get_stream_crop(state, pad, stream);
         |                ^
   drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c:262:7: error: incompatible integer to pointer conversion assigning to 'struct v4l2_rect *' from 'int' [-Wint-conversion]
     262 |         rect = v4l2_subdev_state_get_stream_crop(state, pad, stream);
         |              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   13 errors generated.


vim +/MEDIA_BUS_FMT_META_8 +45 drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c

    27	
    28	static const u32 csi2_supported_codes[] = {
    29		MEDIA_BUS_FMT_RGB565_1X16,
    30		MEDIA_BUS_FMT_RGB888_1X24,
    31		MEDIA_BUS_FMT_UYVY8_1X16,
    32		MEDIA_BUS_FMT_YUYV8_1X16,
    33		MEDIA_BUS_FMT_SBGGR10_1X10,
    34		MEDIA_BUS_FMT_SGBRG10_1X10,
    35		MEDIA_BUS_FMT_SGRBG10_1X10,
    36		MEDIA_BUS_FMT_SRGGB10_1X10,
    37		MEDIA_BUS_FMT_SBGGR12_1X12,
    38		MEDIA_BUS_FMT_SGBRG12_1X12,
    39		MEDIA_BUS_FMT_SGRBG12_1X12,
    40		MEDIA_BUS_FMT_SRGGB12_1X12,
    41		MEDIA_BUS_FMT_SBGGR8_1X8,
    42		MEDIA_BUS_FMT_SGBRG8_1X8,
    43		MEDIA_BUS_FMT_SGRBG8_1X8,
    44		MEDIA_BUS_FMT_SRGGB8_1X8,
  > 45		MEDIA_BUS_FMT_META_8,
  > 46		MEDIA_BUS_FMT_META_10,
  > 47		MEDIA_BUS_FMT_META_12,
  > 48		MEDIA_BUS_FMT_META_16,
  > 49		MEDIA_BUS_FMT_META_24,
    50		0
    51	};
    52
diff mbox series

Patch

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
index ac9fa3e0d7ab..a6430d531129 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
@@ -42,6 +42,11 @@  static const u32 csi2_supported_codes[] = {
 	MEDIA_BUS_FMT_SGBRG8_1X8,
 	MEDIA_BUS_FMT_SGRBG8_1X8,
 	MEDIA_BUS_FMT_SRGGB8_1X8,
+	MEDIA_BUS_FMT_META_8,
+	MEDIA_BUS_FMT_META_10,
+	MEDIA_BUS_FMT_META_12,
+	MEDIA_BUS_FMT_META_16,
+	MEDIA_BUS_FMT_META_24,
 	0
 };
 
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
index 735d2d642d87..15fa7ed22b2f 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
@@ -35,11 +35,14 @@  static int queue_setup(struct vb2_queue *q, unsigned int *num_buffers,
 	/* num_planes == 0: we're being called through VIDIOC_REQBUFS */
 	if (!*num_planes) {
 		use_fmt = true;
-		*num_planes = av->mpix.num_planes;
+		if (av->vfmt.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+			*num_planes = av->vfmt.fmt.pix_mp.num_planes;
+		else if (av->vfmt.type == V4L2_BUF_TYPE_META_CAPTURE)
+			*num_planes = 1;
 	}
 
 	for (i = 0; i < *num_planes; i++) {
-		size = av->mpix.plane_fmt[i].sizeimage;
+		size = ipu6_get_data_size(&av->vfmt, i);
 		if (use_fmt) {
 			sizes[i] = size;
 		} else if (sizes[i] < size) {
@@ -59,16 +62,17 @@  static int ipu6_isys_buf_prepare(struct vb2_buffer *vb)
 	struct ipu6_isys_queue *aq = vb2_queue_to_isys_queue(vb->vb2_queue);
 	struct ipu6_isys_video *av = ipu6_isys_queue_to_video(aq);
 	struct device *dev = &av->isys->adev->auxdev.dev;
+	u32 bytesperline = ipu6_get_bytes_per_line(&av->vfmt);
+	u32 height = ipu6_get_frame_height(&av->vfmt);
+	u32 size = ipu6_get_data_size(&av->vfmt, 0);
 
 	dev_dbg(dev, "buffer: %s: configured size %u, buffer size %lu\n",
-		av->vdev.name, av->mpix.plane_fmt[0].sizeimage,
-		vb2_plane_size(vb, 0));
+		av->vdev.name, size, vb2_plane_size(vb, 0));
 
-	if (av->mpix.plane_fmt[0].sizeimage > vb2_plane_size(vb, 0))
+	if (size > vb2_plane_size(vb, 0))
 		return -EINVAL;
 
-	vb2_set_plane_payload(vb, 0, av->mpix.plane_fmt[0].bytesperline *
-			      av->mpix.height);
+	vb2_set_plane_payload(vb, 0, bytesperline * height);
 	vb->planes[0].data_offset = 0;
 
 	return 0;
@@ -437,18 +441,22 @@  static int ipu6_isys_link_fmt_validate(struct ipu6_isys_queue *aq)
 		return ret;
 	}
 
-	if (format.width != av->mpix.width ||
-	    format.height != av->mpix.height) {
-		dev_dbg(dev, "wrong width or height %ux%u (%ux%u expected)\n",
-			av->mpix.width, av->mpix.height,
-			format.width, format.height);
+	if (format.width != ipu6_get_frame_width(&av->vfmt) ||
+	    format.height != ipu6_get_frame_height(&av->vfmt)) {
+		dev_err(dev, "wrong width or height %ux%u (%ux%u expected)\n",
+			ipu6_get_frame_width(&av->vfmt),
+			ipu6_get_frame_height(&av->vfmt), format.width,
+			format.height);
 		return -EINVAL;
 	}
 
-	if (format.field != av->mpix.field) {
-		dev_dbg(dev, "wrong field value 0x%8.8x (0x%8.8x expected)\n",
-			av->mpix.field, format.field);
-		return -EINVAL;
+	if (av->vfmt.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+		if (format.field != av->vfmt.fmt.pix_mp.field) {
+			dev_dbg(dev,
+				"wrong field value 0x%8.8x (%8.8x expected)\n",
+				av->vfmt.fmt.pix_mp.field, format.field);
+			return -EINVAL;
+		}
 	}
 
 	if (format.code != av->pfmt->code) {
@@ -531,8 +539,8 @@  static int start_streaming(struct vb2_queue *q, unsigned int count)
 	int nr_queues, ret;
 
 	dev_dbg(dev, "stream: %s: width %u, height %u, css pixelformat %u\n",
-		av->vdev.name, av->mpix.width, av->mpix.height,
-		av->pfmt->css_pixelformat);
+		av->vdev.name, ipu6_get_frame_width(&av->vfmt),
+		ipu6_get_frame_height(&av->vfmt), av->pfmt->css_pixelformat);
 
 	ret = ipu6_isys_setup_video(av, &source_entity, &nr_queues);
 	if (ret < 0) {
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
index 510c5ca34f9f..3c9263ac02a3 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
@@ -20,25 +20,30 @@  unsigned int ipu6_isys_mbus_code_to_bpp(u32 code)
 {
 	switch (code) {
 	case MEDIA_BUS_FMT_RGB888_1X24:
+	case MEDIA_BUS_FMT_META_24:
 		return 24;
 	case MEDIA_BUS_FMT_RGB565_1X16:
 	case MEDIA_BUS_FMT_UYVY8_1X16:
 	case MEDIA_BUS_FMT_YUYV8_1X16:
+	case MEDIA_BUS_FMT_META_16:
 		return 16;
 	case MEDIA_BUS_FMT_SBGGR12_1X12:
 	case MEDIA_BUS_FMT_SGBRG12_1X12:
 	case MEDIA_BUS_FMT_SGRBG12_1X12:
 	case MEDIA_BUS_FMT_SRGGB12_1X12:
+	case MEDIA_BUS_FMT_META_12:
 		return 12;
 	case MEDIA_BUS_FMT_SBGGR10_1X10:
 	case MEDIA_BUS_FMT_SGBRG10_1X10:
 	case MEDIA_BUS_FMT_SGRBG10_1X10:
 	case MEDIA_BUS_FMT_SRGGB10_1X10:
+	case MEDIA_BUS_FMT_META_10:
 		return 10;
 	case MEDIA_BUS_FMT_SBGGR8_1X8:
 	case MEDIA_BUS_FMT_SGBRG8_1X8:
 	case MEDIA_BUS_FMT_SGRBG8_1X8:
 	case MEDIA_BUS_FMT_SRGGB8_1X8:
+	case MEDIA_BUS_FMT_META_8:
 		return 8;
 	default:
 		WARN_ON(1);
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index 847eac26bcd6..1a023bf1e1a6 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -85,6 +85,11 @@  const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = {
 	 IPU6_FW_ISYS_FRAME_FORMAT_RGB565},
 	{V4L2_PIX_FMT_BGR24, 24, 24, MEDIA_BUS_FMT_RGB888_1X24,
 	 IPU6_FW_ISYS_FRAME_FORMAT_RGBA888},
+	{V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8, 0},
+	{V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10, 0},
+	{V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12, 0},
+	{V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16, 0},
+	{V4L2_META_FMT_GENERIC_CSI2_24, 24, 24, MEDIA_BUS_FMT_META_24, 0},
 };
 
 static int video_open(struct file *file)
@@ -181,12 +186,12 @@  static int ipu6_isys_vidioc_enum_framesizes(struct file *file, void *fh,
 	return 0;
 }
 
-static int vidioc_g_fmt_vid_cap_mplane(struct file *file, void *fh,
-				       struct v4l2_format *fmt)
+static int vidioc_get_format(struct file *file, void *fh,
+			     struct v4l2_format *fmt)
 {
 	struct ipu6_isys_video *av = video_drvdata(file);
 
-	fmt->fmt.pix_mp = av->mpix;
+	*fmt = av->vfmt;
 
 	return 0;
 }
@@ -245,30 +250,114 @@  ipu6_isys_video_try_fmt_vid_mplane(struct ipu6_isys_video *av,
 	return pfmt;
 }
 
-static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *fh,
-				       struct v4l2_format *f)
+static const struct ipu6_isys_pixelformat *
+ipu6_isys_video_try_fmt_meta(struct ipu6_isys_video *av,
+			     struct v4l2_meta_format *meta)
+{
+	const struct ipu6_isys_pixelformat *pfmt =
+		ipu6_isys_get_pixelformat(meta->dataformat);
+
+	memset(&av->vfmt, 0, sizeof(av->vfmt));
+	av->vfmt.type = V4L2_BUF_TYPE_META_CAPTURE;
+	av->pfmt = pfmt;
+
+	meta->dataformat = pfmt->pixelformat;
+	meta->width = clamp(meta->width, IPU6_ISYS_MIN_WIDTH,
+			    IPU6_ISYS_MAX_WIDTH);
+	meta->height = clamp(meta->height, IPU6_ISYS_MIN_HEIGHT,
+			     IPU6_ISYS_MAX_HEIGHT);
+
+	if (pfmt->bpp != pfmt->bpp_packed)
+		meta->bytesperline = meta->width *
+				     DIV_ROUND_UP(pfmt->bpp, BITS_PER_BYTE);
+	else
+		meta->bytesperline =
+			DIV_ROUND_UP(meta->width * pfmt->bpp, BITS_PER_BYTE);
+
+	meta->bytesperline = ALIGN(meta->bytesperline, av->isys->line_align);
+	meta->buffersize =
+		max(max(meta->buffersize, meta->bytesperline * meta->height +
+			max(meta->bytesperline,
+			    av->isys->pdata->ipdata->isys_dma_overshoot)), 1U);
+
+	return pfmt;
+}
+
+static const struct ipu6_isys_pixelformat *
+ipu6_isys_video_try_fmt(struct ipu6_isys_video *av, struct v4l2_format *f)
+{
+	if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		return ipu6_isys_video_try_fmt_vid_mplane(av, &f->fmt.pix_mp);
+	else if (f->type == V4L2_BUF_TYPE_META_CAPTURE)
+		return ipu6_isys_video_try_fmt_meta(av, &f->fmt.meta);
+	else
+		return &ipu6_isys_pfmts[0];
+}
+
+static int vidioc_set_format(struct file *file, void *fh,
+			     struct v4l2_format *f)
 {
 	struct ipu6_isys_video *av = video_drvdata(file);
 
 	if (av->aq.vbq.streaming)
 		return -EBUSY;
 
-	av->pfmt = ipu6_isys_video_try_fmt_vid_mplane(av, &f->fmt.pix_mp);
-	av->mpix = f->fmt.pix_mp;
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
+	    f->type != V4L2_BUF_TYPE_META_CAPTURE)
+		return -EINVAL;
+
+	av->pfmt = ipu6_isys_video_try_fmt(av, f);
+	av->vfmt = *f;
 
 	return 0;
 }
 
-static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *fh,
-					 struct v4l2_format *f)
+static int vidioc_try_format(struct file *file, void *fh,
+			     struct v4l2_format *f)
 {
 	struct ipu6_isys_video *av = video_drvdata(file);
 
-	ipu6_isys_video_try_fmt_vid_mplane(av, &f->fmt.pix_mp);
+	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
+	    f->type != V4L2_BUF_TYPE_META_CAPTURE)
+		return -EINVAL;
+
+	ipu6_isys_video_try_fmt(av, f);
 
 	return 0;
 }
 
+static int vidioc_request_qbufs(struct file *file, void *priv,
+				struct v4l2_requestbuffers *p)
+{
+	struct ipu6_isys_video *av = video_drvdata(file);
+	int ret;
+
+	av->aq.vbq.is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(p->type);
+	av->aq.vbq.is_output = V4L2_TYPE_IS_OUTPUT(p->type);
+
+	ret = vb2_queue_change_type(&av->aq.vbq, p->type);
+	if (ret)
+		return ret;
+
+	return vb2_ioctl_reqbufs(file, priv, p);
+}
+
+static int vidioc_create_bufs(struct file *file, void *priv,
+			      struct v4l2_create_buffers *p)
+{
+	struct ipu6_isys_video *av = video_drvdata(file);
+	int ret;
+
+	av->aq.vbq.is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(p->format.type);
+	av->aq.vbq.is_output = V4L2_TYPE_IS_OUTPUT(p->format.type);
+
+	ret = vb2_queue_change_type(&av->aq.vbq, p->format.type);
+	if (ret)
+		return ret;
+
+	return vb2_ioctl_create_bufs(file, priv, p);
+}
+
 static int link_validate(struct media_link *link)
 {
 	struct ipu6_isys_video *av =
@@ -279,6 +368,8 @@  static int link_validate(struct media_link *link)
 	struct v4l2_mbus_framefmt *s_fmt;
 	struct media_pad *s_pad;
 	u32 s_stream;
+	u32 height;
+	u32 width;
 	int ret = -EPIPE;
 
 	if (!link->source->entity)
@@ -305,11 +396,13 @@  static int link_validate(struct media_link *link)
 		goto unlock;
 	}
 
-	if (s_fmt->width != av->mpix.width ||
-	    s_fmt->height != av->mpix.height || s_fmt->code != av->pfmt->code) {
+	height = ipu6_get_frame_height(&av->vfmt);
+	width = ipu6_get_frame_width(&av->vfmt);
+	if (s_fmt->width != width || s_fmt->height != height ||
+	    s_fmt->code != av->pfmt->code) {
 		dev_err(dev, "format mismatch %dx%d,%x != %dx%d,%x\n",
-			s_fmt->width, s_fmt->height, s_fmt->code,
-			av->mpix.width, av->mpix.height, av->pfmt->code);
+			s_fmt->width, s_fmt->height, s_fmt->code, width, height,
+			av->pfmt->code);
 		goto unlock;
 	}
 
@@ -393,10 +486,10 @@  static int ipu6_isys_fw_pin_cfg(struct ipu6_isys_video *av,
 
 	output_pin = &cfg->output_pins[output_pins];
 	output_pin->input_pin_id = input_pins;
-	output_pin->output_res.width = av->mpix.width;
-	output_pin->output_res.height = av->mpix.height;
+	output_pin->output_res.width = ipu6_get_frame_width(&av->vfmt);
+	output_pin->output_res.height = ipu6_get_frame_height(&av->vfmt);
 
-	output_pin->stride = av->mpix.plane_fmt[0].bytesperline;
+	output_pin->stride = ipu6_get_bytes_per_line(&av->vfmt);
 	if (av->pfmt->bpp != av->pfmt->bpp_packed)
 		output_pin->pt = IPU6_FW_ISYS_PIN_TYPE_RAW_SOC;
 	else
@@ -663,8 +756,8 @@  void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av,
 
 	esd = media_entity_to_v4l2_subdev(av->stream->source_entity);
 
-	av->watermark.width = av->mpix.width;
-	av->watermark.height = av->mpix.height;
+	av->watermark.width = ipu6_get_frame_width(&av->vfmt);
+	av->watermark.height = ipu6_get_frame_height(&av->vfmt);
 	av->watermark.sram_gran_shift = isys->pdata->ipdata->sram_gran_shift;
 	av->watermark.sram_gran_size = isys->pdata->ipdata->sram_gran_size;
 
@@ -992,11 +1085,15 @@  static const struct v4l2_ioctl_ops ioctl_ops_mplane = {
 	.vidioc_querycap = ipu6_isys_vidioc_querycap,
 	.vidioc_enum_fmt_vid_cap = ipu6_isys_vidioc_enum_fmt,
 	.vidioc_enum_framesizes = ipu6_isys_vidioc_enum_framesizes,
-	.vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane,
-	.vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane,
-	.vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane,
-	.vidioc_reqbufs = vb2_ioctl_reqbufs,
-	.vidioc_create_bufs = vb2_ioctl_create_bufs,
+	.vidioc_g_fmt_vid_cap_mplane = vidioc_get_format,
+	.vidioc_s_fmt_vid_cap_mplane = vidioc_set_format,
+	.vidioc_try_fmt_vid_cap_mplane = vidioc_try_format,
+	.vidioc_enum_fmt_meta_cap = ipu6_isys_vidioc_enum_fmt,
+	.vidioc_g_fmt_meta_cap = vidioc_get_format,
+	.vidioc_s_fmt_meta_cap = vidioc_set_format,
+	.vidioc_try_fmt_meta_cap = vidioc_try_format,
+	.vidioc_reqbufs = vidioc_request_qbufs,
+	.vidioc_create_bufs = vidioc_create_bufs,
 	.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
 	.vidioc_querybuf = vb2_ioctl_querybuf,
 	.vidioc_qbuf = vb2_ioctl_qbuf,
@@ -1199,7 +1296,8 @@  int ipu6_isys_video_init(struct ipu6_isys_video *av)
 
 	mutex_init(&av->mutex);
 	av->vdev.device_caps = V4L2_CAP_STREAMING | V4L2_CAP_IO_MC |
-			       V4L2_CAP_VIDEO_CAPTURE_MPLANE;
+			       V4L2_CAP_VIDEO_CAPTURE_MPLANE |
+			       V4L2_CAP_META_CAPTURE;
 	av->vdev.vfl_dir = VFL_DIR_RX;
 
 	ret = ipu6_isys_queue_init(&av->aq);
@@ -1220,8 +1318,8 @@  int ipu6_isys_video_init(struct ipu6_isys_video *av)
 	av->vdev.queue = &av->aq.vbq;
 	av->vdev.lock = &av->mutex;
 
-	ipu6_isys_video_try_fmt_vid_mplane(av, &format.fmt.pix_mp);
-	av->mpix = format.fmt.pix_mp;
+	ipu6_isys_video_try_fmt(av, &format);
+	av->vfmt = format;
 
 	set_bit(V4L2_FL_USES_V4L2_FH, &av->vdev.flags);
 	video_set_drvdata(&av->vdev, av);
@@ -1251,3 +1349,52 @@  void ipu6_isys_video_cleanup(struct ipu6_isys_video *av)
 	media_entity_cleanup(&av->vdev.entity);
 	mutex_destroy(&av->mutex);
 }
+
+u32 ipu6_get_data_size(struct v4l2_format *vfmt, int plane)
+{
+	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		return vfmt->fmt.pix_mp.plane_fmt[plane].sizeimage;
+	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
+		return vfmt->fmt.meta.buffersize;
+
+	WARN_ON_ONCE(1);
+
+	return 0;
+}
+
+u32 ipu6_get_bytes_per_line(struct v4l2_format *vfmt)
+{
+	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		return vfmt->fmt.pix_mp.plane_fmt[0].bytesperline;
+	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
+		return vfmt->fmt.meta.bytesperline;
+
+	WARN_ON_ONCE(1);
+
+	return 0;
+}
+
+u32 ipu6_get_frame_width(struct v4l2_format *vfmt)
+{
+	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		return vfmt->fmt.pix_mp.width;
+	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
+		return vfmt->fmt.meta.width;
+
+	WARN_ON_ONCE(1);
+
+	return 0;
+}
+
+u32 ipu6_get_frame_height(struct v4l2_format *vfmt)
+{
+	if (vfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		return vfmt->fmt.pix_mp.height;
+	else if (vfmt->type == V4L2_BUF_TYPE_META_CAPTURE)
+		return vfmt->fmt.meta.height;
+
+	WARN_ON_ONCE(1);
+
+	return 0;
+}
+
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.h b/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
index 21cd33c7e277..2634ec0fd68b 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
@@ -90,7 +90,7 @@  struct ipu6_isys_video {
 	struct mutex mutex;
 	struct media_pad pad;
 	struct video_device vdev;
-	struct v4l2_pix_format_mplane mpix;
+	struct v4l2_format vfmt;
 	const struct ipu6_isys_pixelformat *pfmt;
 	struct ipu6_isys *isys;
 	struct ipu6_isys_stream *stream;
@@ -133,4 +133,9 @@  void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av,
 					  bool state);
 void ipu6_isys_update_stream_watermark(struct ipu6_isys_video *av, bool state);
 
+u32 ipu6_get_data_size(struct v4l2_format *vfmt, int plane);
+u32 ipu6_get_bytes_per_line(struct v4l2_format *vfmt);
+u32 ipu6_get_frame_width(struct v4l2_format *vfmt);
+u32 ipu6_get_frame_height(struct v4l2_format *vfmt);
+
 #endif /* IPU6_ISYS_VIDEO_H */