mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
media: uvcvideo: Remove duplicated cap/out code
The *_vid_cap and *_vid_out helpers seem to be identical: - Remove all the cap/out duplicated code. - Remove s/g_parm helpers - Reorder uvc_ioctl_ops And now that we are at it, fix a comment for uvc_acquire_privileges() Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Link: https://lore.kernel.org/r/20241202-uvc-dup-cap-out-v3-1-d40b11bb74b7@chromium.org Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
7309f3e2b7
commit
840fb2c339
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "uvcvideo.h"
|
||||
|
||||
static int uvc_acquire_privileges(struct uvc_fh *handle);
|
||||
|
||||
static int uvc_control_add_xu_mapping(struct uvc_video_chain *chain,
|
||||
struct uvc_control_mapping *map,
|
||||
const struct uvc_xu_control_mapping *xmap)
|
||||
|
@ -361,9 +363,11 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int uvc_v4l2_get_format(struct uvc_streaming *stream,
|
||||
static int uvc_ioctl_g_fmt(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
const struct uvc_format *format;
|
||||
const struct uvc_frame *frame;
|
||||
int ret = 0;
|
||||
|
@ -395,14 +399,20 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int uvc_v4l2_set_format(struct uvc_streaming *stream,
|
||||
static int uvc_ioctl_s_fmt(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
struct uvc_streaming_control probe;
|
||||
const struct uvc_format *format;
|
||||
const struct uvc_frame *frame;
|
||||
int ret;
|
||||
|
||||
ret = uvc_acquire_privileges(handle);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (fmt->type != stream->type)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -426,10 +436,12 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
|
||||
static int uvc_ioctl_g_parm(struct file *file, void *fh,
|
||||
struct v4l2_streamparm *parm)
|
||||
{
|
||||
u32 numerator, denominator;
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
|
||||
if (parm->type != stream->type)
|
||||
return -EINVAL;
|
||||
|
@ -461,9 +473,11 @@ static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
|
||||
static int uvc_ioctl_s_parm(struct file *file, void *fh,
|
||||
struct v4l2_streamparm *parm)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
struct uvc_streaming_control probe;
|
||||
struct v4l2_fract timeperframe;
|
||||
const struct uvc_format *format;
|
||||
|
@ -472,6 +486,10 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
|
|||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
ret = uvc_acquire_privileges(handle);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (parm->type != stream->type)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -573,6 +591,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
|
|||
* - VIDIOC_S_INPUT
|
||||
* - VIDIOC_S_PARM
|
||||
* - VIDIOC_S_FMT
|
||||
* - VIDIOC_CREATE_BUFS
|
||||
* - VIDIOC_REQBUFS
|
||||
*/
|
||||
static int uvc_acquire_privileges(struct uvc_fh *handle)
|
||||
|
@ -685,11 +704,13 @@ static int uvc_ioctl_querycap(struct file *file, void *fh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int uvc_ioctl_enum_fmt(struct uvc_streaming *stream,
|
||||
static int uvc_ioctl_enum_fmt(struct file *file, void *fh,
|
||||
struct v4l2_fmtdesc *fmt)
|
||||
{
|
||||
const struct uvc_format *format;
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
enum v4l2_buf_type type = fmt->type;
|
||||
const struct uvc_format *format;
|
||||
u32 index = fmt->index;
|
||||
|
||||
if (fmt->type != stream->type || fmt->index >= stream->nformats)
|
||||
|
@ -707,81 +728,7 @@ static int uvc_ioctl_enum_fmt(struct uvc_streaming *stream,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int uvc_ioctl_enum_fmt_vid_cap(struct file *file, void *fh,
|
||||
struct v4l2_fmtdesc *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
|
||||
return uvc_ioctl_enum_fmt(stream, fmt);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_enum_fmt_vid_out(struct file *file, void *fh,
|
||||
struct v4l2_fmtdesc *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
|
||||
return uvc_ioctl_enum_fmt(stream, fmt);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_g_fmt_vid_cap(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
|
||||
return uvc_v4l2_get_format(stream, fmt);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_g_fmt_vid_out(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
|
||||
return uvc_v4l2_get_format(stream, fmt);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_s_fmt_vid_cap(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
int ret;
|
||||
|
||||
ret = uvc_acquire_privileges(handle);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return uvc_v4l2_set_format(stream, fmt);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_s_fmt_vid_out(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
int ret;
|
||||
|
||||
ret = uvc_acquire_privileges(handle);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return uvc_v4l2_set_format(stream, fmt);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_try_fmt_vid_cap(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
struct uvc_streaming_control probe;
|
||||
|
||||
return uvc_v4l2_try_format(stream, fmt, &probe, NULL, NULL);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_try_fmt_vid_out(struct file *file, void *fh,
|
||||
static int uvc_ioctl_try_fmt(struct file *file, void *fh,
|
||||
struct v4l2_format *fmt)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
|
@ -1212,29 +1159,6 @@ static int uvc_ioctl_g_selection(struct file *file, void *fh,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int uvc_ioctl_g_parm(struct file *file, void *fh,
|
||||
struct v4l2_streamparm *parm)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
|
||||
return uvc_v4l2_get_streamparm(stream, parm);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_s_parm(struct file *file, void *fh,
|
||||
struct v4l2_streamparm *parm)
|
||||
{
|
||||
struct uvc_fh *handle = fh;
|
||||
struct uvc_streaming *stream = handle->stream;
|
||||
int ret;
|
||||
|
||||
ret = uvc_acquire_privileges(handle);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return uvc_v4l2_set_streamparm(stream, parm);
|
||||
}
|
||||
|
||||
static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
|
||||
struct v4l2_frmsizeenum *fsize)
|
||||
{
|
||||
|
@ -1543,15 +1467,17 @@ static unsigned long uvc_v4l2_get_unmapped_area(struct file *file,
|
|||
#endif
|
||||
|
||||
const struct v4l2_ioctl_ops uvc_ioctl_ops = {
|
||||
.vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt,
|
||||
.vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt,
|
||||
.vidioc_s_fmt_vid_cap = uvc_ioctl_s_fmt,
|
||||
.vidioc_s_fmt_vid_out = uvc_ioctl_s_fmt,
|
||||
.vidioc_g_parm = uvc_ioctl_g_parm,
|
||||
.vidioc_s_parm = uvc_ioctl_s_parm,
|
||||
.vidioc_querycap = uvc_ioctl_querycap,
|
||||
.vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt_vid_cap,
|
||||
.vidioc_enum_fmt_vid_out = uvc_ioctl_enum_fmt_vid_out,
|
||||
.vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt_vid_cap,
|
||||
.vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt_vid_out,
|
||||
.vidioc_s_fmt_vid_cap = uvc_ioctl_s_fmt_vid_cap,
|
||||
.vidioc_s_fmt_vid_out = uvc_ioctl_s_fmt_vid_out,
|
||||
.vidioc_try_fmt_vid_cap = uvc_ioctl_try_fmt_vid_cap,
|
||||
.vidioc_try_fmt_vid_out = uvc_ioctl_try_fmt_vid_out,
|
||||
.vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt,
|
||||
.vidioc_enum_fmt_vid_out = uvc_ioctl_enum_fmt,
|
||||
.vidioc_try_fmt_vid_cap = uvc_ioctl_try_fmt,
|
||||
.vidioc_try_fmt_vid_out = uvc_ioctl_try_fmt,
|
||||
.vidioc_reqbufs = uvc_ioctl_reqbufs,
|
||||
.vidioc_querybuf = uvc_ioctl_querybuf,
|
||||
.vidioc_qbuf = uvc_ioctl_qbuf,
|
||||
|
@ -1570,8 +1496,6 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
|
|||
.vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls,
|
||||
.vidioc_querymenu = uvc_ioctl_querymenu,
|
||||
.vidioc_g_selection = uvc_ioctl_g_selection,
|
||||
.vidioc_g_parm = uvc_ioctl_g_parm,
|
||||
.vidioc_s_parm = uvc_ioctl_s_parm,
|
||||
.vidioc_enum_framesizes = uvc_ioctl_enum_framesizes,
|
||||
.vidioc_enum_frameintervals = uvc_ioctl_enum_frameintervals,
|
||||
.vidioc_subscribe_event = uvc_ioctl_subscribe_event,
|
||||
|
|
Loading…
Reference in New Issue
Block a user