public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 08/14] media: omap3isp: implement create/prepare_bufs
Date: Mon, 1 Dec 2025 09:54:50 +0100	[thread overview]
Message-ID: <ffb6123b-40d3-43bb-b42e-bc3f3a58a4c2@kernel.org> (raw)
In-Reply-To: <aPiQbZBFfzzWvCbV@kekkonen.localdomain>

On 22/10/2025 10:06, Sakari Ailus wrote:
> 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.

Hmm, I'm hesitant to do that for two reasons:

1) Consistency with existing vb2 callbacks
2) It's harder to backport this to older kernels.

Since this is an old driver, the chances someone might want to backport this
to an old kernel is higher than usual.

If you really want this, then I prefer to make a new patch that introduces
the guards for all vb2 callbacks in this driver.

Regards,

	Hans

> 
> 
>> +}
>> +
>>  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,
> 


  reply	other threads:[~2025-12-01  8:54 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
2025-12-01  8:54     ` Hans Verkuil [this message]
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=ffb6123b-40d3-43bb-b42e-bc3f3a58a4c2@kernel.org \
    --to=hverkuil+cisco@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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