Commit 99ba0703 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: v4l2-core: drop v4l2_window clipping and bitmap support

There are no longer any drivers that support clipping and bitmap
support for the capture or output overlay interfaces, so drop
this.

Always set the bitmap, clips and clipcount fields to 0, and
remove the compat32 support.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 2e19bfc8
...@@ -38,18 +38,13 @@ ...@@ -38,18 +38,13 @@
* data to the routine. * data to the routine.
*/ */
struct v4l2_clip32 {
struct v4l2_rect c;
compat_caddr_t next;
};
struct v4l2_window32 { struct v4l2_window32 {
struct v4l2_rect w; struct v4l2_rect w;
__u32 field; /* enum v4l2_field */ __u32 field; /* enum v4l2_field */
__u32 chromakey; __u32 chromakey;
compat_caddr_t clips; /* actually struct v4l2_clip32 * */ compat_caddr_t clips; /* always NULL */
__u32 clipcount; __u32 clipcount; /* always 0 */
compat_caddr_t bitmap; compat_caddr_t bitmap; /* always NULL */
__u8 global_alpha; __u8 global_alpha;
}; };
...@@ -65,17 +60,12 @@ static int get_v4l2_window32(struct v4l2_window *p64, ...@@ -65,17 +60,12 @@ static int get_v4l2_window32(struct v4l2_window *p64,
.w = w32.w, .w = w32.w,
.field = w32.field, .field = w32.field,
.chromakey = w32.chromakey, .chromakey = w32.chromakey,
.clips = (void __force *)compat_ptr(w32.clips), .clips = NULL,
.clipcount = w32.clipcount, .clipcount = 0,
.bitmap = compat_ptr(w32.bitmap), .bitmap = NULL,
.global_alpha = w32.global_alpha, .global_alpha = w32.global_alpha,
}; };
if (p64->clipcount > 2048)
return -EINVAL;
if (!p64->clipcount)
p64->clips = NULL;
return 0; return 0;
} }
...@@ -89,16 +79,13 @@ static int put_v4l2_window32(struct v4l2_window *p64, ...@@ -89,16 +79,13 @@ static int put_v4l2_window32(struct v4l2_window *p64,
.w = p64->w, .w = p64->w,
.field = p64->field, .field = p64->field,
.chromakey = p64->chromakey, .chromakey = p64->chromakey,
.clips = (uintptr_t)p64->clips, .clips = 0,
.clipcount = p64->clipcount, .clipcount = 0,
.bitmap = ptr_to_compat(p64->bitmap), .bitmap = 0,
.global_alpha = p64->global_alpha, .global_alpha = p64->global_alpha,
}; };
/* copy everything except the clips pointer */ if (copy_to_user(p32, &w32, sizeof(w32)))
if (copy_to_user(p32, &w32, offsetof(struct v4l2_window32, clips)) ||
copy_to_user(&p32->clipcount, &w32.clipcount,
sizeof(w32) - offsetof(struct v4l2_window32, clipcount)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -1043,29 +1030,6 @@ int v4l2_compat_get_array_args(struct file *file, void *mbuf, ...@@ -1043,29 +1030,6 @@ int v4l2_compat_get_array_args(struct file *file, void *mbuf,
memset(mbuf, 0, array_size); memset(mbuf, 0, array_size);
switch (cmd) { switch (cmd) {
case VIDIOC_G_FMT32:
case VIDIOC_S_FMT32:
case VIDIOC_TRY_FMT32: {
struct v4l2_format *f64 = arg;
struct v4l2_clip *c64 = mbuf;
struct v4l2_clip32 __user *c32 = user_ptr;
u32 clipcount = f64->fmt.win.clipcount;
if ((f64->type != V4L2_BUF_TYPE_VIDEO_OVERLAY &&
f64->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY) ||
clipcount == 0)
return 0;
if (clipcount > 2048)
return -EINVAL;
while (clipcount--) {
if (copy_from_user(c64, c32, sizeof(c64->c)))
return -EFAULT;
c64->next = NULL;
c64++;
c32++;
}
break;
}
#ifdef CONFIG_COMPAT_32BIT_TIME #ifdef CONFIG_COMPAT_32BIT_TIME
case VIDIOC_QUERYBUF32_TIME32: case VIDIOC_QUERYBUF32_TIME32:
case VIDIOC_QBUF32_TIME32: case VIDIOC_QBUF32_TIME32:
...@@ -1136,28 +1100,6 @@ int v4l2_compat_put_array_args(struct file *file, void __user *user_ptr, ...@@ -1136,28 +1100,6 @@ int v4l2_compat_put_array_args(struct file *file, void __user *user_ptr,
int err = 0; int err = 0;
switch (cmd) { switch (cmd) {
case VIDIOC_G_FMT32:
case VIDIOC_S_FMT32:
case VIDIOC_TRY_FMT32: {
struct v4l2_format *f64 = arg;
struct v4l2_clip *c64 = mbuf;
struct v4l2_clip32 __user *c32 = user_ptr;
u32 clipcount = f64->fmt.win.clipcount;
if ((f64->type != V4L2_BUF_TYPE_VIDEO_OVERLAY &&
f64->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY) ||
clipcount == 0)
return 0;
if (clipcount > 2048)
return -EINVAL;
while (clipcount--) {
if (copy_to_user(c32, c64, sizeof(c64->c)))
return -EFAULT;
c64++;
c32++;
}
break;
}
#ifdef CONFIG_COMPAT_32BIT_TIME #ifdef CONFIG_COMPAT_32BIT_TIME
case VIDIOC_QUERYBUF32_TIME32: case VIDIOC_QUERYBUF32_TIME32:
case VIDIOC_QBUF32_TIME32: case VIDIOC_QBUF32_TIME32:
......
...@@ -310,14 +310,10 @@ static void v4l_print_format(const void *arg, bool write_only) ...@@ -310,14 +310,10 @@ static void v4l_print_format(const void *arg, bool write_only)
case V4L2_BUF_TYPE_VIDEO_OVERLAY: case V4L2_BUF_TYPE_VIDEO_OVERLAY:
case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
win = &p->fmt.win; win = &p->fmt.win;
/* Note: we can't print the clip list here since the clips pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, global_alpha=0x%02x\n",
* pointer is a userspace pointer, not a kernelspace
* pointer. */
pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
win->w.width, win->w.height, win->w.left, win->w.top, win->w.width, win->w.height, win->w.left, win->w.top,
prt_names(win->field, v4l2_field_names), prt_names(win->field, v4l2_field_names),
win->chromakey, win->clipcount, win->clips, win->chromakey, win->global_alpha);
win->bitmap, win->global_alpha);
break; break;
case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_CAPTURE:
case V4L2_BUF_TYPE_VBI_OUTPUT: case V4L2_BUF_TYPE_VBI_OUTPUT:
...@@ -1618,29 +1614,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, ...@@ -1618,29 +1614,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
if (ret) if (ret)
return ret; return ret;
/*
* fmt can't be cleared for these overlay types due to the 'clips'
* 'clipcount' and 'bitmap' pointers in struct v4l2_window.
* Those are provided by the user. So handle these two overlay types
* first, and then just do a simple memset for the other types.
*/
switch (p->type) {
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: {
struct v4l2_clip *clips = p->fmt.win.clips;
u32 clipcount = p->fmt.win.clipcount;
void __user *bitmap = p->fmt.win.bitmap;
memset(&p->fmt, 0, sizeof(p->fmt)); memset(&p->fmt, 0, sizeof(p->fmt));
p->fmt.win.clips = clips;
p->fmt.win.clipcount = clipcount;
p->fmt.win.bitmap = bitmap;
break;
}
default:
memset(&p->fmt, 0, sizeof(p->fmt));
break;
}
switch (p->type) { switch (p->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
...@@ -1728,6 +1702,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, ...@@ -1728,6 +1702,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
if (unlikely(!ops->vidioc_s_fmt_vid_overlay)) if (unlikely(!ops->vidioc_s_fmt_vid_overlay))
break; break;
memset_after(p, 0, fmt.win); memset_after(p, 0, fmt.win);
p->fmt.win.clips = NULL;
p->fmt.win.clipcount = 0;
p->fmt.win.bitmap = NULL;
return ops->vidioc_s_fmt_vid_overlay(file, fh, arg); return ops->vidioc_s_fmt_vid_overlay(file, fh, arg);
case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_CAPTURE:
if (unlikely(!ops->vidioc_s_fmt_vbi_cap)) if (unlikely(!ops->vidioc_s_fmt_vbi_cap))
...@@ -1759,6 +1736,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, ...@@ -1759,6 +1736,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
if (unlikely(!ops->vidioc_s_fmt_vid_out_overlay)) if (unlikely(!ops->vidioc_s_fmt_vid_out_overlay))
break; break;
memset_after(p, 0, fmt.win); memset_after(p, 0, fmt.win);
p->fmt.win.clips = NULL;
p->fmt.win.clipcount = 0;
p->fmt.win.bitmap = NULL;
return ops->vidioc_s_fmt_vid_out_overlay(file, fh, arg); return ops->vidioc_s_fmt_vid_out_overlay(file, fh, arg);
case V4L2_BUF_TYPE_VBI_OUTPUT: case V4L2_BUF_TYPE_VBI_OUTPUT:
if (unlikely(!ops->vidioc_s_fmt_vbi_out)) if (unlikely(!ops->vidioc_s_fmt_vbi_out))
...@@ -1830,6 +1810,9 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, ...@@ -1830,6 +1810,9 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
if (unlikely(!ops->vidioc_try_fmt_vid_overlay)) if (unlikely(!ops->vidioc_try_fmt_vid_overlay))
break; break;
memset_after(p, 0, fmt.win); memset_after(p, 0, fmt.win);
p->fmt.win.clips = NULL;
p->fmt.win.clipcount = 0;
p->fmt.win.bitmap = NULL;
return ops->vidioc_try_fmt_vid_overlay(file, fh, arg); return ops->vidioc_try_fmt_vid_overlay(file, fh, arg);
case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_CAPTURE:
if (unlikely(!ops->vidioc_try_fmt_vbi_cap)) if (unlikely(!ops->vidioc_try_fmt_vbi_cap))
...@@ -1861,6 +1844,9 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, ...@@ -1861,6 +1844,9 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay)) if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay))
break; break;
memset_after(p, 0, fmt.win); memset_after(p, 0, fmt.win);
p->fmt.win.clips = NULL;
p->fmt.win.clipcount = 0;
p->fmt.win.bitmap = NULL;
return ops->vidioc_try_fmt_vid_out_overlay(file, fh, arg); return ops->vidioc_try_fmt_vid_out_overlay(file, fh, arg);
case V4L2_BUF_TYPE_VBI_OUTPUT: case V4L2_BUF_TYPE_VBI_OUTPUT:
if (unlikely(!ops->vidioc_try_fmt_vbi_out)) if (unlikely(!ops->vidioc_try_fmt_vbi_out))
...@@ -3134,27 +3120,6 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, ...@@ -3134,27 +3120,6 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
} }
break; break;
} }
case VIDIOC_G_FMT:
case VIDIOC_S_FMT:
case VIDIOC_TRY_FMT: {
struct v4l2_format *fmt = parg;
if (fmt->type != V4L2_BUF_TYPE_VIDEO_OVERLAY &&
fmt->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY)
break;
if (fmt->fmt.win.clipcount > 2048)
return -EINVAL;
if (!fmt->fmt.win.clipcount)
break;
*user_ptr = (void __user *)fmt->fmt.win.clips;
*kernel_ptr = (void **)&fmt->fmt.win.clips;
*array_size = sizeof(struct v4l2_clip)
* fmt->fmt.win.clipcount;
ret = 1;
break;
}
case VIDIOC_SUBDEV_G_ROUTING: case VIDIOC_SUBDEV_G_ROUTING:
case VIDIOC_SUBDEV_S_ROUTING: { case VIDIOC_SUBDEV_S_ROUTING: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment