diff options
Diffstat (limited to 'drivers/media/pci/saa7134/saa7134-video.c')
| -rw-r--r-- | drivers/media/pci/saa7134/saa7134-video.c | 515 |
1 files changed, 21 insertions, 494 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 5bc4b8fc8ebf..4a51b873e47a 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -1,19 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * * device driver for philips saa7134 based TV cards * video4linux video interface * * (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #include "saa7134.h" @@ -99,70 +90,58 @@ static int video_out[][9] = { static struct saa7134_format formats[] = { { - .name = "8 bpp gray", .fourcc = V4L2_PIX_FMT_GREY, .depth = 8, .pm = 0x06, },{ - .name = "15 bpp RGB, le", .fourcc = V4L2_PIX_FMT_RGB555, .depth = 16, .pm = 0x13 | 0x80, },{ - .name = "15 bpp RGB, be", .fourcc = V4L2_PIX_FMT_RGB555X, .depth = 16, .pm = 0x13 | 0x80, .bswap = 1, },{ - .name = "16 bpp RGB, le", .fourcc = V4L2_PIX_FMT_RGB565, .depth = 16, .pm = 0x10 | 0x80, },{ - .name = "16 bpp RGB, be", .fourcc = V4L2_PIX_FMT_RGB565X, .depth = 16, .pm = 0x10 | 0x80, .bswap = 1, },{ - .name = "24 bpp RGB, le", .fourcc = V4L2_PIX_FMT_BGR24, .depth = 24, .pm = 0x11, },{ - .name = "24 bpp RGB, be", .fourcc = V4L2_PIX_FMT_RGB24, .depth = 24, .pm = 0x11, .bswap = 1, },{ - .name = "32 bpp RGB, le", .fourcc = V4L2_PIX_FMT_BGR32, .depth = 32, .pm = 0x12, },{ - .name = "32 bpp RGB, be", .fourcc = V4L2_PIX_FMT_RGB32, .depth = 32, .pm = 0x12, .bswap = 1, .wswap = 1, },{ - .name = "4:2:2 packed, YUYV", .fourcc = V4L2_PIX_FMT_YUYV, .depth = 16, .pm = 0x00, .bswap = 1, .yuv = 1, },{ - .name = "4:2:2 packed, UYVY", .fourcc = V4L2_PIX_FMT_UYVY, .depth = 16, .pm = 0x00, .yuv = 1, },{ - .name = "4:2:2 planar, Y-Cb-Cr", .fourcc = V4L2_PIX_FMT_YUV422P, .depth = 16, .pm = 0x09, @@ -171,7 +150,6 @@ static struct saa7134_format formats[] = { .hshift = 1, .vshift = 0, },{ - .name = "4:2:0 planar, Y-Cb-Cr", .fourcc = V4L2_PIX_FMT_YUV420, .depth = 12, .pm = 0x0a, @@ -180,7 +158,6 @@ static struct saa7134_format formats[] = { .hshift = 1, .vshift = 1, },{ - .name = "4:2:0 planar, Y-Cb-Cr", .fourcc = V4L2_PIX_FMT_YVU420, .depth = 12, .pm = 0x0a, @@ -594,193 +571,6 @@ static void set_size(struct saa7134_dev *dev, int task, /* ------------------------------------------------------------------ */ -struct cliplist { - __u16 position; - __u8 enable; - __u8 disable; -}; - -static void set_cliplist(struct saa7134_dev *dev, int reg, - struct cliplist *cl, int entries, char *name) -{ - __u8 winbits = 0; - int i; - - for (i = 0; i < entries; i++) { - winbits |= cl[i].enable; - winbits &= ~cl[i].disable; - if (i < 15 && cl[i].position == cl[i+1].position) - continue; - saa_writeb(reg + 0, winbits); - saa_writeb(reg + 2, cl[i].position & 0xff); - saa_writeb(reg + 3, cl[i].position >> 8); - video_dbg("clip: %s winbits=%02x pos=%d\n", - name,winbits,cl[i].position); - reg += 8; - } - for (; reg < 0x400; reg += 8) { - saa_writeb(reg+ 0, 0); - saa_writeb(reg + 1, 0); - saa_writeb(reg + 2, 0); - saa_writeb(reg + 3, 0); - } -} - -static int clip_range(int val) -{ - if (val < 0) - val = 0; - return val; -} - -/* Sort into smallest position first order */ -static int cliplist_cmp(const void *a, const void *b) -{ - const struct cliplist *cla = a; - const struct cliplist *clb = b; - if (cla->position < clb->position) - return -1; - if (cla->position > clb->position) - return 1; - return 0; -} - -static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips, - int nclips, int interlace) -{ - struct cliplist col[16], row[16]; - int cols = 0, rows = 0, i; - int div = interlace ? 2 : 1; - - memset(col, 0, sizeof(col)); - memset(row, 0, sizeof(row)); - for (i = 0; i < nclips && i < 8; i++) { - col[cols].position = clip_range(clips[i].c.left); - col[cols].enable = (1 << i); - cols++; - col[cols].position = clip_range(clips[i].c.left+clips[i].c.width); - col[cols].disable = (1 << i); - cols++; - row[rows].position = clip_range(clips[i].c.top / div); - row[rows].enable = (1 << i); - rows++; - row[rows].position = clip_range((clips[i].c.top + clips[i].c.height) - / div); - row[rows].disable = (1 << i); - rows++; - } - sort(col, cols, sizeof col[0], cliplist_cmp, NULL); - sort(row, rows, sizeof row[0], cliplist_cmp, NULL); - set_cliplist(dev,0x380,col,cols,"cols"); - set_cliplist(dev,0x384,row,rows,"rows"); - return 0; -} - -static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win, bool try) -{ - enum v4l2_field field; - int maxw, maxh; - - if (!try && (dev->ovbuf.base == NULL || dev->ovfmt == NULL)) - return -EINVAL; - if (win->w.width < 48) - win->w.width = 48; - if (win->w.height < 32) - win->w.height = 32; - if (win->clipcount > 8) - win->clipcount = 8; - - win->chromakey = 0; - win->global_alpha = 0; - field = win->field; - maxw = dev->crop_current.width; - maxh = dev->crop_current.height; - - if (V4L2_FIELD_ANY == field) { - field = (win->w.height > maxh/2) - ? V4L2_FIELD_INTERLACED - : V4L2_FIELD_TOP; - } - switch (field) { - case V4L2_FIELD_TOP: - case V4L2_FIELD_BOTTOM: - maxh = maxh / 2; - break; - default: - field = V4L2_FIELD_INTERLACED; - break; - } - - win->field = field; - if (win->w.width > maxw) - win->w.width = maxw; - if (win->w.height > maxh) - win->w.height = maxh; - return 0; -} - -static int start_preview(struct saa7134_dev *dev) -{ - unsigned long base,control,bpl; - int err; - - err = verify_preview(dev, &dev->win, false); - if (0 != err) - return err; - - dev->ovfield = dev->win.field; - video_dbg("start_preview %dx%d+%d+%d %s field=%s\n", - dev->win.w.width, dev->win.w.height, - dev->win.w.left, dev->win.w.top, - dev->ovfmt->name, v4l2_field_names[dev->ovfield]); - - /* setup window + clipping */ - set_size(dev, TASK_B, dev->win.w.width, dev->win.w.height, - V4L2_FIELD_HAS_BOTH(dev->ovfield)); - setup_clipping(dev, dev->clips, dev->nclips, - V4L2_FIELD_HAS_BOTH(dev->ovfield)); - if (dev->ovfmt->yuv) - saa_andorb(SAA7134_DATA_PATH(TASK_B), 0x3f, 0x03); - else - saa_andorb(SAA7134_DATA_PATH(TASK_B), 0x3f, 0x01); - saa_writeb(SAA7134_OFMT_VIDEO_B, dev->ovfmt->pm | 0x20); - - /* dma: setup channel 1 (= Video Task B) */ - base = (unsigned long)dev->ovbuf.base; - base += dev->ovbuf.fmt.bytesperline * dev->win.w.top; - base += dev->ovfmt->depth/8 * dev->win.w.left; - bpl = dev->ovbuf.fmt.bytesperline; - control = SAA7134_RS_CONTROL_BURST_16; - if (dev->ovfmt->bswap) - control |= SAA7134_RS_CONTROL_BSWAP; - if (dev->ovfmt->wswap) - control |= SAA7134_RS_CONTROL_WSWAP; - if (V4L2_FIELD_HAS_BOTH(dev->ovfield)) { - saa_writel(SAA7134_RS_BA1(1),base); - saa_writel(SAA7134_RS_BA2(1),base+bpl); - saa_writel(SAA7134_RS_PITCH(1),bpl*2); - saa_writel(SAA7134_RS_CONTROL(1),control); - } else { - saa_writel(SAA7134_RS_BA1(1),base); - saa_writel(SAA7134_RS_BA2(1),base); - saa_writel(SAA7134_RS_PITCH(1),bpl); - saa_writel(SAA7134_RS_CONTROL(1),control); - } - - /* start dma */ - dev->ovenable = 1; - saa7134_set_dmabits(dev); - - return 0; -} - -static int stop_preview(struct saa7134_dev *dev) -{ - dev->ovenable = 0; - saa7134_set_dmabits(dev); - return 0; -} - /* * Media Controller helper functions */ @@ -846,7 +636,7 @@ static int buffer_activate(struct saa7134_dev *dev, { struct saa7134_dmaqueue *dmaq = buf->vb2.vb2_buf.vb2_queue->drv_priv; unsigned long base,control,bpl; - unsigned long bpl_uv,lines_uv,base2,base3,tmp; /* planar */ + unsigned long bpl_uv, lines_uv, base2, base3; /* planar */ video_dbg("buffer_activate buf=%p\n", buf); buf->top_seen = 0; @@ -892,7 +682,7 @@ static int buffer_activate(struct saa7134_dev *dev, base2 = base + bpl * dev->height; base3 = base2 + bpl_uv * lines_uv; if (dev->fmt->uvswap) - tmp = base2, base2 = base3, base3 = tmp; + swap(base2, base3); video_dbg("uv: bpl=%ld lines=%ld base2/3=%ld/%ld\n", bpl_uv,lines_uv,base2,base3); if (V4L2_FIELD_HAS_BOTH(dev->field)) { @@ -1031,8 +821,7 @@ int saa7134_vb2_start_streaming(struct vb2_queue *vq, unsigned int count) */ if ((dmaq == &dev->video_q && !vb2_is_streaming(&dev->vbi_vbq)) || (dmaq == &dev->vbi_q && !vb2_is_streaming(&dev->video_vbq))) - pm_qos_add_request(&dev->qos_request, - PM_QOS_CPU_DMA_LATENCY, 20); + cpu_latency_qos_add_request(&dev->qos_request, 20); dmaq->seq_nr = 0; return 0; @@ -1047,7 +836,7 @@ void saa7134_vb2_stop_streaming(struct vb2_queue *vq) if ((dmaq == &dev->video_q && !vb2_is_streaming(&dev->vbi_vbq)) || (dmaq == &dev->vbi_q && !vb2_is_streaming(&dev->video_vbq))) - pm_qos_remove_request(&dev->qos_request); + cpu_latency_qos_remove_request(&dev->qos_request); } static const struct vb2_ops vb2_qops = { @@ -1055,8 +844,6 @@ static const struct vb2_ops vb2_qops = { .buf_init = buffer_init, .buf_prepare = buffer_prepare, .buf_queue = saa7134_vb2_buffer_queue, - .wait_prepare = vb2_ops_wait_prepare, - .wait_finish = vb2_ops_wait_finish, .start_streaming = saa7134_vb2_start_streaming, .stop_streaming = saa7134_vb2_stop_streaming, }; @@ -1066,8 +853,6 @@ static const struct vb2_ops vb2_qops = { static int saa7134_s_ctrl(struct v4l2_ctrl *ctrl) { struct saa7134_dev *dev = container_of(ctrl->handler, struct saa7134_dev, ctrl_handler); - unsigned long flags; - int restart_overlay = 0; switch (ctrl->id) { case V4L2_CID_BRIGHTNESS: @@ -1105,15 +890,12 @@ static int saa7134_s_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_HFLIP: dev->ctl_mirror = ctrl->val; - restart_overlay = 1; break; case V4L2_CID_PRIVATE_Y_EVEN: dev->ctl_y_even = ctrl->val; - restart_overlay = 1; break; case V4L2_CID_PRIVATE_Y_ODD: dev->ctl_y_odd = ctrl->val; - restart_overlay = 1; break; case V4L2_CID_PRIVATE_AUTOMUTE: { @@ -1136,12 +918,6 @@ static int saa7134_s_ctrl(struct v4l2_ctrl *ctrl) default: return -EINVAL; } - if (restart_overlay && dev->overlay_owner) { - spin_lock_irqsave(&dev->slock, flags); - stop_preview(dev); - start_preview(dev); - spin_unlock_irqrestore(&dev->slock, flags); - } return 0; } @@ -1174,21 +950,11 @@ static int video_release(struct file *file) { struct video_device *vdev = video_devdata(file); struct saa7134_dev *dev = video_drvdata(file); - struct v4l2_fh *fh = file->private_data; struct saa6588_command cmd; - unsigned long flags; mutex_lock(&dev->lock); saa7134_tvaudio_close(dev); - /* turn off overlay */ - if (fh == dev->overlay_owner) { - spin_lock_irqsave(&dev->slock,flags); - stop_preview(dev); - spin_unlock_irqrestore(&dev->slock,flags); - dev->overlay_owner = NULL; - } - if (vdev->vfl_type == VFL_TYPE_RADIO) v4l2_fh_release(file); else @@ -1202,7 +968,7 @@ static int video_release(struct file *file) saa_call_all(dev, tuner, standby); if (vdev->vfl_type == VFL_TYPE_RADIO) - saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd); + saa_call_all(dev, core, command, SAA6588_CMD_CLOSE, &cmd); mutex_unlock(&dev->lock); return 0; @@ -1221,7 +987,7 @@ static ssize_t radio_read(struct file *file, char __user *data, cmd.result = -ENODEV; mutex_lock(&dev->lock); - saa_call_all(dev, core, ioctl, SAA6588_CMD_READ, &cmd); + saa_call_all(dev, core, command, SAA6588_CMD_READ, &cmd); mutex_unlock(&dev->lock); return cmd.result; @@ -1237,7 +1003,7 @@ static __poll_t radio_poll(struct file *file, poll_table *wait) cmd.event_list = wait; cmd.poll_mask = 0; mutex_lock(&dev->lock); - saa_call_all(dev, core, ioctl, SAA6588_CMD_POLL, &cmd); + saa_call_all(dev, core, command, SAA6588_CMD_POLL, &cmd); mutex_unlock(&dev->lock); return rc | cmd.poll_mask; @@ -1285,36 +1051,6 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int saa7134_g_fmt_vid_overlay(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct saa7134_dev *dev = video_drvdata(file); - struct v4l2_clip __user *clips = f->fmt.win.clips; - u32 clipcount = f->fmt.win.clipcount; - int err = 0; - int i; - - if (saa7134_no_overlay > 0) { - pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); - return -EINVAL; - } - f->fmt.win = dev->win; - f->fmt.win.clips = clips; - if (clips == NULL) - clipcount = 0; - if (dev->nclips < clipcount) - clipcount = dev->nclips; - f->fmt.win.clipcount = clipcount; - - for (i = 0; !err && i < clipcount; i++) { - if (copy_to_user(&f->fmt.win.clips[i].c, &dev->clips[i].c, - sizeof(struct v4l2_rect))) - err = -EFAULT; - } - - return err; -} - static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { @@ -1368,21 +1104,6 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int saa7134_try_fmt_vid_overlay(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct saa7134_dev *dev = video_drvdata(file); - - if (saa7134_no_overlay > 0) { - pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); - return -EINVAL; - } - - if (f->fmt.win.clips == NULL) - f->fmt.win.clipcount = 0; - return verify_preview(dev, &f->fmt.win, true); -} - static int saa7134_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { @@ -1400,40 +1121,6 @@ static int saa7134_s_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, - struct v4l2_format *f) -{ - struct saa7134_dev *dev = video_drvdata(file); - int err; - unsigned long flags; - - if (saa7134_no_overlay > 0) { - pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); - return -EINVAL; - } - if (f->fmt.win.clips == NULL) - f->fmt.win.clipcount = 0; - err = verify_preview(dev, &f->fmt.win, true); - if (0 != err) - return err; - - dev->win = f->fmt.win; - dev->nclips = f->fmt.win.clipcount; - - if (copy_from_user(dev->clips, f->fmt.win.clips, - sizeof(struct v4l2_clip) * dev->nclips)) - return -EFAULT; - - if (priv == dev->overlay_owner) { - spin_lock_irqsave(&dev->slock, flags); - stop_preview(dev); - start_preview(dev); - spin_unlock_irqrestore(&dev->slock, flags); - } - - return 0; -} - int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i) { struct saa7134_dev *dev = video_drvdata(file); @@ -1498,50 +1185,17 @@ int saa7134_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { struct saa7134_dev *dev = video_drvdata(file); - struct video_device *vdev = video_devdata(file); - u32 radio_caps, video_caps, vbi_caps; - - unsigned int tuner_type = dev->tuner_type; strscpy(cap->driver, "saa7134", sizeof(cap->driver)); strscpy(cap->card, saa7134_boards[dev->board].name, sizeof(cap->card)); - sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); - - cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; - if ((tuner_type != TUNER_ABSENT) && (tuner_type != UNSET)) - cap->device_caps |= V4L2_CAP_TUNER; - - radio_caps = V4L2_CAP_RADIO; + cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | + V4L2_CAP_RADIO | V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_VBI_CAPTURE | V4L2_CAP_DEVICE_CAPS; + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) + cap->capabilities |= V4L2_CAP_TUNER; if (dev->has_rds) - radio_caps |= V4L2_CAP_RDS_CAPTURE; - - video_caps = V4L2_CAP_VIDEO_CAPTURE; - if (saa7134_no_overlay <= 0 && !is_empress(file)) - video_caps |= V4L2_CAP_VIDEO_OVERLAY; - - vbi_caps = V4L2_CAP_VBI_CAPTURE; - - switch (vdev->vfl_type) { - case VFL_TYPE_RADIO: - cap->device_caps |= radio_caps; - break; - case VFL_TYPE_GRABBER: - cap->device_caps |= video_caps; - break; - case VFL_TYPE_VBI: - cap->device_caps |= vbi_caps; - break; - default: - return -EINVAL; - } - cap->capabilities = radio_caps | video_caps | vbi_caps | - cap->device_caps | V4L2_CAP_DEVICE_CAPS; - if (vdev->vfl_type == VFL_TYPE_RADIO) { - cap->device_caps &= ~V4L2_CAP_STREAMING; - if (!dev->has_rds) - cap->device_caps &= ~V4L2_CAP_READWRITE; - } + cap->capabilities |= V4L2_CAP_RDS_CAPTURE; return 0; } @@ -1550,17 +1204,9 @@ EXPORT_SYMBOL_GPL(saa7134_querycap); int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id) { struct saa7134_dev *dev = video_drvdata(file); - struct v4l2_fh *fh = priv; - unsigned long flags; unsigned int i; v4l2_std_id fixup; - if (is_empress(file) && dev->overlay_owner) { - /* Don't change the std from the mpeg device - if overlay is active. */ - return -EBUSY; - } - for (i = 0; i < TVNORMS; i++) if (id == tvnorms[i].id) break; @@ -1592,20 +1238,7 @@ int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id) return -EINVAL; } - id = tvnorms[i].id; - - if (!is_empress(file) && fh == dev->overlay_owner) { - spin_lock_irqsave(&dev->slock, flags); - stop_preview(dev); - spin_unlock_irqrestore(&dev->slock, flags); - - set_tvnorm(dev, &tvnorms[i]); - - spin_lock_irqsave(&dev->slock, flags); - start_preview(dev); - spin_unlock_irqrestore(&dev->slock, flags); - } else - set_tvnorm(dev, &tvnorms[i]); + set_tvnorm(dev, &tvnorms[i]); saa7134_tvaudio_do_scan(dev); return 0; @@ -1655,8 +1288,7 @@ static int saa7134_g_pixelaspect(struct file *file, void *priv, { struct saa7134_dev *dev = video_drvdata(file); - if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - type != V4L2_BUF_TYPE_VIDEO_OVERLAY) + if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; if (dev->tvnorm->id & V4L2_STD_525_60) { @@ -1670,12 +1302,11 @@ static int saa7134_g_pixelaspect(struct file *file, void *priv, return 0; } -static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection *sel) +static int saa7134_g_selection(struct file *file, void *priv, struct v4l2_selection *sel) { struct saa7134_dev *dev = video_drvdata(file); - if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; switch (sel->target) { @@ -1694,21 +1325,18 @@ static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection return 0; } -static int saa7134_s_selection(struct file *file, void *f, struct v4l2_selection *sel) +static int saa7134_s_selection(struct file *file, void *priv, struct v4l2_selection *sel) { struct saa7134_dev *dev = video_drvdata(file); struct v4l2_rect *b = &dev->crop_bounds; struct v4l2_rect *c = &dev->crop_current; - if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - if (dev->overlay_owner) - return -EBUSY; if (vb2_is_streaming(&dev->video_vbq)) return -EBUSY; @@ -1819,97 +1447,11 @@ static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index >= FORMATS) return -EINVAL; - strscpy(f->description, formats[f->index].name, - sizeof(f->description)); - f->pixelformat = formats[f->index].fourcc; return 0; } -static int saa7134_enum_fmt_vid_overlay(struct file *file, void *priv, - struct v4l2_fmtdesc *f) -{ - if (saa7134_no_overlay > 0) { - pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); - return -EINVAL; - } - - if ((f->index >= FORMATS) || formats[f->index].planar) - return -EINVAL; - - strscpy(f->description, formats[f->index].name, - sizeof(f->description)); - - f->pixelformat = formats[f->index].fourcc; - - return 0; -} - -static int saa7134_g_fbuf(struct file *file, void *f, - struct v4l2_framebuffer *fb) -{ - struct saa7134_dev *dev = video_drvdata(file); - - *fb = dev->ovbuf; - fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING; - - return 0; -} - -static int saa7134_s_fbuf(struct file *file, void *f, - const struct v4l2_framebuffer *fb) -{ - struct saa7134_dev *dev = video_drvdata(file); - struct saa7134_format *fmt; - - if (!capable(CAP_SYS_ADMIN) && - !capable(CAP_SYS_RAWIO)) - return -EPERM; - - /* check args */ - fmt = format_by_fourcc(fb->fmt.pixelformat); - if (NULL == fmt) - return -EINVAL; - - /* ok, accept it */ - dev->ovbuf = *fb; - dev->ovfmt = fmt; - if (0 == dev->ovbuf.fmt.bytesperline) - dev->ovbuf.fmt.bytesperline = - dev->ovbuf.fmt.width*fmt->depth/8; - return 0; -} - -static int saa7134_overlay(struct file *file, void *priv, unsigned int on) -{ - struct saa7134_dev *dev = video_drvdata(file); - unsigned long flags; - - if (on) { - if (saa7134_no_overlay > 0) { - video_dbg("no_overlay\n"); - return -EINVAL; - } - - if (dev->overlay_owner && priv != dev->overlay_owner) - return -EBUSY; - dev->overlay_owner = priv; - spin_lock_irqsave(&dev->slock, flags); - start_preview(dev); - spin_unlock_irqrestore(&dev->slock, flags); - } - if (!on) { - if (priv != dev->overlay_owner) - return -EINVAL; - spin_lock_irqsave(&dev->slock, flags); - stop_preview(dev); - spin_unlock_irqrestore(&dev->slock, flags); - dev->overlay_owner = NULL; - } - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int vidioc_g_register (struct file *file, void *priv, struct v4l2_dbg_register *reg) @@ -1979,10 +1521,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_g_fmt_vid_cap = saa7134_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap = saa7134_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = saa7134_s_fmt_vid_cap, - .vidioc_enum_fmt_vid_overlay = saa7134_enum_fmt_vid_overlay, - .vidioc_g_fmt_vid_overlay = saa7134_g_fmt_vid_overlay, - .vidioc_try_fmt_vid_overlay = saa7134_try_fmt_vid_overlay, - .vidioc_s_fmt_vid_overlay = saa7134_s_fmt_vid_overlay, .vidioc_g_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap, .vidioc_try_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap, .vidioc_s_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap, @@ -2004,9 +1542,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_s_tuner = saa7134_s_tuner, .vidioc_g_selection = saa7134_g_selection, .vidioc_s_selection = saa7134_s_selection, - .vidioc_g_fbuf = saa7134_g_fbuf, - .vidioc_s_fbuf = saa7134_s_fbuf, - .vidioc_overlay = saa7134_overlay, .vidioc_g_frequency = saa7134_g_frequency, .vidioc_s_frequency = saa7134_s_frequency, #ifdef CONFIG_VIDEO_ADV_DEBUG @@ -2153,13 +1688,6 @@ int saa7134_video_init1(struct saa7134_dev *dev) dev->width = 720; dev->height = 576; dev->field = V4L2_FIELD_INTERLACED; - dev->win.w.width = dev->width; - dev->win.w.height = dev->height; - dev->win.field = V4L2_FIELD_INTERLACED; - dev->ovbuf.fmt.width = dev->width; - dev->ovbuf.fmt.height = dev->height; - dev->ovbuf.fmt.pixelformat = dev->fmt->fourcc; - dev->ovbuf.fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; if (saa7134_boards[dev->board].video_out) saa7134_videoport_init(dev); @@ -2213,10 +1741,9 @@ int saa7134_video_init1(struct saa7134_dev *dev) void saa7134_video_fini(struct saa7134_dev *dev) { + timer_delete_sync(&dev->video_q.timeout); /* free stuff */ - vb2_queue_release(&dev->video_vbq); saa7134_pgtable_free(dev->pci, &dev->video_q.pt); - vb2_queue_release(&dev->vbi_vbq); saa7134_pgtable_free(dev->pci, &dev->vbi_q.pt); v4l2_ctrl_handler_free(&dev->ctrl_handler); if (card_has_radio(dev)) |
