Commit 2e19bfc8 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vivid: drop bitmap and clipping output overlay support

This test driver is the only remaining driver still using
the clipping and bitmap method. Drop support for this so
we can remove this in the V4L2 API as well.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ccaa9d50
......@@ -834,7 +834,6 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev)
vfree(dev->scaled_line);
vfree(dev->blended_line);
vfree(dev->edid);
vfree(dev->bitmap_out);
tpg_free(&dev->tpg);
kfree(dev->query_dv_timings_qmenu);
kfree(dev->query_dv_timings_qmenu_strings);
......
......@@ -22,8 +22,6 @@
#define dprintk(dev, level, fmt, arg...) \
v4l2_dbg(level, vivid_debug, &dev->v4l2_dev, fmt, ## arg)
/* The maximum number of clip rectangles */
#define MAX_CLIPS 16
/* The maximum number of inputs */
#define MAX_INPUTS 16
/* The maximum number of outputs */
......@@ -372,10 +370,6 @@ struct vivid_dev {
void *fb_vbase_out;
bool overlay_out_enabled;
int overlay_out_top, overlay_out_left;
void *bitmap_out;
struct v4l2_clip clips_out[MAX_CLIPS];
struct v4l2_clip try_clips_out[MAX_CLIPS];
unsigned clipcount_out;
unsigned fbuf_out_flags;
u32 chromakey_out;
u8 global_alpha_out;
......
......@@ -53,31 +53,10 @@ static void copy_pix(struct vivid_dev *dev, int win_y, int win_x,
u16 *cap, const u16 *osd)
{
u16 out;
int left = dev->overlay_out_left;
int top = dev->overlay_out_top;
int fb_x = win_x + left;
int fb_y = win_y + top;
int i;
out = *cap;
*cap = *osd;
if (dev->bitmap_out) {
const u8 *p = dev->bitmap_out;
unsigned stride = (dev->compose_out.width + 7) / 8;
win_x -= dev->compose_out.left;
win_y -= dev->compose_out.top;
if (!(p[stride * win_y + win_x / 8] & (1 << (win_x & 7))))
return;
}
for (i = 0; i < dev->clipcount_out; i++) {
struct v4l2_rect *r = &dev->clips_out[i].c;
if (fb_y >= r->top && fb_y < r->top + r->height &&
fb_x >= r->left && fb_x < r->left + r->width)
return;
}
if ((dev->fbuf_out_flags & V4L2_FBUF_FLAG_CHROMAKEY) &&
*osd != dev->chromakey_out)
return;
......@@ -251,7 +230,7 @@ static noinline_for_stack int vivid_copy_buffer(struct vivid_dev *dev, unsigned
u8 *voutbuf;
u8 *vosdbuf = NULL;
unsigned y;
bool blend = dev->bitmap_out || dev->clipcount_out || dev->fbuf_out_flags;
bool blend = dev->fbuf_out_flags;
/* Coarse scaling with Bresenham */
unsigned vid_out_int_part;
unsigned vid_out_fract_part;
......
......@@ -793,11 +793,6 @@ int vivid_vid_out_s_selection(struct file *file, void *fh, struct v4l2_selection
}
s->r.top *= factor;
s->r.height *= factor;
if (dev->bitmap_out && (compose->width != s->r.width ||
compose->height != s->r.height)) {
vfree(dev->bitmap_out);
dev->bitmap_out = NULL;
}
*compose = s->r;
break;
default:
......@@ -836,7 +831,6 @@ int vidioc_g_fmt_vid_out_overlay(struct file *file, void *priv,
struct vivid_dev *dev = video_drvdata(file);
const struct v4l2_rect *compose = &dev->compose_out;
struct v4l2_window *win = &f->fmt.win;
unsigned clipcount = win->clipcount;
if (!dev->has_fb)
return -EINVAL;
......@@ -844,22 +838,9 @@ int vidioc_g_fmt_vid_out_overlay(struct file *file, void *priv,
win->w.left = dev->overlay_out_left;
win->w.width = compose->width;
win->w.height = compose->height;
win->clipcount = dev->clipcount_out;
win->field = V4L2_FIELD_ANY;
win->chromakey = dev->chromakey_out;
win->global_alpha = dev->global_alpha_out;
if (clipcount > dev->clipcount_out)
clipcount = dev->clipcount_out;
if (dev->bitmap_out == NULL)
win->bitmap = NULL;
else if (win->bitmap) {
if (copy_to_user(win->bitmap, dev->bitmap_out,
((dev->compose_out.width + 7) / 8) * dev->compose_out.height))
return -EFAULT;
}
if (clipcount && win->clips)
memcpy(win->clips, dev->clips_out,
clipcount * sizeof(dev->clips_out[0]));
return 0;
}
......@@ -869,7 +850,6 @@ int vidioc_try_fmt_vid_out_overlay(struct file *file, void *priv,
struct vivid_dev *dev = video_drvdata(file);
const struct v4l2_rect *compose = &dev->compose_out;
struct v4l2_window *win = &f->fmt.win;
int i, j;
if (!dev->has_fb)
return -EINVAL;
......@@ -884,38 +864,6 @@ int vidioc_try_fmt_vid_out_overlay(struct file *file, void *priv,
* so always set this to ANY.
*/
win->field = V4L2_FIELD_ANY;
if (win->clipcount && !win->clips)
win->clipcount = 0;
if (win->clipcount > MAX_CLIPS)
win->clipcount = MAX_CLIPS;
if (win->clipcount) {
memcpy(dev->try_clips_out, win->clips,
win->clipcount * sizeof(dev->clips_out[0]));
for (i = 0; i < win->clipcount; i++) {
struct v4l2_rect *r = &dev->try_clips_out[i].c;
r->top = clamp_t(s32, r->top, 0, dev->display_height - 1);
r->height = clamp_t(s32, r->height, 1, dev->display_height - r->top);
r->left = clamp_t(u32, r->left, 0, dev->display_width - 1);
r->width = clamp_t(u32, r->width, 1, dev->display_width - r->left);
}
/*
* Yeah, so sue me, it's an O(n^2) algorithm. But n is a small
* number and it's typically a one-time deal.
*/
for (i = 0; i < win->clipcount - 1; i++) {
struct v4l2_rect *r1 = &dev->try_clips_out[i].c;
for (j = i + 1; j < win->clipcount; j++) {
struct v4l2_rect *r2 = &dev->try_clips_out[j].c;
if (v4l2_rect_overlap(r1, r2))
return -EINVAL;
}
}
memcpy(win->clips, dev->try_clips_out,
win->clipcount * sizeof(dev->clips_out[0]));
}
return 0;
}
......@@ -923,34 +871,14 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
struct v4l2_format *f)
{
struct vivid_dev *dev = video_drvdata(file);
const struct v4l2_rect *compose = &dev->compose_out;
struct v4l2_window *win = &f->fmt.win;
int ret = vidioc_try_fmt_vid_out_overlay(file, priv, f);
unsigned bitmap_size = ((compose->width + 7) / 8) * compose->height;
unsigned clips_size = win->clipcount * sizeof(dev->clips_out[0]);
void *new_bitmap = NULL;
if (ret)
return ret;
if (win->bitmap) {
new_bitmap = vzalloc(bitmap_size);
if (!new_bitmap)
return -ENOMEM;
if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
vfree(new_bitmap);
return -EFAULT;
}
}
dev->overlay_out_top = win->w.top;
dev->overlay_out_left = win->w.left;
vfree(dev->bitmap_out);
dev->bitmap_out = new_bitmap;
dev->clipcount_out = win->clipcount;
if (dev->clipcount_out)
memcpy(dev->clips_out, dev->try_clips_out, clips_size);
dev->chromakey_out = win->chromakey;
dev->global_alpha_out = win->global_alpha;
return ret;
......@@ -975,8 +903,6 @@ int vivid_vid_out_g_fbuf(struct file *file, void *fh,
struct vivid_dev *dev = video_drvdata(file);
a->capability = V4L2_FBUF_CAP_EXTERNOVERLAY |
V4L2_FBUF_CAP_BITMAP_CLIPPING |
V4L2_FBUF_CAP_LIST_CLIPPING |
V4L2_FBUF_CAP_CHROMAKEY |
V4L2_FBUF_CAP_SRC_CHROMAKEY |
V4L2_FBUF_CAP_GLOBAL_ALPHA |
......
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