aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pms.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/pms.c')
-rw-r--r--drivers/media/video/pms.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 05ca55939e77..09835ca098b1 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -12,10 +12,10 @@
12 * Most of this code is directly derived from his userspace driver. 12 * Most of this code is directly derived from his userspace driver.
13 * His driver works so send any reports to alan@redhat.com unless the 13 * His driver works so send any reports to alan@redhat.com unless the
14 * userspace driver also doesn't work for you... 14 * userspace driver also doesn't work for you...
15 * 15 *
16 * Changes: 16 * Changes:
17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it> 17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it>
18 * - pms_capture: report back -EFAULT 18 * - pms_capture: report back -EFAULT
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
@@ -66,14 +66,14 @@ static int standard = 0; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
66/* 66/*
67 * I/O ports and Shared Memory 67 * I/O ports and Shared Memory
68 */ 68 */
69 69
70static int io_port = 0x250; 70static int io_port = 0x250;
71static int data_port = 0x251; 71static int data_port = 0x251;
72static int mem_base = 0xC8000; 72static int mem_base = 0xC8000;
73static void __iomem *mem; 73static void __iomem *mem;
74static int video_nr = -1; 74static int video_nr = -1;
75 75
76 76
77 77
78static inline void mvv_write(u8 index, u8 value) 78static inline void mvv_write(u8 index, u8 value)
79{ 79{
@@ -90,9 +90,9 @@ static int pms_i2c_stat(u8 slave)
90{ 90{
91 int counter; 91 int counter;
92 int i; 92 int i;
93 93
94 outb(0x28, io_port); 94 outb(0x28, io_port);
95 95
96 counter=0; 96 counter=0;
97 while((inb(data_port)&0x01)==0) 97 while((inb(data_port)&0x01)==0)
98 if(counter++==256) 98 if(counter++==256)
@@ -101,9 +101,9 @@ static int pms_i2c_stat(u8 slave)
101 while((inb(data_port)&0x01)!=0) 101 while((inb(data_port)&0x01)!=0)
102 if(counter++==256) 102 if(counter++==256)
103 break; 103 break;
104 104
105 outb(slave, io_port); 105 outb(slave, io_port);
106 106
107 counter=0; 107 counter=0;
108 while((inb(data_port)&0x01)==0) 108 while((inb(data_port)&0x01)==0)
109 if(counter++==256) 109 if(counter++==256)
@@ -112,7 +112,7 @@ static int pms_i2c_stat(u8 slave)
112 while((inb(data_port)&0x01)!=0) 112 while((inb(data_port)&0x01)!=0)
113 if(counter++==256) 113 if(counter++==256)
114 break; 114 break;
115 115
116 for(i=0;i<12;i++) 116 for(i=0;i<12;i++)
117 { 117 {
118 char st=inb(data_port); 118 char st=inb(data_port);
@@ -122,7 +122,7 @@ static int pms_i2c_stat(u8 slave)
122 break; 122 break;
123 } 123 }
124 outb(0x29, io_port); 124 outb(0x29, io_port);
125 return inb(data_port); 125 return inb(data_port);
126} 126}
127 127
128static int pms_i2c_write(u16 slave, u16 sub, u16 data) 128static int pms_i2c_write(u16 slave, u16 sub, u16 data)
@@ -130,19 +130,19 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
130 int skip=0; 130 int skip=0;
131 int count; 131 int count;
132 int i; 132 int i;
133 133
134 for(i=0;i<i2c_count;i++) 134 for(i=0;i<i2c_count;i++)
135 { 135 {
136 if((i2cinfo[i].slave==slave) && 136 if((i2cinfo[i].slave==slave) &&
137 (i2cinfo[i].sub == sub)) 137 (i2cinfo[i].sub == sub))
138 { 138 {
139 if(i2cinfo[i].data==data) 139 if(i2cinfo[i].data==data)
140 skip=1; 140 skip=1;
141 i2cinfo[i].data=data; 141 i2cinfo[i].data=data;
142 i=i2c_count+1; 142 i=i2c_count+1;
143 } 143 }
144 } 144 }
145 145
146 if(i==i2c_count && i2c_count<64) 146 if(i==i2c_count && i2c_count<64)
147 { 147 {
148 i2cinfo[i2c_count].slave=slave; 148 i2cinfo[i2c_count].slave=slave;
@@ -150,16 +150,16 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
150 i2cinfo[i2c_count].data=data; 150 i2cinfo[i2c_count].data=data;
151 i2c_count++; 151 i2c_count++;
152 } 152 }
153 153
154 if(skip) 154 if(skip)
155 return 0; 155 return 0;
156 156
157 mvv_write(0x29, sub); 157 mvv_write(0x29, sub);
158 mvv_write(0x2A, data); 158 mvv_write(0x2A, data);
159 mvv_write(0x28, slave); 159 mvv_write(0x28, slave);
160 160
161 outb(0x28, io_port); 161 outb(0x28, io_port);
162 162
163 count=0; 163 count=0;
164 while((inb(data_port)&1)==0) 164 while((inb(data_port)&1)==0)
165 if(count>255) 165 if(count>255)
@@ -167,9 +167,9 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
167 while((inb(data_port)&1)!=0) 167 while((inb(data_port)&1)!=0)
168 if(count>255) 168 if(count>255)
169 break; 169 break;
170 170
171 count=inb(data_port); 171 count=inb(data_port);
172 172
173 if(count&2) 173 if(count&2)
174 return -1; 174 return -1;
175 return count; 175 return count;
@@ -189,8 +189,8 @@ static int pms_i2c_read(int slave, int sub)
189 189
190static void pms_i2c_andor(int slave, int sub, int and, int or) 190static void pms_i2c_andor(int slave, int sub, int and, int or)
191{ 191{
192 u8 tmp; 192 u8 tmp;
193 193
194 tmp=pms_i2c_read(slave, sub); 194 tmp=pms_i2c_read(slave, sub);
195 tmp = (tmp&and)|or; 195 tmp = (tmp&and)|or;
196 pms_i2c_write(slave, sub, tmp); 196 pms_i2c_write(slave, sub, tmp);
@@ -199,7 +199,7 @@ static void pms_i2c_andor(int slave, int sub, int and, int or)
199/* 199/*
200 * Control functions 200 * Control functions
201 */ 201 */
202 202
203 203
204static void pms_videosource(short source) 204static void pms_videosource(short source)
205{ 205{
@@ -234,8 +234,8 @@ static void pms_colour(short colour)
234 break; 234 break;
235 } 235 }
236} 236}
237 237
238 238
239static void pms_contrast(short contrast) 239static void pms_contrast(short contrast)
240{ 240{
241 switch(decoder) 241 switch(decoder)
@@ -269,14 +269,14 @@ static void pms_format(short format)
269{ 269{
270 int target; 270 int target;
271 standard = format; 271 standard = format;
272 272
273 if(decoder==PHILIPS1) 273 if(decoder==PHILIPS1)
274 target=0x42; 274 target=0x42;
275 else if(decoder==PHILIPS2) 275 else if(decoder==PHILIPS2)
276 target=0x8A; 276 target=0x8A;
277 else 277 else
278 return; 278 return;
279 279
280 switch(format) 280 switch(format)
281 { 281 {
282 case 0: /* Auto */ 282 case 0: /* Auto */
@@ -302,7 +302,7 @@ static void pms_format(short format)
302 302
303/* 303/*
304 * These features of the PMS card are not currently exposes. They 304 * These features of the PMS card are not currently exposes. They
305 * could become a private v4l ioctl for PMSCONFIG or somesuch if 305 * could become a private v4l ioctl for PMSCONFIG or somesuch if
306 * people need it. We also don't yet use the PMS interrupt. 306 * people need it. We also don't yet use the PMS interrupt.
307 */ 307 */
308 308
@@ -324,7 +324,7 @@ static void pms_hstart(short start)
324/* 324/*
325 * Bandpass filters 325 * Bandpass filters
326 */ 326 */
327 327
328static void pms_bandpass(short pass) 328static void pms_bandpass(short pass)
329{ 329{
330 if(decoder==PHILIPS2) 330 if(decoder==PHILIPS2)
@@ -493,7 +493,7 @@ static void pms_vert(u8 deciden, u8 decinum)
493/* 493/*
494 * Turn 16bit ratios into best small ratio the chipset can grok 494 * Turn 16bit ratios into best small ratio the chipset can grok
495 */ 495 */
496 496
497static void pms_vertdeci(unsigned short decinum, unsigned short deciden) 497static void pms_vertdeci(unsigned short decinum, unsigned short deciden)
498{ 498{
499 /* Knock it down by /5 once */ 499 /* Knock it down by /5 once */
@@ -546,7 +546,7 @@ static void pms_horzdeci(short decinum, short deciden)
546 decinum=512; 546 decinum=512;
547 deciden=640; /* 768 would be ideal */ 547 deciden=640; /* 768 would be ideal */
548 } 548 }
549 549
550 while(((decinum|deciden)&1)==0) 550 while(((decinum|deciden)&1)==0)
551 { 551 {
552 decinum>>=1; 552 decinum>>=1;
@@ -559,7 +559,7 @@ static void pms_horzdeci(short decinum, short deciden)
559 } 559 }
560 if(deciden==32) 560 if(deciden==32)
561 deciden--; 561 deciden--;
562 562
563 mvv_write(0x24, 0x80|deciden); 563 mvv_write(0x24, 0x80|deciden);
564 mvv_write(0x25, decinum); 564 mvv_write(0x25, decinum);
565} 565}
@@ -567,14 +567,14 @@ static void pms_horzdeci(short decinum, short deciden)
567static void pms_resolution(short width, short height) 567static void pms_resolution(short width, short height)
568{ 568{
569 int fg_height; 569 int fg_height;
570 570
571 fg_height=height; 571 fg_height=height;
572 if(fg_height>280) 572 if(fg_height>280)
573 fg_height=280; 573 fg_height=280;
574 574
575 mvv_write(0x18, fg_height); 575 mvv_write(0x18, fg_height);
576 mvv_write(0x19, fg_height>>8); 576 mvv_write(0x19, fg_height>>8);
577 577
578 if(standard==1) 578 if(standard==1)
579 { 579 {
580 mvv_write(0x1A, 0xFC); 580 mvv_write(0x1A, 0xFC);
@@ -598,7 +598,7 @@ static void pms_resolution(short width, short height)
598 mvv_write(0x42, 0x00); 598 mvv_write(0x42, 0x00);
599 mvv_write(0x43, 0x00); 599 mvv_write(0x43, 0x00);
600 mvv_write(0x44, MVVMEMORYWIDTH); 600 mvv_write(0x44, MVVMEMORYWIDTH);
601 601
602 mvv_write(0x22, width+8); 602 mvv_write(0x22, width+8);
603 mvv_write(0x23, (width+8)>> 8); 603 mvv_write(0x23, (width+8)>> 8);
604 604
@@ -618,7 +618,7 @@ static void pms_resolution(short width, short height)
618/* 618/*
619 * Set Input 619 * Set Input
620 */ 620 */
621 621
622static void pms_vcrinput(short input) 622static void pms_vcrinput(short input)
623{ 623{
624 if(decoder==PHILIPS2) 624 if(decoder==PHILIPS2)
@@ -643,20 +643,20 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
643 mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */ 643 mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */
644 644
645/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */ 645/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */
646 646
647 for (y = 0; y < dev->height; y++ ) 647 for (y = 0; y < dev->height; y++ )
648 { 648 {
649 writeb(0, mem); /* synchronisiert neue Zeile */ 649 writeb(0, mem); /* synchronisiert neue Zeile */
650 650
651 /* 651 /*
652 * This is in truth a fifo, be very careful as if you 652 * This is in truth a fifo, be very careful as if you
653 * forgot this odd things will occur 8) 653 * forgot this odd things will occur 8)
654 */ 654 */
655 655
656 memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */ 656 memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */
657 cnt -= dev->height; 657 cnt -= dev->height;
658 while (cnt <= 0) 658 while (cnt <= 0)
659 { 659 {
660 /* 660 /*
661 * Don't copy too far 661 * Don't copy too far
662 */ 662 */
@@ -666,7 +666,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
666 cnt += dev->height; 666 cnt += dev->height;
667 if (copy_to_user(buf, tmp+32, dt)) 667 if (copy_to_user(buf, tmp+32, dt))
668 return len ? len : -EFAULT; 668 return len ? len : -EFAULT;
669 buf += dt; 669 buf += dt;
670 len += dt; 670 len += dt;
671 } 671 }
672 } 672 }
@@ -683,7 +683,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
683{ 683{
684 struct video_device *dev = video_devdata(file); 684 struct video_device *dev = video_devdata(file);
685 struct pms_device *pd=(struct pms_device *)dev; 685 struct pms_device *pd=(struct pms_device *)dev;
686 686
687 switch(cmd) 687 switch(cmd)
688 { 688 {
689 case VIDIOCGCAP: 689 case VIDIOCGCAP:
@@ -806,7 +806,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
806 ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15))) 806 ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15)))
807 return -EINVAL; 807 return -EINVAL;
808 pd->picture= *p; 808 pd->picture= *p;
809 809
810 /* 810 /*
811 * Now load the card. 811 * Now load the card.
812 */ 812 */
@@ -815,7 +815,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
815 pms_brightness(p->brightness>>8); 815 pms_brightness(p->brightness>>8);
816 pms_hue(p->hue>>8); 816 pms_hue(p->hue>>8);
817 pms_colour(p->colour>>8); 817 pms_colour(p->colour>>8);
818 pms_contrast(p->contrast>>8); 818 pms_contrast(p->contrast>>8);
819 mutex_unlock(&pd->lock); 819 mutex_unlock(&pd->lock);
820 return 0; 820 return 0;
821 } 821 }
@@ -873,7 +873,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
873 struct video_device *v = video_devdata(file); 873 struct video_device *v = video_devdata(file);
874 struct pms_device *pd=(struct pms_device *)v; 874 struct pms_device *pd=(struct pms_device *)v;
875 int len; 875 int len;
876 876
877 mutex_lock(&pd->lock); 877 mutex_lock(&pd->lock);
878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count); 878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count);
879 mutex_unlock(&pd->lock); 879 mutex_unlock(&pd->lock);
@@ -905,13 +905,13 @@ static struct pms_device pms_device;
905/* 905/*
906 * Probe for and initialise the Mediavision PMS 906 * Probe for and initialise the Mediavision PMS
907 */ 907 */
908 908
909static int init_mediavision(void) 909static int init_mediavision(void)
910{ 910{
911 int id; 911 int id;
912 int idec, decst; 912 int idec, decst;
913 int i; 913 int i;
914 914
915 unsigned char i2c_defs[]={ 915 unsigned char i2c_defs[]={
916 0x4C,0x30,0x00,0xE8, 916 0x4C,0x30,0x00,0xE8,
917 0xB6,0xE2,0x00,0x00, 917 0xB6,0xE2,0x00,0x00,
@@ -925,7 +925,7 @@ static int init_mediavision(void)
925 mem = ioremap(mem_base, 0x800); 925 mem = ioremap(mem_base, 0x800);
926 if (!mem) 926 if (!mem)
927 return -ENOMEM; 927 return -ENOMEM;
928 928
929 if (!request_region(0x9A01, 1, "Mediavision PMS config")) 929 if (!request_region(0x9A01, 1, "Mediavision PMS config"))
930 { 930 {
931 printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n"); 931 printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n");
@@ -941,18 +941,18 @@ static int init_mediavision(void)
941 } 941 }
942 outb(0xB8, 0x9A01); /* Unlock */ 942 outb(0xB8, 0x9A01); /* Unlock */
943 outb(io_port>>4, 0x9A01); /* Set IO port */ 943 outb(io_port>>4, 0x9A01); /* Set IO port */
944 944
945 945
946 id=mvv_read(3); 946 id=mvv_read(3);
947 decst=pms_i2c_stat(0x43); 947 decst=pms_i2c_stat(0x43);
948 948
949 if(decst!=-1) 949 if(decst!=-1)
950 idec=2; 950 idec=2;
951 else if(pms_i2c_stat(0xb9)!=-1) 951 else if(pms_i2c_stat(0xb9)!=-1)
952 idec=3; 952 idec=3;
953 else if(pms_i2c_stat(0x8b)!=-1) 953 else if(pms_i2c_stat(0x8b)!=-1)
954 idec=1; 954 idec=1;
955 else 955 else
956 idec=0; 956 idec=0;
957 957
958 printk(KERN_INFO "PMS type is %d\n", idec); 958 printk(KERN_INFO "PMS type is %d\n", idec);
@@ -966,11 +966,11 @@ static int init_mediavision(void)
966 /* 966 /*
967 * Ok we have a PMS of some sort 967 * Ok we have a PMS of some sort
968 */ 968 */
969 969
970 mvv_write(0x04, mem_base>>12); /* Set the memory area */ 970 mvv_write(0x04, mem_base>>12); /* Set the memory area */
971 971
972 /* Ok now load the defaults */ 972 /* Ok now load the defaults */
973 973
974 for(i=0;i<0x19;i++) 974 for(i=0;i<0x19;i++)
975 { 975 {
976 if(i2c_defs[i]==0xFF) 976 if(i2c_defs[i]==0xFF)
@@ -978,7 +978,7 @@ static int init_mediavision(void)
978 else 978 else
979 pms_i2c_write(0x8A, i, i2c_defs[i]); 979 pms_i2c_write(0x8A, i, i2c_defs[i]);
980 } 980 }
981 981
982 pms_i2c_write(0xB8,0x00,0x12); 982 pms_i2c_write(0xB8,0x00,0x12);
983 pms_i2c_write(0xB8,0x04,0x00); 983 pms_i2c_write(0xB8,0x04,0x00);
984 pms_i2c_write(0xB8,0x07,0x00); 984 pms_i2c_write(0xB8,0x07,0x00);
@@ -987,18 +987,18 @@ static int init_mediavision(void)
987 pms_i2c_write(0xB8,0x0A,0x00); 987 pms_i2c_write(0xB8,0x0A,0x00);
988 pms_i2c_write(0xB8,0x0B,0x10); 988 pms_i2c_write(0xB8,0x0B,0x10);
989 pms_i2c_write(0xB8,0x10,0x03); 989 pms_i2c_write(0xB8,0x10,0x03);
990 990
991 mvv_write(0x01, 0x00); 991 mvv_write(0x01, 0x00);
992 mvv_write(0x05, 0xA0); 992 mvv_write(0x05, 0xA0);
993 mvv_write(0x08, 0x25); 993 mvv_write(0x08, 0x25);
994 mvv_write(0x09, 0x00); 994 mvv_write(0x09, 0x00);
995 mvv_write(0x0A, 0x20|MVVMEMORYWIDTH); 995 mvv_write(0x0A, 0x20|MVVMEMORYWIDTH);
996 996
997 mvv_write(0x10, 0x02); 997 mvv_write(0x10, 0x02);
998 mvv_write(0x1E, 0x0C); 998 mvv_write(0x1E, 0x0C);
999 mvv_write(0x1F, 0x03); 999 mvv_write(0x1F, 0x03);
1000 mvv_write(0x26, 0x06); 1000 mvv_write(0x26, 0x06);
1001 1001
1002 mvv_write(0x2B, 0x00); 1002 mvv_write(0x2B, 0x00);
1003 mvv_write(0x2C, 0x20); 1003 mvv_write(0x2C, 0x20);
1004 mvv_write(0x2D, 0x00); 1004 mvv_write(0x2D, 0x00);
@@ -1018,13 +1018,13 @@ static int init_mediavision(void)
1018/* 1018/*
1019 * Initialization and module stuff 1019 * Initialization and module stuff
1020 */ 1020 */
1021 1021
1022static int __init init_pms_cards(void) 1022static int __init init_pms_cards(void)
1023{ 1023{
1024 printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n"); 1024 printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n");
1025 1025
1026 data_port = io_port +1; 1026 data_port = io_port +1;
1027 1027
1028 if(init_mediavision()) 1028 if(init_mediavision())
1029 { 1029 {
1030 printk(KERN_INFO "Board not found.\n"); 1030 printk(KERN_INFO "Board not found.\n");