diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-05-31 10:48:50 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-06-17 09:58:37 -0400 |
commit | 3a0a5a782abb16f257fb1d8fd874ed054ba9a82d (patch) | |
tree | efe007dbe46b5748d67e6ed921120654f0dbd9a0 | |
parent | 89f3a1422998b35b991c6a059e7acbc99166c5cd (diff) |
[media] saa7134: fix format-related compliance issues
- map overlay format values to the supported ranges
- set colorspace
- zero priv field
- fix cliplist handling
- fix field handling
- initialize ovbuf values
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/pci/saa7134/saa7134-video.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index a7baa246b653..e3457aea6a33 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c | |||
@@ -825,20 +825,22 @@ static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips, | |||
825 | return 0; | 825 | return 0; |
826 | } | 826 | } |
827 | 827 | ||
828 | static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win) | 828 | static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win, bool try) |
829 | { | 829 | { |
830 | enum v4l2_field field; | 830 | enum v4l2_field field; |
831 | int maxw, maxh; | 831 | int maxw, maxh; |
832 | 832 | ||
833 | if (NULL == dev->ovbuf.base) | 833 | if (!try && (dev->ovbuf.base == NULL || dev->ovfmt == NULL)) |
834 | return -EINVAL; | 834 | return -EINVAL; |
835 | if (NULL == dev->ovfmt) | 835 | if (win->w.width < 48) |
836 | return -EINVAL; | 836 | win->w.width = 48; |
837 | if (win->w.width < 48 || win->w.height < 32) | 837 | if (win->w.height < 32) |
838 | return -EINVAL; | 838 | win->w.height = 32; |
839 | if (win->clipcount > 2048) | 839 | if (win->clipcount > 8) |
840 | return -EINVAL; | 840 | win->clipcount = 8; |
841 | 841 | ||
842 | win->chromakey = 0; | ||
843 | win->global_alpha = 0; | ||
842 | field = win->field; | 844 | field = win->field; |
843 | maxw = dev->crop_current.width; | 845 | maxw = dev->crop_current.width; |
844 | maxh = dev->crop_current.height; | 846 | maxh = dev->crop_current.height; |
@@ -853,10 +855,9 @@ static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win) | |||
853 | case V4L2_FIELD_BOTTOM: | 855 | case V4L2_FIELD_BOTTOM: |
854 | maxh = maxh / 2; | 856 | maxh = maxh / 2; |
855 | break; | 857 | break; |
856 | case V4L2_FIELD_INTERLACED: | ||
857 | break; | ||
858 | default: | 858 | default: |
859 | return -EINVAL; | 859 | field = V4L2_FIELD_INTERLACED; |
860 | break; | ||
860 | } | 861 | } |
861 | 862 | ||
862 | win->field = field; | 863 | win->field = field; |
@@ -872,7 +873,7 @@ static int start_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) | |||
872 | unsigned long base,control,bpl; | 873 | unsigned long base,control,bpl; |
873 | int err; | 874 | int err; |
874 | 875 | ||
875 | err = verify_preview(dev, &dev->win); | 876 | err = verify_preview(dev, &dev->win, false); |
876 | if (0 != err) | 877 | if (0 != err) |
877 | return err; | 878 | return err; |
878 | 879 | ||
@@ -1564,6 +1565,8 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv, | |||
1564 | (f->fmt.pix.width * dev->fmt->depth) >> 3; | 1565 | (f->fmt.pix.width * dev->fmt->depth) >> 3; |
1565 | f->fmt.pix.sizeimage = | 1566 | f->fmt.pix.sizeimage = |
1566 | f->fmt.pix.height * f->fmt.pix.bytesperline; | 1567 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
1568 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
1569 | f->fmt.pix.priv = 0; | ||
1567 | return 0; | 1570 | return 0; |
1568 | } | 1571 | } |
1569 | 1572 | ||
@@ -1572,14 +1575,32 @@ static int saa7134_g_fmt_vid_overlay(struct file *file, void *priv, | |||
1572 | { | 1575 | { |
1573 | struct saa7134_fh *fh = priv; | 1576 | struct saa7134_fh *fh = priv; |
1574 | struct saa7134_dev *dev = fh->dev; | 1577 | struct saa7134_dev *dev = fh->dev; |
1578 | struct v4l2_clip *clips = f->fmt.win.clips; | ||
1579 | u32 clipcount = f->fmt.win.clipcount; | ||
1580 | int err = 0; | ||
1581 | int i; | ||
1575 | 1582 | ||
1576 | if (saa7134_no_overlay > 0) { | 1583 | if (saa7134_no_overlay > 0) { |
1577 | printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); | 1584 | printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); |
1578 | return -EINVAL; | 1585 | return -EINVAL; |
1579 | } | 1586 | } |
1587 | mutex_lock(&dev->lock); | ||
1580 | f->fmt.win = dev->win; | 1588 | f->fmt.win = dev->win; |
1589 | f->fmt.win.clips = clips; | ||
1590 | if (clips == NULL) | ||
1591 | clipcount = 0; | ||
1592 | if (dev->nclips < clipcount) | ||
1593 | clipcount = dev->nclips; | ||
1594 | f->fmt.win.clipcount = clipcount; | ||
1595 | |||
1596 | for (i = 0; !err && i < clipcount; i++) { | ||
1597 | if (copy_to_user(&f->fmt.win.clips[i].c, &dev->clips[i].c, | ||
1598 | sizeof(struct v4l2_rect))) | ||
1599 | err = -EFAULT; | ||
1600 | } | ||
1601 | mutex_unlock(&dev->lock); | ||
1581 | 1602 | ||
1582 | return 0; | 1603 | return err; |
1583 | } | 1604 | } |
1584 | 1605 | ||
1585 | static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, | 1606 | static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, |
@@ -1609,10 +1630,9 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, | |||
1609 | case V4L2_FIELD_BOTTOM: | 1630 | case V4L2_FIELD_BOTTOM: |
1610 | maxh = maxh / 2; | 1631 | maxh = maxh / 2; |
1611 | break; | 1632 | break; |
1612 | case V4L2_FIELD_INTERLACED: | ||
1613 | break; | ||
1614 | default: | 1633 | default: |
1615 | return -EINVAL; | 1634 | field = V4L2_FIELD_INTERLACED; |
1635 | break; | ||
1616 | } | 1636 | } |
1617 | 1637 | ||
1618 | f->fmt.pix.field = field; | 1638 | f->fmt.pix.field = field; |
@@ -1629,6 +1649,8 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, | |||
1629 | (f->fmt.pix.width * fmt->depth) >> 3; | 1649 | (f->fmt.pix.width * fmt->depth) >> 3; |
1630 | f->fmt.pix.sizeimage = | 1650 | f->fmt.pix.sizeimage = |
1631 | f->fmt.pix.height * f->fmt.pix.bytesperline; | 1651 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
1652 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
1653 | f->fmt.pix.priv = 0; | ||
1632 | 1654 | ||
1633 | return 0; | 1655 | return 0; |
1634 | } | 1656 | } |
@@ -1644,7 +1666,9 @@ static int saa7134_try_fmt_vid_overlay(struct file *file, void *priv, | |||
1644 | return -EINVAL; | 1666 | return -EINVAL; |
1645 | } | 1667 | } |
1646 | 1668 | ||
1647 | return verify_preview(dev, &f->fmt.win); | 1669 | if (f->fmt.win.clips == NULL) |
1670 | f->fmt.win.clipcount = 0; | ||
1671 | return verify_preview(dev, &f->fmt.win, true); | ||
1648 | } | 1672 | } |
1649 | 1673 | ||
1650 | static int saa7134_s_fmt_vid_cap(struct file *file, void *priv, | 1674 | static int saa7134_s_fmt_vid_cap(struct file *file, void *priv, |
@@ -1677,7 +1701,9 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, | |||
1677 | printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); | 1701 | printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); |
1678 | return -EINVAL; | 1702 | return -EINVAL; |
1679 | } | 1703 | } |
1680 | err = verify_preview(dev, &f->fmt.win); | 1704 | if (f->fmt.win.clips == NULL) |
1705 | f->fmt.win.clipcount = 0; | ||
1706 | err = verify_preview(dev, &f->fmt.win, true); | ||
1681 | if (0 != err) | 1707 | if (0 != err) |
1682 | return err; | 1708 | return err; |
1683 | 1709 | ||
@@ -1686,9 +1712,6 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, | |||
1686 | dev->win = f->fmt.win; | 1712 | dev->win = f->fmt.win; |
1687 | dev->nclips = f->fmt.win.clipcount; | 1713 | dev->nclips = f->fmt.win.clipcount; |
1688 | 1714 | ||
1689 | if (dev->nclips > 8) | ||
1690 | dev->nclips = 8; | ||
1691 | |||
1692 | if (copy_from_user(dev->clips, f->fmt.win.clips, | 1715 | if (copy_from_user(dev->clips, f->fmt.win.clips, |
1693 | sizeof(struct v4l2_clip) * dev->nclips)) { | 1716 | sizeof(struct v4l2_clip) * dev->nclips)) { |
1694 | mutex_unlock(&dev->lock); | 1717 | mutex_unlock(&dev->lock); |
@@ -2454,6 +2477,13 @@ int saa7134_video_init1(struct saa7134_dev *dev) | |||
2454 | dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | 2477 | dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); |
2455 | dev->width = 720; | 2478 | dev->width = 720; |
2456 | dev->height = 576; | 2479 | dev->height = 576; |
2480 | dev->win.w.width = dev->width; | ||
2481 | dev->win.w.height = dev->height; | ||
2482 | dev->win.field = V4L2_FIELD_INTERLACED; | ||
2483 | dev->ovbuf.fmt.width = dev->width; | ||
2484 | dev->ovbuf.fmt.height = dev->height; | ||
2485 | dev->ovbuf.fmt.pixelformat = dev->fmt->fourcc; | ||
2486 | dev->ovbuf.fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
2457 | 2487 | ||
2458 | if (saa7134_boards[dev->board].video_out) | 2488 | if (saa7134_boards[dev->board].video_out) |
2459 | saa7134_videoport_init(dev); | 2489 | saa7134_videoport_init(dev); |