2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Zoran zr36057/zr36067 PCI controller driver, for the
|
|
|
|
* Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux
|
|
|
|
* Media Labs LML33/LML33R10.
|
|
|
|
*
|
|
|
|
* This part handles card-specific data and detection
|
2006-03-25 20:19:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
|
|
|
|
*
|
|
|
|
* Currently maintained by:
|
|
|
|
* Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
* Laurent Pinchart <laurent.pinchart@skynet.be>
|
|
|
|
* Mailinglist <mjpeg-users@lists.sf.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2006-04-27 21:17:00 +08:00
|
|
|
#include <linux/delay.h>
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/vmalloc.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/i2c-algo-bit.h>
|
2009-02-20 04:31:17 +08:00
|
|
|
#include <linux/videodev2.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/sem.h>
|
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/interrupt.h>
|
2006-03-22 14:54:16 +08:00
|
|
|
#include <linux/mutex.h>
|
2009-03-09 04:04:38 +08:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <media/v4l2-common.h>
|
|
|
|
#include <media/bt819.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "videocodec.h"
|
|
|
|
#include "zoran.h"
|
|
|
|
#include "zoran_card.h"
|
|
|
|
#include "zoran_device.h"
|
|
|
|
#include "zoran_procfs.h"
|
|
|
|
|
|
|
|
extern const struct zoran_format zoran_formats[];
|
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
static int card[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param_array(card, int, NULL, 0444);
|
2009-01-13 00:09:46 +08:00
|
|
|
MODULE_PARM_DESC(card, "Card type");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
The video mem address of the video card.
|
|
|
|
The driver has a little database for some videocards
|
|
|
|
to determine it from there. If your video card is not in there
|
|
|
|
you have either to give it to the driver as a parameter
|
|
|
|
or set in in a VIDIOCSFBUF ioctl
|
|
|
|
*/
|
|
|
|
|
2008-04-23 01:41:48 +08:00
|
|
|
static unsigned long vidmem; /* default = 0 - Video memory base address */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(vidmem, ulong, 0444);
|
|
|
|
MODULE_PARM_DESC(vidmem, "Default video memory base address");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Default input and video norm at startup of the driver.
|
|
|
|
*/
|
|
|
|
|
2008-04-23 01:41:48 +08:00
|
|
|
static unsigned int default_input; /* default 0 = Composite, 1 = S-Video */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(default_input, uint, 0444);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(default_input,
|
|
|
|
"Default input (0=Composite, 1=S-Video, 2=Internal)");
|
|
|
|
|
2006-04-27 21:17:00 +08:00
|
|
|
static int default_mux = 1; /* 6 Eyes input selection */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(default_mux, int, 0644);
|
2006-04-27 21:17:00 +08:00
|
|
|
MODULE_PARM_DESC(default_mux,
|
|
|
|
"Default 6 Eyes mux setting (Input selection)");
|
|
|
|
|
2008-04-23 01:41:48 +08:00
|
|
|
static int default_norm; /* default 0 = PAL, 1 = NTSC 2 = SECAM */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(default_norm, int, 0444);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");
|
|
|
|
|
2007-07-18 05:29:42 +08:00
|
|
|
/* /dev/videoN, -1 for autodetect */
|
2009-01-13 00:09:46 +08:00
|
|
|
static int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param_array(video_nr, int, NULL, 0444);
|
2009-01-13 00:09:46 +08:00
|
|
|
MODULE_PARM_DESC(video_nr, "Video device number (-1=Auto)");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-02-19 05:33:35 +08:00
|
|
|
int v4l_nbufs = 4;
|
2009-02-21 02:06:59 +08:00
|
|
|
int v4l_bufsize = 864; /* Everybody should be able to work with this setting */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(v4l_nbufs, int, 0644);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(v4l_nbufs, "Maximum number of V4L buffers to use");
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(v4l_bufsize, int, 0644);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(v4l_bufsize, "Maximum size per V4L buffer (in kB)");
|
|
|
|
|
|
|
|
int jpg_nbufs = 32;
|
|
|
|
int jpg_bufsize = 512; /* max size for 100% quality full-PAL frame */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(jpg_nbufs, int, 0644);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(jpg_nbufs, "Maximum number of JPG buffers to use");
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(jpg_bufsize, int, 0644);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(jpg_bufsize, "Maximum size per JPG buffer (in kB)");
|
|
|
|
|
|
|
|
int pass_through = 0; /* 1=Pass through TV signal when device is not used */
|
|
|
|
/* 0=Show color bar when device is not used (LML33: only if lml33dpath=1) */
|
2007-07-18 05:29:42 +08:00
|
|
|
module_param(pass_through, int, 0644);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(pass_through,
|
|
|
|
"Pass TV signal through to TV-out when idling");
|
|
|
|
|
2007-07-18 05:29:41 +08:00
|
|
|
int zr36067_debug = 1;
|
|
|
|
module_param_named(debug, zr36067_debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(debug, "Debug level (0-5)");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 01:45:49 +08:00
|
|
|
#define ZORAN_VERSION "0.10.1"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
|
|
|
|
MODULE_AUTHOR("Serguei Miridonov");
|
|
|
|
MODULE_LICENSE("GPL");
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 01:45:49 +08:00
|
|
|
MODULE_VERSION(ZORAN_VERSION);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
#define ZR_DEVICE(subven, subdev, data) { \
|
|
|
|
.vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
|
|
|
|
.subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
|
|
|
|
|
2009-01-09 10:27:32 +08:00
|
|
|
static struct pci_device_id zr36067_pci_tbl[] = {
|
2009-01-13 00:09:46 +08:00
|
|
|
ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus),
|
|
|
|
ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus),
|
|
|
|
ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10),
|
|
|
|
ZR_DEVICE(PCI_VENDOR_ID_IOMEGA, PCI_DEVICE_ID_IOMEGA_BUZ, BUZ),
|
|
|
|
ZR_DEVICE(PCI_ANY_ID, PCI_ANY_ID, NUM_CARDS),
|
2009-01-09 10:27:32 +08:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
static unsigned int zoran_num; /* number of cards found */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* videocodec bus functions ZR36060 */
|
|
|
|
static u32
|
|
|
|
zr36060_read (struct videocodec *codec,
|
|
|
|
u16 reg)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) codec->master_data->data;
|
|
|
|
__u32 data;
|
|
|
|
|
|
|
|
if (post_office_wait(zr)
|
|
|
|
|| post_office_write(zr, 0, 1, reg >> 8)
|
|
|
|
|| post_office_write(zr, 0, 2, reg & 0xff)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = post_office_read(zr, 0, 3) & 0xff;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zr36060_write (struct videocodec *codec,
|
|
|
|
u16 reg,
|
|
|
|
u32 val)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) codec->master_data->data;
|
|
|
|
|
|
|
|
if (post_office_wait(zr)
|
|
|
|
|| post_office_write(zr, 0, 1, reg >> 8)
|
|
|
|
|| post_office_write(zr, 0, 2, reg & 0xff)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
post_office_write(zr, 0, 3, val & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* videocodec bus functions ZR36050 */
|
|
|
|
static u32
|
|
|
|
zr36050_read (struct videocodec *codec,
|
|
|
|
u16 reg)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) codec->master_data->data;
|
|
|
|
__u32 data;
|
|
|
|
|
|
|
|
if (post_office_wait(zr)
|
|
|
|
|| post_office_write(zr, 1, 0, reg >> 2)) { // reg. HIGHBYTES
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = post_office_read(zr, 0, reg & 0x03) & 0xff; // reg. LOWBYTES + read
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zr36050_write (struct videocodec *codec,
|
|
|
|
u16 reg,
|
|
|
|
u32 val)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) codec->master_data->data;
|
|
|
|
|
|
|
|
if (post_office_wait(zr)
|
|
|
|
|| post_office_write(zr, 1, 0, reg >> 2)) { // reg. HIGHBYTES
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
post_office_write(zr, 0, reg & 0x03, val & 0xff); // reg. LOWBYTES + wr. data
|
|
|
|
}
|
|
|
|
|
|
|
|
/* videocodec bus functions ZR36016 */
|
|
|
|
static u32
|
|
|
|
zr36016_read (struct videocodec *codec,
|
|
|
|
u16 reg)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) codec->master_data->data;
|
|
|
|
__u32 data;
|
|
|
|
|
|
|
|
if (post_office_wait(zr)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = post_office_read(zr, 2, reg & 0x03) & 0xff; // read
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hack for in zoran_device.c */
|
|
|
|
void
|
|
|
|
zr36016_write (struct videocodec *codec,
|
|
|
|
u16 reg,
|
|
|
|
u32 val)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) codec->master_data->data;
|
|
|
|
|
|
|
|
if (post_office_wait(zr)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
post_office_write(zr, 2, reg & 0x03, val & 0x0ff); // wr. data
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Board specific information
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
dc10_init (struct zoran *zr)
|
|
|
|
{
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Pixel clock selection */
|
|
|
|
GPIO(zr, 4, 0);
|
|
|
|
GPIO(zr, 5, 1);
|
|
|
|
/* Enable the video bus sync signals */
|
|
|
|
GPIO(zr, 7, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dc10plus_init (struct zoran *zr)
|
|
|
|
{
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
buz_init (struct zoran *zr)
|
|
|
|
{
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* some stuff from Iomega */
|
|
|
|
pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15);
|
|
|
|
pci_write_config_dword(zr->pci_dev, 0x0c, 0x00012020);
|
|
|
|
pci_write_config_dword(zr->pci_dev, 0xe8, 0xc0200000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lml33_init (struct zoran *zr)
|
|
|
|
{
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
GPIO(zr, 2, 1); // Set Composite input/output
|
|
|
|
}
|
|
|
|
|
2006-04-27 21:17:00 +08:00
|
|
|
static void
|
|
|
|
avs6eyes_init (struct zoran *zr)
|
|
|
|
{
|
|
|
|
// AverMedia 6-Eyes original driver by Christer Weinigel
|
|
|
|
|
|
|
|
// Lifted straight from Christer's old driver and
|
|
|
|
// modified slightly by Martin Samuelsson.
|
|
|
|
|
|
|
|
int mux = default_mux; /* 1 = BT866, 7 = VID1 */
|
|
|
|
|
|
|
|
GPIO(zr, 4, 1); /* Bt866 SLEEP on */
|
|
|
|
udelay(2);
|
|
|
|
|
|
|
|
GPIO(zr, 0, 1); /* ZR36060 /RESET on */
|
|
|
|
GPIO(zr, 1, 0); /* ZR36060 /SLEEP on */
|
|
|
|
GPIO(zr, 2, mux & 1); /* MUX S0 */
|
|
|
|
GPIO(zr, 3, 0); /* /FRAME on */
|
|
|
|
GPIO(zr, 4, 0); /* Bt866 SLEEP off */
|
|
|
|
GPIO(zr, 5, mux & 2); /* MUX S1 */
|
|
|
|
GPIO(zr, 6, 0); /* ? */
|
|
|
|
GPIO(zr, 7, mux & 4); /* MUX S2 */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static char *
|
|
|
|
codecid_to_modulename (u16 codecid)
|
|
|
|
{
|
|
|
|
char *name = NULL;
|
|
|
|
|
|
|
|
switch (codecid) {
|
|
|
|
case CODEC_TYPE_ZR36060:
|
|
|
|
name = "zr36060";
|
|
|
|
break;
|
|
|
|
case CODEC_TYPE_ZR36050:
|
|
|
|
name = "zr36050";
|
|
|
|
break;
|
|
|
|
case CODEC_TYPE_ZR36016:
|
|
|
|
name = "zr36016";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// struct tvnorm {
|
|
|
|
// u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;
|
|
|
|
// };
|
|
|
|
|
|
|
|
static struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };
|
|
|
|
static struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };
|
|
|
|
static struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };
|
|
|
|
static struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };
|
|
|
|
|
|
|
|
static struct tvnorm f50ccir601_lml33 = { 864, 720, 75+34, 804, 625, 576, 18 };
|
|
|
|
static struct tvnorm f60ccir601_lml33 = { 858, 720, 57+34, 788, 525, 480, 16 };
|
|
|
|
|
|
|
|
/* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */
|
|
|
|
static struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 };
|
|
|
|
static struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 };
|
|
|
|
|
|
|
|
/* FIXME: I cannot swap U and V in saa7114, so i do one
|
|
|
|
* pixel left shift in zoran (75 -> 74)
|
|
|
|
* (Maxim Yevtyushkin <max@linuxmedialabs.com>) */
|
|
|
|
static struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74+54, 804, 625, 576, 18 };
|
|
|
|
static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56+54, 788, 525, 480, 16 };
|
|
|
|
|
2006-04-27 21:17:00 +08:00
|
|
|
/* FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I
|
|
|
|
* copy Maxim's left shift hack for the 6 Eyes.
|
|
|
|
*
|
|
|
|
* Christer's driver used the unshifted norms, though...
|
|
|
|
* /Sam */
|
|
|
|
static struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 };
|
|
|
|
static struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 };
|
|
|
|
|
2009-02-20 03:18:23 +08:00
|
|
|
static const unsigned short vpx3220_addrs[] = { 0x43, 0x47, I2C_CLIENT_END };
|
|
|
|
static const unsigned short saa7110_addrs[] = { 0x4e, 0x4f, I2C_CLIENT_END };
|
|
|
|
static const unsigned short saa7111_addrs[] = { 0x25, 0x24, I2C_CLIENT_END };
|
|
|
|
static const unsigned short saa7114_addrs[] = { 0x21, 0x20, I2C_CLIENT_END };
|
|
|
|
static const unsigned short adv717x_addrs[] = { 0x6a, 0x6b, 0x2a, 0x2b, I2C_CLIENT_END };
|
|
|
|
static const unsigned short ks0127_addrs[] = { 0x6c, 0x6d, I2C_CLIENT_END };
|
|
|
|
static const unsigned short saa7185_addrs[] = { 0x44, I2C_CLIENT_END };
|
|
|
|
static const unsigned short bt819_addrs[] = { 0x45, I2C_CLIENT_END };
|
|
|
|
static const unsigned short bt856_addrs[] = { 0x44, I2C_CLIENT_END };
|
|
|
|
static const unsigned short bt866_addrs[] = { 0x44, I2C_CLIENT_END };
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
|
|
|
|
{
|
|
|
|
.type = DC10_old,
|
|
|
|
.name = "DC10(old)",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "vpx3220a",
|
|
|
|
.addrs_decoder = vpx3220_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36050,
|
|
|
|
.video_vfe = CODEC_TYPE_ZR36016,
|
|
|
|
|
|
|
|
.inputs = 3,
|
|
|
|
.input = {
|
|
|
|
{ 1, "Composite" },
|
|
|
|
{ 2, "S-Video" },
|
|
|
|
{ 0, "Internal/comp" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50sqpixel_dc10,
|
|
|
|
&f60sqpixel_dc10,
|
|
|
|
&f50sqpixel_dc10
|
|
|
|
},
|
|
|
|
.jpeg_int = 0,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 },
|
|
|
|
.gpcs = { -1, 0 },
|
|
|
|
.vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
.gws_not_connected = 0,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &dc10_init,
|
|
|
|
}, {
|
|
|
|
.type = DC10_new,
|
|
|
|
.name = "DC10(new)",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "saa7110",
|
|
|
|
.addrs_decoder = saa7110_addrs,
|
|
|
|
.i2c_encoder = "adv7175",
|
|
|
|
.addrs_encoder = adv717x_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36060,
|
|
|
|
|
|
|
|
.inputs = 3,
|
|
|
|
.input = {
|
|
|
|
{ 0, "Composite" },
|
|
|
|
{ 7, "S-Video" },
|
|
|
|
{ 5, "Internal/comp" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50sqpixel,
|
|
|
|
&f60sqpixel,
|
|
|
|
&f50sqpixel},
|
|
|
|
.jpeg_int = ZR36057_ISR_GIRQ0,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.gpio = { 3, 0, 6, 1, 2, -1, 4, 5 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
.gpcs = { -1, 1},
|
|
|
|
.vfe_pol = { 1, 1, 1, 1, 0, 0, 0, 0 },
|
|
|
|
.gws_not_connected = 0,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &dc10plus_init,
|
|
|
|
}, {
|
|
|
|
.type = DC10plus,
|
|
|
|
.name = "DC10plus",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "saa7110",
|
|
|
|
.addrs_decoder = saa7110_addrs,
|
|
|
|
.i2c_encoder = "adv7175",
|
|
|
|
.addrs_encoder = adv717x_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36060,
|
|
|
|
|
|
|
|
.inputs = 3,
|
|
|
|
.input = {
|
|
|
|
{ 0, "Composite" },
|
|
|
|
{ 7, "S-Video" },
|
|
|
|
{ 5, "Internal/comp" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50sqpixel,
|
|
|
|
&f60sqpixel,
|
|
|
|
&f50sqpixel
|
|
|
|
},
|
|
|
|
.jpeg_int = ZR36057_ISR_GIRQ0,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.gpio = { 3, 0, 6, 1, 2, -1, 4, 5 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
.gpcs = { -1, 1 },
|
|
|
|
.vfe_pol = { 1, 1, 1, 1, 0, 0, 0, 0 },
|
|
|
|
.gws_not_connected = 0,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &dc10plus_init,
|
|
|
|
}, {
|
|
|
|
.type = DC30,
|
|
|
|
.name = "DC30",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "vpx3220a",
|
|
|
|
.addrs_decoder = vpx3220_addrs,
|
|
|
|
.i2c_encoder = "adv7175",
|
|
|
|
.addrs_encoder = adv717x_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36050,
|
|
|
|
.video_vfe = CODEC_TYPE_ZR36016,
|
|
|
|
|
|
|
|
.inputs = 3,
|
|
|
|
.input = {
|
|
|
|
{ 1, "Composite" },
|
|
|
|
{ 2, "S-Video" },
|
|
|
|
{ 0, "Internal/comp" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50sqpixel_dc10,
|
|
|
|
&f60sqpixel_dc10,
|
|
|
|
&f50sqpixel_dc10
|
|
|
|
},
|
|
|
|
.jpeg_int = 0,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 },
|
|
|
|
.gpcs = { -1, 0 },
|
|
|
|
.vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
.gws_not_connected = 0,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &dc10_init,
|
|
|
|
}, {
|
|
|
|
.type = DC30plus,
|
|
|
|
.name = "DC30plus",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "vpx3220a",
|
|
|
|
.addrs_decoder = vpx3220_addrs,
|
|
|
|
.i2c_encoder = "adv7175",
|
|
|
|
.addrs_encoder = adv717x_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36050,
|
|
|
|
.video_vfe = CODEC_TYPE_ZR36016,
|
|
|
|
|
|
|
|
.inputs = 3,
|
|
|
|
.input = {
|
|
|
|
{ 1, "Composite" },
|
|
|
|
{ 2, "S-Video" },
|
|
|
|
{ 0, "Internal/comp" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50sqpixel_dc10,
|
|
|
|
&f60sqpixel_dc10,
|
|
|
|
&f50sqpixel_dc10
|
|
|
|
},
|
|
|
|
.jpeg_int = 0,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 1, 0, 0, 0, 0 },
|
|
|
|
.gpcs = { -1, 0 },
|
|
|
|
.vfe_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
.gws_not_connected = 0,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &dc10_init,
|
|
|
|
}, {
|
|
|
|
.type = LML33,
|
|
|
|
.name = "LML33",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "bt819a",
|
|
|
|
.addrs_decoder = bt819_addrs,
|
|
|
|
.i2c_encoder = "bt856",
|
|
|
|
.addrs_encoder = bt856_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36060,
|
|
|
|
|
|
|
|
.inputs = 2,
|
|
|
|
.input = {
|
|
|
|
{ 0, "Composite" },
|
|
|
|
{ 7, "S-Video" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50ccir601_lml33,
|
|
|
|
&f60ccir601_lml33,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
.jpeg_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ0,
|
|
|
|
.gpio = { 1, -1, 3, 5, 7, -1, -1, -1 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 0, 1, 0, 0, 0 },
|
|
|
|
.gpcs = { 3, 1 },
|
|
|
|
.vfe_pol = { 1, 1, 0, 0, 0, 1, 0, 0 },
|
|
|
|
.gws_not_connected = 1,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &lml33_init,
|
|
|
|
}, {
|
|
|
|
.type = LML33R10,
|
|
|
|
.name = "LML33R10",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "saa7114",
|
|
|
|
.addrs_decoder = saa7114_addrs,
|
|
|
|
.i2c_encoder = "adv7170",
|
|
|
|
.addrs_encoder = adv717x_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36060,
|
|
|
|
|
|
|
|
.inputs = 2,
|
|
|
|
.input = {
|
|
|
|
{ 0, "Composite" },
|
|
|
|
{ 7, "S-Video" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50ccir601_lm33r10,
|
|
|
|
&f60ccir601_lm33r10,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
.jpeg_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ0,
|
|
|
|
.gpio = { 1, -1, 3, 5, 7, -1, -1, -1 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 0, 1, 0, 0, 0 },
|
|
|
|
.gpcs = { 3, 1 },
|
|
|
|
.vfe_pol = { 1, 1, 0, 0, 0, 1, 0, 0 },
|
|
|
|
.gws_not_connected = 1,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &lml33_init,
|
|
|
|
}, {
|
|
|
|
.type = BUZ,
|
|
|
|
.name = "Buz",
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "saa7111",
|
|
|
|
.addrs_decoder = saa7111_addrs,
|
|
|
|
.i2c_encoder = "saa7185",
|
|
|
|
.addrs_encoder = saa7185_addrs,
|
2005-04-17 06:20:36 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36060,
|
|
|
|
|
|
|
|
.inputs = 2,
|
|
|
|
.input = {
|
|
|
|
{ 3, "Composite" },
|
|
|
|
{ 7, "S-Video" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
|
2005-04-17 06:20:36 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50ccir601,
|
|
|
|
&f60ccir601,
|
|
|
|
&f50ccir601
|
|
|
|
},
|
|
|
|
.jpeg_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ0,
|
|
|
|
.gpio = { 1, -1, 3, -1, -1, -1, -1, -1 },
|
|
|
|
.gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
.gpcs = { 3, 1 },
|
|
|
|
.vfe_pol = { 1, 1, 0, 0, 0, 1, 0, 0 },
|
|
|
|
.gws_not_connected = 1,
|
2006-04-27 21:17:00 +08:00
|
|
|
.input_mux = 0,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = &buz_init,
|
2006-04-27 21:17:00 +08:00
|
|
|
}, {
|
|
|
|
.type = AVS6EYES,
|
|
|
|
.name = "6-Eyes",
|
|
|
|
/* AverMedia chose not to brand the 6-Eyes. Thus it
|
|
|
|
can't be autodetected, and requires card=x. */
|
2009-02-20 03:18:23 +08:00
|
|
|
.i2c_decoder = "ks0127",
|
|
|
|
.addrs_decoder = ks0127_addrs,
|
|
|
|
.i2c_encoder = "bt866",
|
|
|
|
.addrs_encoder = bt866_addrs,
|
2006-04-27 21:17:00 +08:00
|
|
|
.video_codec = CODEC_TYPE_ZR36060,
|
|
|
|
|
|
|
|
.inputs = 10,
|
|
|
|
.input = {
|
|
|
|
{ 0, "Composite 1" },
|
|
|
|
{ 1, "Composite 2" },
|
|
|
|
{ 2, "Composite 3" },
|
|
|
|
{ 4, "Composite 4" },
|
|
|
|
{ 5, "Composite 5" },
|
|
|
|
{ 6, "Composite 6" },
|
|
|
|
{ 8, "S-Video 1" },
|
|
|
|
{ 9, "S-Video 2" },
|
|
|
|
{10, "S-Video 3" },
|
|
|
|
{15, "YCbCr" }
|
|
|
|
},
|
2009-02-19 04:26:06 +08:00
|
|
|
.norms = V4L2_STD_NTSC|V4L2_STD_PAL,
|
2006-04-27 21:17:00 +08:00
|
|
|
.tvn = {
|
|
|
|
&f50ccir601_avs6eyes,
|
|
|
|
&f60ccir601_avs6eyes,
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
.jpeg_int = ZR36057_ISR_GIRQ1,
|
|
|
|
.vsync_int = ZR36057_ISR_GIRQ0,
|
|
|
|
.gpio = { 1, 0, 3, -1, -1, -1, -1, -1 },// Validity unknown /Sam
|
|
|
|
.gpio_pol = { 0, 0, 0, 0, 0, 0, 0, 0 }, // Validity unknown /Sam
|
|
|
|
.gpcs = { 3, 1 }, // Validity unknown /Sam
|
|
|
|
.vfe_pol = { 1, 0, 0, 0, 0, 1, 0, 0 }, // Validity unknown /Sam
|
|
|
|
.gws_not_connected = 1,
|
|
|
|
.input_mux = 1,
|
|
|
|
.init = &avs6eyes_init,
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-04-27 21:17:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I2C functions
|
|
|
|
*/
|
|
|
|
/* software I2C functions */
|
|
|
|
static int
|
|
|
|
zoran_i2c_getsda (void *data)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) data;
|
|
|
|
|
|
|
|
return (btread(ZR36057_I2CBR) >> 1) & 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zoran_i2c_getscl (void *data)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) data;
|
|
|
|
|
|
|
|
return btread(ZR36057_I2CBR) & 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zoran_i2c_setsda (void *data,
|
|
|
|
int state)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) data;
|
|
|
|
|
|
|
|
if (state)
|
|
|
|
zr->i2cbr |= 2;
|
|
|
|
else
|
|
|
|
zr->i2cbr &= ~2;
|
|
|
|
btwrite(zr->i2cbr, ZR36057_I2CBR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zoran_i2c_setscl (void *data,
|
|
|
|
int state)
|
|
|
|
{
|
|
|
|
struct zoran *zr = (struct zoran *) data;
|
|
|
|
|
|
|
|
if (state)
|
|
|
|
zr->i2cbr |= 1;
|
|
|
|
else
|
|
|
|
zr->i2cbr &= ~1;
|
|
|
|
btwrite(zr->i2cbr, ZR36057_I2CBR);
|
|
|
|
}
|
|
|
|
|
2008-06-13 00:20:46 +08:00
|
|
|
static const struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.setsda = zoran_i2c_setsda,
|
|
|
|
.setscl = zoran_i2c_setscl,
|
|
|
|
.getsda = zoran_i2c_getsda,
|
|
|
|
.getscl = zoran_i2c_getscl,
|
|
|
|
.udelay = 10,
|
|
|
|
.timeout = 100,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
zoran_register_i2c (struct zoran *zr)
|
|
|
|
{
|
|
|
|
memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template,
|
|
|
|
sizeof(struct i2c_algo_bit_data));
|
|
|
|
zr->i2c_algo.data = zr;
|
2008-06-13 00:20:46 +08:00
|
|
|
strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr),
|
|
|
|
sizeof(zr->i2c_adapter.name));
|
2009-02-20 03:18:23 +08:00
|
|
|
i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
zr->i2c_adapter.algo_data = &zr->i2c_algo;
|
2007-02-14 05:09:03 +08:00
|
|
|
zr->i2c_adapter.dev.parent = &zr->pci_dev->dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
return i2c_bit_add_bus(&zr->i2c_adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zoran_unregister_i2c (struct zoran *zr)
|
|
|
|
{
|
2006-12-11 04:21:33 +08:00
|
|
|
i2c_del_adapter(&zr->i2c_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check a zoran_params struct for correctness, insert default params */
|
|
|
|
|
|
|
|
int
|
|
|
|
zoran_check_jpg_settings (struct zoran *zr,
|
2009-02-19 04:11:17 +08:00
|
|
|
struct zoran_jpg_settings *settings,
|
|
|
|
int try)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int err = 0, err0 = 0;
|
|
|
|
|
|
|
|
dprintk(4,
|
|
|
|
KERN_DEBUG
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, settings->decimation, settings->HorDcm,
|
2005-04-17 06:20:36 +08:00
|
|
|
settings->VerDcm, settings->TmpDcm);
|
|
|
|
dprintk(4,
|
|
|
|
KERN_DEBUG
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - x: %d, y: %d, w: %d, y: %d\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, settings->img_x, settings->img_y,
|
2005-04-17 06:20:36 +08:00
|
|
|
settings->img_width, settings->img_height);
|
|
|
|
/* Check decimation, set default values for decimation = 1, 2, 4 */
|
|
|
|
switch (settings->decimation) {
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
settings->HorDcm = 1;
|
|
|
|
settings->VerDcm = 1;
|
|
|
|
settings->TmpDcm = 1;
|
|
|
|
settings->field_per_buff = 2;
|
|
|
|
settings->img_x = 0;
|
|
|
|
settings->img_y = 0;
|
|
|
|
settings->img_width = BUZ_MAX_WIDTH;
|
|
|
|
settings->img_height = BUZ_MAX_HEIGHT / 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
settings->HorDcm = 2;
|
|
|
|
settings->VerDcm = 1;
|
|
|
|
settings->TmpDcm = 2;
|
|
|
|
settings->field_per_buff = 1;
|
|
|
|
settings->img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0;
|
|
|
|
settings->img_y = 0;
|
|
|
|
settings->img_width =
|
|
|
|
(BUZ_MAX_WIDTH == 720) ? 704 : BUZ_MAX_WIDTH;
|
|
|
|
settings->img_height = BUZ_MAX_HEIGHT / 2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
if (zr->card.type == DC10_new) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_DEBUG
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - HDec by 4 is not supported on the DC10\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->HorDcm = 4;
|
|
|
|
settings->VerDcm = 2;
|
|
|
|
settings->TmpDcm = 2;
|
|
|
|
settings->field_per_buff = 1;
|
|
|
|
settings->img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0;
|
|
|
|
settings->img_y = 0;
|
|
|
|
settings->img_width =
|
|
|
|
(BUZ_MAX_WIDTH == 720) ? 704 : BUZ_MAX_WIDTH;
|
|
|
|
settings->img_height = BUZ_MAX_HEIGHT / 2;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
/* We have to check the data the user has set */
|
|
|
|
|
|
|
|
if (settings->HorDcm != 1 && settings->HorDcm != 2 &&
|
2009-02-19 04:11:17 +08:00
|
|
|
(zr->card.type == DC10_new || settings->HorDcm != 4)) {
|
|
|
|
settings->HorDcm = clamp(settings->HorDcm, 1, 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->VerDcm != 1 && settings->VerDcm != 2) {
|
|
|
|
settings->VerDcm = clamp(settings->VerDcm, 1, 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->TmpDcm != 1 && settings->TmpDcm != 2) {
|
|
|
|
settings->TmpDcm = clamp(settings->TmpDcm, 1, 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (settings->field_per_buff != 1 &&
|
2009-02-19 04:11:17 +08:00
|
|
|
settings->field_per_buff != 2) {
|
|
|
|
settings->field_per_buff = clamp(settings->field_per_buff, 1, 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->img_x < 0) {
|
|
|
|
settings->img_x = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->img_y < 0) {
|
|
|
|
settings->img_y = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->img_width < 0 || settings->img_width > BUZ_MAX_WIDTH) {
|
|
|
|
settings->img_width = clamp(settings->img_width, 0, (int)BUZ_MAX_WIDTH);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->img_height < 0 || settings->img_height > BUZ_MAX_HEIGHT / 2) {
|
|
|
|
settings->img_height = clamp(settings->img_height, 0, BUZ_MAX_HEIGHT / 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH) {
|
|
|
|
settings->img_x = BUZ_MAX_WIDTH - settings->img_width;
|
|
|
|
err0++;
|
|
|
|
}
|
|
|
|
if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2) {
|
|
|
|
settings->img_y = BUZ_MAX_HEIGHT / 2 - settings->img_height;
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
2009-02-19 04:11:17 +08:00
|
|
|
}
|
|
|
|
if (settings->img_width % (16 * settings->HorDcm) != 0) {
|
|
|
|
settings->img_width -= settings->img_width % (16 * settings->HorDcm);
|
|
|
|
if (settings->img_width == 0)
|
|
|
|
settings->img_width = 16 * settings->HorDcm;
|
|
|
|
err0++;
|
|
|
|
}
|
|
|
|
if (settings->img_height % (8 * settings->VerDcm) != 0) {
|
|
|
|
settings->img_height -= settings->img_height % (8 * settings->VerDcm);
|
|
|
|
if (settings->img_height == 0)
|
|
|
|
settings->img_height = 8 * settings->VerDcm;
|
2005-04-17 06:20:36 +08:00
|
|
|
err0++;
|
|
|
|
}
|
|
|
|
|
2009-02-19 04:11:17 +08:00
|
|
|
if (!try && err0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - error in params for decimation = 0\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
err++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - decimation = %d, must be 0, 1, 2 or 4\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, settings->decimation);
|
2005-04-17 06:20:36 +08:00
|
|
|
err++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->jpg_comp.quality > 100)
|
|
|
|
settings->jpg_comp.quality = 100;
|
|
|
|
if (settings->jpg_comp.quality < 5)
|
|
|
|
settings->jpg_comp.quality = 5;
|
|
|
|
if (settings->jpg_comp.APPn < 0)
|
|
|
|
settings->jpg_comp.APPn = 0;
|
|
|
|
if (settings->jpg_comp.APPn > 15)
|
|
|
|
settings->jpg_comp.APPn = 15;
|
|
|
|
if (settings->jpg_comp.APP_len < 0)
|
|
|
|
settings->jpg_comp.APP_len = 0;
|
|
|
|
if (settings->jpg_comp.APP_len > 60)
|
|
|
|
settings->jpg_comp.APP_len = 60;
|
|
|
|
if (settings->jpg_comp.COM_len < 0)
|
|
|
|
settings->jpg_comp.COM_len = 0;
|
|
|
|
if (settings->jpg_comp.COM_len > 60)
|
|
|
|
settings->jpg_comp.COM_len = 60;
|
|
|
|
if (err)
|
|
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
zoran_open_init_params (struct zoran *zr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* User must explicitly set a window */
|
|
|
|
zr->overlay_settings.is_set = 0;
|
|
|
|
zr->overlay_mask = NULL;
|
|
|
|
zr->overlay_active = ZORAN_FREE;
|
|
|
|
|
|
|
|
zr->v4l_memgrab_active = 0;
|
|
|
|
zr->v4l_overlay_active = 0;
|
|
|
|
zr->v4l_grab_frame = NO_GRAB_ACTIVE;
|
|
|
|
zr->v4l_grab_seq = 0;
|
|
|
|
zr->v4l_settings.width = 192;
|
|
|
|
zr->v4l_settings.height = 144;
|
2008-09-07 16:21:34 +08:00
|
|
|
zr->v4l_settings.format = &zoran_formats[7]; /* YUY2 - YUV-4:2:2 packed */
|
2005-04-17 06:20:36 +08:00
|
|
|
zr->v4l_settings.bytesperline =
|
|
|
|
zr->v4l_settings.width *
|
|
|
|
((zr->v4l_settings.format->depth + 7) / 8);
|
|
|
|
|
|
|
|
/* DMA ring stuff for V4L */
|
|
|
|
zr->v4l_pend_tail = 0;
|
|
|
|
zr->v4l_pend_head = 0;
|
|
|
|
zr->v4l_sync_tail = 0;
|
|
|
|
zr->v4l_buffers.active = ZORAN_FREE;
|
|
|
|
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
|
|
|
|
zr->v4l_buffers.buffer[i].state = BUZ_STATE_USER; /* nothing going on */
|
|
|
|
}
|
|
|
|
zr->v4l_buffers.allocated = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < BUZ_MAX_FRAME; i++) {
|
|
|
|
zr->jpg_buffers.buffer[i].state = BUZ_STATE_USER; /* nothing going on */
|
|
|
|
}
|
|
|
|
zr->jpg_buffers.active = ZORAN_FREE;
|
|
|
|
zr->jpg_buffers.allocated = 0;
|
|
|
|
/* Set necessary params and call zoran_check_jpg_settings to set the defaults */
|
|
|
|
zr->jpg_settings.decimation = 1;
|
|
|
|
zr->jpg_settings.jpg_comp.quality = 50; /* default compression factor 8 */
|
|
|
|
if (zr->card.type != BUZ)
|
|
|
|
zr->jpg_settings.odd_even = 1;
|
|
|
|
else
|
|
|
|
zr->jpg_settings.odd_even = 0;
|
|
|
|
zr->jpg_settings.jpg_comp.APPn = 0;
|
|
|
|
zr->jpg_settings.jpg_comp.APP_len = 0; /* No APPn marker */
|
|
|
|
memset(zr->jpg_settings.jpg_comp.APP_data, 0,
|
|
|
|
sizeof(zr->jpg_settings.jpg_comp.APP_data));
|
|
|
|
zr->jpg_settings.jpg_comp.COM_len = 0; /* No COM marker */
|
|
|
|
memset(zr->jpg_settings.jpg_comp.COM_data, 0,
|
|
|
|
sizeof(zr->jpg_settings.jpg_comp.COM_data));
|
|
|
|
zr->jpg_settings.jpg_comp.jpeg_markers =
|
2010-12-25 17:58:01 +08:00
|
|
|
V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT;
|
2009-02-19 04:11:17 +08:00
|
|
|
i = zoran_check_jpg_settings(zr, &zr->jpg_settings, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (i)
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s internal error\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
clear_interrupt_counters(zr);
|
|
|
|
zr->testing = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __devinit
|
|
|
|
test_interrupts (struct zoran *zr)
|
|
|
|
{
|
|
|
|
DEFINE_WAIT(wait);
|
|
|
|
int timeout, icr;
|
|
|
|
|
|
|
|
clear_interrupt_counters(zr);
|
|
|
|
|
|
|
|
zr->testing = 1;
|
|
|
|
icr = btread(ZR36057_ICR);
|
|
|
|
btwrite(0x78000000 | ZR36057_ICR_IntPinEn, ZR36057_ICR);
|
|
|
|
prepare_to_wait(&zr->test_q, &wait, TASK_INTERRUPTIBLE);
|
|
|
|
timeout = schedule_timeout(HZ);
|
|
|
|
finish_wait(&zr->test_q, &wait);
|
|
|
|
btwrite(0, ZR36057_ICR);
|
|
|
|
btwrite(0x78000000, ZR36057_ISR);
|
|
|
|
zr->testing = 0;
|
|
|
|
dprintk(5, KERN_INFO "%s: Testing interrupts...\n", ZR_DEVNAME(zr));
|
|
|
|
if (timeout) {
|
|
|
|
dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
|
|
|
|
}
|
2007-07-18 05:29:41 +08:00
|
|
|
if (zr36067_debug > 1)
|
2005-04-17 06:20:36 +08:00
|
|
|
print_interrupts(zr);
|
|
|
|
btwrite(icr, ZR36057_ICR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit
|
|
|
|
zr36057_init (struct zoran *zr)
|
|
|
|
{
|
2006-03-22 14:48:37 +08:00
|
|
|
int j, err;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk(1,
|
|
|
|
KERN_INFO
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - initializing card[%d], zr=%p\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, zr->id, zr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* default setup of all parameters which will persist between opens */
|
|
|
|
zr->user = 0;
|
|
|
|
|
|
|
|
init_waitqueue_head(&zr->v4l_capq);
|
|
|
|
init_waitqueue_head(&zr->jpg_capq);
|
|
|
|
init_waitqueue_head(&zr->test_q);
|
|
|
|
zr->jpg_buffers.allocated = 0;
|
|
|
|
zr->v4l_buffers.allocated = 0;
|
|
|
|
|
2009-02-20 04:31:17 +08:00
|
|
|
zr->vbuf_base = (void *) vidmem;
|
|
|
|
zr->vbuf_width = 0;
|
|
|
|
zr->vbuf_height = 0;
|
|
|
|
zr->vbuf_depth = 0;
|
|
|
|
zr->vbuf_bytesperline = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Avoid nonsense settings from user for default input/norm */
|
2009-05-03 04:52:52 +08:00
|
|
|
if (default_norm < 0 || default_norm > 2)
|
2009-02-20 04:31:17 +08:00
|
|
|
default_norm = 0;
|
|
|
|
if (default_norm == 0) {
|
2009-02-19 04:26:06 +08:00
|
|
|
zr->norm = V4L2_STD_PAL;
|
|
|
|
zr->timing = zr->card.tvn[0];
|
2009-02-20 04:31:17 +08:00
|
|
|
} else if (default_norm == 1) {
|
2009-02-19 04:26:06 +08:00
|
|
|
zr->norm = V4L2_STD_NTSC;
|
|
|
|
zr->timing = zr->card.tvn[1];
|
|
|
|
} else {
|
|
|
|
zr->norm = V4L2_STD_SECAM;
|
|
|
|
zr->timing = zr->card.tvn[2];
|
|
|
|
}
|
|
|
|
if (zr->timing == NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_WARNING
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - default TV standard not supported by hardware. PAL will be used.\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-02-19 04:26:06 +08:00
|
|
|
zr->norm = V4L2_STD_PAL;
|
|
|
|
zr->timing = zr->card.tvn[0];
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-07-18 05:29:42 +08:00
|
|
|
if (default_input > zr->card.inputs-1) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_WARNING
|
|
|
|
"%s: default_input value %d out of range (0-%d)\n",
|
|
|
|
ZR_DEVNAME(zr), default_input, zr->card.inputs-1);
|
|
|
|
default_input = 0;
|
|
|
|
}
|
|
|
|
zr->input = default_input;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* default setup (will be repeated at every open) */
|
|
|
|
zoran_open_init_params(zr);
|
|
|
|
|
|
|
|
/* allocate memory *before* doing anything to the hardware
|
|
|
|
* in case allocation fails */
|
2006-03-22 14:48:37 +08:00
|
|
|
zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
|
2010-12-31 22:28:51 +08:00
|
|
|
zr->video_dev = video_device_alloc();
|
2006-03-22 14:48:37 +08:00
|
|
|
if (!zr->stat_com || !zr->video_dev) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - kmalloc (STAT_COM) failed\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2006-03-22 14:48:37 +08:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit_free;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
|
2008-06-23 01:19:49 +08:00
|
|
|
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now add the template and register the device unit.
|
|
|
|
*/
|
|
|
|
memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
|
2009-02-19 00:52:24 +08:00
|
|
|
zr->video_dev->parent = &zr->pci_dev->dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
|
2012-09-05 17:05:50 +08:00
|
|
|
/* It's not a mem2mem device, but you can both capture and output from
|
|
|
|
one and the same device. This should really be split up into two
|
|
|
|
device nodes, but that's a job for another day. */
|
|
|
|
zr->video_dev->vfl_dir = VFL_DIR_M2M;
|
2007-07-18 05:29:42 +08:00
|
|
|
err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr[zr->id]);
|
2006-03-22 14:48:37 +08:00
|
|
|
if (err < 0)
|
2009-01-11 23:02:54 +08:00
|
|
|
goto exit_free;
|
2009-01-13 00:09:46 +08:00
|
|
|
video_set_drvdata(zr->video_dev, zr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
zoran_init_hardware(zr);
|
2007-07-18 05:29:41 +08:00
|
|
|
if (zr36067_debug > 2)
|
2005-04-17 06:20:36 +08:00
|
|
|
detect_guest_activity(zr);
|
|
|
|
test_interrupts(zr);
|
|
|
|
if (!pass_through) {
|
2009-02-20 03:18:23 +08:00
|
|
|
decoder_call(zr, video, s_stream, 0);
|
2009-04-02 22:26:22 +08:00
|
|
|
encoder_call(zr, video, s_routing, 2, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
zr->zoran_proc = NULL;
|
|
|
|
zr->initialized = 1;
|
|
|
|
return 0;
|
2006-03-22 14:48:37 +08:00
|
|
|
|
|
|
|
exit_free:
|
|
|
|
kfree(zr->stat_com);
|
|
|
|
kfree(zr->video_dev);
|
|
|
|
return err;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
static void __devexit zoran_remove(struct pci_dev *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-02-20 03:18:23 +08:00
|
|
|
struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
|
|
|
|
struct zoran *zr = to_zoran(v4l2_dev);
|
2009-01-11 23:02:54 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!zr->initialized)
|
2008-07-14 20:51:03 +08:00
|
|
|
goto exit_free;
|
2009-01-11 23:02:54 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* unregister videocodec bus */
|
|
|
|
if (zr->codec) {
|
|
|
|
struct videocodec_master *master = zr->codec->master_data;
|
2005-11-07 17:01:31 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
videocodec_detach(zr->codec);
|
2005-11-07 17:01:31 +08:00
|
|
|
kfree(master);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (zr->vfe) {
|
|
|
|
struct videocodec_master *master = zr->vfe->master_data;
|
2005-11-07 17:01:31 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
videocodec_detach(zr->vfe);
|
2005-11-07 17:01:31 +08:00
|
|
|
kfree(master);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* unregister i2c bus */
|
|
|
|
zoran_unregister_i2c(zr);
|
|
|
|
/* disable PCI bus-mastering */
|
|
|
|
zoran_set_pci_master(zr, 0);
|
|
|
|
/* put chip into reset */
|
|
|
|
btwrite(0, ZR36057_SPGPPCR);
|
|
|
|
free_irq(zr->pci_dev->irq, zr);
|
|
|
|
/* unmap and free memory */
|
2006-03-22 14:48:37 +08:00
|
|
|
kfree(zr->stat_com);
|
2005-04-17 06:20:36 +08:00
|
|
|
zoran_proc_cleanup(zr);
|
|
|
|
iounmap(zr->zr36057_mem);
|
|
|
|
pci_disable_device(zr->pci_dev);
|
|
|
|
video_unregister_device(zr->video_dev);
|
2008-07-14 20:51:03 +08:00
|
|
|
exit_free:
|
2009-02-20 03:18:23 +08:00
|
|
|
v4l2_device_unregister(&zr->v4l2_dev);
|
2008-07-14 20:51:03 +08:00
|
|
|
kfree(zr);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
zoran_vdev_release (struct video_device *vdev)
|
|
|
|
{
|
|
|
|
kfree(vdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct videocodec_master * __devinit
|
|
|
|
zoran_setup_videocodec (struct zoran *zr,
|
|
|
|
int type)
|
|
|
|
{
|
|
|
|
struct videocodec_master *m = NULL;
|
|
|
|
|
|
|
|
m = kmalloc(sizeof(struct videocodec_master), GFP_KERNEL);
|
|
|
|
if (!m) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s - no memory\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2007-10-15 23:09:17 +08:00
|
|
|
/* magic and type are unused for master struct. Makes sense only at
|
|
|
|
codec structs.
|
|
|
|
In the past, .type were initialized to the old V4L1 .hardware
|
|
|
|
value, as VID_HARDWARE_ZR36067
|
|
|
|
*/
|
|
|
|
m->magic = 0L;
|
|
|
|
m->type = 0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER;
|
2009-08-08 23:58:52 +08:00
|
|
|
strlcpy(m->name, ZR_DEVNAME(zr), sizeof(m->name));
|
2005-04-17 06:20:36 +08:00
|
|
|
m->data = zr;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CODEC_TYPE_ZR36060:
|
|
|
|
m->readreg = zr36060_read;
|
|
|
|
m->writereg = zr36060_write;
|
|
|
|
m->flags |= CODEC_FLAG_JPEG | CODEC_FLAG_VFE;
|
|
|
|
break;
|
|
|
|
case CODEC_TYPE_ZR36050:
|
|
|
|
m->readreg = zr36050_read;
|
|
|
|
m->writereg = zr36050_write;
|
|
|
|
m->flags |= CODEC_FLAG_JPEG;
|
|
|
|
break;
|
|
|
|
case CODEC_TYPE_ZR36016:
|
|
|
|
m->readreg = zr36016_read;
|
|
|
|
m->writereg = zr36016_write;
|
|
|
|
m->flags |= CODEC_FLAG_VFE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2009-03-14 23:53:37 +08:00
|
|
|
static void zoran_subdev_notify(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
2009-03-09 04:04:38 +08:00
|
|
|
{
|
|
|
|
struct zoran *zr = to_zoran(sd->v4l2_dev);
|
|
|
|
|
|
|
|
/* Bt819 needs to reset its FIFO buffer using #FRST pin and
|
|
|
|
LML33 card uses GPIO(7) for that. */
|
|
|
|
if (cmd == BT819_FIFO_RESET_LOW)
|
|
|
|
GPIO(zr, 7, 0);
|
|
|
|
else if (cmd == BT819_FIFO_RESET_HIGH)
|
|
|
|
GPIO(zr, 7, 1);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2008-02-03 23:18:59 +08:00
|
|
|
* Scan for a Buz card (actually for the PCI controller ZR36057),
|
2005-04-17 06:20:36 +08:00
|
|
|
* request the irq and map the io memory
|
|
|
|
*/
|
2009-01-11 23:02:54 +08:00
|
|
|
static int __devinit zoran_probe(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned char latency, need_latency;
|
|
|
|
struct zoran *zr;
|
|
|
|
int result;
|
|
|
|
struct videocodec_master *master_vfe = NULL;
|
|
|
|
struct videocodec_master *master_codec = NULL;
|
|
|
|
int card_num;
|
2009-02-20 03:18:23 +08:00
|
|
|
char *codec_name, *vfe_name;
|
2009-01-11 23:02:54 +08:00
|
|
|
unsigned int nr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
nr = zoran_num++;
|
2009-01-11 23:02:54 +08:00
|
|
|
if (nr >= BUZ_MAX) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: driver limited to %d card(s) maximum\n",
|
2009-01-11 23:02:54 +08:00
|
|
|
ZORAN_NAME, BUZ_MAX);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
|
|
|
|
if (!zr) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s - kzalloc failed\n",
|
|
|
|
ZORAN_NAME, __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2009-03-09 04:04:38 +08:00
|
|
|
zr->v4l2_dev.notify = zoran_subdev_notify;
|
2009-02-20 03:18:23 +08:00
|
|
|
if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev))
|
|
|
|
goto zr_free_mem;
|
2009-01-11 23:02:54 +08:00
|
|
|
zr->pci_dev = pdev;
|
|
|
|
zr->id = nr;
|
|
|
|
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
|
|
|
|
spin_lock_init(&zr->spinlock);
|
|
|
|
mutex_init(&zr->resource_lock);
|
2010-10-27 20:30:32 +08:00
|
|
|
mutex_init(&zr->other_lock);
|
2009-01-11 23:02:54 +08:00
|
|
|
if (pci_enable_device(pdev))
|
2009-02-20 03:18:23 +08:00
|
|
|
goto zr_unreg;
|
2011-03-21 22:35:56 +08:00
|
|
|
zr->revision = zr->pci_dev->revision;
|
2009-01-13 00:09:46 +08:00
|
|
|
|
|
|
|
dprintk(1,
|
|
|
|
KERN_INFO
|
2009-01-13 00:09:46 +08:00
|
|
|
"%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
|
2009-01-13 00:09:46 +08:00
|
|
|
ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision,
|
2009-01-13 00:09:46 +08:00
|
|
|
zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0));
|
2009-01-13 00:09:46 +08:00
|
|
|
if (zr->revision >= 2) {
|
2009-01-11 23:02:54 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_INFO
|
2009-01-13 00:09:46 +08:00
|
|
|
"%s: Subsystem vendor=0x%04x id=0x%04x\n",
|
|
|
|
ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor,
|
|
|
|
zr->pci_dev->subsystem_device);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
/* Use auto-detected card type? */
|
|
|
|
if (card[nr] == -1) {
|
|
|
|
if (zr->revision < 2) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-01-13 00:09:46 +08:00
|
|
|
"%s: No card type specified, please use the card=X module parameter\n",
|
|
|
|
ZR_DEVNAME(zr));
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
|
|
|
"%s: It is not possible to auto-detect ZR36057 based cards\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
ZR_DEVNAME(zr));
|
2009-02-20 03:18:23 +08:00
|
|
|
goto zr_unreg;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
card_num = ent->driver_data;
|
|
|
|
if (card_num >= NUM_CARDS) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
|
|
|
"%s: Unknown card, try specifying card=X module parameter\n",
|
2009-01-11 23:02:54 +08:00
|
|
|
ZR_DEVNAME(zr));
|
2009-02-20 03:18:23 +08:00
|
|
|
goto zr_unreg;
|
2009-01-13 00:09:46 +08:00
|
|
|
}
|
|
|
|
dprintk(3,
|
|
|
|
KERN_DEBUG
|
|
|
|
"%s: %s() - card %s detected\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name);
|
|
|
|
} else {
|
|
|
|
card_num = card[nr];
|
|
|
|
if (card_num >= NUM_CARDS || card_num < 0) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
|
|
|
"%s: User specified card type %d out of range (0 .. %d)\n",
|
|
|
|
ZR_DEVNAME(zr), card_num, NUM_CARDS - 1);
|
2009-02-20 03:18:23 +08:00
|
|
|
goto zr_unreg;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
/* even though we make this a non pointer and thus
|
|
|
|
* theoretically allow for making changes to this struct
|
|
|
|
* on a per-individual card basis at runtime, this is
|
|
|
|
* strongly discouraged. This structure is intended to
|
|
|
|
* keep general card information, no settings or anything */
|
|
|
|
zr->card = zoran_cards[card_num];
|
|
|
|
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)),
|
|
|
|
"%s[%u]", zr->card.name, zr->id);
|
|
|
|
|
2009-01-13 00:09:46 +08:00
|
|
|
zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
|
2009-01-11 23:02:54 +08:00
|
|
|
if (!zr->zr36057_mem) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s() - ioremap failed\n",
|
2009-01-13 00:09:46 +08:00
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-02-20 03:18:23 +08:00
|
|
|
goto zr_unreg;
|
2009-01-11 23:02:54 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
result = request_irq(zr->pci_dev->irq, zoran_irq,
|
|
|
|
IRQF_SHARED | IRQF_DISABLED, ZR_DEVNAME(zr), zr);
|
|
|
|
if (result < 0) {
|
|
|
|
if (result == -EINVAL) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - bad irq number or handler\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
} else if (result == -EBUSY) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - IRQ %d busy, change your PnP config in BIOS\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, zr->pci_dev->irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2009-01-11 23:02:54 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
2009-03-11 10:28:33 +08:00
|
|
|
"%s: %s - can't assign irq, error code %d\n",
|
|
|
|
ZR_DEVNAME(zr), __func__, result);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
goto zr_unmap;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
/* set PCI latency timer */
|
|
|
|
pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER,
|
|
|
|
&latency);
|
|
|
|
need_latency = zr->revision > 1 ? 32 : 48;
|
|
|
|
if (latency != need_latency) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(2, KERN_INFO "%s: Changing PCI latency from %d to %d\n",
|
2009-01-11 23:02:54 +08:00
|
|
|
ZR_DEVNAME(zr), latency, need_latency);
|
|
|
|
pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER,
|
|
|
|
need_latency);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
zr36057_restart(zr);
|
|
|
|
/* i2c */
|
|
|
|
dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n",
|
|
|
|
ZR_DEVNAME(zr));
|
|
|
|
|
|
|
|
if (zoran_register_i2c(zr) < 0) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s - can't initialize i2c bus\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
goto zr_free_irq;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-08-10 13:49:08 +08:00
|
|
|
zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev,
|
2010-09-24 21:16:44 +08:00
|
|
|
&zr->i2c_adapter, zr->card.i2c_decoder,
|
2009-08-10 13:49:08 +08:00
|
|
|
0, zr->card.addrs_decoder);
|
2009-02-20 03:18:23 +08:00
|
|
|
|
2010-09-24 19:19:18 +08:00
|
|
|
if (zr->card.i2c_encoder)
|
2009-08-10 13:49:08 +08:00
|
|
|
zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev,
|
2010-09-24 21:16:44 +08:00
|
|
|
&zr->i2c_adapter, zr->card.i2c_encoder,
|
2009-08-10 13:49:08 +08:00
|
|
|
0, zr->card.addrs_encoder);
|
2009-02-20 03:18:23 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
dprintk(2,
|
|
|
|
KERN_INFO "%s: Initializing videocodec bus...\n",
|
|
|
|
ZR_DEVNAME(zr));
|
|
|
|
|
|
|
|
if (zr->card.video_codec) {
|
|
|
|
codec_name = codecid_to_modulename(zr->card.video_codec);
|
|
|
|
if (codec_name) {
|
|
|
|
result = request_module(codec_name);
|
|
|
|
if (result) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
|
|
|
"%s: failed to load modules %s: %d\n",
|
|
|
|
ZR_DEVNAME(zr), codec_name, result);
|
|
|
|
}
|
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
}
|
|
|
|
if (zr->card.video_vfe) {
|
|
|
|
vfe_name = codecid_to_modulename(zr->card.video_vfe);
|
|
|
|
if (vfe_name) {
|
|
|
|
result = request_module(vfe_name);
|
|
|
|
if (result < 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
|
|
|
"%s: failed to load modules %s: %d\n",
|
|
|
|
ZR_DEVNAME(zr), vfe_name, result);
|
|
|
|
}
|
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
/* reset JPEG codec */
|
|
|
|
jpeg_codec_sleep(zr, 1);
|
|
|
|
jpeg_codec_reset(zr);
|
|
|
|
/* video bus enabled */
|
|
|
|
/* display codec revision */
|
|
|
|
if (zr->card.video_codec != 0) {
|
|
|
|
master_codec = zoran_setup_videocodec(zr, zr->card.video_codec);
|
|
|
|
if (!master_codec)
|
|
|
|
goto zr_unreg_i2c;
|
|
|
|
zr->codec = videocodec_attach(master_codec);
|
|
|
|
if (!zr->codec) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s - no codec found\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
goto zr_free_codec;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
if (zr->codec->type != zr->card.video_codec) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s - wrong codec\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
goto zr_detach_codec;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
if (zr->card.video_vfe != 0) {
|
|
|
|
master_vfe = zoran_setup_videocodec(zr, zr->card.video_vfe);
|
|
|
|
if (!master_vfe)
|
|
|
|
goto zr_detach_codec;
|
|
|
|
zr->vfe = videocodec_attach(master_vfe);
|
|
|
|
if (!zr->vfe) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s - no VFE found\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
goto zr_free_vfe;
|
|
|
|
}
|
|
|
|
if (zr->vfe->type != zr->card.video_vfe) {
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_ERR "%s: %s = wrong VFE\n",
|
|
|
|
ZR_DEVNAME(zr), __func__);
|
2009-01-11 23:02:54 +08:00
|
|
|
goto zr_detach_vfe;
|
|
|
|
}
|
|
|
|
}
|
2006-10-04 07:44:12 +08:00
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
/* take care of Natoma chipset and a revision 1 zr36057 */
|
|
|
|
if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
|
|
|
|
zr->jpg_buffers.need_contiguous = 1;
|
2009-03-11 10:28:33 +08:00
|
|
|
dprintk(1, KERN_INFO
|
2009-01-11 23:02:54 +08:00
|
|
|
"%s: ZR36057/Natoma bug, max. buffer size is 128K\n",
|
|
|
|
ZR_DEVNAME(zr));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-01-11 23:02:54 +08:00
|
|
|
|
|
|
|
if (zr36057_init(zr) < 0)
|
|
|
|
goto zr_detach_vfe;
|
|
|
|
|
|
|
|
zoran_proc_init(zr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
zr_detach_vfe:
|
|
|
|
videocodec_detach(zr->vfe);
|
|
|
|
zr_free_vfe:
|
|
|
|
kfree(master_vfe);
|
|
|
|
zr_detach_codec:
|
|
|
|
videocodec_detach(zr->codec);
|
|
|
|
zr_free_codec:
|
|
|
|
kfree(master_codec);
|
|
|
|
zr_unreg_i2c:
|
|
|
|
zoran_unregister_i2c(zr);
|
|
|
|
zr_free_irq:
|
|
|
|
btwrite(0, ZR36057_SPGPPCR);
|
|
|
|
free_irq(zr->pci_dev->irq, zr);
|
|
|
|
zr_unmap:
|
|
|
|
iounmap(zr->zr36057_mem);
|
2009-02-20 03:18:23 +08:00
|
|
|
zr_unreg:
|
|
|
|
v4l2_device_unregister(&zr->v4l2_dev);
|
2009-01-11 23:02:54 +08:00
|
|
|
zr_free_mem:
|
|
|
|
kfree(zr);
|
|
|
|
|
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
static struct pci_driver zoran_driver = {
|
|
|
|
.name = "zr36067",
|
|
|
|
.id_table = zr36067_pci_tbl,
|
|
|
|
.probe = zoran_probe,
|
2009-06-04 22:07:16 +08:00
|
|
|
.remove = __devexit_p(zoran_remove),
|
2009-01-11 23:02:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init zoran_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-01-11 23:02:54 +08:00
|
|
|
int res;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 01:45:49 +08:00
|
|
|
printk(KERN_INFO "Zoran MJPEG board driver version %s\n",
|
|
|
|
ZORAN_VERSION);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* check the parameters we have been given, adjust if necessary */
|
|
|
|
if (v4l_nbufs < 2)
|
|
|
|
v4l_nbufs = 2;
|
|
|
|
if (v4l_nbufs > VIDEO_MAX_FRAME)
|
|
|
|
v4l_nbufs = VIDEO_MAX_FRAME;
|
|
|
|
/* The user specfies the in KB, we want them in byte
|
|
|
|
* (and page aligned) */
|
|
|
|
v4l_bufsize = PAGE_ALIGN(v4l_bufsize * 1024);
|
|
|
|
if (v4l_bufsize < 32768)
|
|
|
|
v4l_bufsize = 32768;
|
|
|
|
/* 2 MB is arbitrary but sufficient for the maximum possible images */
|
|
|
|
if (v4l_bufsize > 2048 * 1024)
|
|
|
|
v4l_bufsize = 2048 * 1024;
|
|
|
|
if (jpg_nbufs < 4)
|
|
|
|
jpg_nbufs = 4;
|
|
|
|
if (jpg_nbufs > BUZ_MAX_FRAME)
|
|
|
|
jpg_nbufs = BUZ_MAX_FRAME;
|
|
|
|
jpg_bufsize = PAGE_ALIGN(jpg_bufsize * 1024);
|
|
|
|
if (jpg_bufsize < 8192)
|
|
|
|
jpg_bufsize = 8192;
|
|
|
|
if (jpg_bufsize > (512 * 1024))
|
|
|
|
jpg_bufsize = 512 * 1024;
|
|
|
|
/* Use parameter for vidmem or try to find a video card */
|
|
|
|
if (vidmem) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_INFO
|
|
|
|
"%s: Using supplied video memory base address @ 0x%lx\n",
|
|
|
|
ZORAN_NAME, vidmem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* some mainboards might not do PCI-PCI data transfer well */
|
2006-09-14 22:47:55 +08:00
|
|
|
if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dprintk(1,
|
|
|
|
KERN_WARNING
|
2006-09-14 22:47:55 +08:00
|
|
|
"%s: chipset does not support reliable PCI-PCI DMA\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
ZORAN_NAME);
|
|
|
|
}
|
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
res = pci_register_driver(&zoran_driver);
|
|
|
|
if (res) {
|
|
|
|
dprintk(1,
|
|
|
|
KERN_ERR
|
|
|
|
"%s: Unable to register ZR36057 driver\n",
|
|
|
|
ZORAN_NAME);
|
|
|
|
return res;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
static void __exit zoran_exit(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-01-11 23:02:54 +08:00
|
|
|
pci_unregister_driver(&zoran_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-01-11 23:02:54 +08:00
|
|
|
module_init(zoran_init);
|
|
|
|
module_exit(zoran_exit);
|