Linux Media Controller development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 08/14] media: omap3isp: implement create/prepare_bufs
Date: Wed, 22 Oct 2025 11:06:05 +0300	[thread overview]
Message-ID: <aPiQbZBFfzzWvCbV@kekkonen.localdomain> (raw)
In-Reply-To: <cc4ae2ac6aae997ad63bc0e694b7ca53a0a6ad32.1760707611.git.hverkuil+cisco@kernel.org>

Hi Hans,

On Fri, Oct 17, 2025 at 03:26:45PM +0200, Hans Verkuil wrote:
> Add missing ioctls. This makes v4l2-compliance happier:
> 
> 	warn: v4l2-test-buffers.cpp(813): VIDIOC_CREATE_BUFS not supported
> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> 
> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
> ---
>  drivers/media/platform/ti/omap3isp/ispvideo.c | 47 ++++++++++++++++++-
>  1 file changed, 45 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
> index 69d17e4dcd36..471defa6e7fb 100644
> --- a/drivers/media/platform/ti/omap3isp/ispvideo.c
> +++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
> @@ -325,6 +325,13 @@ static int isp_video_queue_setup(struct vb2_queue *queue,
>  	struct isp_video_fh *vfh = vb2_get_drv_priv(queue);
>  	struct isp_video *video = vfh->video;
>  
> +	if (*num_planes) {
> +		if (*num_planes != 1)
> +			return -EINVAL;
> +		if (sizes[0] < vfh->format.fmt.pix.sizeimage)
> +			return -EINVAL;
> +		return 0;
> +	}
>  	*num_planes = 1;
>  
>  	sizes[0] = vfh->format.fmt.pix.sizeimage;
> @@ -340,6 +347,7 @@ static int isp_video_buffer_prepare(struct vb2_buffer *buf)
>  {
>  	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(buf);
>  	struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue);
> +	unsigned int size = vfh->format.fmt.pix.sizeimage;
>  	struct isp_buffer *buffer = to_isp_buffer(vbuf);
>  	struct isp_video *video = vfh->video;
>  	dma_addr_t addr;
> @@ -360,8 +368,13 @@ static int isp_video_buffer_prepare(struct vb2_buffer *buf)
>  		return -EINVAL;
>  	}
>  
> -	vb2_set_plane_payload(&buffer->vb.vb2_buf, 0,
> -			      vfh->format.fmt.pix.sizeimage);
> +	if (vb2_plane_size(&buffer->vb.vb2_buf, 0) < size) {
> +		dev_dbg(video->isp->dev,
> +			"data will not fit into plane (%lu < %u)\n",
> +			vb2_plane_size(&buffer->vb.vb2_buf, 0), size);
> +		return -EINVAL;
> +	}
> +	vb2_set_plane_payload(&buffer->vb.vb2_buf, 0, size);
>  	buffer->dma = addr;
>  
>  	return 0;
> @@ -935,6 +948,20 @@ isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb)
>  	return ret;
>  }
>  
> +static int
> +isp_video_create_bufs(struct file *file, void *fh, struct v4l2_create_buffers *p)
> +{
> +	struct isp_video_fh *vfh = file_to_isp_video_fh(file);
> +	struct isp_video *video = video_drvdata(file);
> +	int ret;
> +
> +	mutex_lock(&video->queue_lock);
> +	ret = vb2_create_bufs(&vfh->queue, p);
> +	mutex_unlock(&video->queue_lock);
> +
> +	return ret;
> +}
> +
>  static int
>  isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
>  {
> @@ -949,6 +976,20 @@ isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
>  	return ret;
>  }
>  
> +static int
> +isp_video_prepare_buf(struct file *file, void *fh, struct v4l2_buffer *b)
> +{
> +	struct isp_video_fh *vfh = file_to_isp_video_fh(file);
> +	struct isp_video *video = video_drvdata(file);
> +	int ret;
> +
> +	mutex_lock(&video->queue_lock);
> +	ret = vb2_prepare_buf(&vfh->queue, video->video.v4l2_dev->mdev, b);
> +	mutex_unlock(&video->queue_lock);
> +
> +	return ret;

Also:

#include <linux/cleanup.h>

...

	guard(mutex)(&video->queue_lock);

	return vb2_prepare_buf(&vfh->queue, video->video.v4l2_dev->mdev, b);

Same for create_bufs implementation.


> +}
> +
>  static int
>  isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
>  {
> @@ -1303,7 +1344,9 @@ static const struct v4l2_ioctl_ops isp_video_ioctl_ops = {
>  	.vidioc_g_parm			= isp_video_get_param,
>  	.vidioc_s_parm			= isp_video_set_param,
>  	.vidioc_reqbufs			= isp_video_reqbufs,
> +	.vidioc_create_bufs		= isp_video_create_bufs,
>  	.vidioc_querybuf		= isp_video_querybuf,
> +	.vidioc_prepare_buf		= isp_video_prepare_buf,
>  	.vidioc_qbuf			= isp_video_qbuf,
>  	.vidioc_dqbuf			= isp_video_dqbuf,
>  	.vidioc_streamon		= isp_video_streamon,

-- 
Kind regards,

Sakari Ailus

  reply	other threads:[~2025-10-22  8:06 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 13:26 [PATCH 00/14] media: omap3isp: v4l2-compliance fixes Hans Verkuil
2025-10-17 13:26 ` [PATCH 01/14] media: omap3isp: configure entity functions Hans Verkuil
2025-10-17 13:26 ` [PATCH 02/14] media: omap3isp: add V4L2_CAP_IO_MC and don't set bus_info Hans Verkuil
2025-10-17 13:26 ` [PATCH 03/14] media: omap3isp: isp_video_mbus_to_pix/pix_to_mbus fixes Hans Verkuil
2025-10-22  7:48   ` Sakari Ailus
2025-12-01  8:27     ` Hans Verkuil
2025-12-01 10:22       ` Sakari Ailus
2025-12-01 12:56         ` Sakari Ailus
2025-12-01 15:35           ` Hans Verkuil
2025-12-01 16:43             ` Sakari Ailus
2025-12-02  7:18               ` Hans Verkuil
2025-10-17 13:26 ` [PATCH 04/14] media: omap3isp: implement enum_fmt_vid_cap/out Hans Verkuil
2025-10-22  7:56   ` Sakari Ailus
2025-12-01  8:40     ` Hans Verkuil
2025-12-01 11:35       ` Sakari Ailus
2025-12-01 13:44         ` Hans Verkuil
2025-12-01 15:27           ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 05/14] media: omap3isp: use V4L2_COLORSPACE_SRGB instead of _JPEG Hans Verkuil
2025-10-17 13:26 ` [PATCH 06/14] media: omap3isp: set initial format Hans Verkuil
2025-10-17 13:26 ` [PATCH 07/14] media: omap3isp: rework isp_video_try/set_format Hans Verkuil
2025-10-22  8:04   ` Sakari Ailus
2025-12-01  8:48     ` Hans Verkuil
2025-12-01 12:42       ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 08/14] media: omap3isp: implement create/prepare_bufs Hans Verkuil
2025-10-22  8:06   ` Sakari Ailus [this message]
2025-12-01  8:54     ` Hans Verkuil
2025-12-01 12:42       ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 09/14] media: omap3isp: better VIDIOC_G/S_PARM handling Hans Verkuil
2025-10-22  8:09   ` Sakari Ailus
2025-12-01 10:28     ` Hans Verkuil
2025-12-01 13:40       ` Hans Verkuil
2025-12-01 15:10         ` Sakari Ailus
2025-10-17 13:26 ` [PATCH 10/14] media: omap3isp: support ctrl events for isppreview Hans Verkuil
2025-10-17 13:26 ` [PATCH 11/14] media: omap3isp: ispccp2: always clamp in ccp2_try_format() Hans Verkuil
2025-10-17 13:26 ` [PATCH 12/14] media: omap3isp: isppreview: always clamp in preview_try_format() Hans Verkuil
2025-10-17 13:26 ` [PATCH 13/14] DO NOT MERGE: media: omap3isp: change default resolution to 864x648 Hans Verkuil
2025-10-17 13:26 ` [PATCH 14/14] DO NOT MERGE: omap3-beagle-xm.dts: add Leopard Imaging li5m03 support Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aPiQbZBFfzzWvCbV@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox