11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Zoran zr36057/zr36067 PCI controller driver, for the 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Media Labs LML33/LML33R10. 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This part handles card-specific data and detection 7d56410e0a594150c5ca06319da7bc8901c4d455eMauro Carvalho Chehab * 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Currently maintained by: 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Ronald Bultje <rbultje@ronald.bitfreak.net> 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Laurent Pinchart <laurent.pinchart@skynet.be> 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Mailinglist <mjpeg-users@lists.sf.net> 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This program is free software; you can redistribute it and/or modify 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * it under the terms of the GNU General Public License as published by 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * the Free Software Foundation; either version 2 of the License, or 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (at your option) any later version. 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This program is distributed in the hope that it will be useful, 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * but WITHOUT ANY WARRANTY; without even the implied warranty of 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * GNU General Public License for more details. 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * You should have received a copy of the GNU General Public License 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * along with this program; if not, write to the Free Software 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 30fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson#include <linux/delay.h> 31fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/types.h> 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/kernel.h> 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/module.h> 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/init.h> 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/vmalloc.h> 375a0e3ad6af8660be21ca98a971cd00f331318c05Tejun Heo#include <linux/slab.h> 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/proc_fs.h> 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/i2c.h> 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/i2c-algo-bit.h> 427f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil#include <linux/videodev2.h> 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/spinlock.h> 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/sem.h> 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/kmod.h> 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/wait.h> 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/pci.h> 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/interrupt.h> 50384c36893f94e0e2145832cf2f20684ae372aee5Ingo Molnar#include <linux/mutex.h> 511cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil#include <linux/io.h> 521cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil#include <media/v4l2-common.h> 531cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil#include <media/bt819.h> 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "videocodec.h" 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "zoran.h" 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "zoran_card.h" 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "zoran_device.h" 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "zoran_procfs.h" 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern const struct zoran_format zoran_formats[]; 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6345bdcefea25cad2d7443f5b45a5319e2bd201048Trent Piephostatic int card[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 }; 6460e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param_array(card, int, NULL, 0444); 6545bdcefea25cad2d7443f5b45a5319e2bd201048Trent PiephoMODULE_PARM_DESC(card, "Card type"); 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds The video mem address of the video card. 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds The driver has a little database for some videocards 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds to determine it from there. If your video card is not in there 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds you have either to give it to the driver as a parameter 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds or set in in a VIDIOCSFBUF ioctl 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 75ff699e6bd02eb1c6d02c7c2b576c2ee6caab201cDouglas Schilling Landgrafstatic unsigned long vidmem; /* default = 0 - Video memory base address */ 7660e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(vidmem, ulong, 0444); 7760e3cac47a442fae74d3429f706350229623bcceTrent PiephoMODULE_PARM_DESC(vidmem, "Default video memory base address"); 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds Default input and video norm at startup of the driver. 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds*/ 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 83ff699e6bd02eb1c6d02c7c2b576c2ee6caab201cDouglas Schilling Landgrafstatic unsigned int default_input; /* default 0 = Composite, 1 = S-Video */ 8460e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(default_input, uint, 0444); 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(default_input, 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "Default input (0=Composite, 1=S-Video, 2=Internal)"); 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 88fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelssonstatic int default_mux = 1; /* 6 Eyes input selection */ 8960e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(default_mux, int, 0644); 90fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin SamuelssonMODULE_PARM_DESC(default_mux, 91fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson "Default 6 Eyes mux setting (Input selection)"); 92fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 93ff699e6bd02eb1c6d02c7c2b576c2ee6caab201cDouglas Schilling Landgrafstatic int default_norm; /* default 0 = PAL, 1 = NTSC 2 = SECAM */ 9460e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(default_norm, int, 0444); 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)"); 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9760e3cac47a442fae74d3429f706350229623bcceTrent Piepho/* /dev/videoN, -1 for autodetect */ 9845bdcefea25cad2d7443f5b45a5319e2bd201048Trent Piephostatic int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 }; 9960e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param_array(video_nr, int, NULL, 0444); 10045bdcefea25cad2d7443f5b45a5319e2bd201048Trent PiephoMODULE_PARM_DESC(video_nr, "Video device number (-1=Auto)"); 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 102497d7d0b92b1eccbd76bbe054d791e471d29b599Hans Verkuilint v4l_nbufs = 4; 103e686e73ca7e6b157c8a4877c5dc9655b20c4967aHans Verkuilint v4l_bufsize = 864; /* Everybody should be able to work with this setting */ 10460e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(v4l_nbufs, int, 0644); 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(v4l_nbufs, "Maximum number of V4L buffers to use"); 10660e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(v4l_bufsize, int, 0644); 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(v4l_bufsize, "Maximum size per V4L buffer (in kB)"); 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint jpg_nbufs = 32; 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint jpg_bufsize = 512; /* max size for 100% quality full-PAL frame */ 11160e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(jpg_nbufs, int, 0644); 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(jpg_nbufs, "Maximum number of JPG buffers to use"); 11360e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(jpg_bufsize, int, 0644); 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(jpg_bufsize, "Maximum size per JPG buffer (in kB)"); 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint pass_through = 0; /* 1=Pass through TV signal when device is not used */ 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 0=Show color bar when device is not used (LML33: only if lml33dpath=1) */ 11860e3cac47a442fae74d3429f706350229623bcceTrent Piephomodule_param(pass_through, int, 0644); 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_PARM_DESC(pass_through, 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "Pass TV signal through to TV-out when idling"); 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 12218b548ca580838a2cc5813a941e6dab28660bb22Jean Delvareint zr36067_debug = 1; 12318b548ca580838a2cc5813a941e6dab28660bb22Jean Delvaremodule_param_named(debug, zr36067_debug, int, 0644); 12418b548ca580838a2cc5813a941e6dab28660bb22Jean DelvareMODULE_PARM_DESC(debug, "Debug level (0-5)"); 1251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1261990d50b58bef127a647005fdcada6d07081d3efMauro Carvalho Chehab#define ZORAN_VERSION "0.10.1" 1271990d50b58bef127a647005fdcada6d07081d3efMauro Carvalho Chehab 1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver"); 1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_AUTHOR("Serguei Miridonov"); 1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_LICENSE("GPL"); 1311990d50b58bef127a647005fdcada6d07081d3efMauro Carvalho ChehabMODULE_VERSION(ZORAN_VERSION); 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 13317faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho#define ZR_DEVICE(subven, subdev, data) { \ 13417faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \ 13517faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) } 13617faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho 137dbdf03b48bd32150b4023ea0dd22f566958b6294Mauro Carvalho Chehabstatic struct pci_device_id zr36067_pci_tbl[] = { 13817faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus), 13917faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus), 14017faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10), 14117faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVICE(PCI_VENDOR_ID_IOMEGA, PCI_DEVICE_ID_IOMEGA_BUZ, BUZ), 14217faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVICE(PCI_ANY_ID, PCI_ANY_ID, NUM_CARDS), 143dbdf03b48bd32150b4023ea0dd22f566958b6294Mauro Carvalho Chehab {0} 144dbdf03b48bd32150b4023ea0dd22f566958b6294Mauro Carvalho Chehab}; 145dbdf03b48bd32150b4023ea0dd22f566958b6294Mauro Carvalho ChehabMODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 147601139e08339b15997c6ae638dc5bf42c51ea204Trent Piephostatic unsigned int zoran_num; /* number of cards found */ 1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* videocodec bus functions ZR36060 */ 1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic u32 1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszr36060_read (struct videocodec *codec, 1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 reg) 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) codec->master_data->data; 1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __u32 data; 1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (post_office_wait(zr) 1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds || post_office_write(zr, 0, 1, reg >> 8) 1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds || post_office_write(zr, 0, 2, reg & 0xff)) { 1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -1; 1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data = post_office_read(zr, 0, 3) & 0xff; 1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return data; 1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszr36060_write (struct videocodec *codec, 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 reg, 1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 val) 1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) codec->master_data->data; 1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (post_office_wait(zr) 1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds || post_office_write(zr, 0, 1, reg >> 8) 1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds || post_office_write(zr, 0, 2, reg & 0xff)) { 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds post_office_write(zr, 0, 3, val & 0xff); 1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* videocodec bus functions ZR36050 */ 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic u32 1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszr36050_read (struct videocodec *codec, 1861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 reg) 1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) codec->master_data->data; 1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __u32 data; 1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (post_office_wait(zr) 1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds || post_office_write(zr, 1, 0, reg >> 2)) { // reg. HIGHBYTES 1931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -1; 1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data = post_office_read(zr, 0, reg & 0x03) & 0xff; // reg. LOWBYTES + read 1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return data; 1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszr36050_write (struct videocodec *codec, 2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 reg, 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 val) 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) codec->master_data->data; 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (post_office_wait(zr) 2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds || post_office_write(zr, 1, 0, reg >> 2)) { // reg. HIGHBYTES 2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds post_office_write(zr, 0, reg & 0x03, val & 0xff); // reg. LOWBYTES + wr. data 2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* videocodec bus functions ZR36016 */ 2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic u32 2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszr36016_read (struct videocodec *codec, 2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 reg) 2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) codec->master_data->data; 2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __u32 data; 2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (post_office_wait(zr)) { 2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -1; 2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data = post_office_read(zr, 2, reg & 0x03) & 0xff; // read 2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return data; 2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* hack for in zoran_device.c */ 2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid 2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszr36016_write (struct videocodec *codec, 2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 reg, 2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 val) 2361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) codec->master_data->data; 2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (post_office_wait(zr)) { 2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 2411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds post_office_write(zr, 2, reg & 0x03, val & 0x0ff); // wr. data 2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Board specific information 2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsdc10_init (struct zoran *zr) 2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 253c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__); 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Pixel clock selection */ 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds GPIO(zr, 4, 0); 2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds GPIO(zr, 5, 1); 2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Enable the video bus sync signals */ 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds GPIO(zr, 7, 0); 2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 2631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsdc10plus_init (struct zoran *zr) 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 265c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__); 2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsbuz_init (struct zoran *zr) 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 271c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__); 2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* some stuff from Iomega */ 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15); 2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pci_write_config_dword(zr->pci_dev, 0x0c, 0x00012020); 2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pci_write_config_dword(zr->pci_dev, 0xe8, 0xc0200000); 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldslml33_init (struct zoran *zr) 2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 282c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__); 2831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds GPIO(zr, 2, 1); // Set Composite input/output 2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 287fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelssonstatic void 288fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelssonavs6eyes_init (struct zoran *zr) 289fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson{ 290fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson // AverMedia 6-Eyes original driver by Christer Weinigel 291fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 292fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson // Lifted straight from Christer's old driver and 293fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson // modified slightly by Martin Samuelsson. 294fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 295fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson int mux = default_mux; /* 1 = BT866, 7 = VID1 */ 296fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 297fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 4, 1); /* Bt866 SLEEP on */ 298fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson udelay(2); 299fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 300fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 0, 1); /* ZR36060 /RESET on */ 301fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 1, 0); /* ZR36060 /SLEEP on */ 302fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 2, mux & 1); /* MUX S0 */ 303fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 3, 0); /* /FRAME on */ 304fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 4, 0); /* Bt866 SLEEP off */ 305fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 5, mux & 2); /* MUX S1 */ 306fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 6, 0); /* ? */ 307fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson GPIO(zr, 7, mux & 4); /* MUX S2 */ 308fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 309fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson} 310fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic char * 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldscodecid_to_modulename (u16 codecid) 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds char *name = NULL; 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (codecid) { 3171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case CODEC_TYPE_ZR36060: 3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds name = "zr36060"; 3191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case CODEC_TYPE_ZR36050: 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds name = "zr36050"; 3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case CODEC_TYPE_ZR36016: 3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds name = "zr36016"; 3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 3261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return name; 3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds// struct tvnorm { 3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds// u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart; 3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds// }; 3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 }; 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 }; 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 }; 3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 }; 3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f50ccir601_lml33 = { 864, 720, 75+34, 804, 625, 576, 18 }; 3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f60ccir601_lml33 = { 858, 720, 57+34, 788, 525, 480, 16 }; 3421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */ 3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 }; 3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 }; 3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* FIXME: I cannot swap U and V in saa7114, so i do one 3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * pixel left shift in zoran (75 -> 74) 3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (Maxim Yevtyushkin <max@linuxmedialabs.com>) */ 3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74+54, 804, 625, 576, 18 }; 3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56+54, 788, 525, 480, 16 }; 3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 353fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson/* FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I 354fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson * copy Maxim's left shift hack for the 6 Eyes. 355fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson * 356fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson * Christer's driver used the unshifted norms, though... 357fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson * /Sam */ 358fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelssonstatic struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 }; 359fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelssonstatic struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 }; 360fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 3610ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short vpx3220_addrs[] = { 0x43, 0x47, I2C_CLIENT_END }; 3620ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short saa7110_addrs[] = { 0x4e, 0x4f, I2C_CLIENT_END }; 3630ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short saa7111_addrs[] = { 0x25, 0x24, I2C_CLIENT_END }; 3640ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short saa7114_addrs[] = { 0x21, 0x20, I2C_CLIENT_END }; 3650ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short adv717x_addrs[] = { 0x6a, 0x6b, 0x2a, 0x2b, I2C_CLIENT_END }; 3660ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short ks0127_addrs[] = { 0x6c, 0x6d, I2C_CLIENT_END }; 3670ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short saa7185_addrs[] = { 0x44, I2C_CLIENT_END }; 3680ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short bt819_addrs[] = { 0x45, I2C_CLIENT_END }; 3690ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short bt856_addrs[] = { 0x44, I2C_CLIENT_END }; 3700ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilstatic const unsigned short bt866_addrs[] = { 0x44, I2C_CLIENT_END }; 3710ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil 3724c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartmanstatic struct card_info zoran_cards[NUM_CARDS] = { 3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = DC10_old, 3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "DC10(old)", 3760ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "vpx3220a", 3770ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = vpx3220_addrs, 3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36050, 3791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_vfe = CODEC_TYPE_ZR36016, 3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 3, 3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 1, "Composite" }, 3841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 2, "S-Video" }, 3851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Internal/comp" } 3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 387107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, 3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel_dc10, 3901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60sqpixel_dc10, 3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel_dc10 3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = 0, 3941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ1, 3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 2, 1, -1, 3, 7, 0, 4, 5 }, 3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 }, 3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { -1, 0 }, 3981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, 3991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 0, 400fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &dc10_init, 4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = DC10_new, 4041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "DC10(new)", 4050ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "saa7110", 4060ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = saa7110_addrs, 4070ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "adv7175", 4080ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = adv717x_addrs, 4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36060, 4101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 3, 4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Composite" }, 4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 7, "S-Video" }, 4151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 5, "Internal/comp" } 4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 417107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, 4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 4191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel, 4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60sqpixel, 4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel}, 4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = ZR36057_ISR_GIRQ0, 4231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ1, 4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 3, 0, 6, 1, 2, -1, 4, 5 }, 4251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, 4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { -1, 1}, 4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 1, 1, 1, 1, 0, 0, 0, 0 }, 4281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 0, 429fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &dc10plus_init, 4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = DC10plus, 4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "DC10plus", 4340ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "saa7110", 4350ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = saa7110_addrs, 4360ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "adv7175", 4370ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = adv717x_addrs, 4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36060, 4391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 3, 4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Composite" }, 4431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 7, "S-Video" }, 4441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 5, "Internal/comp" } 4451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 446107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, 4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel, 4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60sqpixel, 4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel 4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 4521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = ZR36057_ISR_GIRQ0, 4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ1, 4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 3, 0, 6, 1, 2, -1, 4, 5 }, 4551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, 4561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { -1, 1 }, 4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 1, 1, 1, 1, 0, 0, 0, 0 }, 4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 0, 459fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 4601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &dc10plus_init, 4611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 4621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = DC30, 4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "DC30", 4640ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "vpx3220a", 4650ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = vpx3220_addrs, 4660ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "adv7175", 4670ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = adv717x_addrs, 4681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36050, 4691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_vfe = CODEC_TYPE_ZR36016, 4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 3, 4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 4731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 1, "Composite" }, 4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 2, "S-Video" }, 4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Internal/comp" } 4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 477107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, 4781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 4791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel_dc10, 4801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60sqpixel_dc10, 4811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel_dc10 4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 4831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = 0, 4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ1, 4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 2, 1, -1, 3, 7, 0, 4, 5 }, 4861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 }, 4871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { -1, 0 }, 4881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, 4891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 0, 490fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 4911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &dc10_init, 4921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 4931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = DC30plus, 4941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "DC30plus", 4950ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "vpx3220a", 4960ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = vpx3220_addrs, 4970ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "adv7175", 4980ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = adv717x_addrs, 4991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36050, 5001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_vfe = CODEC_TYPE_ZR36016, 5011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 3, 5031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 5041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 1, "Composite" }, 5051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 2, "S-Video" }, 5061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Internal/comp" } 5071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 508107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, 5091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 5101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel_dc10, 5111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60sqpixel_dc10, 5121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50sqpixel_dc10 5131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 5141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = 0, 5151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ1, 5161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 2, 1, -1, 3, 7, 0, 4, 5 }, 5171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 }, 5181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { -1, 0 }, 5191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, 5201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 0, 521fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 5221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &dc10_init, 5231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 5241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = LML33, 5251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "LML33", 5260ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "bt819a", 5270ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = bt819_addrs, 5280ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "bt856", 5290ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = bt856_addrs, 5301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36060, 5311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 2, 5331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 5341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Composite" }, 5351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 7, "S-Video" } 5361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 537107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL, 5381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 5391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50ccir601_lml33, 5401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60ccir601_lml33, 5411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds NULL 5421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 5431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = ZR36057_ISR_GIRQ1, 5441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ0, 5451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 1, -1, 3, 5, 7, -1, -1, -1 }, 5461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 0, 1, 0, 0, 0 }, 5471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { 3, 1 }, 5481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 1, 1, 0, 0, 0, 1, 0, 0 }, 5491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 1, 550fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 5511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &lml33_init, 5521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 5531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = LML33R10, 5541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "LML33R10", 5550ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "saa7114", 5560ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = saa7114_addrs, 5570ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "adv7170", 5580ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = adv717x_addrs, 5591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36060, 5601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 2, 5621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 5631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 0, "Composite" }, 5641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 7, "S-Video" } 5651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 566107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL, 5671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 5681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50ccir601_lm33r10, 5691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60ccir601_lm33r10, 5701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds NULL 5711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 5721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = ZR36057_ISR_GIRQ1, 5731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ0, 5741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 1, -1, 3, 5, 7, -1, -1, -1 }, 5751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 0, 1, 0, 0, 0 }, 5761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { 3, 1 }, 5771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 1, 1, 0, 0, 0, 1, 0, 0 }, 5781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 1, 579fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 5801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &lml33_init, 5811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, { 5821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .type = BUZ, 5831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .name = "Buz", 5840ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "saa7111", 5850ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = saa7111_addrs, 5860ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "saa7185", 5870ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = saa7185_addrs, 5881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .video_codec = CODEC_TYPE_ZR36060, 5891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .inputs = 2, 5911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .input = { 5921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 3, "Composite" }, 5931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 7, "S-Video" } 5941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 595107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, 5961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .tvn = { 5971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50ccir601, 5981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f60ccir601, 5991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds &f50ccir601 6001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds }, 6011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .jpeg_int = ZR36057_ISR_GIRQ1, 6021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vsync_int = ZR36057_ISR_GIRQ0, 6031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio = { 1, -1, 3, -1, -1, -1, -1, -1 }, 6041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, 6051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gpcs = { 3, 1 }, 6061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .vfe_pol = { 1, 1, 0, 0, 0, 1, 0, 0 }, 6071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .gws_not_connected = 1, 608fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 0, 6091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .init = &buz_init, 610fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson }, { 611fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .type = AVS6EYES, 612fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .name = "6-Eyes", 613fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson /* AverMedia chose not to brand the 6-Eyes. Thus it 614fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson can't be autodetected, and requires card=x. */ 6150ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_decoder = "ks0127", 6160ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_decoder = ks0127_addrs, 6170ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .i2c_encoder = "bt866", 6180ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil .addrs_encoder = bt866_addrs, 619fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .video_codec = CODEC_TYPE_ZR36060, 620fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 621fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .inputs = 10, 622fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input = { 623fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 0, "Composite 1" }, 624fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 1, "Composite 2" }, 625fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 2, "Composite 3" }, 626fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 4, "Composite 4" }, 627fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 5, "Composite 5" }, 628fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 6, "Composite 6" }, 629fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 8, "S-Video 1" }, 630fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson { 9, "S-Video 2" }, 631fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson {10, "S-Video 3" }, 632fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson {15, "YCbCr" } 633fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson }, 634107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil .norms = V4L2_STD_NTSC|V4L2_STD_PAL, 635fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .tvn = { 636fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson &f50ccir601_avs6eyes, 637fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson &f60ccir601_avs6eyes, 638fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson NULL 639fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson }, 640fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .jpeg_int = ZR36057_ISR_GIRQ1, 641fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .vsync_int = ZR36057_ISR_GIRQ0, 642fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .gpio = { 1, 0, 3, -1, -1, -1, -1, -1 },// Validity unknown /Sam 643fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, // Validity unknown /Sam 644fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .gpcs = { 3, 1 }, // Validity unknown /Sam 645fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .vfe_pol = { 1, 0, 0, 0, 0, 1, 0, 0 }, // Validity unknown /Sam 646fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .gws_not_connected = 1, 647fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .input_mux = 1, 648fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson .init = &avs6eyes_init, 6491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 650fbe60daac4c34e39d1ca69684bcb76e62461ac21Martin Samuelsson 6511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 6521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 6541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * I2C functions 6551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 6561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* software I2C functions */ 6571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 6581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_i2c_getsda (void *data) 6591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 6601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) data; 6611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (btread(ZR36057_I2CBR) >> 1) & 1; 6631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 6641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 6661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_i2c_getscl (void *data) 6671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 6681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) data; 6691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return btread(ZR36057_I2CBR) & 1; 6711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 6721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 6741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_i2c_setsda (void *data, 6751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int state) 6761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 6771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) data; 6781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (state) 6801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->i2cbr |= 2; 6811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds else 6821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->i2cbr &= ~2; 6831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(zr->i2cbr, ZR36057_I2CBR); 6841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 6851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 6871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_i2c_setscl (void *data, 6881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int state) 6891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 6901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr = (struct zoran *) data; 6911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (state) 6931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->i2cbr |= 1; 6941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds else 6951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->i2cbr &= ~1; 6961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(zr->i2cbr, ZR36057_I2CBR); 6971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 6981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6996275163e3ddbf0f0b34981bf6dc50b803e5a1c67Jean Delvarestatic const struct i2c_algo_bit_data zoran_i2c_bit_data_template = { 7001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .setsda = zoran_i2c_setsda, 7011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .setscl = zoran_i2c_setscl, 7021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .getsda = zoran_i2c_getsda, 7031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .getscl = zoran_i2c_getscl, 7041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .udelay = 10, 7051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds .timeout = 100, 7061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 7071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 7091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_register_i2c (struct zoran *zr) 7101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 71137320d7bc0180979d49de21b90f30a97f57b3ee1Ezequiel Garcia zr->i2c_algo = zoran_i2c_bit_data_template; 7121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->i2c_algo.data = zr; 7136275163e3ddbf0f0b34981bf6dc50b803e5a1c67Jean Delvare strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), 7146275163e3ddbf0f0b34981bf6dc50b803e5a1c67Jean Delvare sizeof(zr->i2c_adapter.name)); 7150ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev); 7161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->i2c_adapter.algo_data = &zr->i2c_algo; 71712a917f69d1468c91d646dbad8408dd0d39d6207Jean Delvare zr->i2c_adapter.dev.parent = &zr->pci_dev->dev; 7181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return i2c_bit_add_bus(&zr->i2c_adapter); 7191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 7201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic void 7221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_unregister_i2c (struct zoran *zr) 7231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 7243269711b76ba27b78862c48398b0d313ccaa99c2Jean Delvare i2c_del_adapter(&zr->i2c_adapter); 7251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 7261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Check a zoran_params struct for correctness, insert default params */ 7281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint 7301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_check_jpg_settings (struct zoran *zr, 7310ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil struct zoran_jpg_settings *settings, 7320ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil int try) 7331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 7341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int err = 0, err0 = 0; 7351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(4, 7371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_DEBUG 738c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n", 739c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__, settings->decimation, settings->HorDcm, 7401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->VerDcm, settings->TmpDcm); 7411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(4, 7421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_DEBUG 743c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - x: %d, y: %d, w: %d, y: %d\n", 744c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__, settings->img_x, settings->img_y, 7451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_width, settings->img_height); 7461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Check decimation, set default values for decimation = 1, 2, 4 */ 7471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (settings->decimation) { 7481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 1: 7491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->HorDcm = 1; 7511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->VerDcm = 1; 7521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->TmpDcm = 1; 7531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->field_per_buff = 2; 7541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_x = 0; 7551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_y = 0; 7561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_width = BUZ_MAX_WIDTH; 7571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_height = BUZ_MAX_HEIGHT / 2; 7581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 7591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 2: 7601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->HorDcm = 2; 7621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->VerDcm = 1; 7631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->TmpDcm = 2; 7641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->field_per_buff = 1; 7651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0; 7661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_y = 0; 7671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_width = 7681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (BUZ_MAX_WIDTH == 720) ? 704 : BUZ_MAX_WIDTH; 7691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_height = BUZ_MAX_HEIGHT / 2; 7701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 7711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 4: 7721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (zr->card.type == DC10_new) { 7741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 7751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_DEBUG 776c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - HDec by 4 is not supported on the DC10\n", 777c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 7781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 7791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 7801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 7811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->HorDcm = 4; 7831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->VerDcm = 2; 7841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->TmpDcm = 2; 7851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->field_per_buff = 1; 7861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0; 7871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_y = 0; 7881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_width = 7891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (BUZ_MAX_WIDTH == 720) ? 704 : BUZ_MAX_WIDTH; 7901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->img_height = BUZ_MAX_HEIGHT / 2; 7911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 7921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0: 7931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* We have to check the data the user has set */ 7951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->HorDcm != 1 && settings->HorDcm != 2 && 7970ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil (zr->card.type == DC10_new || settings->HorDcm != 4)) { 7980ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->HorDcm = clamp(settings->HorDcm, 1, 2); 7991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8000ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8010ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->VerDcm != 1 && settings->VerDcm != 2) { 8020ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->VerDcm = clamp(settings->VerDcm, 1, 2); 8031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8040ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8050ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->TmpDcm != 1 && settings->TmpDcm != 2) { 8060ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->TmpDcm = clamp(settings->TmpDcm, 1, 2); 8071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8080ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->field_per_buff != 1 && 8100ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->field_per_buff != 2) { 8110ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->field_per_buff = clamp(settings->field_per_buff, 1, 2); 8121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8130ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8140ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_x < 0) { 8150ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_x = 0; 8161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8170ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8180ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_y < 0) { 8190ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_y = 0; 8201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8210ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8220ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_width < 0 || settings->img_width > BUZ_MAX_WIDTH) { 8230ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_width = clamp(settings->img_width, 0, (int)BUZ_MAX_WIDTH); 8241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8250ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8260ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_height < 0 || settings->img_height > BUZ_MAX_HEIGHT / 2) { 8270ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_height = clamp(settings->img_height, 0, BUZ_MAX_HEIGHT / 2); 8281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8290ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8300ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH) { 8310ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_x = BUZ_MAX_WIDTH - settings->img_width; 8320ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil err0++; 8330ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8340ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2) { 8350ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_y = BUZ_MAX_HEIGHT / 2 - settings->img_height; 8361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8370ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8380ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_width % (16 * settings->HorDcm) != 0) { 8390ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_width -= settings->img_width % (16 * settings->HorDcm); 8400ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_width == 0) 8410ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_width = 16 * settings->HorDcm; 8420ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil err0++; 8430ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil } 8440ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_height % (8 * settings->VerDcm) != 0) { 8450ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_height -= settings->img_height % (8 * settings->VerDcm); 8460ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (settings->img_height == 0) 8470ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil settings->img_height = 8 * settings->VerDcm; 8481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err0++; 8491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8510ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil if (!try && err0) { 8521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 8531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_ERR 854c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - error in params for decimation = 0\n", 855c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 8561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err++; 8571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 8591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 8601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 8611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_ERR 862c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - decimation = %d, must be 0, 1, 2 or 4\n", 863c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__, settings->decimation); 8641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds err++; 8651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 8661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.quality > 100) 8691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.quality = 100; 8701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.quality < 5) 8711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.quality = 5; 8721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.APPn < 0) 8731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.APPn = 0; 8741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.APPn > 15) 8751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.APPn = 15; 8761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.APP_len < 0) 8771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.APP_len = 0; 8781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.APP_len > 60) 8791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.APP_len = 60; 8801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.COM_len < 0) 8811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.COM_len = 0; 8821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (settings->jpg_comp.COM_len > 60) 8831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds settings->jpg_comp.COM_len = 60; 8841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (err) 8851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EINVAL; 8861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 8871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 8881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid 8901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_open_init_params (struct zoran *zr) 8911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 8921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int i; 8931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* User must explicitly set a window */ 8951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->overlay_settings.is_set = 0; 8961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->overlay_mask = NULL; 8971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->overlay_active = ZORAN_FREE; 8981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_memgrab_active = 0; 9001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_overlay_active = 0; 9011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_grab_frame = NO_GRAB_ACTIVE; 9021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_grab_seq = 0; 9031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_settings.width = 192; 9041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_settings.height = 144; 905c014ec90bc1b951e3fff89bc6ba826b8ef0f444bJean Delvare zr->v4l_settings.format = &zoran_formats[7]; /* YUY2 - YUV-4:2:2 packed */ 9061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_settings.bytesperline = 9071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_settings.width * 9081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ((zr->v4l_settings.format->depth + 7) / 8); 9091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* DMA ring stuff for V4L */ 9111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_pend_tail = 0; 9121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_pend_head = 0; 9131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_sync_tail = 0; 9141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_buffers.active = ZORAN_FREE; 9151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds for (i = 0; i < VIDEO_MAX_FRAME; i++) { 9161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_buffers.buffer[i].state = BUZ_STATE_USER; /* nothing going on */ 9171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 9181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_buffers.allocated = 0; 9191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds for (i = 0; i < BUZ_MAX_FRAME; i++) { 9211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_buffers.buffer[i].state = BUZ_STATE_USER; /* nothing going on */ 9221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 9231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_buffers.active = ZORAN_FREE; 9241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_buffers.allocated = 0; 9251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Set necessary params and call zoran_check_jpg_settings to set the defaults */ 9261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.decimation = 1; 9271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.jpg_comp.quality = 50; /* default compression factor 8 */ 9281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (zr->card.type != BUZ) 9291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.odd_even = 1; 9301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds else 9311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.odd_even = 0; 9321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.jpg_comp.APPn = 0; 9331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.jpg_comp.APP_len = 0; /* No APPn marker */ 9341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds memset(zr->jpg_settings.jpg_comp.APP_data, 0, 9351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds sizeof(zr->jpg_settings.jpg_comp.APP_data)); 9361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.jpg_comp.COM_len = 0; /* No COM marker */ 9371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds memset(zr->jpg_settings.jpg_comp.COM_data, 0, 9381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds sizeof(zr->jpg_settings.jpg_comp.COM_data)); 9391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_settings.jpg_comp.jpeg_markers = 940ad1ecf8639e51ab8066cd4f37fd36b6b7cbdd8b3Hans Verkuil V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT; 9410ba514d5d39d017e320ffba6d2a98563b829d37cHans Verkuil i = zoran_check_jpg_settings(zr, &zr->jpg_settings, 0); 9421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (i) 943c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s internal error\n", 944c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 9451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds clear_interrupt_counters(zr); 9471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->testing = 0; 9481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 9491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9504c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartmanstatic void test_interrupts (struct zoran *zr) 9511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 9521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DEFINE_WAIT(wait); 9531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int timeout, icr; 9541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds clear_interrupt_counters(zr); 9561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->testing = 1; 9581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds icr = btread(ZR36057_ICR); 9591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(0x78000000 | ZR36057_ICR_IntPinEn, ZR36057_ICR); 9601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds prepare_to_wait(&zr->test_q, &wait, TASK_INTERRUPTIBLE); 9611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds timeout = schedule_timeout(HZ); 9621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds finish_wait(&zr->test_q, &wait); 9631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(0, ZR36057_ICR); 9641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(0x78000000, ZR36057_ISR); 9651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->testing = 0; 9661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(5, KERN_INFO "%s: Testing interrupts...\n", ZR_DEVNAME(zr)); 9671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (timeout) { 9681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, ": time spent: %d\n", 1 * HZ - timeout); 9691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 97018b548ca580838a2cc5813a941e6dab28660bb22Jean Delvare if (zr36067_debug > 1) 9711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds print_interrupts(zr); 9721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(icr, ZR36057_ICR); 9731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 9741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9754c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartmanstatic int zr36057_init (struct zoran *zr) 9761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 977daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare int j, err; 9781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 9801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_INFO 981c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - initializing card[%d], zr=%p\n", 982c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__, zr->id, zr); 9831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* default setup of all parameters which will persist between opens */ 9851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->user = 0; 9861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds init_waitqueue_head(&zr->v4l_capq); 9881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds init_waitqueue_head(&zr->jpg_capq); 9891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds init_waitqueue_head(&zr->test_q); 9901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->jpg_buffers.allocated = 0; 9911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->v4l_buffers.allocated = 0; 9921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9937f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil zr->vbuf_base = (void *) vidmem; 9947f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil zr->vbuf_width = 0; 9957f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil zr->vbuf_height = 0; 9967f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil zr->vbuf_depth = 0; 9977f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil zr->vbuf_bytesperline = 0; 9981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Avoid nonsense settings from user for default input/norm */ 1000b475f4eeda1da16e995b2302f6eebdfb08ce18cdRoel Kluin if (default_norm < 0 || default_norm > 2) 10017f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil default_norm = 0; 10027f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil if (default_norm == 0) { 1003107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->norm = V4L2_STD_PAL; 1004107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->timing = zr->card.tvn[0]; 10057f6adeaf2d8800b66c5dd6c2cf2622dfdd68bd31Hans Verkuil } else if (default_norm == 1) { 1006107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->norm = V4L2_STD_NTSC; 1007107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->timing = zr->card.tvn[1]; 1008107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil } else { 1009107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->norm = V4L2_STD_SECAM; 1010107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->timing = zr->card.tvn[2]; 1011107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil } 1012107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil if (zr->timing == NULL) { 10131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 10141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_WARNING 1015c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - default TV standard not supported by hardware. PAL will be used.\n", 1016c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 1017107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->norm = V4L2_STD_PAL; 1018107063c6156a0cbf055e771baafc28a3e3c0fb9bHans Verkuil zr->timing = zr->card.tvn[0]; 10191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 102160e3cac47a442fae74d3429f706350229623bcceTrent Piepho if (default_input > zr->card.inputs-1) { 102260e3cac47a442fae74d3429f706350229623bcceTrent Piepho dprintk(1, 102360e3cac47a442fae74d3429f706350229623bcceTrent Piepho KERN_WARNING 102460e3cac47a442fae74d3429f706350229623bcceTrent Piepho "%s: default_input value %d out of range (0-%d)\n", 102560e3cac47a442fae74d3429f706350229623bcceTrent Piepho ZR_DEVNAME(zr), default_input, zr->card.inputs-1); 102660e3cac47a442fae74d3429f706350229623bcceTrent Piepho default_input = 0; 102760e3cac47a442fae74d3429f706350229623bcceTrent Piepho } 102860e3cac47a442fae74d3429f706350229623bcceTrent Piepho zr->input = default_input; 10291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* default setup (will be repeated at every open) */ 10311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zoran_open_init_params(zr); 10321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* allocate memory *before* doing anything to the hardware 10341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * in case allocation fails */ 1035daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL); 10366ce3ced4f73e3f0c345f47dc99fd21f2248724a8Hans Verkuil zr->video_dev = video_device_alloc(); 1037daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare if (!zr->stat_com || !zr->video_dev) { 10381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 10391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_ERR 1040c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - kmalloc (STAT_COM) failed\n", 1041c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 1042daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare err = -ENOMEM; 1043daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare goto exit_free; 10441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds for (j = 0; j < BUZ_NUM_STAT_COM; j++) { 10469c169df8d6877c618587bf40498f2ef378c97eb8Al Viro zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */ 10471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 10501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Now add the template and register the device unit. 10511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 10521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); 10539592bd0a9e74c344f674663137e5ccff7a39f7d0Hans Verkuil zr->video_dev->v4l2_dev = &zr->v4l2_dev; 10541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); 1055954f340fc7f2fa2ae8812670da49e828d2686d8eHans Verkuil /* It's not a mem2mem device, but you can both capture and output from 1056954f340fc7f2fa2ae8812670da49e828d2686d8eHans Verkuil one and the same device. This should really be split up into two 1057954f340fc7f2fa2ae8812670da49e828d2686d8eHans Verkuil device nodes, but that's a job for another day. */ 1058954f340fc7f2fa2ae8812670da49e828d2686d8eHans Verkuil zr->video_dev->vfl_dir = VFL_DIR_M2M; 105960e3cac47a442fae74d3429f706350229623bcceTrent Piepho err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr[zr->id]); 1060daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare if (err < 0) 106166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto exit_free; 1062601139e08339b15997c6ae638dc5bf42c51ea204Trent Piepho video_set_drvdata(zr->video_dev, zr); 10631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zoran_init_hardware(zr); 106518b548ca580838a2cc5813a941e6dab28660bb22Jean Delvare if (zr36067_debug > 2) 10661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds detect_guest_activity(zr); 10671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds test_interrupts(zr); 10681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!pass_through) { 10690ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil decoder_call(zr, video, s_stream, 0); 10705325b4272a53b43f55b82cc369c310c2fcacdca1Hans Verkuil encoder_call(zr, video, s_routing, 2, 0, 0); 10711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->zoran_proc = NULL; 10741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zr->initialized = 1; 10751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 1076daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare 1077daf72f408c66aee4ac939f614293a78841aa7717Jean Delvareexit_free: 1078daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare kfree(zr->stat_com); 1079daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare kfree(zr->video_dev); 1080daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare return err; 10811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 10821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10834c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartmanstatic void zoran_remove(struct pci_dev *pdev) 10841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 10850ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev); 10860ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil struct zoran *zr = to_zoran(v4l2_dev); 108766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 10881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!zr->initialized) 108985b9b8a444413ea5706096df13012520ed6c5103Jean Delvare goto exit_free; 109066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 10911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* unregister videocodec bus */ 10921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (zr->codec) { 10931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct videocodec_master *master = zr->codec->master_data; 10942ea7533060e361810c21b2f5ee02151c4dfb85d8Jesper Juhl 10951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds videocodec_detach(zr->codec); 10962ea7533060e361810c21b2f5ee02151c4dfb85d8Jesper Juhl kfree(master); 10971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (zr->vfe) { 10991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct videocodec_master *master = zr->vfe->master_data; 11002ea7533060e361810c21b2f5ee02151c4dfb85d8Jesper Juhl 11011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds videocodec_detach(zr->vfe); 11022ea7533060e361810c21b2f5ee02151c4dfb85d8Jesper Juhl kfree(master); 11031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 11041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 11051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* unregister i2c bus */ 11061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zoran_unregister_i2c(zr); 11071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* disable PCI bus-mastering */ 11081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zoran_set_pci_master(zr, 0); 11091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* put chip into reset */ 11101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds btwrite(0, ZR36057_SPGPPCR); 11111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds free_irq(zr->pci_dev->irq, zr); 11121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* unmap and free memory */ 1113daf72f408c66aee4ac939f614293a78841aa7717Jean Delvare kfree(zr->stat_com); 11141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds zoran_proc_cleanup(zr); 11151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds iounmap(zr->zr36057_mem); 11161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pci_disable_device(zr->pci_dev); 11171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds video_unregister_device(zr->video_dev); 111885b9b8a444413ea5706096df13012520ed6c5103Jean Delvareexit_free: 11190ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil v4l2_device_unregister(&zr->v4l2_dev); 112085b9b8a444413ea5706096df13012520ed6c5103Jean Delvare kfree(zr); 11211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 11221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 11231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid 11241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldszoran_vdev_release (struct video_device *vdev) 11251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 11261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds kfree(vdev); 11271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 11281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 11294c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartmanstatic struct videocodec_master *zoran_setup_videocodec(struct zoran *zr, 11304c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartman int type) 11311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 11321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct videocodec_master *m = NULL; 11331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 11341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m = kmalloc(sizeof(struct videocodec_master), GFP_KERNEL); 11351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!m) { 1136c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s - no memory\n", 1137c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 11381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return m; 11391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 11401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 114122c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab /* magic and type are unused for master struct. Makes sense only at 114222c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab codec structs. 114322c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab In the past, .type were initialized to the old V4L1 .hardware 114422c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab value, as VID_HARDWARE_ZR36067 114522c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab */ 114622c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab m->magic = 0L; 114722c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab m->type = 0; 114822c4a4e98ece0eaff13b3d0ac73c5283013eb6b1Mauro Carvalho Chehab 11491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER; 1150bd0eb12f61fef7f500e374b8d5068e7556f61901Roel Kluin strlcpy(m->name, ZR_DEVNAME(zr), sizeof(m->name)); 11511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->data = zr; 11521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 11531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (type) 11541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 11551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case CODEC_TYPE_ZR36060: 11561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->readreg = zr36060_read; 11571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->writereg = zr36060_write; 11581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->flags |= CODEC_FLAG_JPEG | CODEC_FLAG_VFE; 11591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 11601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case CODEC_TYPE_ZR36050: 11611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->readreg = zr36050_read; 11621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->writereg = zr36050_write; 11631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->flags |= CODEC_FLAG_JPEG; 11641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 11651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case CODEC_TYPE_ZR36016: 11661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->readreg = zr36016_read; 11671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->writereg = zr36016_write; 11681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds m->flags |= CODEC_FLAG_VFE; 11691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 11701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 11711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 11721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return m; 11731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 11741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 117533470423aba5da982dc944658da232942824f2d5Hans Verkuilstatic void zoran_subdev_notify(struct v4l2_subdev *sd, unsigned int cmd, void *arg) 11761cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil{ 11771cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil struct zoran *zr = to_zoran(sd->v4l2_dev); 11781cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil 11791cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil /* Bt819 needs to reset its FIFO buffer using #FRST pin and 11801cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil LML33 card uses GPIO(7) for that. */ 11811cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil if (cmd == BT819_FIFO_RESET_LOW) 11821cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil GPIO(zr, 7, 0); 11831cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil else if (cmd == BT819_FIFO_RESET_HIGH) 11841cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil GPIO(zr, 7, 1); 11851cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil} 11861cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil 11871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 1188c84e6036ba7177a404cc860cb5a440e06fad92ddJoe Perches * Scan for a Buz card (actually for the PCI controller ZR36057), 11891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * request the irq and map the io memory 11901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 11914c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartmanstatic int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 11921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 11931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned char latency, need_latency; 11941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct zoran *zr; 11951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int result; 11961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct videocodec_master *master_vfe = NULL; 11971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct videocodec_master *master_codec = NULL; 11981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int card_num; 11990ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil char *codec_name, *vfe_name; 120066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho unsigned int nr; 12011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 12021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1203601139e08339b15997c6ae638dc5bf42c51ea204Trent Piepho nr = zoran_num++; 120466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (nr >= BUZ_MAX) { 1205c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: driver limited to %d card(s) maximum\n", 120666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZORAN_NAME, BUZ_MAX); 120766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho return -ENOENT; 120866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 12091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 121066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr = kzalloc(sizeof(struct zoran), GFP_KERNEL); 121166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (!zr) { 1212c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s - kzalloc failed\n", 1213c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZORAN_NAME, __func__); 121466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho return -ENOMEM; 121566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 12161cd3c0fa927084549005fc22e54d99684b314f14Hans Verkuil zr->v4l2_dev.notify = zoran_subdev_notify; 12170ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev)) 12180ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil goto zr_free_mem; 121966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr->pci_dev = pdev; 122066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr->id = nr; 122166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); 122266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho spin_lock_init(&zr->spinlock); 122366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho mutex_init(&zr->resource_lock); 12240edf2e5e2bd0ae7689ce8a57ae3c87cc1f0c6548Arnd Bergmann mutex_init(&zr->other_lock); 122566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (pci_enable_device(pdev)) 12260ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil goto zr_unreg; 1227abd34d8d6b213c792c1a06fd75488595c5fb6d3fBjørn Mork zr->revision = zr->pci_dev->revision; 122817faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho 122917faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho dprintk(1, 123017faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho KERN_INFO 12315e098b668977c85838af09005bd96c2e987654f0Trent Piepho "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n", 123217faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision, 12335e098b668977c85838af09005bd96c2e987654f0Trent Piepho zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0)); 123417faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho if (zr->revision >= 2) { 123566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(1, 123666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho KERN_INFO 123717faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho "%s: Subsystem vendor=0x%04x id=0x%04x\n", 123817faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor, 123917faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho zr->pci_dev->subsystem_device); 124017faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho } 12411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 124217faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho /* Use auto-detected card type? */ 124317faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho if (card[nr] == -1) { 124417faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho if (zr->revision < 2) { 12451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 12461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_ERR 124717faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho "%s: No card type specified, please use the card=X module parameter\n", 124817faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVNAME(zr)); 124917faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho dprintk(1, 125017faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho KERN_ERR 125117faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho "%s: It is not possible to auto-detect ZR36057 based cards\n", 12521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ZR_DEVNAME(zr)); 12530ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil goto zr_unreg; 12541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 12551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 125617faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho card_num = ent->driver_data; 125717faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho if (card_num >= NUM_CARDS) { 125817faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho dprintk(1, 125917faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho KERN_ERR 126017faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho "%s: Unknown card, try specifying card=X module parameter\n", 126166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZR_DEVNAME(zr)); 12620ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil goto zr_unreg; 126317faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho } 126417faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho dprintk(3, 126517faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho KERN_DEBUG 126617faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho "%s: %s() - card %s detected\n", 126717faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name); 126817faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho } else { 126917faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho card_num = card[nr]; 127017faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho if (card_num >= NUM_CARDS || card_num < 0) { 127117faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho dprintk(1, 127217faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho KERN_ERR 127317faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho "%s: User specified card type %d out of range (0 .. %d)\n", 127417faeb20912af5d2a1422fdb606e785f9b1d88baTrent Piepho ZR_DEVNAME(zr), card_num, NUM_CARDS - 1); 12750ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil goto zr_unreg; 12761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 127766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 12781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 127966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* even though we make this a non pointer and thus 128066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho * theoretically allow for making changes to this struct 128166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho * on a per-individual card basis at runtime, this is 128266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho * strongly discouraged. This structure is intended to 128366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho * keep general card information, no settings or anything */ 128466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr->card = zoran_cards[card_num]; 128566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), 128666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho "%s[%u]", zr->card.name, zr->id); 128766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 12885e098b668977c85838af09005bd96c2e987654f0Trent Piepho zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0); 128966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (!zr->zr36057_mem) { 1290c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s() - ioremap failed\n", 12915e098b668977c85838af09005bd96c2e987654f0Trent Piepho ZR_DEVNAME(zr), __func__); 12920ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil goto zr_unreg; 129366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 12941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 129566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho result = request_irq(zr->pci_dev->irq, zoran_irq, 12967b5e71ad0437390b57b0e9bb834405f043cb72e8Michael Opdenacker IRQF_SHARED, ZR_DEVNAME(zr), zr); 129766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (result < 0) { 129866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (result == -EINVAL) { 129966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(1, 130066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho KERN_ERR 1301c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - bad irq number or handler\n", 1302c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 130366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } else if (result == -EBUSY) { 130466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(1, 130566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho KERN_ERR 1306c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - IRQ %d busy, change your PnP config in BIOS\n", 1307c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__, zr->pci_dev->irq); 13081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } else { 130966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(1, 131066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho KERN_ERR 1311c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho "%s: %s - can't assign irq, error code %d\n", 1312c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__, result); 13131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 131466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_unmap; 131566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 13161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 131766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* set PCI latency timer */ 131866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, 131966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho &latency); 132066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho need_latency = zr->revision > 1 ? 32 : 48; 132166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (latency != need_latency) { 1322c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(2, KERN_INFO "%s: Changing PCI latency from %d to %d\n", 132366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZR_DEVNAME(zr), latency, need_latency); 132466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, 132566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho need_latency); 132666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 13271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 132866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr36057_restart(zr); 132966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* i2c */ 133066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", 133166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZR_DEVNAME(zr)); 133266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 133366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zoran_register_i2c(zr) < 0) { 1334c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s - can't initialize i2c bus\n", 1335c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 133666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_free_irq; 133766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 13381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 133953dacb15705901e14b03dcba27e40364fedd9d09Hans Verkuil zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, 13409a1f8b34aa539000da17a06235e4bec254d0bfb5Laurent Pinchart &zr->i2c_adapter, zr->card.i2c_decoder, 134153dacb15705901e14b03dcba27e40364fedd9d09Hans Verkuil 0, zr->card.addrs_decoder); 13420ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil 134399f7d81bd7c33a31cbd8c87757fa4faa8c6b1425Laurent Pinchart if (zr->card.i2c_encoder) 134453dacb15705901e14b03dcba27e40364fedd9d09Hans Verkuil zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, 13459a1f8b34aa539000da17a06235e4bec254d0bfb5Laurent Pinchart &zr->i2c_adapter, zr->card.i2c_encoder, 134653dacb15705901e14b03dcba27e40364fedd9d09Hans Verkuil 0, zr->card.addrs_encoder); 13470ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil 134866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(2, 134966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho KERN_INFO "%s: Initializing videocodec bus...\n", 135066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZR_DEVNAME(zr)); 135166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 135266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr->card.video_codec) { 135366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho codec_name = codecid_to_modulename(zr->card.video_codec); 135466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (codec_name) { 135566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho result = request_module(codec_name); 135666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (result) { 13571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 13581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_ERR 13591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "%s: failed to load modules %s: %d\n", 13601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ZR_DEVNAME(zr), codec_name, result); 13611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 13621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 136366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 136466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr->card.video_vfe) { 136566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho vfe_name = codecid_to_modulename(zr->card.video_vfe); 136666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (vfe_name) { 136766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho result = request_module(vfe_name); 136866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (result < 0) { 13691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 13701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_ERR 13711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "%s: failed to load modules %s: %d\n", 13721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ZR_DEVNAME(zr), vfe_name, result); 13731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 13741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 137566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 13761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 137766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* reset JPEG codec */ 137866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho jpeg_codec_sleep(zr, 1); 137966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho jpeg_codec_reset(zr); 138066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* video bus enabled */ 138166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* display codec revision */ 138266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr->card.video_codec != 0) { 138366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho master_codec = zoran_setup_videocodec(zr, zr->card.video_codec); 138466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (!master_codec) 138566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_unreg_i2c; 138666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr->codec = videocodec_attach(master_codec); 138766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (!zr->codec) { 1388c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s - no codec found\n", 1389c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 139066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_free_codec; 13911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 139266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr->codec->type != zr->card.video_codec) { 1393c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s - wrong codec\n", 1394c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 139566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_detach_codec; 13961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 13971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 139866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr->card.video_vfe != 0) { 139966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho master_vfe = zoran_setup_videocodec(zr, zr->card.video_vfe); 140066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (!master_vfe) 140166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_detach_codec; 140266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr->vfe = videocodec_attach(master_vfe); 140366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (!zr->vfe) { 1404c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s - no VFE found\n", 1405c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 140666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_free_vfe; 140766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 140866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr->vfe->type != zr->card.video_vfe) { 1409c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_ERR "%s: %s = wrong VFE\n", 1410c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho ZR_DEVNAME(zr), __func__); 141166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_detach_vfe; 141266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 141366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho } 1414e491cbc8b2eabc8856bf890006604edd91b1cce2Alan Cox 141566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho /* take care of Natoma chipset and a revision 1 zr36057 */ 141666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) { 141766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zr->jpg_buffers.need_contiguous = 1; 1418c61402bae843f1f7ec29a6fe81681be21c3d201cTrent Piepho dprintk(1, KERN_INFO 141966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho "%s: ZR36057/Natoma bug, max. buffer size is 128K\n", 142066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZR_DEVNAME(zr)); 14211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 142266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 142366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (zr36057_init(zr) < 0) 142466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho goto zr_detach_vfe; 142566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 142666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zoran_proc_init(zr); 142766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 142866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho return 0; 142966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 143066aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_detach_vfe: 143166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho videocodec_detach(zr->vfe); 143266aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_free_vfe: 143366aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho kfree(master_vfe); 143466aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_detach_codec: 143566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho videocodec_detach(zr->codec); 143666aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_free_codec: 143766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho kfree(master_codec); 143866aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_unreg_i2c: 143966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho zoran_unregister_i2c(zr); 144066aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_free_irq: 144166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho btwrite(0, ZR36057_SPGPPCR); 144266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho free_irq(zr->pci_dev->irq, zr); 144366aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_unmap: 144466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho iounmap(zr->zr36057_mem); 14450ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuilzr_unreg: 14460ab6e1c38d80ab586e3a1ca9e71844131d9f51dcHans Verkuil v4l2_device_unregister(&zr->v4l2_dev); 144766aa66ea31371daad562bf22ff245caf707d5d40Trent Piephozr_free_mem: 144866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho kfree(zr); 144966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 145066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho return -ENODEV; 14511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 14521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 145366aa66ea31371daad562bf22ff245caf707d5d40Trent Piephostatic struct pci_driver zoran_driver = { 145466aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho .name = "zr36067", 145566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho .id_table = zr36067_pci_tbl, 145666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho .probe = zoran_probe, 14574c62e9764ab403d42f9b8871b1241fe7812f19d4Greg Kroah-Hartman .remove = zoran_remove, 145866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho}; 145966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho 146066aa66ea31371daad562bf22ff245caf707d5d40Trent Piephostatic int __init zoran_init(void) 14611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 146266aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho int res; 14631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 14641990d50b58bef127a647005fdcada6d07081d3efMauro Carvalho Chehab printk(KERN_INFO "Zoran MJPEG board driver version %s\n", 14651990d50b58bef127a647005fdcada6d07081d3efMauro Carvalho Chehab ZORAN_VERSION); 14661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 14671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* check the parameters we have been given, adjust if necessary */ 14681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (v4l_nbufs < 2) 14691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds v4l_nbufs = 2; 14701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (v4l_nbufs > VIDEO_MAX_FRAME) 14711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds v4l_nbufs = VIDEO_MAX_FRAME; 14721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* The user specfies the in KB, we want them in byte 14731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (and page aligned) */ 14741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds v4l_bufsize = PAGE_ALIGN(v4l_bufsize * 1024); 14751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (v4l_bufsize < 32768) 14761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds v4l_bufsize = 32768; 14771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2 MB is arbitrary but sufficient for the maximum possible images */ 14781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (v4l_bufsize > 2048 * 1024) 14791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds v4l_bufsize = 2048 * 1024; 14801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (jpg_nbufs < 4) 14811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds jpg_nbufs = 4; 14821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (jpg_nbufs > BUZ_MAX_FRAME) 14831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds jpg_nbufs = BUZ_MAX_FRAME; 14841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds jpg_bufsize = PAGE_ALIGN(jpg_bufsize * 1024); 14851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (jpg_bufsize < 8192) 14861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds jpg_bufsize = 8192; 14871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (jpg_bufsize > (512 * 1024)) 14881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds jpg_bufsize = 512 * 1024; 14891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Use parameter for vidmem or try to find a video card */ 14901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (vidmem) { 14911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 14921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_INFO 14931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "%s: Using supplied video memory base address @ 0x%lx\n", 14941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ZORAN_NAME, vidmem); 14951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 14961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 14971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* some mainboards might not do PCI-PCI data transfer well */ 1498e355880b838c80ff53e6386a1caad10e6f719259Alan Cox if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) { 14991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dprintk(1, 15001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds KERN_WARNING 1501e355880b838c80ff53e6386a1caad10e6f719259Alan Cox "%s: chipset does not support reliable PCI-PCI DMA\n", 15021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ZORAN_NAME); 15031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 15041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 150566aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho res = pci_register_driver(&zoran_driver); 150666aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho if (res) { 150766aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho dprintk(1, 150866aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho KERN_ERR 150966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho "%s: Unable to register ZR36057 driver\n", 151066aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho ZORAN_NAME); 151166aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho return res; 15121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 15131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 15141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 15151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 15161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 151766aa66ea31371daad562bf22ff245caf707d5d40Trent Piephostatic void __exit zoran_exit(void) 15181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 151966aa66ea31371daad562bf22ff245caf707d5d40Trent Piepho pci_unregister_driver(&zoran_driver); 15201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 15211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 152266aa66ea31371daad562bf22ff245caf707d5d40Trent Piephomodule_init(zoran_init); 152366aa66ea31371daad562bf22ff245caf707d5d40Trent Piephomodule_exit(zoran_exit); 1524