2 * Media Vision Pro Movie Studio
4 * "all you need is an I2C bus some RAM and a prayer"
6 * This draws heavily on code
8 * (c) Wolfgang Koehler, wolf@first.gmd.de, Dec. 1994
10 * 14478 Potsdam, Germany
12 * Most of this code is directly derived from his userspace driver.
13 * His driver works so send any reports to alan@lxorguk.ukuu.org.uk
14 * unless the userspace driver also doesn't work for you...
17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it>
18 * - pms_capture: report back -EFAULT
21 #include <linux/module.h>
22 #include <linux/delay.h>
23 #include <linux/errno.h>
25 #include <linux/kernel.h>
26 #include <linux/slab.h>
28 #include <linux/ioport.h>
29 #include <linux/init.h>
31 #include <linux/videodev.h>
32 #include <media/v4l2-common.h>
33 #include <media/v4l2-ioctl.h>
34 #include <media/v4l2-device.h>
35 #include <linux/mutex.h>
37 #include <asm/uaccess.h>
39 MODULE_LICENSE("GPL");
45 #define MVVMEMORYWIDTH 0x40 /* 512 bytes */
55 struct v4l2_device v4l2_dev;
56 struct video_device vdev;
57 struct video_picture picture;
63 struct i2c_info i2cinfo[64];
66 int standard; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
72 static struct pms pms_card;
75 * I/O ports and Shared Memory
78 static int io_port = 0x250;
79 module_param(io_port, int, 0);
81 static int mem_base = 0xc8000;
82 module_param(mem_base, int, 0);
84 static int video_nr = -1;
85 module_param(video_nr, int, 0);
88 static inline void mvv_write(struct pms *dev, u8 index, u8 value)
90 outw(index | (value << 8), dev->io);
93 static inline u8 mvv_read(struct pms *dev, u8 index)
96 return inb(dev->data);
99 static int pms_i2c_stat(struct pms *dev, u8 slave)
106 while ((inb(dev->data) & 0x01) == 0)
107 if (counter++ == 256)
110 while ((inb(dev->data) & 0x01) != 0)
111 if (counter++ == 256)
114 outb(slave, dev->io);
117 while ((inb(dev->data) & 0x01) == 0)
118 if (counter++ == 256)
121 while ((inb(dev->data) & 0x01) != 0)
122 if (counter++ == 256)
125 for (i = 0; i < 12; i++) {
126 char st = inb(dev->data);
134 return inb(dev->data);
137 static int pms_i2c_write(struct pms *dev, u16 slave, u16 sub, u16 data)
143 for (i = 0; i < dev->i2c_count; i++) {
144 if ((dev->i2cinfo[i].slave == slave) &&
145 (dev->i2cinfo[i].sub == sub)) {
146 if (dev->i2cinfo[i].data == data)
148 dev->i2cinfo[i].data = data;
149 i = dev->i2c_count + 1;
153 if (i == dev->i2c_count && dev->i2c_count < 64) {
154 dev->i2cinfo[dev->i2c_count].slave = slave;
155 dev->i2cinfo[dev->i2c_count].sub = sub;
156 dev->i2cinfo[dev->i2c_count].data = data;
163 mvv_write(dev, 0x29, sub);
164 mvv_write(dev, 0x2A, data);
165 mvv_write(dev, 0x28, slave);
170 while ((inb(dev->data) & 1) == 0)
173 while ((inb(dev->data) & 1) != 0)
177 count = inb(dev->data);
184 static int pms_i2c_read(struct pms *dev, int slave, int sub)
188 for (i = 0; i < dev->i2c_count; i++) {
189 if (dev->i2cinfo[i].slave == slave && dev->i2cinfo[i].sub == sub)
190 return dev->i2cinfo[i].data;
196 static void pms_i2c_andor(struct pms *dev, int slave, int sub, int and, int or)
200 tmp = pms_i2c_read(dev, slave, sub);
201 tmp = (tmp & and) | or;
202 pms_i2c_write(dev, slave, sub, tmp);
210 static void pms_videosource(struct pms *dev, short source)
212 mvv_write(dev, 0x2E, source ? 0x31 : 0x30);
215 static void pms_hue(struct pms *dev, short hue)
217 switch (dev->decoder) {
219 pms_i2c_write(dev, 0x8a, 0x00, hue);
222 pms_i2c_write(dev, 0x8a, 0x07, hue);
225 pms_i2c_write(dev, 0x42, 0x07, hue);
230 static void pms_colour(struct pms *dev, short colour)
232 switch (dev->decoder) {
234 pms_i2c_write(dev, 0x8a, 0x00, colour);
237 pms_i2c_write(dev, 0x42, 0x12, colour);
243 static void pms_contrast(struct pms *dev, short contrast)
245 switch (dev->decoder) {
247 pms_i2c_write(dev, 0x8a, 0x00, contrast);
250 pms_i2c_write(dev, 0x42, 0x13, contrast);
255 static void pms_brightness(struct pms *dev, short brightness)
257 switch (dev->decoder) {
259 pms_i2c_write(dev, 0x8a, 0x00, brightness);
260 pms_i2c_write(dev, 0x8a, 0x00, brightness);
261 pms_i2c_write(dev, 0x8a, 0x00, brightness);
264 pms_i2c_write(dev, 0x42, 0x19, brightness);
270 static void pms_format(struct pms *dev, short format)
274 dev->standard = format;
276 if (dev->decoder == PHILIPS1)
278 else if (dev->decoder == PHILIPS2)
285 pms_i2c_andor(dev, target, 0x0d, 0xfe, 0x00);
286 pms_i2c_andor(dev, target, 0x0f, 0x3f, 0x80);
289 pms_i2c_andor(dev, target, 0x0d, 0xfe, 0x00);
290 pms_i2c_andor(dev, target, 0x0f, 0x3f, 0x40);
293 pms_i2c_andor(dev, target, 0x0d, 0xfe, 0x00);
294 pms_i2c_andor(dev, target, 0x0f, 0x3f, 0x00);
297 pms_i2c_andor(dev, target, 0x0d, 0xfe, 0x01);
298 pms_i2c_andor(dev, target, 0x0f, 0x3f, 0x00);
303 #ifdef FOR_FUTURE_EXPANSION
306 * These features of the PMS card are not currently exposes. They
307 * could become a private v4l ioctl for PMSCONFIG or somesuch if
308 * people need it. We also don't yet use the PMS interrupt.
311 static void pms_hstart(struct pms *dev, short start)
313 switch (dev->decoder) {
315 pms_i2c_write(dev, 0x8a, 0x05, start);
316 pms_i2c_write(dev, 0x8a, 0x18, start);
319 pms_i2c_write(dev, 0x42, 0x05, start);
320 pms_i2c_write(dev, 0x42, 0x18, start);
329 static void pms_bandpass(struct pms *dev, short pass)
331 if (dev->decoder == PHILIPS2)
332 pms_i2c_andor(dev, 0x8a, 0x06, 0xcf, (pass & 0x03) << 4);
333 else if (dev->decoder == PHILIPS1)
334 pms_i2c_andor(dev, 0x42, 0x06, 0xcf, (pass & 0x03) << 4);
337 static void pms_antisnow(struct pms *dev, short snow)
339 if (dev->decoder == PHILIPS2)
340 pms_i2c_andor(dev, 0x8a, 0x06, 0xf3, (snow & 0x03) << 2);
341 else if (dev->decoder == PHILIPS1)
342 pms_i2c_andor(dev, 0x42, 0x06, 0xf3, (snow & 0x03) << 2);
345 static void pms_sharpness(struct pms *dev, short sharp)
347 if (dev->decoder == PHILIPS2)
348 pms_i2c_andor(dev, 0x8a, 0x06, 0xfc, sharp & 0x03);
349 else if (dev->decoder == PHILIPS1)
350 pms_i2c_andor(dev, 0x42, 0x06, 0xfc, sharp & 0x03);
353 static void pms_chromaagc(struct pms *dev, short agc)
355 if (dev->decoder == PHILIPS2)
356 pms_i2c_andor(dev, 0x8a, 0x0c, 0x9f, (agc & 0x03) << 5);
357 else if (dev->decoder == PHILIPS1)
358 pms_i2c_andor(dev, 0x42, 0x0c, 0x9f, (agc & 0x03) << 5);
361 static void pms_vertnoise(struct pms *dev, short noise)
363 if (dev->decoder == PHILIPS2)
364 pms_i2c_andor(dev, 0x8a, 0x10, 0xfc, noise & 3);
365 else if (dev->decoder == PHILIPS1)
366 pms_i2c_andor(dev, 0x42, 0x10, 0xfc, noise & 3);
369 static void pms_forcecolour(struct pms *dev, short colour)
371 if (dev->decoder == PHILIPS2)
372 pms_i2c_andor(dev, 0x8a, 0x0c, 0x7f, (colour & 1) << 7);
373 else if (dev->decoder == PHILIPS1)
374 pms_i2c_andor(dev, 0x42, 0x0c, 0x7, (colour & 1) << 7);
377 static void pms_antigamma(struct pms *dev, short gamma)
379 if (dev->decoder == PHILIPS2)
380 pms_i2c_andor(dev, 0xb8, 0x00, 0x7f, (gamma & 1) << 7);
381 else if (dev->decoder == PHILIPS1)
382 pms_i2c_andor(dev, 0x42, 0x20, 0x7, (gamma & 1) << 7);
385 static void pms_prefilter(struct pms *dev, short filter)
387 if (dev->decoder == PHILIPS2)
388 pms_i2c_andor(dev, 0x8a, 0x06, 0xbf, (filter & 1) << 6);
389 else if (dev->decoder == PHILIPS1)
390 pms_i2c_andor(dev, 0x42, 0x06, 0xbf, (filter & 1) << 6);
393 static void pms_hfilter(struct pms *dev, short filter)
395 if (dev->decoder == PHILIPS2)
396 pms_i2c_andor(dev, 0xb8, 0x04, 0x1f, (filter & 7) << 5);
397 else if (dev->decoder == PHILIPS1)
398 pms_i2c_andor(dev, 0x42, 0x24, 0x1f, (filter & 7) << 5);
401 static void pms_vfilter(struct pms *dev, short filter)
403 if (dev->decoder == PHILIPS2)
404 pms_i2c_andor(dev, 0xb8, 0x08, 0x9f, (filter & 3) << 5);
405 else if (dev->decoder == PHILIPS1)
406 pms_i2c_andor(dev, 0x42, 0x28, 0x9f, (filter & 3) << 5);
409 static void pms_killcolour(struct pms *dev, short colour)
411 if (dev->decoder == PHILIPS2) {
412 pms_i2c_andor(dev, 0x8a, 0x08, 0x07, (colour & 0x1f) << 3);
413 pms_i2c_andor(dev, 0x8a, 0x09, 0x07, (colour & 0x1f) << 3);
414 } else if (dev->decoder == PHILIPS1) {
415 pms_i2c_andor(dev, 0x42, 0x08, 0x07, (colour & 0x1f) << 3);
416 pms_i2c_andor(dev, 0x42, 0x09, 0x07, (colour & 0x1f) << 3);
420 static void pms_chromagain(struct pms *dev, short chroma)
422 if (dev->decoder == PHILIPS2)
423 pms_i2c_write(dev, 0x8a, 0x11, chroma);
424 else if (dev->decoder == PHILIPS1)
425 pms_i2c_write(dev, 0x42, 0x11, chroma);
429 static void pms_spacialcompl(struct pms *dev, short data)
431 mvv_write(dev, 0x3b, data);
434 static void pms_spacialcomph(struct pms *dev, short data)
436 mvv_write(dev, 0x3a, data);
439 static void pms_vstart(struct pms *dev, short start)
441 mvv_write(dev, 0x16, start);
442 mvv_write(dev, 0x17, (start >> 8) & 0x01);
447 static void pms_secamcross(struct pms *dev, short cross)
449 if (dev->decoder == PHILIPS2)
450 pms_i2c_andor(dev, 0x8a, 0x0f, 0xdf, (cross & 1) << 5);
451 else if (dev->decoder == PHILIPS1)
452 pms_i2c_andor(dev, 0x42, 0x0f, 0xdf, (cross & 1) << 5);
456 static void pms_swsense(struct pms *dev, short sense)
458 if (dev->decoder == PHILIPS2) {
459 pms_i2c_write(dev, 0x8a, 0x0a, sense);
460 pms_i2c_write(dev, 0x8a, 0x0b, sense);
461 } else if (dev->decoder == PHILIPS1) {
462 pms_i2c_write(dev, 0x42, 0x0a, sense);
463 pms_i2c_write(dev, 0x42, 0x0b, sense);
468 static void pms_framerate(struct pms *dev, short frr)
470 int fps = (dev->standard == 1) ? 30 : 25;
475 mvv_write(dev, 0x14, 0x80 | fps);
476 mvv_write(dev, 0x15, 1);
479 static void pms_vert(struct pms *dev, u8 deciden, u8 decinum)
481 mvv_write(dev, 0x1c, deciden); /* Denominator */
482 mvv_write(dev, 0x1d, decinum); /* Numerator */
486 * Turn 16bit ratios into best small ratio the chipset can grok
489 static void pms_vertdeci(struct pms *dev, unsigned short decinum, unsigned short deciden)
491 /* Knock it down by / 5 once */
492 if (decinum % 5 == 0) {
499 while (decinum % 3 == 0 && deciden % 3 == 0) {
506 while (decinum % 2 == 0 && deciden % 2 == 0) {
513 while (deciden > 32) {
515 decinum = (decinum + 1) / 2;
519 pms_vert(dev, deciden, decinum);
522 static void pms_horzdeci(struct pms *dev, short decinum, short deciden)
524 if (decinum <= 512) {
525 if (decinum % 5 == 0) {
531 deciden = 640; /* 768 would be ideal */
534 while (((decinum | deciden) & 1) == 0) {
538 while (deciden > 32) {
540 decinum = (decinum + 1) >> 1;
545 mvv_write(dev, 0x24, 0x80 | deciden);
546 mvv_write(dev, 0x25, decinum);
549 static void pms_resolution(struct pms *dev, short width, short height)
557 mvv_write(dev, 0x18, fg_height);
558 mvv_write(dev, 0x19, fg_height >> 8);
560 if (dev->standard == 1) {
561 mvv_write(dev, 0x1a, 0xfc);
562 mvv_write(dev, 0x1b, 0x00);
563 if (height > fg_height)
564 pms_vertdeci(dev, 240, 240);
566 pms_vertdeci(dev, fg_height, 240);
568 mvv_write(dev, 0x1a, 0x1a);
569 mvv_write(dev, 0x1b, 0x01);
571 pms_vertdeci(dev, 270, 270);
573 pms_vertdeci(dev, fg_height, 270);
575 mvv_write(dev, 0x12, 0);
576 mvv_write(dev, 0x13, MVVMEMORYWIDTH);
577 mvv_write(dev, 0x42, 0x00);
578 mvv_write(dev, 0x43, 0x00);
579 mvv_write(dev, 0x44, MVVMEMORYWIDTH);
581 mvv_write(dev, 0x22, width + 8);
582 mvv_write(dev, 0x23, (width + 8) >> 8);
584 if (dev->standard == 1)
585 pms_horzdeci(dev, width, 640);
587 pms_horzdeci(dev, width + 8, 768);
589 mvv_write(dev, 0x30, mvv_read(dev, 0x30) & 0xfe);
590 mvv_write(dev, 0x08, mvv_read(dev, 0x08) | 0x01);
591 mvv_write(dev, 0x01, mvv_read(dev, 0x01) & 0xfd);
592 mvv_write(dev, 0x32, 0x00);
593 mvv_write(dev, 0x33, MVVMEMORYWIDTH);
601 static void pms_vcrinput(struct pms *dev, short input)
603 if (dev->decoder == PHILIPS2)
604 pms_i2c_andor(dev, 0x8a, 0x0d, 0x7f, (input & 1) << 7);
605 else if (dev->decoder == PHILIPS1)
606 pms_i2c_andor(dev, 0x42, 0x0d, 0x7f, (input & 1) << 7);
610 static int pms_capture(struct pms *dev, char __user *buf, int rgb555, int count)
613 int dw = 2 * dev->width;
614 char tmp[dw + 32]; /* using a temp buffer is faster than direct */
617 unsigned char r8 = 0x5; /* value for reg8 */
620 r8 |= 0x20; /* else use untranslated rgb = 565 */
621 mvv_write(dev, 0x08, r8); /* capture rgb555/565, init DRAM, PC enable */
623 /* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */
625 for (y = 0; y < dev->height; y++) {
626 writeb(0, dev->mem); /* synchronisiert neue Zeile */
629 * This is in truth a fifo, be very careful as if you
630 * forgot this odd things will occur 8)
633 memcpy_fromio(tmp, dev->mem, dw + 32); /* discard 16 word */
640 if (dt + len > count)
643 if (copy_to_user(buf, tmp + 32, dt))
644 return len ? len : -EFAULT;
654 * Video4linux interfacing
657 static long pms_do_ioctl(struct file *file, unsigned int cmd, void *arg)
659 struct pms *dev = video_drvdata(file);
663 struct video_capability *b = arg;
665 strcpy(b->name, "Mediavision PMS");
666 b->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
676 struct video_channel *v = arg;
678 if (v->channel < 0 || v->channel > 3)
682 /* Good question.. its composite or SVHS so.. */
683 v->type = VIDEO_TYPE_CAMERA;
684 switch (v->channel) {
686 strcpy(v->name, "Composite");
689 strcpy(v->name, "SVideo");
692 strcpy(v->name, "Composite(VCR)");
695 strcpy(v->name, "SVideo(VCR)");
701 struct video_channel *v = arg;
703 if (v->channel < 0 || v->channel > 3)
705 mutex_lock(&dev->lock);
706 pms_videosource(dev, v->channel & 1);
707 pms_vcrinput(dev, v->channel >> 1);
708 mutex_unlock(&dev->lock);
712 struct video_tuner *v = arg;
716 strcpy(v->name, "Format");
719 v->flags = VIDEO_TUNER_PAL | VIDEO_TUNER_NTSC | VIDEO_TUNER_SECAM;
720 switch (dev->standard) {
722 v->mode = VIDEO_MODE_AUTO;
725 v->mode = VIDEO_MODE_NTSC;
728 v->mode = VIDEO_MODE_PAL;
731 v->mode = VIDEO_MODE_SECAM;
737 struct video_tuner *v = arg;
741 mutex_lock(&dev->lock);
743 case VIDEO_MODE_AUTO:
744 pms_framerate(dev, 25);
745 pms_secamcross(dev, 0);
748 case VIDEO_MODE_NTSC:
749 pms_framerate(dev, 30);
750 pms_secamcross(dev, 0);
754 pms_framerate(dev, 25);
755 pms_secamcross(dev, 0);
758 case VIDEO_MODE_SECAM:
759 pms_framerate(dev, 25);
760 pms_secamcross(dev, 1);
764 mutex_unlock(&dev->lock);
767 mutex_unlock(&dev->lock);
771 struct video_picture *p = arg;
777 struct video_picture *p = arg;
779 if (!((p->palette == VIDEO_PALETTE_RGB565 && p->depth == 16) ||
780 (p->palette == VIDEO_PALETTE_RGB555 && p->depth == 15)))
788 mutex_lock(&dev->lock);
789 pms_brightness(dev, p->brightness >> 8);
790 pms_hue(dev, p->hue >> 8);
791 pms_colour(dev, p->colour >> 8);
792 pms_contrast(dev, p->contrast >> 8);
793 mutex_unlock(&dev->lock);
797 struct video_window *vw = arg;
803 if (vw->height < 16 || vw->height > 480)
805 if (vw->width < 16 || vw->width > 640)
807 dev->width = vw->width;
808 dev->height = vw->height;
809 mutex_lock(&dev->lock);
810 pms_resolution(dev, dev->width, dev->height);
811 /* Ok we figured out what to use from our wide choice */
812 mutex_unlock(&dev->lock);
816 struct video_window *vw = arg;
818 memset(vw, 0, sizeof(*vw));
819 vw->width = dev->width;
820 vw->height = dev->height;
839 static long pms_ioctl(struct file *file,
840 unsigned int cmd, unsigned long arg)
842 return video_usercopy(file, cmd, arg, pms_do_ioctl);
845 static ssize_t pms_read(struct file *file, char __user *buf,
846 size_t count, loff_t *ppos)
848 struct pms *dev = video_drvdata(file);
851 mutex_lock(&dev->lock);
852 len = pms_capture(dev, buf, (dev->picture.depth == 16) ? 0 : 1, count);
853 mutex_unlock(&dev->lock);
857 static int pms_exclusive_open(struct file *file)
859 struct pms *dev = video_drvdata(file);
861 return test_and_set_bit(0, &dev->in_use) ? -EBUSY : 0;
864 static int pms_exclusive_release(struct file *file)
866 struct pms *dev = video_drvdata(file);
868 clear_bit(0, &dev->in_use);
872 static const struct v4l2_file_operations pms_fops = {
873 .owner = THIS_MODULE,
874 .open = pms_exclusive_open,
875 .release = pms_exclusive_release,
882 * Probe for and initialise the Mediavision PMS
885 static int init_mediavision(struct pms *dev)
890 static const unsigned char i2c_defs[] = {
891 0x4c, 0x30, 0x00, 0xe8,
892 0xb6, 0xe2, 0x00, 0x00,
893 0xff, 0xff, 0x00, 0x00,
894 0x00, 0x00, 0x78, 0x98,
895 0x00, 0x00, 0x00, 0x00,
896 0x34, 0x0a, 0xf4, 0xce,
900 dev->mem = ioremap(mem_base, 0x800);
904 if (!request_region(0x9a01, 1, "Mediavision PMS config")) {
905 printk(KERN_WARNING "mediavision: unable to detect: 0x9a01 in use.\n");
909 if (!request_region(dev->io, 3, "Mediavision PMS")) {
910 printk(KERN_WARNING "mediavision: I/O port %d in use.\n", dev->io);
911 release_region(0x9a01, 1);
915 outb(0xb8, 0x9a01); /* Unlock */
916 outb(dev->io >> 4, 0x9a01); /* Set IO port */
919 id = mvv_read(dev, 3);
920 decst = pms_i2c_stat(dev, 0x43);
924 else if (pms_i2c_stat(dev, 0xb9) != -1)
926 else if (pms_i2c_stat(dev, 0x8b) != -1)
931 printk(KERN_INFO "PMS type is %d\n", idec);
933 release_region(dev->io, 3);
934 release_region(0x9a01, 1);
940 * Ok we have a PMS of some sort
943 mvv_write(dev, 0x04, mem_base >> 12); /* Set the memory area */
945 /* Ok now load the defaults */
947 for (i = 0; i < 0x19; i++) {
948 if (i2c_defs[i] == 0xff)
949 pms_i2c_andor(dev, 0x8a, i, 0x07, 0x00);
951 pms_i2c_write(dev, 0x8a, i, i2c_defs[i]);
954 pms_i2c_write(dev, 0xb8, 0x00, 0x12);
955 pms_i2c_write(dev, 0xb8, 0x04, 0x00);
956 pms_i2c_write(dev, 0xb8, 0x07, 0x00);
957 pms_i2c_write(dev, 0xb8, 0x08, 0x00);
958 pms_i2c_write(dev, 0xb8, 0x09, 0xff);
959 pms_i2c_write(dev, 0xb8, 0x0a, 0x00);
960 pms_i2c_write(dev, 0xb8, 0x0b, 0x10);
961 pms_i2c_write(dev, 0xb8, 0x10, 0x03);
963 mvv_write(dev, 0x01, 0x00);
964 mvv_write(dev, 0x05, 0xa0);
965 mvv_write(dev, 0x08, 0x25);
966 mvv_write(dev, 0x09, 0x00);
967 mvv_write(dev, 0x0a, 0x20 | MVVMEMORYWIDTH);
969 mvv_write(dev, 0x10, 0x02);
970 mvv_write(dev, 0x1e, 0x0c);
971 mvv_write(dev, 0x1f, 0x03);
972 mvv_write(dev, 0x26, 0x06);
974 mvv_write(dev, 0x2b, 0x00);
975 mvv_write(dev, 0x2c, 0x20);
976 mvv_write(dev, 0x2d, 0x00);
977 mvv_write(dev, 0x2f, 0x70);
978 mvv_write(dev, 0x32, 0x00);
979 mvv_write(dev, 0x33, MVVMEMORYWIDTH);
980 mvv_write(dev, 0x34, 0x00);
981 mvv_write(dev, 0x35, 0x00);
982 mvv_write(dev, 0x3a, 0x80);
983 mvv_write(dev, 0x3b, 0x10);
984 mvv_write(dev, 0x20, 0x00);
985 mvv_write(dev, 0x21, 0x00);
986 mvv_write(dev, 0x30, 0x22);
991 * Initialization and module stuff
996 module_param(enable, int, 0);
999 static int __init pms_init(void)
1001 struct pms *dev = &pms_card;
1002 struct v4l2_device *v4l2_dev = &dev->v4l2_dev;
1005 strlcpy(v4l2_dev->name, "pms", sizeof(v4l2_dev->name));
1007 v4l2_info(v4l2_dev, "Mediavision Pro Movie Studio driver 0.03\n");
1012 "PMS: not enabled, use pms.enable=1 to probe\n");
1017 dev->decoder = PHILIPS2;
1019 dev->data = io_port + 1;
1021 if (init_mediavision(dev)) {
1022 v4l2_err(v4l2_dev, "Board not found.\n");
1026 res = v4l2_device_register(NULL, v4l2_dev);
1028 v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
1032 strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name));
1033 dev->vdev.v4l2_dev = v4l2_dev;
1034 dev->vdev.fops = &pms_fops;
1035 dev->vdev.release = video_device_release_empty;
1036 video_set_drvdata(&dev->vdev, dev);
1037 mutex_init(&dev->lock);
1040 pms_swsense(dev, 75);
1041 pms_resolution(dev, 320, 240);
1042 pms_videosource(dev, 0);
1043 pms_vcrinput(dev, 0);
1044 if (video_register_device(&dev->vdev, VFL_TYPE_GRABBER, video_nr) < 0) {
1045 v4l2_device_unregister(&dev->v4l2_dev);
1046 release_region(dev->io, 3);
1047 release_region(0x9a01, 1);
1054 static void __exit pms_exit(void)
1056 struct pms *dev = &pms_card;
1058 video_unregister_device(&dev->vdev);
1059 release_region(dev->io, 3);
1060 release_region(0x9a01, 1);
1064 module_init(pms_init);
1065 module_exit(pms_exit);