aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-video.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 17:18:45 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 17:18:45 -0400
commitaa5bc2b58e3344da57f26b62e99e13e91c9e0a94 (patch)
treec6e9ea1b3ee8af88b3a050b3fba160ea2f77e404 /drivers/media/video/saa7134/saa7134-video.c
parentd868772fff6c4b881d66af8640251714e1aefa98 (diff)
parentd455cf5d0db9e3eb1b204cd4a61d8c5ccfe4305f (diff)
Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (184 commits) V4L/DVB (5563): Radio-maestro.c Replace radio_ioctl to use video_ioctl2 V4L/DVB (5562): Radio-gemtek-pci.c Replace gemtek_pci_ioctl to use video_ioctl2 V4L/DVB (5560): Ivtv: fix incorrect bitwise-and for command flags. V4L/DVB (5558): Opera: use 7-bit i2c addresses V4L/DVB (5557): Cafe_ccic: check return value of pci_enable_device V4L/DVB (5556): Radio-gemtek.c Replace gemtek_ioctl to use video_ioctl2 V4L/DVB (5555): Radio-aimslab.c Replace rt_ioctl to use video_ioctl2 V4L/DVB (5554): Fix: vidioc_g_parm were not zeroing the memory V4L/DVB (5553): Replace typhoon_do_ioctl to use video_ioctl2 V4L/DVB (5552): Plan-b: Switch to refcounting PCI API V4L/DVB (5551): Plan-b: header change V4L/DVB (5550): Radio-sf16fmi.c Replace fmi_do_ioctl to use video_ioctl2 V4L/DVB (5549): Radio-sf16fmr2.c Replace fmr2_do_ioctl to use video_ioctl2 V4L/DVB (5548): Fix v4l2 buffer to the length V4L/DVB (5547): Add ENUM_FRAMESIZES and ENUM_FRAMEINTERVALS ioctls V4L/DVB (5546): Radio-terratec.c Replace tt_do_ioctl to use video_ioctl2 V4L/DVB (5545): Saa7146: Release capture buffers on device close V4L/DVB (5544): Budget-av: Make inversion setting configurable, add KNC ONE V1.0 card V4L/DVB (5543): Tda10023: Add support for frontend TDA10023 V4L/DVB (5542): Budget-av: Remove polarity switching of the clock for DVB-C ...
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-video.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c85
1 files changed, 36 insertions, 49 deletions
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index f2cb63053041..9985ded20950 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -26,6 +26,7 @@
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/sort.h>
29 30
30#include "saa7134-reg.h" 31#include "saa7134-reg.h"
31#include "saa7134.h" 32#include "saa7134.h"
@@ -516,14 +517,12 @@ static int res_get(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int
516 return 1; 517 return 1;
517} 518}
518 519
519static 520static int res_check(struct saa7134_fh *fh, unsigned int bit)
520int res_check(struct saa7134_fh *fh, unsigned int bit)
521{ 521{
522 return (fh->resources & bit); 522 return (fh->resources & bit);
523} 523}
524 524
525static 525static int res_locked(struct saa7134_dev *dev, unsigned int bit)
526int res_locked(struct saa7134_dev *dev, unsigned int bit)
527{ 526{
528 return (dev->resources & bit); 527 return (dev->resources & bit);
529} 528}
@@ -603,7 +602,14 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
603 saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40); 602 saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40);
604 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); 603 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80);
605 604
606 saa7134_i2c_call_clients(dev,VIDIOC_S_STD,&norm->id); 605 /* only tell the tuner if this is a tv input */
606 if (card_in(dev,dev->ctl_input).tv) {
607 if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290)
608 && ((card(dev).tuner_config == 1)
609 || (card(dev).tuner_config == 2)))
610 saa7134_set_gpio(dev, 22, 5);
611 saa7134_i2c_call_clients(dev,VIDIOC_S_STD,&norm->id);
612 }
607} 613}
608 614
609static void video_mux(struct saa7134_dev *dev, int input) 615static void video_mux(struct saa7134_dev *dev, int input)
@@ -732,25 +738,6 @@ struct cliplist {
732 __u8 disable; 738 __u8 disable;
733}; 739};
734 740
735static void sort_cliplist(struct cliplist *cl, int entries)
736{
737 struct cliplist swap;
738 int i,j,n;
739
740 for (i = entries-2; i >= 0; i--) {
741 for (n = 0, j = 0; j <= i; j++) {
742 if (cl[j].position > cl[j+1].position) {
743 swap = cl[j];
744 cl[j] = cl[j+1];
745 cl[j+1] = swap;
746 n++;
747 }
748 }
749 if (0 == n)
750 break;
751 }
752}
753
754static void set_cliplist(struct saa7134_dev *dev, int reg, 741static void set_cliplist(struct saa7134_dev *dev, int reg,
755 struct cliplist *cl, int entries, char *name) 742 struct cliplist *cl, int entries, char *name)
756{ 743{
@@ -784,15 +771,27 @@ static int clip_range(int val)
784 return val; 771 return val;
785} 772}
786 773
774/* Sort into smallest position first order */
775static int cliplist_cmp(const void *a, const void *b)
776{
777 const struct cliplist *cla = a;
778 const struct cliplist *clb = b;
779 if (cla->position < clb->position)
780 return -1;
781 if (cla->position > clb->position)
782 return 1;
783 return 0;
784}
785
787static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips, 786static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips,
788 int nclips, int interlace) 787 int nclips, int interlace)
789{ 788{
790 struct cliplist col[16], row[16]; 789 struct cliplist col[16], row[16];
791 int cols, rows, i; 790 int cols = 0, rows = 0, i;
792 int div = interlace ? 2 : 1; 791 int div = interlace ? 2 : 1;
793 792
794 memset(col,0,sizeof(col)); cols = 0; 793 memset(col, 0, sizeof(col));
795 memset(row,0,sizeof(row)); rows = 0; 794 memset(row, 0, sizeof(row));
796 for (i = 0; i < nclips && i < 8; i++) { 795 for (i = 0; i < nclips && i < 8; i++) {
797 col[cols].position = clip_range(clips[i].c.left); 796 col[cols].position = clip_range(clips[i].c.left);
798 col[cols].enable = (1 << i); 797 col[cols].enable = (1 << i);
@@ -808,8 +807,8 @@ static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips,
808 row[rows].disable = (1 << i); 807 row[rows].disable = (1 << i);
809 rows++; 808 rows++;
810 } 809 }
811 sort_cliplist(col,cols); 810 sort(col, cols, sizeof col[0], cliplist_cmp, NULL);
812 sort_cliplist(row,rows); 811 sort(row, rows, sizeof row[0], cliplist_cmp, NULL);
813 set_cliplist(dev,0x380,col,cols,"cols"); 812 set_cliplist(dev,0x380,col,cols,"cols");
814 set_cliplist(dev,0x384,row,rows,"rows"); 813 set_cliplist(dev,0x384,row,rows,"rows");
815 return 0; 814 return 0;
@@ -1261,19 +1260,14 @@ static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh)
1261 1260
1262static int saa7134_resource(struct saa7134_fh *fh) 1261static int saa7134_resource(struct saa7134_fh *fh)
1263{ 1262{
1264 int res = 0; 1263 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1264 return RESOURCE_VIDEO;
1265 1265
1266 switch (fh->type) { 1266 if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)
1267 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1267 return RESOURCE_VBI;
1268 res = RESOURCE_VIDEO; 1268
1269 break; 1269 BUG();
1270 case V4L2_BUF_TYPE_VBI_CAPTURE: 1270 return 0;
1271 res = RESOURCE_VBI;
1272 break;
1273 default:
1274 BUG();
1275 }
1276 return res;
1277} 1271}
1278 1272
1279static int video_open(struct inode *inode, struct file *file) 1273static int video_open(struct inode *inode, struct file *file)
@@ -1461,8 +1455,7 @@ static int video_release(struct inode *inode, struct file *file)
1461 return 0; 1455 return 0;
1462} 1456}
1463 1457
1464static int 1458static int video_mmap(struct file *file, struct vm_area_struct * vma)
1465video_mmap(struct file *file, struct vm_area_struct * vma)
1466{ 1459{
1467 struct saa7134_fh *fh = file->private_data; 1460 struct saa7134_fh *fh = file->private_data;
1468 1461
@@ -2461,12 +2454,6 @@ int saa7134_video_init2(struct saa7134_dev *dev)
2461 return 0; 2454 return 0;
2462} 2455}
2463 2456
2464int saa7134_video_fini(struct saa7134_dev *dev)
2465{
2466 /* nothing */
2467 return 0;
2468}
2469
2470void saa7134_irq_video_intl(struct saa7134_dev *dev) 2457void saa7134_irq_video_intl(struct saa7134_dev *dev)
2471{ 2458{
2472 static const char *st[] = { 2459 static const char *st[] = {