aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c388
-rw-r--r--drivers/media/video/saa7134/saa7134.h1
3 files changed, 218 insertions, 172 deletions
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index cbddd35f1618..92c48ee1591b 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -834,6 +834,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
834 vfd->minor = -1; 834 vfd->minor = -1;
835 vfd->dev = &dev->pci->dev; 835 vfd->dev = &dev->pci->dev;
836 vfd->release = video_device_release; 836 vfd->release = video_device_release;
837 vfd->debug = video_debug;
837 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 838 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
838 dev->name, type, saa7134_boards[dev->board].name); 839 dev->name, type, saa7134_boards[dev->board].name);
839 return vfd; 840 return vfd;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 76b841dd7ec0..043e1396857a 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -38,7 +38,7 @@
38 38
39/* ------------------------------------------------------------------ */ 39/* ------------------------------------------------------------------ */
40 40
41static unsigned int video_debug = 0; 41unsigned int video_debug;
42static unsigned int gbuffers = 8; 42static unsigned int gbuffers = 8;
43static unsigned int noninterlaced = 0; 43static unsigned int noninterlaced = 0;
44static unsigned int gbufsize = 720*576*4; 44static unsigned int gbufsize = 720*576*4;
@@ -54,7 +54,7 @@ module_param_string(secam, secam, sizeof(secam), 0644);
54MODULE_PARM_DESC(secam, "force SECAM variant, either DK,L or Lc"); 54MODULE_PARM_DESC(secam, "force SECAM variant, either DK,L or Lc");
55 55
56 56
57#define dprintk(fmt, arg...) if (video_debug) \ 57#define dprintk(fmt, arg...) if (video_debug&0x04) \
58 printk(KERN_DEBUG "%s/video: " fmt, dev->name , ## arg) 58 printk(KERN_DEBUG "%s/video: " fmt, dev->name , ## arg)
59 59
60/* ------------------------------------------------------------------ */ 60/* ------------------------------------------------------------------ */
@@ -217,6 +217,12 @@ static struct saa7134_format formats[] = {
217 .vbi_v_start_1 = 273, \ 217 .vbi_v_start_1 = 273, \
218 .src_timing = 7 218 .src_timing = 7
219 219
220#define SAA7134_NORMS \
221 V4L2_STD_PAL | V4L2_STD_PAL_N | \
222 V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \
223 V4L2_STD_NTSC | V4L2_STD_PAL_M | \
224 V4L2_STD_PAL_60
225
220static struct saa7134_tvnorm tvnorms[] = { 226static struct saa7134_tvnorm tvnorms[] = {
221 { 227 {
222 .name = "PAL", /* autodetect */ 228 .name = "PAL", /* autodetect */
@@ -542,7 +548,6 @@ void res_free(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int bits)
542 548
543static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) 549static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
544{ 550{
545
546 dprintk("set tv norm = %s\n",norm->name); 551 dprintk("set tv norm = %s\n",norm->name);
547 dev->tvnorm = norm; 552 dev->tvnorm = norm;
548 553
@@ -561,7 +566,6 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
561 dev->crop_current = dev->crop_defrect; 566 dev->crop_current = dev->crop_defrect;
562 567
563 saa7134_set_tvnorm_hw(dev); 568 saa7134_set_tvnorm_hw(dev);
564
565} 569}
566 570
567static void video_mux(struct saa7134_dev *dev, int input) 571static void video_mux(struct saa7134_dev *dev, int input)
@@ -1177,11 +1181,18 @@ static int vidioc_s_ctrl(struct file *file, void *f,
1177 struct saa7134_dev *dev = fh->dev; 1181 struct saa7134_dev *dev = fh->dev;
1178 unsigned long flags; 1182 unsigned long flags;
1179 int restart_overlay = 0; 1183 int restart_overlay = 0;
1184 int err = -EINVAL;
1185
1186 err = v4l2_prio_check(&dev->prio, &fh->prio);
1187 if (0 != err)
1188 return err;
1180 1189
1181 mutex_lock(&dev->lock); 1190 mutex_lock(&dev->lock);
1191
1182 ctrl = ctrl_by_id(c->id); 1192 ctrl = ctrl_by_id(c->id);
1183 if (NULL == ctrl) 1193 if (NULL == ctrl)
1184 return -EINVAL; 1194 goto error;
1195
1185 dprintk("set_control name=%s val=%d\n",ctrl->name,c->value); 1196 dprintk("set_control name=%s val=%d\n",ctrl->name,c->value);
1186 switch (ctrl->type) { 1197 switch (ctrl->type) {
1187 case V4L2_CTRL_TYPE_BOOLEAN: 1198 case V4L2_CTRL_TYPE_BOOLEAN:
@@ -1261,8 +1272,7 @@ static int vidioc_s_ctrl(struct file *file, void *f,
1261 break; 1272 break;
1262 } 1273 }
1263 default: 1274 default:
1264 mutex_unlock(&dev->lock); 1275 goto error;
1265 return -EINVAL;
1266 } 1276 }
1267 if (restart_overlay && fh && res_check(fh, RESOURCE_OVERLAY)) { 1277 if (restart_overlay && fh && res_check(fh, RESOURCE_OVERLAY)) {
1268 spin_lock_irqsave(&dev->slock,flags); 1278 spin_lock_irqsave(&dev->slock,flags);
@@ -1270,8 +1280,11 @@ static int vidioc_s_ctrl(struct file *file, void *f,
1270 start_preview(dev,fh); 1280 start_preview(dev,fh);
1271 spin_unlock_irqrestore(&dev->slock,flags); 1281 spin_unlock_irqrestore(&dev->slock,flags);
1272 } 1282 }
1283 err = 0;
1284
1285error:
1273 mutex_unlock(&dev->lock); 1286 mutex_unlock(&dev->lock);
1274 return 0; 1287 return err;
1275} 1288}
1276 1289
1277/* ------------------------------------------------------------------ */ 1290/* ------------------------------------------------------------------ */
@@ -1494,8 +1507,11 @@ static int video_mmap(struct file *file, struct vm_area_struct * vma)
1494 1507
1495/* ------------------------------------------------------------------ */ 1508/* ------------------------------------------------------------------ */
1496 1509
1497static void saa7134_vbi_fmt(struct saa7134_dev *dev, struct v4l2_format *f) 1510static int vidioc_try_get_set_fmt_vbi(struct file *file, void *priv,
1511 struct v4l2_format *f)
1498{ 1512{
1513 struct saa7134_fh *fh = priv;
1514 struct saa7134_dev *dev = fh->dev;
1499 struct saa7134_tvnorm *norm = dev->tvnorm; 1515 struct saa7134_tvnorm *norm = dev->tvnorm;
1500 1516
1501 f->fmt.vbi.sampling_rate = 6750000 * 4; 1517 f->fmt.vbi.sampling_rate = 6750000 * 4;
@@ -1508,39 +1524,37 @@ static void saa7134_vbi_fmt(struct saa7134_dev *dev, struct v4l2_format *f)
1508 f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; 1524 f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
1509 f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */ 1525 f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */
1510 1526
1527 return 0;
1511} 1528}
1512 1529
1513static int vidioc_g_fmt_cap(struct file *file, void *priv, 1530static int vidioc_g_fmt_cap(struct file *file, void *priv,
1514 struct v4l2_format *f) 1531 struct v4l2_format *f)
1515{ 1532{
1516 struct saa7134_fh *fh = priv; 1533 struct saa7134_fh *fh = priv;
1517 struct saa7134_dev *dev = fh->dev;
1518 1534
1519 switch (f->type) { 1535 f->fmt.pix.width = fh->width;
1520 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1536 f->fmt.pix.height = fh->height;
1521 memset(&f->fmt.pix,0,sizeof(f->fmt.pix)); 1537 f->fmt.pix.field = fh->cap.field;
1522 f->fmt.pix.width = fh->width; 1538 f->fmt.pix.pixelformat = fh->fmt->fourcc;
1523 f->fmt.pix.height = fh->height; 1539 f->fmt.pix.bytesperline =
1524 f->fmt.pix.field = fh->cap.field; 1540 (f->fmt.pix.width * fh->fmt->depth) >> 3;
1525 f->fmt.pix.pixelformat = fh->fmt->fourcc; 1541 f->fmt.pix.sizeimage =
1526 f->fmt.pix.bytesperline = 1542 f->fmt.pix.height * f->fmt.pix.bytesperline;
1527 (f->fmt.pix.width * fh->fmt->depth) >> 3; 1543 return 0;
1528 f->fmt.pix.sizeimage = 1544}
1529 f->fmt.pix.height * f->fmt.pix.bytesperline; 1545
1530 return 0; 1546static int vidioc_g_fmt_overlay(struct file *file, void *priv,
1531 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 1547 struct v4l2_format *f)
1532 if (saa7134_no_overlay > 0) { 1548{
1533 printk ("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); 1549 struct saa7134_fh *fh = priv;
1534 return -EINVAL; 1550
1535 } 1551 if (saa7134_no_overlay > 0) {
1536 f->fmt.win = fh->win; 1552 printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
1537 return 0;
1538 case V4L2_BUF_TYPE_VBI_CAPTURE:
1539 saa7134_vbi_fmt(dev,f);
1540 return 0;
1541 default:
1542 return -EINVAL; 1553 return -EINVAL;
1543 } 1554 }
1555 f->fmt.win = fh->win;
1556
1557 return 0;
1544} 1558}
1545 1559
1546static int vidioc_try_fmt_cap(struct file *file, void *priv, 1560static int vidioc_try_fmt_cap(struct file *file, void *priv,
@@ -1548,126 +1562,122 @@ static int vidioc_try_fmt_cap(struct file *file, void *priv,
1548{ 1562{
1549 struct saa7134_fh *fh = priv; 1563 struct saa7134_fh *fh = priv;
1550 struct saa7134_dev *dev = fh->dev; 1564 struct saa7134_dev *dev = fh->dev;
1551 int err; 1565 struct saa7134_format *fmt;
1566 enum v4l2_field field;
1567 unsigned int maxw, maxh;
1552 1568
1553 switch (f->type) { 1569 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1554 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1570 if (NULL == fmt)
1555 { 1571 return -EINVAL;
1556 struct saa7134_format *fmt;
1557 enum v4l2_field field;
1558 unsigned int maxw, maxh;
1559 1572
1560 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 1573 field = f->fmt.pix.field;
1561 if (NULL == fmt) 1574 maxw = min(dev->crop_current.width*4, dev->crop_bounds.width);
1562 return -EINVAL; 1575 maxh = min(dev->crop_current.height*4, dev->crop_bounds.height);
1563 1576
1564 field = f->fmt.pix.field; 1577 if (V4L2_FIELD_ANY == field) {
1565 maxw = min(dev->crop_current.width*4, dev->crop_bounds.width); 1578 field = (f->fmt.pix.height > maxh/2)
1566 maxh = min(dev->crop_current.height*4, dev->crop_bounds.height); 1579 ? V4L2_FIELD_INTERLACED
1580 : V4L2_FIELD_BOTTOM;
1581 }
1582 switch (field) {
1583 case V4L2_FIELD_TOP:
1584 case V4L2_FIELD_BOTTOM:
1585 maxh = maxh / 2;
1586 break;
1587 case V4L2_FIELD_INTERLACED:
1588 break;
1589 default:
1590 return -EINVAL;
1591 }
1567 1592
1568 if (V4L2_FIELD_ANY == field) { 1593 f->fmt.pix.field = field;
1569 field = (f->fmt.pix.height > maxh/2) 1594 if (f->fmt.pix.width < 48)
1570 ? V4L2_FIELD_INTERLACED 1595 f->fmt.pix.width = 48;
1571 : V4L2_FIELD_BOTTOM; 1596 if (f->fmt.pix.height < 32)
1572 } 1597 f->fmt.pix.height = 32;
1573 switch (field) { 1598 if (f->fmt.pix.width > maxw)
1574 case V4L2_FIELD_TOP: 1599 f->fmt.pix.width = maxw;
1575 case V4L2_FIELD_BOTTOM: 1600 if (f->fmt.pix.height > maxh)
1576 maxh = maxh / 2; 1601 f->fmt.pix.height = maxh;
1577 break; 1602 f->fmt.pix.width &= ~0x03;
1578 case V4L2_FIELD_INTERLACED: 1603 f->fmt.pix.bytesperline =
1579 break; 1604 (f->fmt.pix.width * fmt->depth) >> 3;
1580 default: 1605 f->fmt.pix.sizeimage =
1581 return -EINVAL; 1606 f->fmt.pix.height * f->fmt.pix.bytesperline;
1582 }
1583 1607
1584 f->fmt.pix.field = field; 1608 return 0;
1585 if (f->fmt.pix.width < 48) 1609}
1586 f->fmt.pix.width = 48;
1587 if (f->fmt.pix.height < 32)
1588 f->fmt.pix.height = 32;
1589 if (f->fmt.pix.width > maxw)
1590 f->fmt.pix.width = maxw;
1591 if (f->fmt.pix.height > maxh)
1592 f->fmt.pix.height = maxh;
1593 f->fmt.pix.width &= ~0x03;
1594 f->fmt.pix.bytesperline =
1595 (f->fmt.pix.width * fmt->depth) >> 3;
1596 f->fmt.pix.sizeimage =
1597 f->fmt.pix.height * f->fmt.pix.bytesperline;
1598 1610
1599 return 0; 1611static int vidioc_try_fmt_overlay(struct file *file, void *priv,
1600 } 1612 struct v4l2_format *f)
1601 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 1613{
1602 if (saa7134_no_overlay > 0) { 1614 struct saa7134_fh *fh = priv;
1603 printk ("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); 1615 struct saa7134_dev *dev = fh->dev;
1604 return -EINVAL; 1616
1605 } 1617 if (saa7134_no_overlay > 0) {
1606 err = verify_preview(dev,&f->fmt.win); 1618 printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
1607 if (0 != err)
1608 return err;
1609 return 0;
1610 case V4L2_BUF_TYPE_VBI_CAPTURE:
1611 saa7134_vbi_fmt(dev,f);
1612 return 0;
1613 default:
1614 return -EINVAL; 1619 return -EINVAL;
1615 } 1620 }
1621
1622 return verify_preview(dev, &f->fmt.win);
1616} 1623}
1617 1624
1618static int vidioc_s_fmt_cap(struct file *file, void *priv, 1625static int vidioc_s_fmt_cap(struct file *file, void *priv,
1619 struct v4l2_format *f) 1626 struct v4l2_format *f)
1620{ 1627{
1621 struct saa7134_fh *fh = priv; 1628 struct saa7134_fh *fh = priv;
1629 int err;
1630
1631 err = vidioc_try_fmt_cap(file, priv, f);
1632 if (0 != err)
1633 return err;
1634
1635 fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1636 fh->width = f->fmt.pix.width;
1637 fh->height = f->fmt.pix.height;
1638 fh->cap.field = f->fmt.pix.field;
1639 return 0;
1640}
1641
1642static int vidioc_s_fmt_overlay(struct file *file, void *priv,
1643 struct v4l2_format *f)
1644{
1645 struct saa7134_fh *fh = priv;
1622 struct saa7134_dev *dev = fh->dev; 1646 struct saa7134_dev *dev = fh->dev;
1623 unsigned long flags;
1624 int err; 1647 int err;
1648 unsigned int flags;
1625 1649
1626 switch (f->type) { 1650 if (saa7134_no_overlay > 0) {
1627 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1651 printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
1628 err = vidioc_try_fmt_cap(file, priv, f); 1652 return -EINVAL;
1629 if (0 != err) 1653 }
1630 return err; 1654 err = verify_preview(dev, &f->fmt.win);
1631 1655 if (0 != err)
1632 fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); 1656 return err;
1633 fh->width = f->fmt.pix.width;
1634 fh->height = f->fmt.pix.height;
1635 fh->cap.field = f->fmt.pix.field;
1636 return 0;
1637 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
1638 if (saa7134_no_overlay > 0) {
1639 printk ("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
1640 return -EINVAL;
1641 }
1642 err = verify_preview(dev,&f->fmt.win);
1643 if (0 != err)
1644 return err;
1645
1646 mutex_lock(&dev->lock);
1647 fh->win = f->fmt.win;
1648 fh->nclips = f->fmt.win.clipcount;
1649 if (fh->nclips > 8)
1650 fh->nclips = 8;
1651 if (copy_from_user(fh->clips,f->fmt.win.clips,
1652 sizeof(struct v4l2_clip)*fh->nclips)) {
1653 mutex_unlock(&dev->lock);
1654 return -EFAULT;
1655 }
1656 1657
1657 if (res_check(fh, RESOURCE_OVERLAY)) { 1658 mutex_lock(&dev->lock);
1658 spin_lock_irqsave(&dev->slock,flags); 1659
1659 stop_preview(dev,fh); 1660 fh->win = f->fmt.win;
1660 start_preview(dev,fh); 1661 fh->nclips = f->fmt.win.clipcount;
1661 spin_unlock_irqrestore(&dev->slock,flags); 1662
1662 } 1663 if (fh->nclips > 8)
1664 fh->nclips = 8;
1665
1666 if (copy_from_user(fh->clips, f->fmt.win.clips,
1667 sizeof(struct v4l2_clip)*fh->nclips)) {
1663 mutex_unlock(&dev->lock); 1668 mutex_unlock(&dev->lock);
1664 return 0; 1669 return -EFAULT;
1665 case V4L2_BUF_TYPE_VBI_CAPTURE:
1666 saa7134_vbi_fmt(dev,f);
1667 return 0;
1668 default:
1669 return -EINVAL;
1670 } 1670 }
1671
1672 if (res_check(fh, RESOURCE_OVERLAY)) {
1673 spin_lock_irqsave(&dev->slock, flags);
1674 stop_preview(dev, fh);
1675 start_preview(dev, fh);
1676 spin_unlock_irqrestore(&dev->slock, flags);
1677 }
1678
1679 mutex_unlock(&dev->lock);
1680 return 0;
1671} 1681}
1672 1682
1673static int vidioc_queryctrl(struct file *file, void *priv, 1683static int vidioc_queryctrl(struct file *file, void *priv,
@@ -1715,8 +1725,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1715 if (0 != (v2 & 0x0e)) 1725 if (0 != (v2 & 0x0e))
1716 i->status |= V4L2_IN_ST_MACROVISION; 1726 i->status |= V4L2_IN_ST_MACROVISION;
1717 } 1727 }
1718 for (n = 0; n < TVNORMS; n++) 1728 i->std = SAA7134_NORMS;
1719 i->std |= tvnorms[n].id;
1720 return 0; 1729 return 0;
1721} 1730}
1722 1731
@@ -1733,6 +1742,11 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1733{ 1742{
1734 struct saa7134_fh *fh = priv; 1743 struct saa7134_fh *fh = priv;
1735 struct saa7134_dev *dev = fh->dev; 1744 struct saa7134_dev *dev = fh->dev;
1745 int err;
1746
1747 err = v4l2_prio_check(&dev->prio, &fh->prio);
1748 if (0 != err)
1749 return err;
1736 1750
1737 if (i < 0 || i >= SAA7134_INPUT_MAX) 1751 if (i < 0 || i >= SAA7134_INPUT_MAX)
1738 return -EINVAL; 1752 return -EINVAL;
@@ -1752,7 +1766,6 @@ static int vidioc_querycap(struct file *file, void *priv,
1752 1766
1753 unsigned int tuner_type = dev->tuner_type; 1767 unsigned int tuner_type = dev->tuner_type;
1754 1768
1755 memset(cap, 0, sizeof(*cap));
1756 strcpy(cap->driver, "saa7134"); 1769 strcpy(cap->driver, "saa7134");
1757 strlcpy(cap->card, saa7134_boards[dev->board].name, 1770 strlcpy(cap->card, saa7134_boards[dev->board].name,
1758 sizeof(cap->card)); 1771 sizeof(cap->card));
@@ -1779,16 +1792,23 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * id)
1779 unsigned long flags; 1792 unsigned long flags;
1780 unsigned int i; 1793 unsigned int i;
1781 v4l2_std_id fixup; 1794 v4l2_std_id fixup;
1795 int err;
1796
1797 err = v4l2_prio_check(&dev->prio, &fh->prio);
1798 if (0 != err)
1799 return err;
1782 1800
1783 for (i = 0; i < TVNORMS; i++) 1801 for (i = 0; i < TVNORMS; i++)
1784 if (*id == tvnorms[i].id) 1802 if (*id == tvnorms[i].id)
1785 break; 1803 break;
1804
1786 if (i == TVNORMS) 1805 if (i == TVNORMS)
1787 for (i = 0; i < TVNORMS; i++) 1806 for (i = 0; i < TVNORMS; i++)
1788 if (*id & tvnorms[i].id) 1807 if (*id & tvnorms[i].id)
1789 break; 1808 break;
1790 if (i == TVNORMS) 1809 if (i == TVNORMS)
1791 return -EINVAL; 1810 return -EINVAL;
1811
1792 if ((*id & V4L2_STD_SECAM) && (secam[0] != '-')) { 1812 if ((*id & V4L2_STD_SECAM) && (secam[0] != '-')) {
1793 if (secam[0] == 'L' || secam[0] == 'l') { 1813 if (secam[0] == 'L' || secam[0] == 'l') {
1794 if (secam[1] == 'C' || secam[1] == 'c') 1814 if (secam[1] == 'C' || secam[1] == 'c')
@@ -1805,6 +1825,9 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * id)
1805 if (fixup == tvnorms[i].id) 1825 if (fixup == tvnorms[i].id)
1806 break; 1826 break;
1807 } 1827 }
1828
1829 *id = tvnorms[i].id;
1830
1808 mutex_lock(&dev->lock); 1831 mutex_lock(&dev->lock);
1809 if (res_check(fh, RESOURCE_OVERLAY)) { 1832 if (res_check(fh, RESOURCE_OVERLAY)) {
1810 spin_lock_irqsave(&dev->slock, flags); 1833 spin_lock_irqsave(&dev->slock, flags);
@@ -1818,6 +1841,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * id)
1818 spin_unlock_irqrestore(&dev->slock, flags); 1841 spin_unlock_irqrestore(&dev->slock, flags);
1819 } else 1842 } else
1820 set_tvnorm(dev, &tvnorms[i]); 1843 set_tvnorm(dev, &tvnorms[i]);
1844
1821 saa7134_tvaudio_do_scan(dev); 1845 saa7134_tvaudio_do_scan(dev);
1822 mutex_unlock(&dev->lock); 1846 mutex_unlock(&dev->lock);
1823 return 0; 1847 return 0;
@@ -1930,7 +1954,11 @@ static int vidioc_s_tuner(struct file *file, void *priv,
1930{ 1954{
1931 struct saa7134_fh *fh = priv; 1955 struct saa7134_fh *fh = priv;
1932 struct saa7134_dev *dev = fh->dev; 1956 struct saa7134_dev *dev = fh->dev;
1933 int rx, mode; 1957 int rx, mode, err;
1958
1959 err = v4l2_prio_check(&dev->prio, &fh->prio);
1960 if (0 != err)
1961 return err;
1934 1962
1935 mode = dev->thread.mode; 1963 mode = dev->thread.mode;
1936 if (UNSET == mode) { 1964 if (UNSET == mode) {
@@ -1939,6 +1967,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
1939 } 1967 }
1940 if (mode != t->audmode) 1968 if (mode != t->audmode)
1941 dev->thread.mode = t->audmode; 1969 dev->thread.mode = t->audmode;
1970
1942 return 0; 1971 return 0;
1943} 1972}
1944 1973
@@ -1948,9 +1977,9 @@ static int vidioc_g_frequency(struct file *file, void *priv,
1948 struct saa7134_fh *fh = priv; 1977 struct saa7134_fh *fh = priv;
1949 struct saa7134_dev *dev = fh->dev; 1978 struct saa7134_dev *dev = fh->dev;
1950 1979
1951 memset(f, 0, sizeof(*f));
1952 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1980 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1953 f->frequency = dev->ctl_freq; 1981 f->frequency = dev->ctl_freq;
1982
1954 return 0; 1983 return 0;
1955} 1984}
1956 1985
@@ -1959,6 +1988,11 @@ static int vidioc_s_frequency(struct file *file, void *priv,
1959{ 1988{
1960 struct saa7134_fh *fh = priv; 1989 struct saa7134_fh *fh = priv;
1961 struct saa7134_dev *dev = fh->dev; 1990 struct saa7134_dev *dev = fh->dev;
1991 int err;
1992
1993 err = v4l2_prio_check(&dev->prio, &fh->prio);
1994 if (0 != err)
1995 return err;
1962 1996
1963 if (0 != f->tuner) 1997 if (0 != f->tuner)
1964 return -EINVAL; 1998 return -EINVAL;
@@ -1978,7 +2012,6 @@ static int vidioc_s_frequency(struct file *file, void *priv,
1978 2012
1979static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) 2013static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
1980{ 2014{
1981 memset(a, 0, sizeof(*a));
1982 strcpy(a->name, "audio"); 2015 strcpy(a->name, "audio");
1983 return 0; 2016 return 0;
1984} 2017}
@@ -2009,42 +2042,45 @@ static int vidioc_s_priority(struct file *file, void *f,
2009static int vidioc_enum_fmt_cap(struct file *file, void *priv, 2042static int vidioc_enum_fmt_cap(struct file *file, void *priv,
2010 struct v4l2_fmtdesc *f) 2043 struct v4l2_fmtdesc *f)
2011{ 2044{
2012 enum v4l2_buf_type type; 2045 if (f->index >= FORMATS)
2013 unsigned int index; 2046 return -EINVAL;
2014 2047
2015 index = f->index; 2048 strlcpy(f->description, formats[f->index].name,
2016 type = f->type; 2049 sizeof(f->description));
2017 switch (type) {
2018 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
2019 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
2020 if (saa7134_no_overlay > 0)
2021 return -EINVAL;
2022 2050
2023 if (index >= FORMATS) 2051 f->pixelformat = formats[f->index].fourcc;
2024 return -EINVAL;
2025 2052
2026 if (f->type == V4L2_BUF_TYPE_VIDEO_OVERLAY && 2053 return 0;
2027 formats[index].planar) 2054}
2028 return -EINVAL; 2055
2029 memset(f, 0, sizeof(*f)); 2056static int vidioc_enum_fmt_overlay(struct file *file, void *priv,
2030 f->index = index; 2057 struct v4l2_fmtdesc *f)
2031 f->type = type; 2058{
2032 strlcpy(f->description, formats[index].name, 2059 if (saa7134_no_overlay > 0) {
2033 sizeof(f->description)); 2060 printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
2034 f->pixelformat = formats[index].fourcc;
2035 break;
2036 case V4L2_BUF_TYPE_VBI_CAPTURE:
2037 if (0 != index)
2038 return -EINVAL;
2039 memset(f, 0, sizeof(*f));
2040 f->index = index;
2041 f->type = type;
2042 f->pixelformat = V4L2_PIX_FMT_GREY;
2043 strcpy(f->description, "vbi data");
2044 break;
2045 default:
2046 return -EINVAL; 2061 return -EINVAL;
2047 } 2062 }
2063
2064 if ((f->index >= FORMATS) || formats[f->index].planar)
2065 return -EINVAL;
2066
2067 strlcpy(f->description, formats[f->index].name,
2068 sizeof(f->description));
2069
2070 f->pixelformat = formats[f->index].fourcc;
2071
2072 return 0;
2073}
2074
2075static int vidioc_enum_fmt_vbi(struct file *file, void *priv,
2076 struct v4l2_fmtdesc *f)
2077{
2078 if (0 != f->index)
2079 return -EINVAL;
2080
2081 f->pixelformat = V4L2_PIX_FMT_GREY;
2082 strcpy(f->description, "vbi data");
2083
2048 return 0; 2084 return 0;
2049} 2085}
2050 2086
@@ -2180,7 +2216,6 @@ static int vidioc_streamoff(struct file *file, void *priv,
2180static int vidioc_g_parm(struct file *file, void *fh, 2216static int vidioc_g_parm(struct file *file, void *fh,
2181 struct v4l2_streamparm *parm) 2217 struct v4l2_streamparm *parm)
2182{ 2218{
2183 memset(parm, 0, sizeof(*parm));
2184 return 0; 2219 return 0;
2185} 2220}
2186 2221
@@ -2190,7 +2225,6 @@ static int radio_querycap(struct file *file, void *priv,
2190 struct saa7134_fh *fh = file->private_data; 2225 struct saa7134_fh *fh = file->private_data;
2191 struct saa7134_dev *dev = fh->dev; 2226 struct saa7134_dev *dev = fh->dev;
2192 2227
2193 memset(cap, 0, sizeof(*cap));
2194 strcpy(cap->driver, "saa7134"); 2228 strcpy(cap->driver, "saa7134");
2195 strlcpy(cap->card, saa7134_boards[dev->board].name, sizeof(cap->card)); 2229 strlcpy(cap->card, saa7134_boards[dev->board].name, sizeof(cap->card));
2196 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); 2230 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
@@ -2329,6 +2363,14 @@ struct video_device saa7134_video_template =
2329 .vidioc_g_fmt_cap = vidioc_g_fmt_cap, 2363 .vidioc_g_fmt_cap = vidioc_g_fmt_cap,
2330 .vidioc_try_fmt_cap = vidioc_try_fmt_cap, 2364 .vidioc_try_fmt_cap = vidioc_try_fmt_cap,
2331 .vidioc_s_fmt_cap = vidioc_s_fmt_cap, 2365 .vidioc_s_fmt_cap = vidioc_s_fmt_cap,
2366 .vidioc_enum_fmt_overlay = vidioc_enum_fmt_overlay,
2367 .vidioc_g_fmt_overlay = vidioc_g_fmt_overlay,
2368 .vidioc_try_fmt_overlay = vidioc_try_fmt_overlay,
2369 .vidioc_s_fmt_overlay = vidioc_s_fmt_overlay,
2370 .vidioc_enum_fmt_vbi = vidioc_enum_fmt_vbi,
2371 .vidioc_g_fmt_vbi = vidioc_try_get_set_fmt_vbi,
2372 .vidioc_try_fmt_vbi = vidioc_try_get_set_fmt_vbi,
2373 .vidioc_s_fmt_vbi = vidioc_try_get_set_fmt_vbi,
2332 .vidioc_g_audio = vidioc_g_audio, 2374 .vidioc_g_audio = vidioc_g_audio,
2333 .vidioc_s_audio = vidioc_s_audio, 2375 .vidioc_s_audio = vidioc_s_audio,
2334 .vidioc_cropcap = vidioc_cropcap, 2376 .vidioc_cropcap = vidioc_cropcap,
@@ -2360,6 +2402,8 @@ struct video_device saa7134_video_template =
2360 .vidioc_g_parm = vidioc_g_parm, 2402 .vidioc_g_parm = vidioc_g_parm,
2361 .vidioc_g_frequency = vidioc_g_frequency, 2403 .vidioc_g_frequency = vidioc_g_frequency,
2362 .vidioc_s_frequency = vidioc_s_frequency, 2404 .vidioc_s_frequency = vidioc_s_frequency,
2405 .tvnorms = SAA7134_NORMS,
2406 .current_norm = V4L2_STD_PAL,
2363}; 2407};
2364 2408
2365struct video_device saa7134_vbi_template = 2409struct video_device saa7134_vbi_template =
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 5c5b07413076..8fb95094ba84 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -625,6 +625,7 @@ void saa7134_i2c_call_clients(struct saa7134_dev *dev,
625/* ----------------------------------------------------------- */ 625/* ----------------------------------------------------------- */
626/* saa7134-video.c */ 626/* saa7134-video.c */
627 627
628extern unsigned int video_debug;
628extern struct video_device saa7134_video_template; 629extern struct video_device saa7134_video_template;
629extern struct video_device saa7134_radio_template; 630extern struct video_device saa7134_radio_template;
630 631