Re: [PATCH v2 3/4] media: uvcvideo: Allow changing noparam on the fly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 18, 2024 at 09:39:10PM +0000, Ricardo Ribalda wrote:
> Right now the parameter value is read during video_registration and
> cannot be changed afterwards, despite its permissions 0644, that makes
> the user believe that the value can be written.

Well, it can still be written, and will apply to new devices. There's
value in making it fully dynamic though.

> 
> The parameter only affects the beviour of uvc_queue_buffer_complete(),

s/beviour/behaviour/

> with only one check per buffer.
> 
> We can read the value directly from uvc_queue_buffer_complete() and
> therefore allowing changing it with sysfs on the fly.
> 
> Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 2 +-
>  drivers/media/usb/uvc/uvc_queue.c  | 6 ++----
>  drivers/media/usb/uvc/uvcvideo.h   | 4 +---
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index 091145743872..10812a841587 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -1995,7 +1995,7 @@ int uvc_register_video_device(struct uvc_device *dev,
>  	int ret;
>  
>  	/* Initialize the video buffers queue. */
> -	ret = uvc_queue_init(queue, type, !uvc_no_drop_param);
> +	ret = uvc_queue_init(queue, type);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
> index f8464f0aae1b..2ee142621042 100644
> --- a/drivers/media/usb/uvc/uvc_queue.c
> +++ b/drivers/media/usb/uvc/uvc_queue.c
> @@ -208,8 +208,7 @@ static const struct vb2_ops uvc_meta_queue_qops = {
>  	.stop_streaming = uvc_stop_streaming,
>  };
>  
> -int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
> -		    int drop_corrupted)
> +int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
>  {
>  	int ret;
>  
> @@ -239,7 +238,6 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
>  	mutex_init(&queue->mutex);
>  	spin_lock_init(&queue->irqlock);
>  	INIT_LIST_HEAD(&queue->irqqueue);
> -	queue->flags = drop_corrupted ? UVC_QUEUE_DROP_CORRUPTED : 0;
>  
>  	return 0;
>  }
> @@ -472,7 +470,7 @@ static void uvc_queue_buffer_complete(struct kref *ref)
>  	struct vb2_buffer *vb = &buf->buf.vb2_buf;
>  	struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
>  
> -	if ((queue->flags & UVC_QUEUE_DROP_CORRUPTED) && buf->error) {
> +	if (buf->error && !uvc_no_drop_param) {

As this is the only location where the uvc_no_drop_param variable is
read, I don't expect any race condition.

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

>  		uvc_queue_buffer_requeue(queue, buf);
>  		return;
>  	}
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index 07f9921d83f2..ebbd8afcf136 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -316,7 +316,6 @@ struct uvc_buffer {
>  };
>  
>  #define UVC_QUEUE_DISCONNECTED		(1 << 0)
> -#define UVC_QUEUE_DROP_CORRUPTED	(1 << 1)
>  
>  struct uvc_video_queue {
>  	struct vb2_queue queue;
> @@ -674,8 +673,7 @@ extern struct uvc_driver uvc_driver;
>  struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id);
>  
>  /* Video buffers queue management. */
> -int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
> -		   int drop_corrupted);
> +int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type);
>  void uvc_queue_release(struct uvc_video_queue *queue);
>  int uvc_request_buffers(struct uvc_video_queue *queue,
>  			struct v4l2_requestbuffers *rb);

-- 
Regards,

Laurent Pinchart




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux