static void pms_chromaagc(short agc) { if(decoder==PHILIPS2) pms_i2c_andor(0x8A, 0x0C, 0x9F, (agc&0x03)<<5); else if(decoder==PHILIPS1) pms_i2c_andor(0x42, 0x0C, 0x9F, (agc&0x03)<<5); }
static void pms_sharpness(short sharp) { if(decoder==PHILIPS2) pms_i2c_andor(0x8A, 0x06, 0xFC, sharp&0x03); else if(decoder==PHILIPS1) pms_i2c_andor(0x42, 0x06, 0xFC, sharp&0x03); }
static void pms_antisnow(short snow) { if(decoder==PHILIPS2) pms_i2c_andor(0x8A, 0x06, 0xF3, (snow&0x03)<<2); else if(decoder==PHILIPS1) pms_i2c_andor(0x42, 0x06, 0xF3, (snow&0x03)<<2); }
static void pms_bandpass(short pass) { if(decoder==PHILIPS2) pms_i2c_andor(0x8A, 0x06, 0xCF, (pass&0x03)<<4); else if(decoder==PHILIPS1) pms_i2c_andor(0x42, 0x06, 0xCF, (pass&0x03)<<4); }
static void pms_killcolour(short colour) { if(decoder==PHILIPS2) { pms_i2c_andor(0x8A, 0x08, 0x07, (colour&0x1F)<<3); pms_i2c_andor(0x8A, 0x09, 0x07, (colour&0x1F)<<3); } else if(decoder==PHILIPS1) { pms_i2c_andor(0x42, 0x08, 0x07, (colour&0x1F)<<3); pms_i2c_andor(0x42, 0x09, 0x07, (colour&0x1F)<<3); } }
static void pms_format(short format) { int target; standard = format; if(decoder==PHILIPS1) target=0x42; else if(decoder==PHILIPS2) target=0x8A; else return; switch(format) { case 0: /* Auto */ pms_i2c_andor(target, 0x0D, 0xFE,0x00); pms_i2c_andor(target, 0x0F, 0x3F,0x80); break; case 1: /* NTSC */ pms_i2c_andor(target, 0x0D, 0xFE, 0x00); pms_i2c_andor(target, 0x0F, 0x3F, 0x40); break; case 2: /* PAL */ pms_i2c_andor(target, 0x0D, 0xFE, 0x00); pms_i2c_andor(target, 0x0F, 0x3F, 0x00); break; case 3: /* SECAM */ pms_i2c_andor(target, 0x0D, 0xFE, 0x01); pms_i2c_andor(target, 0x0F, 0x3F, 0x00); break; } }
static int init_mediavision(void) { int id; int idec, decst; int i; unsigned char i2c_defs[]={ 0x4C,0x30,0x00,0xE8, 0xB6,0xE2,0x00,0x00, 0xFF,0xFF,0x00,0x00, 0x00,0x00,0x78,0x98, 0x00,0x00,0x00,0x00, 0x34,0x0A,0xF4,0xCE, 0xE4 }; mem = ioremap(mem_base, 0x800); if (!mem) return -ENOMEM; if (!request_region(0x9A01, 1, "Mediavision PMS config")) { printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n"); iounmap(mem); return -EBUSY; } if (!request_region(io_port, 3, "Mediavision PMS")) { printk(KERN_WARNING "mediavision: I/O port %d in use.\n", io_port); release_region(0x9A01, 1); iounmap(mem); return -EBUSY; } outb(0xB8, 0x9A01); /* Unlock */ outb(io_port>>4, 0x9A01); /* Set IO port */ id=mvv_read(3); decst=pms_i2c_stat(0x43); if(decst!=-1) idec=2; else if(pms_i2c_stat(0xb9)!=-1) idec=3; else if(pms_i2c_stat(0x8b)!=-1) idec=1; else idec=0; printk(KERN_INFO "PMS type is %d\n", idec); if(idec == 0) { release_region(io_port, 3); release_region(0x9A01, 1); iounmap(mem); return -ENODEV; } /* * Ok we have a PMS of some sort */ mvv_write(0x04, mem_base>>12); /* Set the memory area */ /* Ok now load the defaults */ for(i=0;i<0x19;i++) { if(i2c_defs[i]==0xFF) pms_i2c_andor(0x8A, i, 0x07,0x00); else pms_i2c_write(0x8A, i, i2c_defs[i]); } pms_i2c_write(0xB8,0x00,0x12); pms_i2c_write(0xB8,0x04,0x00); pms_i2c_write(0xB8,0x07,0x00); pms_i2c_write(0xB8,0x08,0x00); pms_i2c_write(0xB8,0x09,0xFF); pms_i2c_write(0xB8,0x0A,0x00); pms_i2c_write(0xB8,0x0B,0x10); pms_i2c_write(0xB8,0x10,0x03); mvv_write(0x01, 0x00); mvv_write(0x05, 0xA0); mvv_write(0x08, 0x25); mvv_write(0x09, 0x00); mvv_write(0x0A, 0x20|MVVMEMORYWIDTH); mvv_write(0x10, 0x02); mvv_write(0x1E, 0x0C); mvv_write(0x1F, 0x03); mvv_write(0x26, 0x06); mvv_write(0x2B, 0x00); mvv_write(0x2C, 0x20); mvv_write(0x2D, 0x00); mvv_write(0x2F, 0x70); mvv_write(0x32, 0x00); mvv_write(0x33, MVVMEMORYWIDTH); mvv_write(0x34, 0x00); mvv_write(0x35, 0x00); mvv_write(0x3A, 0x80); mvv_write(0x3B, 0x10); mvv_write(0x20, 0x00); mvv_write(0x21, 0x00); mvv_write(0x30, 0x22); return 0; }